BLE Protocol Stack: PHY, Link Layer, L2CAP, ATT and GATT
Follow the BLE layers and the path of a data from the application to the antenna in simple language and know the function of GAP, GATT, ATT, L2CAP and SMP.
Contents

The BLE stack can be seen as a multi-layered administration: each layer solves a specific problem and passes data to the lower layer with a clear contract. This model specifies whether to go to Radio, Connection, Attribute, or Application Logic when debugging.
Controller: PHY and Link Layer
PHY converts bit to wave and wave to bit. Link Layer manages channel, scheduling, advertising, connection, sequence number, error control and link layer encryption. This section usually runs inside the radio controller and manufacturer's firmware.
HCI and Host boundary
In some chips, Host and Controller are on the same chip, and in some products they are separate. HCI moves commands, events, and data between the two. Seeing an HCI error usually means that the Host request was rejected by the Controller or an event about the state of the radio was received.
L2CAP, ATT and SMP
L2CAP carries the data of higher protocols on the logical link, fragmented and reassembled as needed. ATT defines the Attribute table and the Read and Write operations. SMP is responsible for pairing, key generation and part of the security process.
GATT and GAP
GATT on ATT defines Service, Characteristic and Descriptor model and how to use them. GAP manages device discovery, advertising, roles, connection mode and security levels. The application typically works with the GAP and GATT APIs, but the actual behavior depends on all layers.
Track a temperature Notify
The program puts the temperature value in Characteristic. The GATT selects the Notify operation, the ATT constructs a Handle Value Notification, the L2CAP carries it, the Link Layer determines the packet and transmission time, and the PHY transmits the bits on 2.4 GHz. In the receiver, the same path is followed in the opposite direction.
The path of a Notify with a value of 25 degrees
- Application: Converts 25 degrees to 2500 with hundredths of a degree scale.
- ATT: The Notification Opcode puts the Handle value and two data bytes into the PDU.
- L2CAP: carries the PDU on the corresponding channel.
- Link Layer: Manages packaging, transmission time, sequence number and link control.
- PHY: Transfers bits with the selected physical mode.
GATT defines the form of service and access method on ATT; You shouldn't always see an extra header with the name GATT in Capture. GAP is also not a fixed header on every application message. When debugging, first determine which layer the data reached.
Question and answer article
Ask your technical question
Questions and answers are published after moderation. Authors can see their own pending drafts.
No confirmed questions have been registered for this article yet.