Do you want to know how the Bluetooth Low Energy Protocol Stack works?
You’ve come to the right place.
A protocol is a rulebook that devices must adhere to in order to communicate or exchange information.
So, what is the Bluetooth LE Protocol? The same thing. A rulebook that has to be followed by devices that use the standardized Bluetooth Low Energy technology for communication purposes.
Second, picture a rulebook divided into several chapters.
The general functionality of a protocol is also divided into smaller protocols, each of which is in charge of a particularly specific task. These smaller protocols are packaged into a layered architecture called a protocol stack or protocol suite.
So, what is a Bluetooth LE Protocol Stack? The same thing. A package of smaller protocols, where each focuses on a specific role. These smaller protocols are packaged into layers that work together to provide the overall functionality of the Bluetooth Low Energy Protocol.
The knowledge of these two concepts—protocol and protocol stack—clears up the mystery and gives you some idea of what to expect while learning about the Bluetooth Low Energy protocol stack.
Gear up, and let’s get started with our exploration of the Bluetooth LE protocol stack.
Break It Down: Subsystems of the LE Protocol Stack
The Bluetooth Low Energy protocol stack is broadly broken down into three primary components or subsystems.
These are the application, host, and controller blocks.
This is software that acts as a man-machine interface by bundling together the entire functionality of Bluetooth LE protocol in a fashion that is accessible to the user.
The host is typically a software stack made up of the topmost layers of the LE stack as well as what are known as profiles.
A profile offers details on how each protocol in the stack should communicate with one another and work together for a certain usage model.
LE Profiles act as a commander by directing the soldiers (the layers of the protocol stack) in a specific enemy’s direction (specific usage model).
The controller is a subsystem that consists of the lower layer protocols in the LE stack.
The LE controller also consists of a physical radio that can generate and receive radio waves in the 2.4 GHz band, encode the RF signals with data (GFSK modulation) and radiate the signals through an antenna.
It should be able to receive RF waves as well as understand how these signals can be interpreted as data packets with information within them.
Host, Controller, Host Controller Interface (HCI)
The HCI is an optional part of the stack. It provides a standardized communication interface between the host and the controller.
If it is omitted, it means in such a device, the functionality of a host and a controller will be implemented by the same processor.
Source: Inside Bluetooth Low Energy
If it is included, then it allows a device to implement the Bluetooth LE functionality using a host from one vendor and a controller from another vendor (on different chipsets).
For example, a Bluetooth USB dongle attached to a PC.
Another example is a smartwatch.
Open It Up: The Protocol Layers in the LE Subsystems
The host and the controller subsystems house different protocol layers.
Do you want to take a look?
Casting (Different Communication Styles)
In computer networking, casting is the process of sending data from one device to another.
Just as there are many possible ways we humans can communicate with each other, so too are there several types of casting that can take place between devices in a network.
For example, if I want only to have one-to-one communication with one specific person in my contacts, I would send them a direct message on WhatsApp.
However, if I want to send a message to all my contacts, I would broadcast the message on my WhatsApp status.
And if I want to send a message to a specific group of people called ” serious engineers,” I would create a Whatsapp group and add only those people whom I want to communicate with.
Similarly, Bluetooth LE Protocol allows devices to exchange messages in different styles:
- Unicast Communication (one-to-one)
- Broadcast Communication (one-to-many)
In a one-to-one communication style, there is a dedicated link (connection) between two devices, and data can flow in both directions.
An example of this would be sending an “open the door” command from your smartphone to your Tesla’s door lock via Bluetooth LE and receiving a “door open” status notification back in return.
In this type of communication, one device must initially start or stop the connection, and the other device is said to “accept” the connection.
On the other hand, there is the one-to-many communication style. Here, a device can share (broadcast) its data with others without being connected to them.
In Bluetooth LE, sharing data without connecting to others first is referred to as advertising, and searching (listening) for advertised data is referred to as scanning.
Even in this communication style, the devices involved have roles. One device is tasked with advertising, while the other is tasked with scanning.
An example of this would be beacons in a retail store broadcasting their data, which in this case may be marketing notifications, to any LE-enabled smartphone in range. The beacon is the advertiser and the smartphone is the observer who is scanning.
There is also a many-to-many communication style. But we won’t get into that topic for now.
The main thing to bear in mind from this is that in each type of communication style, each device involved has a specific role to play in order for the exchange to be successful.
The GAP, Link Layer & Physical Layer
Let’s start with the GAP.
GAP stands for Generic Access Profile.
The Generic Access Profile is responsible for defining devices’ roles in Bluetooth LE communication, among other things.
There are four device roles defined by the GAP:
In a connection-less communication( broadcasting), where the exchange of data between devices occurs without first establishing a connection, the Bluetooth LE devices involved take on the roles of Broadcaster and Observer.
A broadcaster is expected to share the information, and an Observer is expected to be listening for such information.
In a connection-oriented communication (unicast), where data is only exchanged after a connection has been established between two devices, the Bluetooth LE devices involved take on the roles of Peripheral and Central.
The first step of a connection-oriented communication is device discovery. Here the peripheral device is expected to be announcing its presence by advertising, while the Central device is expected to be looking for such announcements by scanning and then sending a connection indication to the peripheral device.
Once a connection is established, data can flow in both directions between the two devices.
The GAP roles essentially outline the tasks you can anticipate from a device during a Bluetooth LE communication transaction.
Just as you cannot expect a banana to grow on a mango tree, you cannot anticipate that a central device will announce its presence through advertising. That’s the job of a peripheral device.
In summary, one can say that the Generic Access Profile gives us access to the link layer state machine.
Hold on, what’s a link layer state machine? I am glad you asked.
2. The Link Layer
The Link layer is the second lowest protocol in the Bluetooth Low Energy protocol stack.
It’s responsible for managing the state of the LE radio, among other things.
To do this, the Link layer relies on a state machine.
So, what’s a state machine? In short, it’s a model that defines how a system should behave under certain conditions.
Let’s take H2O, for example.
H2O can exist in 3 different states easily observable in nature: solid (ice), liquid (water), and gaseous (steam, fog, clouds).
The behavior of H2O varies in each of these states. When water is liquid, it flows; when it is solid, it is frozen.
And the means of forcing transitions between the three states is also well-defined.
Similar to this, the link layer provides seven different states for a Bluetooth LE radio. The LE radio acts differently in each state.
In this post, we’ll focus on 5 of the seven states. These are:
- Standby state
- Advertising state
- Scanning state
- Initiating state
- Connection state
In a standby state, the LE radio is not doing much. It’s neither sending nor receiving any packets. It is idle. The LE radio can enter the standby state from any of the other six states.
In an advertising state, the LE radio is broadcasting advertisement packets that can be received by any LE-enabled device in range.
The advertisement packets broadcast the device’s presence and share information about it with other devices in the vicinity.
In a scanning state, the LE radio is looking (listening) for packets that are being broadcasted by other LE-enabled devices in range.
In an initiating state, the LE radio is attempting to establish a connection with another LE-enabled device. The LE radio can enter the initiating state from the standby state.
In a connection state, the LE radio is connected to another LE-enabled device, and data can be exchanged between the two devices.
Now let’s link these radio states with the GAP roles.
For a device that has a broadcaster role, its radio can be in the following states: standby and advertising.
For a device that is an observer, its radio can be in the following states: standby and scanning.
For a device that has a peripheral role, its radio can be in the following states: standby, advertising, and connection states.
And for a device that has taken the central role, its radio can be in the following states: standby, scanning, initiating, and connection states.
Based on a device’s GAP role, its radio is expected to be in certain link layer states.
And finally, let’s discuss the Physical layer.
3. Physical layer
The physical layer (PHY) is the lowest layer of the Bluetooth LE protocol stack.
It relates to the physical method used to transmit the information, which in this case is the use of RF waves for transmitting and receiving raw bits over the air.
The PHY defines how these bits are modulated onto an RF carrier wave, as well as how this RF carrier wave is transmitted and received by the radio hardware.
A Bluetooth LE radio hardware must operate in the ISM band (2.4 GHz spectrum), which is segmented into 40 RF channels, each separated by 2 MHz (center-to-center), as shown in the following figure:
Some of the other rules that an LE radio must obey are:
- It should use the Gaussian Frequency Shift Keying (GFKS) as a modulation scheme.
- It should use Frequency Hopping Spread Spectrum (FHSS), which allows the two communicating devices to switch to randomly (agreed-on) selected frequencies for exchanging data. This greatly improves reliability and allows the devices to avoid frequency channels that may be congested and used by other devices in the surrounding environment.
- The transmit power levels are: Minimum: 0.01 mW (-20 dBm), and Maximum: 100mW (+20 dBm) for version >= 5, 10mW (+10 dBm) for version <= 4.2
- The allowed data rates are 1 Mbps for an LE 1M PHY radio, 2 Mbps for an LE 2M PHY radio, and 500 kbps or 125 kbps for an LE Coded PHY radio.
As mentioned, the smaller protocols (layers) in a protocol stack work together for the ultimate functionality of a communication protocol.
In this post, we demonstrated how the GAP layer, link layer, and PHY layer each have unique responsibilities while cooperating as a whole.
- The PHY radio is in charge of exploiting RF waves to transmit and receive raw bits of data.
- The link layer controls the state of the PHY radio based on the GAP role of the device.
However, the GAP does more than just define roles. There is more to the PHY layer than what we have covered here, and there is more to the link layer than the link layer state machine.
Join the Bluetooth Developer Academy to get instant access to the Core Foundations Course and get the full learning experience of the Bluetooth Low Energy stack.
The remaining protocol layers will be discussed in the next blog post.