Skip to content

Using the ble-serial library directly #72

Answered by Jakeler
kgraven asked this question in Q&A
Discussion options

You must be logged in to vote

First of all I edited your post for code formatting, it needs triple backticks for code blocks.

Most important thing to know is that send_loop() will never return without external signals and asyncio.gather will wait for all coroutines to complete. So it does not matter that your 2 sendble() finish after about 6 sec - the second gather is never reached. To get out of it you can either call stop_loop() or directly disconnect().
Also gather runs everything in parallel, I am not sure if you really intend to send both commands practically at the same time. Probably you want something like this instead:

rx_buffer = b''
rx_available = asyncio.Event()

def receive_callback(value: bytes):
    print(

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kgraven
Comment options

Answer selected by kgraven
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants