The LightBlue Bean runs on BLE, or Bluetooth Low Energy. BLE is a protocol developed by Bluetooth SIG that builds on the lessons learned from building lots of Bluetooth Classic devices. Compared to Bluetooth Classic, BLE consumes less power, requires less time and effort to pair devices, and provides lower connection speeds.
The Bluetooth Protocol Stack is divided into two categories: the controller and the host. Each category has sub-categories, which perform specific roles. The two subcategories we are going to look at is the Generic Access Profile (GAP) and the Generic Attribute Profile (GATT).
It is important to differentiate between GAP and GATT.
GATT specifically focuses on how data is formatted, packaged, and sent according to its described rules. In the BLE network stack, the Attribute Protocol (ATT) is closely aligned with GATT, where GATT sits directly on top of ATT. GATT actually uses ATT to describe how data is exchanged from two connected devices.
There are two mechanisms a BLE device can use to communicate to the outside world: broadcasting or connecting. These mechanisms are subjected to the Generic Access Profile (GAP) guidelines. GAP defines how BLE-enabled devices can make themselves available and how two devices can communicate directly with each other.
A device can join a BLE network by adopting these roles specified in GAP:
Broadcasting: These roles don't have to explicitly connect to one another to transfer data.
Connecting: These roles must explicitly connect and handshake to transfer data. These roles are more commonly used than the broadcasting roles.
Central Devices Can Update Connection Parameters: The central device typically establishes the connecting parameters between the peripheral device and itself. The central device can only modify the connecting parameters. However, the peripheral device can ask the central device to change the connection parameters.
Peripheral or Central Devices Can Terminate Connections: Connections might end for a variety of reasons: a device's battery might die or network interference might cause the connection to fail. Devices can also intentionally disconnect from their peers.
Similar to GAP, there are certain roles that interacting devices can adopt:
One example of a client-server relationship is as follows: I push a button on Bean and I want the computer to read that information. Bean acts as a server and provides information. The computer acts as a client, reading that information.
GAP and GATT roles are essentially independent of one another. Peripheral or central devices can BOTH act as a server or client, depending on how data is flowing. In contrast to the above example, if I wanted to send an update from from the computer to Bean, the computer acts as a server and Bean acts as a client.
Our guide focuses primarily on how GAP and GATT work. If you're interested on learning more about BLE in general, check out some of the resources below: