Main Content

Bluetooth LE Channel Selection Algorithms

This example shows how to select the Bluetooth® low energy (LE) channel index by using the channel selection algorithms specified in the Bluetooth Core Specification [ 2 ]. Using this example, you can:

  • Use Algorithm #1 or Algorithm #2 to select a channel index for connection, periodic advertising, or isochronous events.

  • Generate the desired number of channel hops for analyzing the channel selection algorithm by using a graphical user interface (GUI).

  • Verify Algorithm #2 by using the sample data specified in Bluetooth Core Specification [ 2 ].

  • Plot and analyze the channel hopping pattern of Algorithm #1 and Algorithm #2.

  • Visualize the channel selection histogram for 100 connection events.

Bluetooth LE Channels

The Bluetooth LE system operates in the 2.4 GHz ISM band at 2400 - 2483.5 MHz. It uses 40 RF channels (each channel is 2 MHz wide). The figure below shows the mapping between the frequencies and Bluetooth LE channels. Each of these RF channels is allocated a unique channel index (labeled as "Channel" in the figure).

Bluetooth LE categorizes these 40 RF channels into three advertising channels (channel indices: 37, 38, 39) and thirty-seven data channels (channel indices: 0 to 36). Note that the advertising channels are interspersed across the 2.4 GHz spectrum. The purpose of this wide spacing is to avoid interference from other devices operating in the same spectrum, such as WLAN. Advertising channels are mainly used for transmitting advertising packets, scan request/response packets and connection indication packets. Data channels are mainly used for exchanging data packets.

Channel Hopping

Channel hopping is used in Bluetooth to reduce interference and improve throughput. The Bluetooth Core Specification [ 2 ] specifies rules for switching between channels and algorithms used when performing channel hopping.

The use of the unlicensed 2.4GHz ISM band by several wireless technologies causes increased interference and results in retransmissions to correct errors in received packets. Since Bluetooth LE is a low energy protocol, it is more susceptible to interference. Bluetooth LE uses channel hopping to mitigate the impact of interference. When one channel is completely blocked due to interference, devices can still continue to communicate with each other on other channels.

An advertising device transmits advertising packets on the three advertising channels in a cyclic manner (starting from channel index 37). The same procedure is used by the scanning or initiating device, listening on the three advertising channels in a cyclic manner.

A connected device changes to a new data channel for every connection event. A connection event is a sequence of data packet exchanges between two connected devices. The connection events periodically occur with an interval called connection interval. All the packets within a connection event are transmitted on the same data channel. A new connection event uses a new data channel.

The Bluetooth Core Specification specifies 'Algorithm #1' and 'Algorithm #2' channel selection algorithms to select data channels for each connection event. For more information about the channel selection algorithms, see Section 4.5.8, Part B, Vol 6 of [ 2 ].

The two channel selection algorithms avoid channels that are prone to transmission errors. The Central and Peripheral nodes exchange a channel map between them. This map indicates the good and bad data channels. The classification of good and bad data channels is dependent on implementation of channel classification and varies according to SNR (Signal-To-Noise Ratio), PER (Packet Error Rate), etc. Only the good data channels are used for communication between devices. The channel map is updated by the Central device if it recognizes any bad data channels. The two channel selection algorithms use the channel map to determine whether the selected data channel is good to use. If the selected data channel turns out to be bad, a new data channel is selected using the channel remapping procedure. This procedure remaps the bad data channel to one of the good data channels. Each algorithm has a unique remapping procedure. For more information about the channel selection algorithms, see Section 4.5.8, Part-B, Vol-6 of [ 2 ].

Simulating Algorithm #1

Create a Bluetooth LE channel selection System object specifying the Algorithm as 1.

csa = bleChannelSelection('Algorithm', 1);

Specify the hop increment count and number of used (good) channels.

csa.HopIncrement = 8;
csa.UsedChannels = [0, 5, 13, 9, 24, 36]
csa = 
  bleChannelSelection with properties:

       Algorithm: 1
    HopIncrement: 8
    UsedChannels: [0 5 9 13 24 36]
    ChannelIndex: 0
    EventCounter: 0

Determine the next channel hop. Select a new channel for each new connection event.

nextChannel = csa();
fprintf('Selected channel for connection event %d by using ''Algorithm #1'' is: %d\n', csa.EventCounter, nextChannel);
Selected channel for connection event 0 by using 'Algorithm #1' is: 9

Simulating Algorithm #2

Create a Bluetooth LE channel selection System object specifying the Algorithm as 2.

csa = bleChannelSelection('Algorithm', 2);

Specify the access address and number of used (good) channels.

csa.AccessAddress = 'E89BED68';
csa.UsedChannels = [9, 10, 21, 22, 23, 33, 34, 35, 36]
csa = 
  bleChannelSelection with properties:

                   Algorithm: 2
               AccessAddress: 'E89BED68'
    SubeventChannelSelection: false
                UsedChannels: [9 10 21 22 23 33 34 35 36]
                ChannelIndex: 0
                EventCounter: 0

Determine the next channel hop. Select a new channel for each new connection event.

nextChannel = csa();
fprintf('Selected channel for connection event %d by using ''Algorithm #2'' is: %d\n', csa.EventCounter, nextChannel);
Selected channel for connection event 0 by using 'Algorithm #2' is: 22

GUI for Analyzing Channel Selection Algorithms

The BLEChannelSelectionUI app provides a GUI to generate the desired number of channel hops.

BLEChannelSelectionUI

Using this GUI, you can:

  • Analyze 'Algorithm #1' and 'Algorithm #2'

  • Plot the channel hopping pattern and channel selection histogram of 'Algorithm #1' and 'Algorithm #2'

Algorithm Verification with Sample Data

The Bluetooth Core Specification specifies sample data to verify 'Algorithm #2'. For more information, see Section 3, Vol 6, Part C in [ 2 ]. However, there is no sample data available for verifying Algorithm #1.

Sample data 1 (37 good data channels)

  1. Access Address = 8E89BED6

  2. Used Channels = [0:36]

When you use the above inputs, the Algorithm #2 select these channels.

This code selects three channels for the first three connection events by using Algorithm #2.

csa = bleChannelSelection('Algorithm', 2);

Set the connection access address.

csa.AccessAddress = '8E89BED6';

Specify 37 good data channels as used channels.

csa.UsedChannels = (0:36);

Select channel indices for first four connection events. Verify outputs with the values stated in the preceding table.

numConnectionEvents = 4;
for index = 1:numConnectionEvents
    channel = csa();
    fprintf('Event Counter: %d, Selected Channel: %d\n', csa.EventCounter, channel);
end
Event Counter: 0, Selected Channel: 25
Event Counter: 1, Selected Channel: 20
Event Counter: 2, Selected Channel: 6
Event Counter: 3, Selected Channel: 21

Sample data 2 (nine good data channels)

  1. Access Address = 8E89BED6

  2. Used Channels = [9, 10, 21, 22, 23, 33, 34, 35, 36]

When you use the above inputs, the Algorithm #2 select these channels. Since the channel map contains bad channels, the channel remapping procedure used in the algorithm is also verified.

This code selects nine channels for the first nine connection events by using Algorithm #2.

csa = bleChannelSelection('Algorithm', 2);

Set the connection access address.

csa.AccessAddress = '8E89BED6';

Specify nine good data channels as used channels.

csa.UsedChannels = [9, 10, 21, 22, 23, 33, 34, 35, 36];

Select channel indices for first nine connection events. Verify outputs with the values stated in the preceding table.

numConnectionEvents = 9;
for index = 1:numConnectionEvents
    channel = csa();
    fprintf('Event Counter: %d, Selected Channel: %d\n', csa.EventCounter, channel);
end
Event Counter: 0, Selected Channel: 35
Event Counter: 1, Selected Channel: 9
Event Counter: 2, Selected Channel: 33
Event Counter: 3, Selected Channel: 21
Event Counter: 4, Selected Channel: 34
Event Counter: 5, Selected Channel: 36
Event Counter: 6, Selected Channel: 23
Event Counter: 7, Selected Channel: 9
Event Counter: 8, Selected Channel: 34

Plot and Analyze Channel Hopping Patterns

This code snippet selects the channel indices for the first 100 connection events by using 'Algorithm #1'. Create a channel selection algorithm System object for 'Algorithm #1.

csa = bleChannelSelection;

Generate channel hop sequence for 100 connection events.

numConnectionEvents = 100;
hopSequence = zeros(1, numConnectionEvents);
for index = 1:numConnectionEvents
    hopSequence(index) = csa();
end

The helperBLEPlotChannelHopSequence helper function plots the channel hopping pattern and the histogram of the selected channels.

helperBLEPlotChannelHopSequence(csa, hopSequence);

This code snippet selects the channel indices for the first 100 connection events by using 'Algorithm #2'. Create a channel selection algorithm System object for 'Algorithm #2.

csa = bleChannelSelection('Algorithm', 2);

Generate channel hop sequence for 100 connection events.

numConnectionEvents = 100;
hopSequence = zeros(1, numConnectionEvents);
for index = 1:numConnectionEvents
    hopSequence(index) = csa();
end

The helperBLEPlotChannelHopSequence helper function plots the channel hopping pattern and the histogram of the selected channels.

helperBLEPlotChannelHopSequence(csa, hopSequence);

The preceding plots show the difference between the two algorithms.

  • Algorithm #1 is a simple incremental algorithm that produces a uniform sequence of channels. There is no randomization involved in the process of selecting a new channel.

  • Algorithm #2 was introduced in version 5.0 of the Bluetooth Core Specification. Compared to Algorithm #1, Algorithm #2 is more complex and produces a randomized sequence of channels.

Appendix

The example uses this helper:

Selected Bibliography

  1. Bluetooth Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed June 13, 2022. https://www.bluetooth.com.

  2. Bluetooth Special Interest Group (SIG). "Bluetooth Core Specification." Version 5.3. https://www.bluetooth.com/.

See Also

Objects