GATT operations

As we’ve seen, the GATT layer defines services and characteristics, made up of attributes, that are stored in the GATT server. In this lesson we will discuss data exchange in Bluetooth LE which refers to the operations that are executed between the server and the client to learn about attributes and exchange their values in accordance with attributes permissions.

The server can either send data directly to the client or the client can poll the data from the server. But for the client to know what to request from the server, it needs to know what services and characteristics the GATT server offers. The client will therefore perform service discovery at the beginning of the connection, to learn about the services and characteristics of the server, before performing any operations to access them.

Definition

Service discovery: The process in which a GATT client discovers the services and characteristics in an attribute table hosted by a GATT server.

Data access

Recall that the communication here 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. Hence, GATT operations are classified into client-initiated operations and server-initiated operations.

Client-initiated operations

Client-initiated operations are GATT operations where the client requests data from the GATT server. The client can request to either read or write to an attribute, and in the case of the latter, it can choose whether to receive an acknowledgment from the server.

We will take a closer look at these operations in exercise 1 of this lesson.

Read

If a client wishes to read a certain value stored in an attribute on a GATT server, the client sends a read request to the server. To which the server responds by returning the attribute value.

Write

If the client wishes to write a certain value to an attribute, it sends a write request and provides data that matches the same format of the target attribute. If the server accepts the write operation, it responds with an acknowledgement.

Write without response

If this operation is enabled, a client can write data to an attribute without waiting for an acknowledgment from the server. This is a non-acknowledged write operation that can be used when quick data exchange is needed.

Server-initiated operations

The other category of GATT operations are server-initiated operations, where the server sends information directly to the client, without receiving a request first. In this case, the server can either notify or indicate.

We will take a closer look at server-initiated operations in exercise 2 of this lesson.

Notify

A Notify operation is used by the server to automatically push the value of a certain attribute to the client, without the client asking for it. This, for example, can be used to update the client about a certain sensor reading which has changed recently.

Notifications require no acknowledgment back from the client.

Indicate

Similar to the Notify operation, Indicate will also push the attribute value directly to the client. However, in this case, an acknowledgment from the client is required. Because of the acknowledgement requirement, you can only send one Indication per connection interval, meaning Indications are slower than notifications.

Although these operations are initiated by the server, the client is required to enable them first by subscribing to the characteristic and enabling either notifications or indications. This will be explained more in the next topic when we discuss the client characteristic configuration descriptor.


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.