Closed mrdc closed 1 year ago
Closing since the BlueZ backend in Bleak has significantly changed since the issue was opened. Hopefully the original issue could be solved by upgrading BlueZ and/or ensuring that the device is sending the correct information about the attribute database to BlueZ in the first place.
Hi guys, i faced the same problem with my esp32. My outputs:
$ python3 service_explorer.py --address 9C:9C:1F:C4:DD:D6 2 ⨯
2023-12-03 10:03:51,766 __main__ INFO: starting scan...
2023-12-03 10:03:53,745 __main__ INFO: connecting to device...
2023-12-03 10:03:55,642 __main__ INFO: connected
2023-12-03 10:03:55,643 __main__ INFO: [Service] 6e400001-b5a3-f393-e0a9-e50e24dcca9e (Handle: 19): Nordic UART Service
2023-12-03 10:03:55,643 __main__ INFO: [Characteristic] 6e400002-b5a3-f393-e0a9-e50e24dcca9e (Handle: 23): Nordic UART RX (write)
2023-12-03 10:03:55,644 __main__ INFO: [Characteristic] 6e400003-b5a3-f393-e0a9-e50e24dcca9e (Handle: 20): Nordic UART TX (notify)
2023-12-03 10:03:55,854 __main__ INFO: [Descriptor] 00002902-0000-1000-8000-00805f9b34fb (Handle: 22): Client Characteristic Configuration, Value: bytearray(b'\x00\x00')
2023-12-03 10:03:55,854 __main__ INFO: [Service] 00001801-0000-1000-8000-00805f9b34fb (Handle: 15): Generic Attribute Profile
2023-12-03 10:03:55,855 __main__ INFO: [Characteristic] 00002a05-0000-1000-8000-00805f9b34fb (Handle: 16): Service Changed (indicate)
2023-12-03 10:03:55,947 __main__ INFO: [Descriptor] 00002902-0000-1000-8000-00805f9b34fb (Handle: 18): Client Characteristic Configuration, Value: bytearray(b'\x02\x00')
2023-12-03 10:03:55,947 __main__ INFO: disconnecting...
2023-12-03 10:03:58,100 __main__ INFO: disconnected
My code:
$ python3 esp32_ble.py
Traceback (most recent call last):
File "/home/merino/Documents/M2_Data_Science/PT/Car_project/esp32_ble.py", line 31, in <module>
asyncio.run(run())
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 653, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/merino/Documents/M2_Data_Science/PT/Car_project/esp32_ble.py", line 18, in run
await client.write_gatt_char(UUID3, int_parameter.to_bytes(4, byteorder='little'))
File "/home/merino/.local/lib/python3.11/site-packages/bleak/__init__.py", line 769, in write_gatt_char
raise BleakError("Characteristic {char_specifier} was not found!")
bleak.exc.BleakError: Characteristic {char_specifier} was not found!
What is UUID3
?
May be your UUID(write property) is mistake? I met this mistake too. After I modified the UUID, the problem was solved.
Description
I'm trying to connect to a BLE device via
bleak
- it works fine when I use my script on Windows 10, but the same script fails on Linux:What I Did
My code:
The difference I see is a different bleak version on Win and on Linux. On Linux
pip3 install bleak
returns only bleak 0,8.0: