Python Forum
How to continuously receive messages until specified to stop using Bleak
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to continuously receive messages until specified to stop using Bleak
#1
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.
Reply
#2
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.
Reply
#3
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
Reply
#4
(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)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to receive two passed cmdline parameters and access them inside a Python script? pstein 2 360 Feb-17-2024, 12:29 PM
Last Post: deanhystad
  Receive Input on Same Line? johnywhy 8 733 Jan-16-2024, 03:45 AM
Last Post: johnywhy
  How to use asyncio run_forever to continuously handle requests mansky 1 685 Oct-28-2023, 04:26 AM
Last Post: deanhystad
  Read 2 Value with bleak via BLE notify from ESP32 Nietzsche 8 2,839 May-04-2023, 09:31 PM
Last Post: Nietzsche
  Help with bleak - how to send test to BLE device? korenron 1 1,745 Aug-28-2022, 11:28 PM
Last Post: Larz60+
  How can I add an end line character after every value that I receive? GiggsB 11 5,203 Mar-06-2022, 08:51 PM
Last Post: GiggsB
  How to receive webcam capture on spout? buzzdarkyear 2 2,671 Jan-12-2022, 02:26 PM
Last Post: buzzdarkyear
  bleak library RuntimeError: This event loop is already running alice93 3 4,115 Sep-30-2021, 08:06 AM
Last Post: alice93
  How to listen to clipboard content change without polling the clipboard continuously? edgelord 0 2,493 Nov-27-2020, 06:07 AM
Last Post: edgelord
  Custom logging handler looping continuously linuxaddikt 0 1,797 Mar-12-2020, 06:58 PM
Last Post: linuxaddikt

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020