pythonbluetooth-lowenergy

Python BLE discover all UUID characteristics


So far, this code is returning me the UUID of the service. But I have several characteristics inside of it, can I discover their UUID?

import asyncio
from bleak import BleakScanner

async def run():
    devices = await BleakScanner.discover()
    for d in devices:
        print(d.metadata)
            
loop = asyncio.get_event_loop()
loop.run_until_complete(run())

Solution

  • The discover is only getting the advertising information from the device. At that stage your client will not have resolved the services and know about the characteristics. That information is only available once the client has connected to the device. Browsing the documentation it looks like you get the information you want with the services property on the client.

    Example at:

    https://github.com/hbldh/bleak/blob/develop/examples%2Fservice_explorer.py