Integrating with pySerial and maintaining BLE connection #511
Unanswered
JBrakefield
asked this question in
Q&A
Replies: 1 comment
-
Sorry for not responding earlier, but this is a question that I cannot answer quickly and therefore it has not been dealt with... If the problem is "How do I make the connection last longer than the 1 second that The 20 byte limit is not a problem that Bleak imposes per se, but it is a limit negotiated by your OS and your peripheral. Bleak can do little to modify it, as far as I have found out, but I may be wrong on this. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Update 04/08/2021: I may have worked around the issues below by setting up a while loop, but my limited understanding of async is getting in the way of my code behaving as expected. I need to call serial functions as part of the callback handle (handle_rx) but sometimes data is "sent" but not "received", or even if I do get "received" by script 1 (below) I don't see the same results on the other side of the COM port pair.
I'm using pySerial to connect python with a virtual COM port that is paired with another virtual COM port (COM2 <-> COM4). I can successfully talk between the two using two methods: (1) dual python scripts, or (2) a python script to terminal (Tera Term).
I want to do all this while paired to BLE with bleak, so that I may type a message in the terminal (COM2) and have it received by COM4 into python and then to my device over BLE. So far I succeed at sending a message and receiving the return message, but with mixed results. I'm also having the issue of the BLE connection being severed after the first command/return event, ending the script.
I was once able to send a command that returns multiple lines (more than 20 bytes) without any problems. Now, however, my script is stalling after the first chunk and only sends the rest if I send successive commands with a known small return. I have to send that smaller command over and over for the script to finish flushing out the first command's return data. Then, as stated above, my script ends and the BLE connection is severed.
My code below:
Beta Was this translation helpful? Give feedback.
All reactions