Main Content

Create Bluetooth Piconet by Enabling ACL Traffic, SCO Traffic, and AFH

Communications Toolbox™ Library for the Bluetooth® Protocol features enable you to create and configure a Bluetooth piconet. The library provides functionalities to configure asynchronous connection-oriented (ACL) link, synchronous connection-oriented (SCO) link, or both between the Master and the Slave. You can also configure the frequency hopping techniques as basic frequency hopping or adaptive frequency hopping (AFH).

Create Bluetooth Piconet by Enabling ACL Traffic, SCO Traffic, and AFH

Specify the number of Slaves in a Bluetooth piconet. A piconet can contain a maximum of seven Slaves.

numSlaves = 2;

Set the total number of nodes in the piconet (one Master and multiple Slaves).

numNodes = numSlaves + 1;

Specify the type of logical link between the Master and Slaves. Valid logical link values depend on how many Slaves are connected to the Master.

  • If the Master is connected to one Slave, you must specify the logical link value as a one-element vector of 1 (ACL link), 2 (SCO link), or 3 (ACL and SCO links).

  • If the Master is connected to multiple Slaves, you must specify the logical link value as an n-element row vector, where n is the number of Slaves. Each element must be 1 (ACL link), 2 (SCO link), or 3 (ACL and SCO links).

Enable ACL and SCO traffic, specifying the type of ACL and SCO packet as 'DM1' and 'HV3', respectively.

linkTraffic = [1 2];
aclPacketType = 'DM1';
scoPacketType = {2,'HV3'};

To enable AFH, set the sequence type to Connection adaptive.

sequenceType = 'Connection adaptive';

Initialize a cell array to store the Bluetooth nodes.

btNodes = cell(1,numNodes);

Specify the distance (in meters) between two Bluetooth nodes.

interNodeDistance = 10;

Create the nodes, and then configure them as Master or Slave. To create and configure the nodes, use the helperBluetoothFullDuplexNode function.

for nodeIdx = 1:numNodes
    if nodeIdx == 1
        basebandInstance = helperBluetoothBaseband('Role','Master');                            % Baseband Master instance
        basebandInstance = helperBluetoothBaseband('Role','Slave');                             % Baseband Slave instance
    nodePosition = [nodeIdx*interNodeDistance 0 0];                                             % Set node position
    node = helperBluetoothFullDuplexNode('Baseband',basebandInstance);                          % Create and configure node
    node.NodeID = nodeIdx;                                                                      % Update node ID
    node.NodePosition = nodePosition;                                                           % Update node position
    btNodes{nodeIdx} = node;                                                                    % Add Bluetooth nodes in cell array

Create a Bluetooth piconet by using the helperBluetoothCreatePiconet function.



[1] Bluetooth Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed September 17, 2020.

[2] Bluetooth Special Interest Group (SIG). "Bluetooth Core Specification." Version 5.2.

Related Topics