bleak: bleak.exc.BleakError: Characteristic was not found!

  • bleak version: 0.9.1 / 0.8.0
  • Python version: 3.8.6 / 3.8.4
  • Operating System: Windows 10 / Debian 10 (RPi3b+)
  • BlueZ: bluetoothctl: 5.50

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:

bleak.exc.BleakError: Characteristic 11111111-1111-1111-1111-111111111111 was not found!

What I Did

My code:

from bleak import BleakClient
import asyncio


address = "xx:xx:xx:xx:xx:xx"
ble_uuid = "11111111-1111-1111-1111-111111111111"

msg = b'ABC'
async def run(address, loop):
        async with BleakClient(address, loop=loop) as client:
            await client.write_gatt_char(ble_uuid, msg, True)

loop = asyncio.get_event_loop()
loop.run_until_complete(run(address, loop))

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:

pip3 install bleak
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: bleak in /home/pi/.local/lib/python3.8/site-packages (0.8.0)
Traceback (most recent call last):
  File "script.py", line 13, in <module>
    loop.run_until_complete(run(address, loop))
  File "/usr/local/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "script.py", line 11, in run
    await client.write_gatt_char(ble_uuid, msg, True)
  File "/home/pi/.local/lib/python3.8/site-packages/bleak/backends/bluezdbus/client.py", line 580, in write_gatt_char
    raise BleakError("Characteristic {0} was not found!".format(char_specifier))
bleak.exc.BleakError: Characteristic 11111111-1111-1111-1111-111111111111 was not found!

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 54 (7 by maintainers)

Most upvoted comments

INFO:__main__:		[Descriptor] 00002902-0000-1000-8000-00805f9b34fb (Handle: 17): Client Characteristic Configuration) | Value: b''

The value should be two bytes, so there appears to be a problem with the remote device itself.

im getting the same issue bleak.exc.BleakError: Characteristic UUID was not found! while trying to connect to a ble device from a linux PC, i tried all the above things. i tried with both uuid’s which i got from client.get_services()

Same problem 😢

We’re getting ready to do a release (probably tomorrow) that includes some troubleshooting tips on making sure the problem isn’t cached device info. Also, there are major changes to the BlueZ backend, so if anything else, it should at least provide better debugging info.

I can try to install Ubuntu, I hope it will work with CSR 4.0 dongle.