Main Content

configurePeriodicAdv

Configure Bluetooth LE periodic advertisements between Broadcaster and Observer

Since R2024a

    Description

    cfgPeriodicAdvUpdated = configurePeriodicAdv(cfgPeriodicAdv,broadcasterNode,observerNode) configures Bluetooth® low energy (LE) periodic advertisements (PA) between the Broadcaster, broadcasterNode, and the Observer, observerNode, by sharing the common PA synchronization configuration, cfgPeriodicAdv, between the nodes.

    example

    Examples

    collapse all

    This example shows how to simulate a Bluetooth LE piconet with periodic advertisements by following these steps:

    1. Create and configure a Bluetooth LE piconet with Broadcaster and Observer nodes.

    2. Create and Configure a PAT between the Broadcaster and Observer nodes.

    3. Configure and add application traffic at the Broadcaster node.

    4. 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

    collapse all

    Common PA configuration, specified as a bluetoothLEPeriodicAdvConfig object.

    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 single bluetoothLENode object.

    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 single bluetoothLENode object.

    Output Arguments

    collapse all

    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