bleak: Service not detected by Bleak

  • bleak version: 0.19.5
  • Python version: 3.10.6
  • Operating System: Ubuntu 22.04 (Linux 5.15.0-56-generic)
  • BlueZ version (bluetoothctl -v) in case of Linux: 5.64

Description

I have a device (smart scale) which exposes 3 services: device information (0x180A), battery service (0x180F), and a custom vendor-defined service (0xFFF0). The issue I’m having is that Bleak can only see the first two, and the vendor-defined service doesn’t show up. When I check a tool like nRF Connect on my phone, I can see all 3 services. Also and the vendor mobile app for the smart scale is able to connect to the 0xFFF0 service and receive data from the device through it.

I’d greatly appreciate any assistance in finding the reason why Bleak cannot see/connect to this service. Please let me know if there is any other info I can provide.

Here is the output when running examples/service_explorer.py:

2022-12-11 21:21:10,169 __main__ INFO: starting scan...
2022-12-11 21:21:14,636 __main__ INFO: connecting to device...
2022-12-11 21:21:16,150 __main__ INFO: connected
2022-12-11 21:21:16,150 __main__ INFO: [Service] 0000180a-0000-1000-8000-00805f9b34fb (Handle: 1): Device Information
2022-12-11 21:21:16,309 __main__ INFO:   [Characteristic] 00002a27-0000-1000-8000-00805f9b34fb (Handle: 2): Hardware Revision String (read), Value: bytearray(b'1.2')
2022-12-11 21:21:16,489 __main__ INFO:   [Characteristic] 00002a29-0000-1000-8000-00805f9b34fb (Handle: 6): Manufacturer Name String (read), Value: bytearray(b'eufy')
2022-12-11 21:21:16,579 __main__ INFO:   [Characteristic] 00002a25-0000-1000-8000-00805f9b34fb (Handle: 10): Serial Number String (read), Value: bytearray(b'0002LF1101100001')
2022-12-11 21:21:16,668 __main__ INFO:   [Characteristic] 00002a26-0000-1000-8000-00805f9b34fb (Handle: 4): Firmware Revision String (read), Value: bytearray(b'106.112.106')
2022-12-11 21:21:16,758 __main__ INFO:   [Characteristic] 00002a24-0000-1000-8000-00805f9b34fb (Handle: 8): Model Number String (read), Value: bytearray(b'T9148')
2022-12-11 21:21:16,758 __main__ INFO: [Service] 0000180f-0000-1000-8000-00805f9b34fb (Handle: 12): Battery Service
2022-12-11 21:21:16,848 __main__ INFO:   [Characteristic] 00002a19-0000-1000-8000-00805f9b34fb (Handle: 13): Battery Level (read,notify), Value: bytearray(b'd')
2022-12-11 21:21:16,938 __main__ INFO:     [Descriptor] 00002902-0000-1000-8000-00805f9b34fb (Handle: 15): Client Characteristic Configuration, Value: bytearray(b'\x01\x00')
2022-12-11 21:21:16,938 __main__ INFO: disconnecting...
2022-12-11 21:21:19,639 __main__ INFO: disconnected

Here is a screenshot from nRF Connect showing all 3 services: Screenshot_20221211-224659

What I Did

Here is the script I wrote to try to connect to the 0xFFF0 service (which has an 0xFFF4 notify characteristic):

import asyncio
import binascii

from bleak import BleakClient, BleakGATTCharacteristic

SCALE_MAC = "CF:E6:08:09:01:02"
WEIGHT_CHARACTERISTIC_UUID = "0000fff4-0000-1000-8000-00805f9b34fb"

def notification_handler(characteristic: BleakGATTCharacteristic, data: bytearray):
    print(f"{characteristic.description}: {binascii.hexlify(data)}")

async def main():
    async with BleakClient(SCALE_MAC) as client:
        print(f"Connected: {client.is_connected}")

        await client.start_notify(WEIGHT_CHARACTERISTIC_UUID, notification_handler)
        await asyncio.sleep(60.0)
        await client.stop_notify(WEIGHT_CHARACTERISTIC_UUID)  

asyncio.run(main())

Here is the output I get when I run this script:

Connected: True
Traceback (most recent call last):
  File "/home/brandon/repos/bttest/bttest/main.py", line 29, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 646, in run_until_complete
    return future.result()
  File "/home/brandon/repos/bttest/bttest/main.py", line 23, in main
    await client.start_notify(WEIGHT_CHARACTERISTIC_UUID, notification_handler)
  File "/home/brandon/.cache/pypoetry/virtualenvs/bttest-OGrXrS0o-py3.10/lib/python3.10/site-packages/bleak/__init__.py", line 639, in start_notify
    raise BleakError(f"Characteristic {char_specifier} not found!")
bleak.exc.BleakError: Characteristic 0000fff4-0000-1000-8000-00805f9b34fb not found!

Logs

Here are the debug logs from running the above script. bleak_debug.log

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15

Most upvoted comments

If the characteristic doesn’t show up in BlueZ, then there is no way for Bleak to use it.