bleak icon indicating copy to clipboard operation
bleak copied to clipboard

ESP32 "The attribute could not be found" on start_notify

Open alexanderturner opened this issue 1 year ago • 3 comments

  • bleak version: 0.21.1
  • Python version: 3.11.4
  • Operating System: macOS 13.5 (Ventura)
  • BlueZ version (bluetoothctl -v) in case of Linux:

Description

start_notify calls an error on macOS, the application works fine on Windows devices. The peripheral is an ESP32-S3. The characteristic is valid and subscriptions work on mobile debugging apps without error.

What I Did

    OTA_CONTROL_UUID = '00000101-0000-1000-8000-00805f9b34fb'


    async with BleakClient(esp32, winrt=dict(use_cached_services=False)) as client:

        await client.start_notify(
            OTA_CONTROL_UUID,
            _ota_notification_handler
        )

Logs

    asyncio.run(send_ota("bms-main.bin"))
  File "/usr/local/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/[email protected]/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/Users/aturner/Code/Projects/LiTrek/esp32-micro/ota_pc_update/main.py", line 62, in send_ota
    await client.start_notify(
  File "/Users/aturner/.espressif/python_env/idf5.0_py3.11_env/lib/python3.11/site-packages/bleak/__init__.py", line 822, in start_notify
    raise BleakError(f"Characteristic {char_specifier} not found!")
bleak.exc.BleakError: Characteristic 101 not found!

Screenshot 2023-09-24 at 9 02 20 pm

alexanderturner avatar Sep 24 '23 11:09 alexanderturner

Originally I thought this to be a mac issue, however it exists in the same form on a WIndows 10 machine as well. Works fine on Linux (Ubuntu 22.04)

alexanderturner avatar Sep 26 '23 13:09 alexanderturner

Bumping this

alexanderturner avatar Oct 03 '23 09:10 alexanderturner

I know this is a late comment, but if this is still a problem, can you try listing all characteristics before enabling notifications on the specific one

    OTA_CONTROL_UUID = '00000101-0000-1000-8000-00805f9b34fb'


    async with BleakClient(esp32, winrt=dict(use_cached_services=False)) as client:

        # First, list the GATT server structure
        for service in client.services:
            print(f"[Service] {service}")
            for char in service.characteristics:
                print(f"  [Characteristic] {char} ({','.join(char.properties)})")
                for descriptor in char.descriptors:
                    print(f"    [Descriptor] {descriptor}")

        await client.start_notify(
            OTA_CONTROL_UUID,
            _ota_notification_handler
        )

bojanpotocnik avatar Jan 08 '24 12:01 bojanpotocnik