Python BLE 发现所有 UUID 特征

Python BLE discover all UUID characteristics

到目前为止,这段代码正在向我返回服务的 UUID。但是我里面有几个特征,我能查到他们的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())

discover只是从设备获取广告信息。在那个阶段,您的客户将不会解析服务并了解其特征。该信息仅在客户端连接到设备后可用。浏览文档,您似乎通过 get_services 获得了所需的信息,因为 returns GATT 服务树:

https://bleak.readthedocs.io/en/latest/api.html#bleak.backends.client.BaseBleakClient.get_services