Breaking Down the BLE Link Layer—The 7 States of Bluetooth LE Radio
Explore the seven states of the Bluetooth LE radio, how the link layer state machine manages the LE radio, and the roles of these states in wireless communication.
In wireless communication, the radio is a component that enables devices to transmit and receive information through electromagnetic waves. It facilitates data exchange between devices over the air, eliminating the need for physical connections. Controlling the radio is crucial for Bluetooth LE because of its specific communication setups and application data types. Each configuration and data type demands tailored radio optimizations for optimal performance.
For instance, there are isochronous data that require precise synchronization. Then there's the reliable user data type, where "reliable" signifies that peripheral devices can identify errors in received packets and request retransmission. In this case, radio optimizations focus on facilitating bidirectional communication channels, allowing for data exchange and acknowledgments.
On the other hand, we have the unreliable user data type, where "unreliable" denotes that devices aren't privy to acknowledgments for their transmissions. For this data type, radio optimizations are geared toward enabling efficient broadcast communication.
With all that in mind, you can see how taking control of the Bluetooth radio ensures smooth communication across a diverse range of scenarios and adapts to the specific needs of each data type. Now, you might be curious, what's the trick to controlling the LE radio? Well, the answer lies in using a state machine, which we'll dig into in the next section.
What’s a State Machine? Components of a Finite State Machine
A state machine, or finite state machine (FSM), is a mathematical model of computation and a conceptual tool used in computer science, engineering, and other fields to represent systems with a finite number of states, transitions between those states, and actions. Figure 1 shows a high-level overview of an FSM.
Figure 1. A high-level representation of an FSM. Image used courtesy of Isaac Computer Science
This model describes a system's behavior in terms of its current state and the rules for transitioning from one state to another based on inputs, events, or conditions.
A state machine consists of the following components:
- States: A finite set of distinct conditions or situations the system can be in. Each state represents a specific behavior or configuration of the system.
- Transitions: A set of rules or conditions that define how the system can move from one state to another. These transitions are usually triggered by input signals or events.
- Initial state: The state in which the system starts. There can only be one initial state.
- Final state(s) (optional): One or more states where the system can end or halt its operation. Not all state machines have final states.
State machines can model various systems, including digital circuits, communication protocols, software systems, and even business processes. They help understand, design, and analyze such systems' behavior, making them easier to manage and maintain.
Next, let's explore how the Bluetooth LE communication protocol uses a state machine to manage the behavior of its radio.
The Link Layer and Its Role in Managing the BLE Radio
The Bluetooth LE communication protocol consists of multiple layers, with the physical (PHY) layer being the most fundamental. The PHY layer includes the radio, composed of 40 physical channels. However, the radio alone doesn't determine how these channels are used. This is where the link layer (Figure 2), the second layer in the Bluetooth LE protocol suite, comes into play.
Figure 2. An example BLE protocol stack showing the link layer. Image used courtesy of Microchip
The link layer defines the usage of the physical channels through a state machine, which manages the radio's behavior and optimizes it for a specific application traffic type. The term "link" refers to a logical baseband channel that is established between devices. The term "logical" here implies a conceptual or virtual connection rather than a tangible, physical one.
Overall, the main difference between a link and a physical channel lies in their abstraction levels within the communication process. While physical channels are the raw pathways for data transmission, links serve as virtual pathways that use well-defined frameworks to manage and control data transmission over the physical channels. Basically, the link layer creates and oversees links, which adapts the physical channels' behavior to meet the unique needs of different application traffic types. To handle the diverse radio behaviors required by various data types, the link layer employs a state machine for efficient management.
States in Bluetooth LE Link Layer State Machine
The Bluetooth LE radio operates within seven distinct states (Figure 3), each with a specific purpose or behavior and set of transitions to and from other states.
Figure 3. State diagram of the link layer state machine. Image used courtesy of Bluetooth via Bluetooth Specification Version 5.3 | Vol 6, Part B, page 2664
The standby state of Bluetooth LE means that the radio is idle. It uses very little power and doesn't send or receive any information (packets). The link layer can switch the radio to this state from any other state.
A device with a radio in this state is called the advertiser. The radio can transition into this state from the standby state, which can be shown in Figure 4.
Figure 4. Advertising process and channel use. Image used courtesy of Bluetooth and Martin Wooley [Click image to enlarge]
In the advertising state, the radio uses channels 37, 38, and 39 to broadcasts advertising packets to announce its presence and provide information to nearby devices. There are three different advertising modes that a LE radio can use to determine the type of connections a device supports.
- Connectable advertising
- Non-connectable advertising
- Scannable advertising
When a device uses connectable advertising, it's telling others, "Hey, I'm here and ready to connect!" It shares information about itself and is open to making a connection with a suitable initiator. When a scanning device receives a connectable advertising packet, it may send a connection request to the advertiser, initiating the connection process. Devices like smartphones or wearables often use this mode when they need to communicate with each other.
In non-connectable advertising, a device says, "I'm here, but I don't want to connect." It shares some info about itself, but it won't make a connection with other devices. This mode is perfect for things like beacons, which only need to broadcast data without having to establish a bidirectional link to anything.
Scannable advertising is a bit like non-connectable advertising, with a twist. A device sends out a little bit of info and hints, "If you're interested, ask me for more!" When another device sends a scan request, the advertiser shares extra details. However, just like non-connectable advertising, scannable advertising doesn't support making connections. This mode allows devices to save energy by only sending out detailed information when it's explicitly requested by a scanning radio.
A radio transitions into this state from the standby state. In the scanning state, the radio listens for advertising packets from other devices. This enables the device to discover nearby Bluetooth LE devices and gather information about their services.
After scanning, if the scanning device does not find a target device to connect with or does not need to establish a connection at that moment, it may return to the standby state. Additionally, if it discovers a target device it wishes to connect with, it can transition to the initiating state.
A radio transitions into this state from the advertising state. The radio attempts to connect with a specific advertiser device in this state. Upon receiving a connectable advertising packet, the radio sends a connection request to the target advertiser. The connection request includes parameters such as channel map, connection interval, and peripheral latency.
Devices in this state exchange data over an established connection. They agree on connection settings, pair, and create secure bonds.
A device can enter this state from the initiating or advertising state. If it comes from the initiating state, it becomes the "central" device, taking charge of managing the connection. If it comes from the advertising state, it takes on the "peripheral" role, following the central device's lead.
During the synchronization state, the radio of the observer device listens for periodic advertising packets and isochronous data packets. Periodic advertising, introduced in Bluetooth 5.0, allows advertisers to broadcast data at fixed intervals. This makes it easier for observer devices to predict when the next packet will be sent, enabling them to synchronize their scanning schedules with the advertising device's schedule.
As a result, observer devices can enter a low-power mode between intervals and wake up just in time to receive the subsequent packet. This power-efficient approach significantly improved legacy advertising, which required a higher RX duty cycle to accommodate the unpredictable timing of advertising events.
Isochronous Broadcasting State
Isochronous communication is all about transmitting time-sensitive data like audio or video between devices, with precise synchronization. This method has stringent timing constraints to avoid aged data. Data has to be sent and received within a specific time frame to preserve its accuracy and relevance.
Radios enter the isochronous broadcasting state from Standby mode to broadcast isochronous data. This state is primarily designed for use in LE audio products and systems. It enables audio to be sent from a source to multiple receivers, called sinks, simultaneously, ensuring that all devices play the sound in sync.
Reliable Application (User) Data Transmission
Reliable application data transmission involves point-to-point (unicast) data transfer between two devices, guaranteeing error-free and accurate reception of the data. The term "reliable" indicates that peripheral devices can identify errors in received packets and ask for retransmission, ensuring proper delivery.
The process of carrying out reliable data transmission in Bluetooth LE involves particular states of the radio.
Here's an overview of the steps and the states involved:
- Advertising State: The peripheral device (e.g., a sensor) starts in the advertising state, broadcasting advertising packets to announce its presence and provide information about its services. These advertising packets usually indicate that the device supports connectable advertising, which means it's open to establishing a connection with a central device (e.g., a smartphone).
- Scanning State: The central device enters the scanning state to listen for advertising packets from nearby peripherals. Upon discovering a peripheral with connectable advertising, the central device may decide to initiate a connection.
- Initiating State: The central device transitions to the initiating state to actively establish a connection with the chosen peripheral. It sends a connection request to the peripheral upon receiving a connectable advertising packet.
- Connection State: Once the connection is established, both devices enter the connection state. In this state, they can exchange data using a data link specifically optimized for connected communication.
Unreliable Application (User) Data Transmission
Unreliable application data transmission involves broadcast communication between devices without assurance of successful reception or error-free data transfer. The term "unreliable" means that devices don't get acknowledgments for their transmissions because the communication channel is unidirectional.
Broadcast communication is typically used for applications where it is more important to minimize latency and power consumption than to ensure data integrity.
Here's an overview of the steps and the states involved:
- Advertising State: The broadcaster device (e.g., a beacon) starts in the advertising state, broadcasting advertising packets over physical channels 37, 38, and 39. These packets usually contain non-connectable or scannable advertising, which indicates that the device is not open to establishing a connection with a central device. Instead, it is focused on sharing information with any devices within its range.
- Scanning State: The observer devices enter the scanning state to listen for advertising packets from nearby broadcasters. Upon discovering a broadcaster with non-connectable or scannable advertising, the observer devices can receive the data shared by the broadcaster.
In this process, the observer devices do not send acknowledgments or connection requests to the broadcaster. As a result, there is no retransmission mechanism in place. If an advertising packet is lost or corrupted, the observer devices will not request retransmission, and the broadcaster will not be aware of any issues with the transmission.
Despite its unreliability, broadcast communication in Bluetooth LE can be advantageous in certain scenarios. It reduces power consumption and latency, as devices do not need to maintain connections or handle acknowledgments and retransmissions. This makes it suitable for applications such as beacons, location-based services, or sensor networks, where the primary goal is to share information periodically with minimal overhead.
Unreliable Isochronous Application (User) Data
Isochronous application data transmission involves sending synchronized audio streams from an audio source device, like a smartphone, to one or more audio syncs devices, such as earbuds or earphones.
Here's an overview of the steps and states involved in isochronous data transmission:
- Advertising State: The broadcaster device starts in the advertising state, broadcasting advertising packets with information about its isochronous capabilities. These packets typically contain information about the data's timing requirements and the type of data being transmitted.
- Scanning State: The observer devices enter the scanning state to listen for advertising packets from nearby broadcasters. Upon discovering a broadcaster with isochronous data capabilities, the observer devices can synchronize their timing with the broadcaster.
- Synchronization State: After synchronizing their timing with the broadcaster, observer devices enter the synchronization state. In this state, they maintain a consistent schedule to receive the isochronous data transmissions from the broadcaster.
- Isochronous Broadcasting State: The broadcaster device transitions to the isochronous broadcasting state to transmit the isochronous data at regular intervals, as defined by the timing requirements. This state ensures the low latency and time-synchronized delivery of data to the observer devices.
Isochronous communication is not limited to broadcasting mode; it can also be connection-oriented or bi-directional. In these cases of unicast data transmission, the radio uses something called Connected Isochronous Group (CIG) events. This is different from when it's broadcasting, which uses Broadcast Isochronous Group (BIG) events.
Benefits of Understanding the Link Layer of BLE Radio
We've looked at the seven states of the Bluetooth LE radio, the way the link layer state machine governs the LE radio, and the roles these states serve. By understanding the different states and their functions, we can appreciate the intricacies of Bluetooth LE technology.