Enable notifications without going through the callback system? #1638
-
DescriptionI am trying to communicate with a device that uses a CH9141K BLE to serial bridge to connect user applications. It looks like it requires the host to enable notifications before it starts sending data over BLE. What I Did
This works fine, though I'm wondering if I can just somehow enable notifications without registering a callback, and then use
to just process messages as they arrive in a loop? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
It depends on the characteristic. If the characteristic supports reading, then sure, just read in a loop. If it doesn't, then notifications is the only way. |
Beta Was this translation helpful? Give feedback.
-
service_explorer.py reports:
The characteristic I need to connect to is 0xFFF1. This is a relatively "dumb" device that forwards data from a serial connection to BLE, and from BLE to a serial connection. Processing is done by a separate microcontroller that doesn't know anything about Bluetooth. So this is pretty much a documentation question: Am I missing something, can I subscribe to notifications without a callback? Or is a callback with a queue the "proper" solution? |
Beta Was this translation helpful? Give feedback.
-
If this is being used for serial data and you don't want to miss any notifications, yes a callback queue is the "proper" solution. ... at least for now - see related feature request: #1501 |
Beta Was this translation helpful? Give feedback.
-
To resolve this: my workaround is to create an async context manager to manage the queue and callback:
This is for a command line utility that just temporarily connects to a BLE device. For a desktop application you probably want to register a callback for the lifetime of the application, as the existing examples show. BTW, this is the project: https://github.com/JensRestemeier/research-WLS-MVAxxx |
Beta Was this translation helpful? Give feedback.
To resolve this: my workaround is to create an async context manager to manage the queue and callback:
This is for a command line util…