Understanding the ATT Protocol in Bluetooth BLE: Core Insights into the Attribute Protocol

Bluetooth Low Energy (BLE) technology has rapidly become one of the mainstream choices for Internet of Things (IoT) device communication since its introduction, thanks to its low power consumption, low cost, and high flexibility. Within the BLE protocol stack, the Attribute Protocol (ATT) is a crucial foundational protocol that defines how devices discover, read, and write data. This article will delve into the core concepts, working principles, and key roles of the ATT protocol in BLE communication.

1. Basic Concepts of the ATT Protocol

The ATT protocol serves as the foundation for data interaction between the Host and Peripheral in the BLE protocol stack. It organizes data on devices into a series of “attributes” through a simple and efficient mechanism, enabling data access and management. Each attribute consists of three core components:

  1. Handle: A unique 16-bit identifier used to distinguish different attributes. The handle is the only index for the client to access the attribute.

  2. Type: Typically a UUID (Universally Unique Identifier) that describes the meaning or data type of the attribute. For example, an attribute may represent the battery level of a device, with its type being <span>0x2A19</span> (Battery Level Service UUID).

  3. Value: The actual data content of the attribute, which can be any binary data, with length depending on the specific application.

The ATT protocol itself does not define the specific meaning of the data; instead, it is the combination of type (UUID) and handle that gives the data specific business logic through the upper layer GATT (Generic Attribute Profile) protocol.

2. Working Modes of the ATT Protocol

The ATT protocol defines two main roles: Client and Server.

  • Server: Typically a BLE peripheral device (such as sensors, smartwatches, etc.), responsible for storing attributes and providing data access services. The server exposes its attribute table through the ATT protocol for the client to query and operate.

  • Client: Typically a BLE host device (such as smartphones, computers, etc.), responsible for actively initiating requests to read or modify attribute values on the server.

The ATT protocol employs a Request-Response or Notification/Indication communication model:

  • Request-Response: The client sends a request (such as reading a specific attribute value) to the server, which returns the corresponding response.

  • Notification/Indication: The server can actively send data to the client (such as sensor data updates) without an explicit request from the client. Notifications do not require client acknowledgment, while indications do require a client acknowledgment.

3. Key Operations of the ATT Protocol

The ATT protocol defines a series of standard operations for managing attribute access. Here are several core operations:

  1. Read Attribute (Read Request/Response)

    The client requests to read a specific attribute value by specifying the handle. The server returns the corresponding value. If the attribute value is lengthy, multiple interactions may be required (such as using the “Read Long Attribute” operation).

  2. Write Attribute (Write Request/Response)

    The client can write data to the server to modify a specific attribute value. The write operation can be with response (Write Request) or without response (Write Command). The latter is suitable for scenarios requiring high real-time performance (such as control commands).

  3. Discover Attributes (Discovery Procedures)

    The client can discover attributes on the server through the ATT protocol, including:

  • Discovering the handle range of all services (Primary Service Discovery)

  • Finding services of a specific UUID (Find By Type Value)

  • Discovering characteristics of services (Characteristic Discovery)

  • Discovering descriptors of characteristics (Descriptor Discovery)

  • Subscribe to Notifications/Indications

    The client can subscribe to a specific attribute of the server, and when that attribute value changes, the server will actively push notifications (or indications). This is very common in real-time data monitoring (such as heart rate monitoring).

  • 4. Features and Advantages of the ATT Protocol

    1. Lightweight Design

      The design of the ATT protocol is very simple, reducing protocol overhead, making it very suitable for low-power devices. Its communication is based on a simple request-response model, without complex handshakes or connection management.

    2. High Flexibility

      Through the combination of UUIDs and handles, the ATT protocol can support almost any type of data structure. The upper layer GATT protocol further defines standardized services (such as battery service, heart rate service, etc.), enabling interoperability between devices from different manufacturers.

    3. Support for Security Mechanisms

      The ATT protocol can be combined with BLE’s security mechanisms (such as pairing and encryption) to ensure data confidentiality and integrity. For example, certain sensitive attributes (such as device keys) can be set to be accessible only over encrypted connections.

    4. Efficient Data Access

      Direct access to attributes via handles avoids complex addressing processes, making data read and write more efficient. Additionally, the ATT protocol supports batch operations (such as reading multiple attributes), further optimizing communication efficiency.

    5. Relationship Between ATT and GATT

    Although the ATT protocol defines the basic mechanisms for data access, it does not specify how data is organized or the business logic. This task is accomplished by the GATT (Generic Attribute Profile) protocol. GATT builds on ATT to define a hierarchy of Services, Characteristics, and Descriptors, allowing BLE devices to expose data in a standardized manner.

    In simple terms:

    • ATT is the “lower-level protocol” responsible for data reading, writing, and discovery.

    • GATT is the “upper-level framework” that defines the semantics and structure of the data.

    For example, a BLE heart rate device may expose a “Heart Rate Measurement” characteristic through GATT, with its value being an attribute containing heart rate data. The client reads the value of this attribute through the ATT protocol, while the GATT protocol informs the client: “This attribute represents the heart rate measurement value.”

    6. Conclusion

    The ATT protocol is the cornerstone of BLE communication, enabling efficient data exchange between devices through a simple attribute model. Whether for smart bands, smart home devices, or industrial sensors, the ATT protocol quietly supports data transmission. Understanding the working principles of the ATT protocol is crucial for developing BLE applications, debugging device communication, or optimizing power consumption.

    In practical development, developers typically do not need to directly manipulate the ATT protocol (but rather through GATT or higher-level SDKs), but grasping the basic concepts of ATT helps in gaining a deeper understanding of BLE’s operational mechanisms. With the rapid development of the Internet of Things, the ATT protocol will continue to play a core role in low-power device communication.

    Leave a Comment