configurePeriodicAdv
Configure Bluetooth LE periodic advertisements between Broadcaster and Observer
Since R2024a
Description
configures Bluetooth® low energy (LE) periodic advertisements (PA) between the Broadcaster,
cfgPeriodicAdvUpdated
= configurePeriodicAdv(cfgPeriodicAdv
,broadcasterNode
,observerNode
)broadcasterNode
, and the Observer, observerNode
,
by sharing the common PA synchronization configuration, cfgPeriodicAdv
,
between the nodes.
Examples
Simulate Bluetooth LE Piconet with Periodic Advertisements
This example shows how to simulate a Bluetooth LE piconet with periodic advertisements by following these steps:
Create and configure a Bluetooth LE piconet with Broadcaster and Observer nodes.
Create and Configure a PAT between the Broadcaster and Observer nodes.
Configure and add application traffic at the Broadcaster node.
Simulate the Bluetooth LE piconet and retrieve the statistics of the Broadcaster and Observer 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 LE node, specifying the role as "broadcaster"
. Specify the name and position of the node.
broadcasterNode = bluetoothLENode("broadcaster"); broadcasterNode.Name = "Broadcaster"; broadcasterNode.Position = [0 0 0]; % In x-, y-, and z-coordinates, in meters
Create two Bluetooth LE nodes, specifying their roles as "observer"
. Specify the names and positions of the nodes.
observerNode1 = bluetoothLENode("observer",Name="Observer1"); observerNode1.Position = [5 5 0]; % x-, y-, and z-coordinates, in meters observerNode2 = bluetoothLENode("observer",Name="Observer2"); observerNode2.Position = [10 0 10]; % x-, y-, and z-coordinates, in meters
Create a PAT between the Broadcaster and Observer nodes by using the Bluetooth LE periodic advertisements configuration object.
cfgPeriodicAdv = bluetoothLEPeriodicAdvConfig(PeriodicAdvInterval=60, ... UsedChannels=10:30, ... PHYMode="LE2M");
Configure the PAT between the Broadcaster and Observer nodes.
cfgPeriodicAdvUpdated = configurePeriodicAdv(cfgPeriodicAdv,broadcasterNode,[observerNode1 observerNode2])
cfgPeriodicAdvUpdated = bluetoothLEPeriodicAdvConfig with properties: PeriodicAdvInterval: 60 PeriodicAdvOffset: 0 PHYMode: "LE2M" UsedChannels: [10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30] AccessAddress: 'D9DA7BEA'
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. Add application traffic at the Broadcaster node.
traffic = networkTrafficOnOff(DataRate=1,PacketSize=15,OnTime=Inf,OffTime=0); addTrafficSource(broadcasterNode,traffic)
Add the Broadcaster and Observer nodes to the wireless network simulator.
addNodes(networkSimulator,[broadcasterNode observerNode1 observerNode2])
Set the simulation time in seconds, and run the simulation.
simulationTime = 600; run(networkSimulator,simulationTime)
Retrieve statistics corresponding to the Broadcaster and Observer nodes. For more information about the statistics, see Bluetooth LE Node Statistics.
broadcasterNodeStats = statistics(broadcasterNode); observerNode1Stats = statistics(observerNode1); observerNode2Stats = statistics(observerNode1);
Input Arguments
cfgPeriodicAdv
— Common PA configuration
bluetoothLEPeriodicAdvConfig
object
Common PA configuration, specified as a bluetoothLEPeriodicAdvConfig
object.
broadcasterNode
— Bluetooth LE node object for the broadcaster node
bluetoothLENode
object | vector of bluetoothLENode
objects
Broadcaster node, specified as a bluetoothLENode
object or a vector of bluetoothLENode
objects. For each object, the Role
property value must be
"broadcaster"
. If you specify this property as a vector:
The object function creates a periodic advertising train (PAT) at each specified Broadcaster and configures the specified Observer to listen for all the PATs.
The
observerNode
input must be a singlebluetoothLENode
object.
observerNode
— Bluetooth LE node object for the observer node
bluetoothLENode
object | vector of bluetoothLENode
objects
Observer node, specified as a bluetoothLENode
object or a vector of bluetoothLENode
objects. For each object, the Role
property value must be
"observer"
. If you specify this property as a vector:
The object function creates a PAT at each specified Broadcaster and configures the specified Observer to listen for the PAT from the Broadcaster.
The
broadcasterNode
input must be a singlebluetoothLENode
object.
Output Arguments
cfgPeriodicAdvUpdated
— Updated PA configuration
bluetoothLEPeriodicAdvConfig
object | vector of bluetoothLEPeriodicAdvConfig
objects
Updated PA configuration, returned as a bluetoothLEPeriodicAdvConfig
object or a vector of
bluetoothLEPeriodicAdvConfig
objects. This output contains the same
number of bluetoothLEPeriodicAdvConfig
objects that the broadcasterNode
and observerNode
inputs specify.
References
[1] Bluetooth Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed November 22, 2023. https://www.bluetooth.com/.
[2] Bluetooth Core Specifications Working Group. "Bluetooth Core Specification" v5.3. https://www.bluetooth.com/.
Version History
Introduced in R2024a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)