获取设备GATT服务列表
用于获取指定连接设备的GATT服务列表。
参考RESTful-API Discover GATT Services and Characteristics
示例
1import asyncio
2import cassiablue
3
4
5async def main():
6 print("start gatt discover")
7 addr = "20:00:00:00:00:01"
8 ok, ret = await cassiablue.gatt_discover(addr)
9 print("gatt discover done:", type(ok), ok, type(ret), ret)
10
11
12asyncio.run(main())
API
- async cassiablue.gatt_discover(addr: str) tuple[ok: bool, result: str]
用于获取指定连接设备的GATT服务列表。结果返回JSON字符串。
- Parameters:
addr: 设备MAC地址
- 返回:
ok: 是否执行成功
result: 执行结果,JSON字符串,示例如下
[ { "uuid": "00001801-0000-1000-8000-00805f9b34fb", "primary": true, "handle": 1, "characteristics": [ { "handle": 3, "properties": 32, "uuid": "00002a05-0000-1000-8000-00805f9b34fb", "descriptors": [ { "handle": 3, "uuid": "00002a05-0000-1000-8000-00805f9b34fb" }, { "handle": 4, "uuid": "00002902-0000-1000-8000-00805f9b34fb" } ] }, { "handle": 6, "properties": 10, "uuid": "00002b29-0000-1000-8000-00805f9b34fb", "descriptors": [ { "handle": 6, "uuid": "00002b29-0000-1000-8000-00805f9b34fb" } ] }, { "handle": 8, "properties": 2, "uuid": "00002b2a-0000-1000-8000-00805f9b34fb", "descriptors": [ { "handle": 8, "uuid": "00002b2a-0000-1000-8000-00805f9b34fb" } ] }, { "handle": 10, "properties": 2, "uuid": "00002b3a-0000-1000-8000-00805f9b34fb", "descriptors": [ { "handle": 10, "uuid": "00002b3a-0000-1000-8000-00805f9b34fb" } ] } ] }, { "uuid": "00001800-0000-1000-8000-00805f9b34fb", "primary": true, "handle": 20, "characteristics": [ { "handle": 22, "properties": 2, "uuid": "00002a00-0000-1000-8000-00805f9b34fb", "descriptors": [ { "handle": 22, "uuid": "00002a00-0000-1000-8000-00805f9b34fb" } ] }, { "handle": 24, "properties": 2, "uuid": "00002a01-0000-1000-8000-00805f9b34fb", "descriptors": [ { "handle": 24, "uuid": "00002a01-0000-1000-8000-00805f9b34fb" } ] }, { "handle": 26, "properties": 2, "uuid": "00002aa6-0000-1000-8000-00805f9b34fb", "descriptors": [ { "handle": 26, "uuid": "00002aa6-0000-1000-8000-00805f9b34fb" } ] } ] }, { "uuid": "6324be9e-236f-1edc-ac33-e2051caa4f2a", "primary": true, "handle": 40, "characteristics": [ { "handle": 42, "properties": 8, "uuid": "6324a123-236f-1edc-ac33-e2051caa4f2a", "descriptors": [ { "handle": 42, "uuid": "6324a123-236f-1edc-ac33-e2051caa4f2a" } ] }, { "handle": 44, "properties": 18, "uuid": "6324a321-236f-1edc-ac33-e2051caa4f2a", "descriptors": [ { "handle": 44, "uuid": "6324a321-236f-1edc-ac33-e2051caa4f2a" }, { "handle": 45, "uuid": "00002902-0000-1000-8000-00805f9b34fb" } ] } ] } ]
字段说明 字段
类型
说明
示例
uuid
str
UUID
00001801-...
handle
int
Handle用于读写操作
1
properties
int
属性
32