Main Content

Create, Configure, and Simulate Bluetooth BR/EDR Piconet

This example shows how to simulate a Bluetooth® basic rate/enhanced data ret (BR/EDR) piconet by using Bluetooth® Toolbox and Communications Toolbox™ Wireless Network Simulation Library.

Using this example, you can:

  1. Create and configure a Bluetooth BR/EDR piconet with one Central and multiple Peripheral nodes.

  2. Create, configure, and share connections between the Central and Peripheral nodes.

  3. Simulate a Bluetooth BR/EDR piconet with synchronous connection-oriented (SCO) traffic, and retrieve the statistics of the Central and Peripheral nodes.

Check if the Communications Toolbox™ Wireless Network Simulation Library support package is installed. If the support package is not installed, MATLAB® returns an error with a link to download and install the support package.

wirelessnetworkSupportPackageCheck;

Create a wireless network simulator.

networkSimulator = wirelessNetworkSimulator.init;

Create a Bluetooth BR/EDR node, specifying the role as "central".

centralNode = bluetoothNode("central");

Create two Bluetooth BR/EDR Peripheral nodes and specify their positions in Cartesian x-, y-, and z-coordinates.

peripheralNode = bluetoothNode("peripheral",Position=[0 1 0; 2 1 2]); % In meters

Create a default Bluetooth BR/EDR connection configuration object to configure and share the connection between the Central and Peripheral nodes. Specify the SCO packet type.

cfgConnection = bluetoothConnectionConfig(SCOPacketType="HV3")
cfgConnection = 
  bluetoothConnectionConfig with properties:

    CentralToPeripheralACLPacketType: "DH1"
    PeripheralToCentralACLPacketType: "DH1"
                       SCOPacketType: "HV3"
                 HoppingSequenceType: "Connection adaptive"
                        UsedChannels: [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 ... ] (1x79 double)
                        PollInterval: 40
                       InstantOffset: 240
                    TransmitterPower: 20
                  SupervisionTimeout: 32000
                      CentralAddress: [1x0 char]
                    PrimaryLTAddress: []

Configure connections between the Central and the Peripheral nodes. Note that, when you configure the connections, the SCO traffic is internally added as two-way traffic between the Central and Peripheral nodes.

connection = configureConnection(cfgConnection,centralNode,[peripheralNode(1) peripheralNode(2)]);

Create a Bluetooth piconet consisting of one Central and two Peripheral nodes.

nodes = [centralNode peripheralNode];

Add the Central and Peripheral nodes to the wireless network simulator.

addNodes(networkSimulator,nodes);

Set the simulation time in seconds, and run the simulation.

simulationTime = 0.5;
run(networkSimulator,simulationTime);

Retrieve application, baseband, and physical layer (PHY) statistics corresponding to the Central and Peripheral nodes.

nodeStats = statistics(nodes)
nodeStats=1×3 struct array with fields:
    Name
    ID
    App
    Baseband
    PHY

References

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

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

See Also

Objects

Related Topics