ATT & GATT: Data representation and exchange

In the previous topic, we discussed the role that the GAP layer plays in defining how Bluetooth LE devices communicate with each other in both the advertisement and connection phases. The communication during advertising is only used for device discovery or for broadcasting data and is handled by the GAP layer itself. However, after establishing a connection, there is a need for bidirectional data exchange. This requires specific data structures and protocols tailored for these purposes.

The Attribute protocol (ATT) layer, and the Generic Attribute protocol (GATT) layer right above it, define how data is represented and exchanged between Bluetooth LE devices. The ATT and GATT layers are concerned with the phase after a connection has been established, as opposed to the GAP layer which takes care of the advertisement process which occurs before a connection is established.

The Attribute Protocol

The ATT layer is the basis on which data is transmitted, received, and handled in the connection phase of Bluetooth LE devices. It is based on a client-server architecture where the server holds the data and can either send it directly to the client or the client can poll the data from the server.

The client and server roles defined in this layer are assigned independently from the peripheral and central roles defined in the GAP layer. So a central can be both a client or a server, and same with a peripheral. This all depends on the application use case and the nature of the data being transferred.

In most cases, the peripheral will be a server since the peripheral is the device that acquires data and holds it. Similarly, the central is typically the client as it is the device receiving said data from the server.

These roles are used by the GATT layer, so they are often referred to as the GATT server and the GATT client.

Definition

GATT server: Device that stores data and provides methods for the GATT client to access the data.
GATT client: Device that accesses the data on the GATT server, through specific GATT operations which will be explained in Lesson 4.

The ATT layer defines a data structure called the attribute, which is used by the GATT server to store data. The server can hold a number of different attributes at the same time.

Definition

Attribute: A standardized data representation format defined by the ATT protocol

The Generic Attribute Profile

The Generic Attribute Profile (GATT) layer sits directly on top of the ATT layer, and builds on it by hierarchically classifying attributes into profiles, services and characteristics. The GATT layer uses these concepts to govern the data transfer between Bluetooth LE devices.

Example of a general profile with services and characteristics

Profiles, services and characteristics

Let’s use a sensor device that measures the heart rate as an example. The heart rate value will be saved as an attribute, called the characteristic value attribute. There will also be another attribute holding metadata about the data stored in the value attribute, called the characteristic declaration attribute. These two attributes together form what’s called a characteristic. In this example, it’s the Heart Rate Measurement characteristic.

All characteristics are enclosed in what’s called a service. Services usually contain multiple characteristics. For this example, the Heart Rate Measurement characteristic is contained in the Heart Rate service. This service also has other characteristics, like the Body Sensor Location characteristic for example.

Then above this, a profile is one or more services that address the same use case. The Heart Rate service is found in the Heart Rate profile, along with the Device Information Service. The Device Information service contains characteristics such as the Manufacturer Name characteristic and the Firmware Revision characteristic.

Example of the Heart Rate profile

Before a client starts interacting with a server, the client is not aware of the nature of the attributes stored on that server. Therefore, the client first performs what’s called Service Discovery where it inquires from the server about the attributes.

Note

The complete list of GAP profiles defined by the Bluetooth SIG can be found here. The Bluetooth specification also allows vendors to define their own profiles for use cases not covered by the SIG-defined profiles.

Register an account
Already have an account? Log in
(All fields are required unless specified optional)

  • 8 or more characters
  • Upper and lower case letters
  • At least one number or special character

Forgot your password?
Enter the email associated with your account, and we will send you a link to reset your password.