Skip to main content

Module att

Module att 

Source
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 findSendOver
primary servicesRead By Group Type of 0x28000x0001..=0xFFFF
characteristicsRead By Type of 0x2803the service’s handle range
descriptorsFind Informationafter the value handle
a valueRead / Read Blobone 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§

gatt_type
GATT’s own attribute types.
opcode
ATT opcodes.

Structs§

AttError
An ATT error code, as the peer reports it.
Characteristic
A discovered characteristic.
Descriptor
A discovered descriptor.
Include
One Include declaration: a service pointing at another service.
Service
A discovered primary service.

Enums§

Response
What came back.
Uuid
A 16- or 128-bit attribute type, as it appears on the wire.

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