You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
hey !
is there another way to read what we receive from bluetooth than asyncio.gather( )?
or is that a way to choose when we receive ?
(when I use it, I can either receive the information only once and i can run the rest of my code, or I can't run the rest of my code and i receive only the data from the ble)
There are many ways to run tasks together, asyncio.gather() is just one of them. This is not specific for ble-serial, but about python asyncio is general, I would suggest reading up on that. Also it is only needed to keep the BLE_interface.send_loop() running, that works on the send buffer.
Receiving is just a regular (non async) callback function you pass into BLE_interface.set_receiver(). You can not choose when to receive by default, because a connected device can send data at any time. It is possible to implement a buffer though, for a example that can hold a single response, take a look here: #72 (comment)
If you need to buffer multiple messages before your code can process it, then you could use asyncio.Queue, that is how it works in the command line tool with serialport emulation.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
hey !
is there another way to read what we receive from bluetooth than asyncio.gather( )?
or is that a way to choose when we receive ?
(when I use it, I can either receive the information only once and i can run the rest of my code, or I can't run the rest of my code and i receive only the data from the ble)
Beta Was this translation helpful? Give feedback.
All reactions