I am trying to make a program that receives data from a bluetooth device until you press a button to make it stop. I attempted to use start_notify however, I do not think I understand how to use it enough. I also used read_gatt_char() but it collects data quite a bit slower which is a problem.
There is not enough information for anyone to be able to attempt to help.
Please show the code you have attempted so far in code tags and any errors in error tags.
Explain clearly what is meant to happen and what is actually currently happening.
There are links in my signature with help on how and what to post.
Quote: am trying to make a program that receives data from a bluetooth device
Use multipricessing, running this code in a separate process.
Quote:until you press a button to make it stop.
Wait for input in the "main" program and terminate the process
https://pymotw.com/3/multiprocessing/basics.html
(Dec-27-2022, 10:56 PM)Yoriz Wrote: [ -> ]There is not enough information for anyone to be able to attempt to help.
Please show the code you have attempted so far in code tags and any errors in error tags.
Explain clearly what is meant to happen and what is actually currently happening.
There are links in my signature with help on how and what to post.
Hello,
I apologize, I was in a rush making this thread and I appreciate the feedback. Here is my code below, this is supposed to be in a class but I took out all of the junk you do not need to worry about.
int1 = 0
queue = []
def callback(characteristic, data):
global int1
int1 = data
async def retrieve():
async with BleakClient(arduino_ble, timeout=5.0) as client:
try:
await client.start_notify(char1, callback)
except Exception as e:
return
while queue.empty():
print(int1)
queue.pop()
client.stop_notify(char1)