获取连接列表
用于获取当前已连接的设备列表。
对应于RESTful-API Get the Device List Connected
示例
1import asyncio
2import cassiablue
3
4
5async def main():
6 print("start get connected devices")
7 ok, ret = await cassiablue.get_connected_devices()
8 print("get connected devices done:", type(ok), ok, type(ret), ret)
9
10
11asyncio.run(main())
API
- async cassiablue.get_connected_devices() tuple[bool, str]
用于获取当前已连接的设备列表。结果返回JSON字符串。
连接列表为空
{ "nodes": {} }
连接列表有设备
{ "nodes": [ { "bdaddrs": { "bdaddr": "20:00:00:00:00:01", "bdaddrType": "random" }, "handle": "", "id": "20:00:00:00:00:01", "connectionState": "connected", "name": "", "chipId": 0, "pairStatus": "none", "rssi": -21, "packetLossRate": 3, "tx_phy": "1M", "rx_phy": "1M" } ] }
字段说明 字段
类型
说明
示例
bdaddr
str
设备MAC地址
20:00:00:00:00:01
bdaddrType
str
设备地址类型
random
id
str
设备MAC地址
20:00:00:00:00:01
chipId
int
芯片
0
rssi
int
RSSI
-21
packetLossRate
int
丢包率
3
tx_phy
str
Tx Phy
1M
rx_phy
str
Rx Phy
1M