GATT Server and Client Roles#
Introduction#
Bluetooth Low Energy is a powerful and complex technology, which is different from the classic Bluetooth with a predefined set of official profiles to choose from. Although Bluetooth Low Energy does have predefined (a.k.a. "adopted") profiles specified by the Bluetooth SIG, they are just the tip of the iceberg, a small subset of the functionality possible to achieve with BLE.
In many (or even most) cases, the best option is to create custom profile(s) for your application because it provides ultimate flexibility without an associated cost. In fact, it can be even easier than using one of the adopted profiles because you get to define exactly how everything works rather than conforming your application into something that is already defined. Also, because there is no official generic "serial port profile" in the BLE world, such as SPP in classic Bluetooth, sometimes a custom implementation is the only option to do what you need.
To have an effective custom implementation, it is important to understand how a BLE connection works, what roles are played by the devices involved, and how data is transferred from one device to the other over the air. Many terms are used, which are usually not interchangeable and mean different things: central, peripheral, client, server, advertise, scan, read, write, notify, and indicate. Understanding the terminology will make it easier to describe and build your BLE application.
Quick Overview#
This document covers the following:
Client devices access remote resources over a BLE link using the GATT protocol. Usually, the central is the client (but not necessarily).
Server devices have a local database and access control methods and provide resources to the remote client. Usually, the peripheral is the server (but not necessarily).
You can use read, write, notify, or indicate operations to move data between the client and the server.
Read and write operations are requested by the client and the server responds (or acknowledges).
Notify and indicate operations are enabled by the client but initiated by the server, providing a way to push data to the client.
Notifications are unacknowledged, while indications are acknowledged. Notifications are therefore faster but less reliable.
To learn about central and peripheral roles, see Central and Peripheral Roles.
GATT Server vs. GATT Client#
An important concept in BLE design is the difference between a GATT server and a GATT client (where GATT means Generic ATTribute profile). These roles are not mutually exclusive, though typically your device will only be a server or a client. Role(s) that your device takes depend on its intended functionality. This is a basic summary of functionalities:
GATT client - a device which accesses data on the remote GATT server via read, write, notify, or indicate operations
GATT server - a device which stores data locally and provides data access methods to a remote GATT client
Unlike the central/peripheral distinction defined under Connections, it is easy to see that one device might be both at the same time, based on how your application defines the data structure and flow for each side of the connection. While it is most common for the peripheral device to be the GATT server and the central device to be the GATT client, this is not required. The GATT functionality of a device is logically separate from the central/peripheral role. The central/peripheral roles control how the BLE radio connection is managed while the client/server roles are dictated by the storage and flow of data.
Most of the example projects in the SDK archive and online implement peripheral devices designed to be GATT servers. These are easy to test with our EFR Connect App (available for Android and iOS). However, there are also a few examples which implement the central end of the connection, designed to be GATT clients.
Receive vs. Transmit - Moving Data#
In BLE projects built using the Bluetooth SDK, the GATT structure can be configured using the built-in tool from Simplicity Studio, called the Bluetooth GATT Configurator. This can be found under the Configuration tools in the .slcp file. After you modify the GATT Configuration, the gatt_db.c/.h an