读取设备GATT特征值

用于读取指定连接设备指定Handle的值。

参考RESTful-API Read the Value of a Specific Characteristic

示例

 1import asyncio
 2import cassiablue
 3
 4
 5async def main():
 6    print("start gatt read")
 7    addr = "20:00:00:00:00:01"
 8    handle = 44
 9    ok, ret = await cassiablue.gatt_read(addr, handle)
10    print("gatt read done:", type(ok), ok, type(ret), ret)
11
12
13asyncio.run(main())

API

async cassiablue.gatt_read(addr: str, handle: str) tuple[ok: bool, result: str]

用于读取指定连接设备指定Handle的值。结果返回JSON字符串。

Parameters:
  • addr: 设备MAC地址

  • handle: 待读取Handle

返回:

  • ok: 是否执行成功

  • result: 执行结果,JSON字符串,示例如下

{
   "handle": "44",
   "value": "A00100"
}
字段说明

字段

类型

说明

示例

handle

str

Handle

44

value

str

Value

A00100