Retrieve device GATT services

Used to retrieve the GATT service list of a specified connected device.

Refer to the RESTful API Discover GATT Services and Characteristics.

Example

 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]

Used to retrieve the GATT service list of a specified connected device. The result is returned as a JSON string.

Parameters:
  • Device MAC address

Returns:

  • ok: Whether the operation was successful

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

[
   {
      "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"
                  }
               ]
            }
      ]
   }
]
Field Description

Field

Type

Description

Example

uuid

str

UUID

00001801-…

handle

int

Handle used for read and write operations

1

properties

int

Properties

32