Read device GATT value

Used to read the value of a specified Handle on a connected device.

Refer RESTful-API Read the Value of a Specific Characteristic.

Example

 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]

Used to read the value of a specified Handle on a connected device. The result is returned as a JSON string.

Parameters:
  • addr: Device MAC address

  • handle: Handle to be read

Returns:

  • ok: Whether the operation was successful

  • result: Execution result as a JSON string. Example:

{
   "handle": "44",
   "value": "A00100"
}
Field Description

Field

Type

Description

Example

handle

str

Handle

44

value

str

Value

A00100