Main Content

bleChannelSelection

BLE channel index for connection, periodic advertising, and isochronous events

Download Required: To use bleChannelSelection, first download Communications Toolbox™ Library for the Bluetooth® Protocol. For more information, see Get and Manage Add-Ons. Alternatively, see Communications Toolbox Library for the Bluetooth Protocol File Exchange.

Description

The bleChannelSelection System object™ selects a Bluetooth low energy (BLE) channel index based on the algorithm specified by the Algorithm property.

To select a BLE channel index:

  1. Create the bleChannelSelection object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

Creation

Description

example

csa = bleChannelSelection creates a default BLE channel selection System object.

csa = bleChannelSelection(Name,Value)sets Properties using one or more name-value pairs. Enclose each property name in quotes. For example, bleChannelSelection('Algorithm',2) specifies a BLE channel index based on Algorithm 2.

Properties

expand all

Note

For more information about BLE channel selection properties, see volume 6, part B, section 4.5.8 of the Bluetooth Core Specification [2].

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Type of BLE channel selection algorithm, specified as 1 or 2 representing Algorithm 1 or Algorithm 2, respectively. Algorithm 1 selects the channel index for connection events. Algorithm 2 selects the channel index for connection events, periodic advertising events, and LE isochronous events.

Data Types: double

Hop increment count, specified as an integer in the range [5, 16]. This property specifies the hop increment count to hop between data channels. If you set the Algorithm property to 1, the System object uses this property as an input argument.

Data Types: double

Unique connection address, specified as an eight-element character vector or a string scalar denoting a four-octet hexadecimal value. This value specifies a unique 32-bit address for the link layer connection between two devices. If you set the Algorithm property to 2, the System object uses this property as an input argument.

Data Types: char | string

List of used (good) data channels, specified as a vector of integers in the range [0, 36]. The vector length must be greater than 1. At least two channels must be set as used (good) channels. This property specifies the set of good channels classified by the Master.

Data Types: double

Flag to enable or disable isochronous event channel selection, specified as 0 (false) or 1 (true). A value of 1 (true) value selects a channel for isochronous events by using the Algorithm 2.

Data Types: logical

Isochronous event counter, specified as an integer in the range [0, 65535]. This property specifies the counter for each isochronous event.

Dependencies

To enable this property, set the SubeventChannelSelection property to 1 (true).

Data Types: double

Subevent counter, specified as an integer in the range [1, 31]. This property specifies the counter for each subevent.

Dependencies

To enable this property, set the SubeventChannelSelection property to 1 (true).

Data Types: double

This property is read-only.

Channel index for current event, specified as 0. This property specifies the channel index for connection event, periodic advertising event, and isochronous event.

Data Types: double

This property is read-only.

Counter for current event, specified as 0. This property specifies the event counter for connection event and periodic advertising event.

Data Types: double

Usage

Description

example

channelIndex = csa selects a channel index based on the applicable Properties. During each call of this function, update the values of IsochronousEventCounter and SubeventNumber properties. During each call of this function, the System object must update the SubeventNumber property sequentially.

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

cloneCreate duplicate System object
isLockedDetermine if System object is in use
stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

Create a BLE channel selection System object to select a BLE channel index based on channel selection Algorithm 1.

csa = bleChannelSelection
csa = 
  bleChannelSelection with properties:

       Algorithm: 1
    HopIncrement: 5
    UsedChannels: [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... ]
    ChannelIndex: 0
    EventCounter: 0

Set a hop increment count of 7. Then, specify a set of used (good) channels classified by the Master and display the object properties.

csa.HopIncrement = 7;
csa.UsedChannels = [0 2 24 6 10 14 26 30 34 36]
csa = 
  bleChannelSelection with properties:

       Algorithm: 1
    HopIncrement: 7
    UsedChannels: [0 2 6 10 14 24 26 30 34 36]
    ChannelIndex: 0
    EventCounter: 0

Select a BLE channel index from the corresponding system object using Algorithm 1 (the default algorithm).

channelIndex = csa()
channelIndex = 30

Create another BLE channel selection System object to select a BLE channel index, this time by specifying the type of channel selection Algorithm 2.

csa2 = bleChannelSelection('Algorithm',2);

Set a unique connection address. Then, specify a set of used (good) channels classified by the Master and display the object properties.

csa2.AccessAddress = '8E89BED6';
csa2.UsedChannels = [9 10 21 22 23 33 34 35 36]
csa2 = 
  bleChannelSelection with properties:

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

Select a BLE channel index from the corresponding System object using Algorithm 2.

channelIndex2 = csa2()
channelIndex2 = 35

Create a BLE channel selection System object with default values.

csa = bleChannelSelection
csa = 
  bleChannelSelection with properties:

       Algorithm: 1
    HopIncrement: 5
    UsedChannels: [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ... ]
    ChannelIndex: 0
    EventCounter: 0

Set the BLE channel selection algorithm to 2. This algorithm supports channel selection for connection events, periodic advertising events, and LE isochronous events. Enable subevent channel selection.

csa.Algorithm = 2;
csa.SubeventChannelSelection = true;

Specify a unique connection address and a set of used (good) channels classified by the Master.

csa.AccessAddress = '8E89BED6';
csa.UsedChannels  = [9 10 21 22 23 33 34 35 36];

In the first isochronous event, select a channel index for the first subevent.

csa.IsochronousEventCounter = 0;
csa.SubeventNumber = 1;
channelIndex = csa()
channelIndex = 35

In the first isochronous event, select a channel index for the second subevent.

csa.SubeventNumber = 2;
channelIndex = csa()
channelIndex = 10

References

[1] Bluetooth Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed November 22, 2019. https://www.bluetooth.com/.

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

Extended Capabilities

Introduced in R2019b