Main Content

bluetoothLEPeriodicAdvConfig

Bluetooth LE periodic advertisements configuration parameters

Since R2024a

    Description

    Use the bluetoothLEPeriodicAdvConfig object to specify the configuration parameters to simulate Bluetooth® low energy (LE) periodic advertisements (PA) between a Broadcaster and an Observer.

    Creation

    Description

    cfgPeriodicAdv = bluetoothLEPeriodicAdvConfig creates a default Bluetooth LE PA configuration object, cfgPeriodicAdv, between a Broadcaster and an Observer.

    cfgPeriodicAdv = bluetoothLEPeriodicAdvConfig(Name=Value) sets properties of the Bluetooth LE PA configuration object by using one or more optional name-value arguments. For example, bluetoothLEPeriodicAdvConfig(PeriodicAdvInterval=0.5) sets the PA interval to 0.5 seconds.

    example

    Properties

    expand all

    Periodic advertising interval, specified as a scalar in the range [0.0075, 81.91875]. Units are in seconds. This property specifies the interval between the start of two consecutive PA events. Set this value as an integer multiple of 1.25 milliseconds. The default value is 0.010 seconds. For more information about PA intervals, see Bluetooth Core Specification v5.3 [2], Vol 6, Part B, Section 4.4.2.2.3.

    Data Types: double

    Offset for starting the PAT, specified as a scalar in the range [0, N]. This equation defines N:

    PeriodicAdvInterval(MaxPeriodicPDUDuration+T_IFS)

    where:

    • PeriodicAdvInterval — Value of the PeriodicAdvInterval property in seconds.

    • MaxPeriodicPDUDuration — Time required for the Broadcaster node to transmit a packet containing the maximum advertising payload, in seconds.

    • T_IFS — Interframe spacing time, in seconds.

    This property specifies the synchronization packet window offset by considering the reference point as the simulation start time. Units are in seconds. For more information about the synchronization packet window offset, see Bluetooth Core Specification v5.3 [2], Vol 6, Part B, Section 2.3.4.6.

    Data Types: double

    PHY mode for generation or decoding, specified as "LE125K", "LE500K", "LE1M", or "LE2M".

    Data Types: char | string

    List of used (good) data channels, specified as a vector of integers. Each element in the vector must be a unique value in the range [0, 36]. This property specifies the indices of the assigned good data channels that the PAT uses. To ensure you set at least two channels as used (good) channels, specify a vector with a length greater than 1.

    Data Types: double

    Object Functions

    configurePeriodicAdvConfigure Bluetooth LE periodic advertisements between Broadcaster and Observer

    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);

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

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

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

    3. 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 advertising interval in seconds.

    broadcasterNode = bluetoothLENode("broadcaster",AdvertisingInterval=0.020);

    Create a Bluetooth LE node, specifying the role as "observer". Specify the scan interval in seconds.

    observerNode = bluetoothLENode("observer",ScanInterval=0.030);

    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 observerNode])

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

    simulationTime = 10;
    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);
    observerNodeStats = statistics(observerNode);

    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