Also known as BLE. Not to be confused with Bluetooth, which is completely different except for where it's the same.

GATT

The Generic Attribute Profile is the core BLE API. A server implements services, which are collections of one or more characteristics, and may have zero or more secondary services. A characteristic has a value, and optional descriptors. All three of these objects have UUIDs. Some UUIDs are assigned, and refer to standard objects. Others are vendor-defined. The UUIDs of a server's services, their characteristics, and their descriptors can be enumerated, but the client must give meaning to them (they are not self-describing). A characteristic can be read-only, write-only, or read-write, as defined by the server.

bluetoothctl

Discover local BLE devices' names and MAC addresses:

  • scan le

Operating with GATT requires connecting, as specified using the server's MAC:

  • connect MAC

Once connected, discover services and characteristics:

  • gatt.list-attributes

Operating with a characteristic requires selecting it by UUID:

  • gatt.select-attribute UUID

Read the selected characteristic:

  • gatt.read

Write the selected characteristic:

  • gatt.write DATA

DATA must be expressed as a series of bytes in the form 0xHH, separated by spaces. This can be generated on the command line via e.g.:

  • echo -n "here is some data" | xxd -p | sed -e 's/\(..\)/0x\1 /g'