NotSupported error from Bluez
joselsegura opened this issue · comments
- bleak version: 0.21.1
- Python version: 3.11.8
- Operating System: Debian GNU/Linux
- BlueZ version (
bluetoothctl -v
) in case of Linux: 5.71
Description
I'm trying to subscribe to events for a given characteristic using start_notify
, but I'm getting the following error:
bleak.exc.BleakDBusError: [org.bluez.Error.NotSupported] Operation is not supported
I wonder if the problem is my bluetooth USB dongle or if I'm missing some step before trying to call start_notify
What I Did
When connecting a BleakClient
to the device and getting the characteristic, I try to start the notifying adding just a lambda
function to check if the notifications are received.
Instead, an exception is raised as states above.
async with BleakClient(device, services=[SERVICE_UUID]) as client:
services = client.services
characteristic1 = services.get_characteristic(CHARACTERISTIC1_UUID)
await client.start_notify(characteristic1, callback=lambda *args, **kwargs: print("Notifiation"))
print("Subscribed to notifications")
await asyncio.sleep(20.0)
await client.stop_notify(characteristic1)
Logs
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/joseluis/saj_h1_modbus_exporter/saj_h1_modbus_exporter/retriever.py", line 59, in tool_cli
asyncio.run(connect_to_device(address))
File "/usr/lib/python3.11/asyncio/runners.py", line 190, in run
return runner.run(main)
^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/runners.py", line 118, in run
return self._loop.run_until_complete(task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/joseluis/saj_h1_modbus_exporter/saj_h1_modbus_exporter/retriever.py", line 30, in connect_to_device
await client.start_notify(characteristic1, callback=lambda *args, **kwargs: print("Noticiation"))
File "/home/joseluis/saj_h1_modbus_exporter/venv/lib/python3.11/site-packages/bleak/__init__.py", line 834, in start_notify
await self._backend.start_notify(characteristic, wrapped_callback, **kwargs)
File "/home/joseluis/saj_h1_modbus_exporter/venv/lib/python3.11/site-packages/bleak/backends/bluezdbus/client.py", line 958, in start_notify
assert_reply(reply)
File "/home/joseluis/saj_h1_modbus_exporter/venv/lib/python3.11/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.NotSupported] Operation is not supported
I assume this is being called on a characteristic that doesn't support notifications.
Can you share the output of the service explorer example for this device so we can see what characteristics are available and what their properties are?
Oh, my...
I just find out that I used the wrong UUID all the time! In my defense, I need to use 2 different characteristics and I switched both UUIDs.
Sorry for the noise