Create, Configure, and Simulate Bluetooth LE Broadcast Audio Network
This example shows how to simulate a Bluetooth® low energy (LE) isochronous broadcast audio network by using Bluetooth® Toolbox and Communications Toolbox™ Wireless Network Simulation Library.
Using this example, you can:
Create and configure a Bluetooth LE piconet with an isochronous broadcaster and receivers.
Add application traffic at the broadcaster.
Simulate the broadcast isochronous network and retrieve the statistics of the broadcaster and receivers.
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 LE node, specifying the role as "isochronous-broadcaster"
. Specify the name and position of the node.
broadcasterNode = bluetoothLENode("isochronous-broadcaster"); broadcasterNode.Name = "Broadcaster"; broadcasterNode.Position = [0 0 0]; % In x-, y-, and z-coordinates, in meters
Create two Bluetooth LE nodes, specifying the role as "synchronized-receiver"
. Specify the name and position of the nodes.
receiverNode1 = bluetoothLENode("synchronized-receiver"); receiverNode1.Name = "Receiver1"; receiverNode1.Position = [10 0 0]; receiverNode2 = bluetoothLENode("synchronized-receiver"); receiverNode2.Name = "Receiver2"; receiverNode2.Position = [20 0 0]
receiverNode2 = bluetoothLENode with properties: TransmitterPower: 20 TransmitterGain: 0 ReceiverRange: 100 ReceiverGain: 0 ReceiverSensitivity: -100 NoiseFigure: 0 InterferenceFidelity: 0 Name: "Receiver2" Position: [20 0 0] Read-only properties: Role: "synchronized-receiver" BIGConfig: [1x1 bluetoothLEBIGConfig] TransmitBuffer: [1x1 struct] ID: 3
Create a default Bluetooth LE broadcast isochronous group (BIG) configuration object.
cfgBIG = bluetoothLEBIGConfig
cfgBIG = bluetoothLEBIGConfig with properties: SeedAccessAddress: "78E52493" PHYMode: "LE1M" NumBIS: 1 ISOInterval: 0.0050 BISSpacing: 0.0022 SubInterval: 0.0022 MaxPDU: 251 BurstNumber: 1 PretransmissionOffset: 0 RepetitionCount: 1 NumSubevents: 1 BISArrangement: "sequential" BIGOffset: 0 ReceiveBISNumbers: 1 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] InstantOffset: 6 BaseCRCInitialization: "1234"
Configure the broadcaster and receiver nodes so they use the default BIG parameters.
configureBIG(cfgBIG,broadcasterNode,receiverNode1); configureBIG(cfgBIG,broadcasterNode,receiverNode2);
Create a networkTrafficOnOff
object to generate an On-Off application traffic pattern. Specify the data rate in kb/s and the packet size in bytes. Enable packet generation to generate an application packet with a payload.
traffic = networkTrafficOnOff(DataRate=500, ... PacketSize=10, ... GeneratePacket=true);
Add application traffic at the broadcaster node by using the addTrafficSource
object function.
addTrafficSource(broadcasterNode,traffic);
Create a broadcast isochronous network consisting of LE broadcast audio nodes.
nodes = {broadcasterNode receiverNode1 receiverNode2};
Add the LE broadcast audio nodes to the wireless network simulator.
addNodes(networkSimulator,nodes)
Set the simulation time in seconds and run the simulation.
simulationTime = 0.3; run(networkSimulator,simulationTime);
Retrieve application, link layer (LL), and physical layer (PHY) statistics corresponding to the broadcaster and receiver nodes. For more information about the statistics, see Bluetooth LE Node Statistics.
broadcasterStats = statistics(broadcasterNode)
broadcasterStats = struct with fields:
Name: "Broadcaster"
ID: 1
App: [1x1 struct]
LL: [1x1 struct]
PHY: [1x1 struct]
receiver1Stats = statistics(receiverNode1)
receiver1Stats = struct with fields:
Name: "Receiver1"
ID: 2
App: [1x1 struct]
LL: [1x1 struct]
PHY: [1x1 struct]
receiver2Stats = statistics(receiverNode2)
receiver2Stats = struct with fields:
Name: "Receiver2"
ID: 3
App: [1x1 struct]
LL: [1x1 struct]
PHY: [1x1 struct]
References
[1] Bluetooth® Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed November 22, 2021. https://www.bluetooth.com/.
[2] Bluetooth Special Interest Group (SIG). "Bluetooth Core Specification." Version 5.3. https://www.bluetooth.com/.