Expand description
The Attribute Protocol.
ATT is what GATT is made of, and on Linux it is reachable directly: an L2CAP socket bound to the fixed ATT channel (CID 4) is a GATT connection, with the kernel establishing the LE link when the socket connects. No daemon, no D-Bus, no privileges.
The protocol is small. Every PDU is an opcode byte and a payload, all little-endian, and every request gets exactly one response — the peer will not accept a second request until the first is answered, which is why a client has to serialise them.
GATT’s discovery procedures are built from four of them:
| To find | Send | Over |
|---|---|---|
| primary services | Read By Group Type of 0x2800 | 0x0001..=0xFFFF |
| characteristics | Read By Type of 0x2803 | the service’s handle range |
| descriptors | Find Information | after the value handle |
| a value | Read / Read Blob | one handle |
Subscribing is not a protocol operation at all: you write 0x0001 to the
characteristic’s Client Characteristic Configuration descriptor, and
notifications then arrive unsolicited as Handle Value Notification.
Modules§
Structs§
- AttError
- An ATT error code, as the peer reports it.
- Characteristic
- A discovered characteristic.
- Descriptor
- A discovered descriptor.
- Include
- One
Includedeclaration: a service pointing at another service. - Service
- A discovered primary service.
Enums§
Functions§
- error_
response Error Response— how a server declines a request it will not serve.- exchange_
mtu_ request - exchange_
mtu_ response Exchange MTU Response— our answer when the peer opens the exchange.- execute_
write_ request Execute Write Request— apply the queued fragments, or discard them.- find_
information_ request - handle_
value_ confirmation - is_
peer_ request - Is this opcode a request the peer is making of us?
- is_
unsolicited - Whether a PDU arrived unprompted, and so must not be matched to a request.
- parse
- Decode one PDU.
- prepare_
write_ request - A write with no response. The peer never acknowledges it, so there is
nothing to wait for and nothing to learn if it is dropped.
Prepare Write Request— one fragment of a value too long for one write. - read_
blob_ request - read_
by_ group_ type_ request - read_
by_ type_ request - read_
request - write_
command - write_
request