addMobility
Description
This feature also requires the Wireless Network Toolbox™ product.
addMobility( adds a
default mobility model (random waypoint) to Bluetooth® low energy (LE) nodes, blenode)blenode. In the random waypoint
model, a wireless node pauses for some duration at a location before moving towards its next
random destination (waypoint) with a random speed. The node repeats this process at each
waypoint.
addMobility(
sets the mobility configuration parameters using one or more optional name-value arguments.
For example, blenode,Name=Value)PauseDuration=0.02 sets the pause duration of a Bluetooth LE
node to 0.02 seconds. If you add the mobility model to multiple wireless nodes in a single
addMobility function call, all the nodes use the mobility parameter
values specified by the name-value arguments.
Examples
This example enables you to:
Create and configure a Bluetooth LE piconet with Central and Peripheral nodes.
Create and configure a link layer (LL) connection between Central and Peripheral nodes.
Add application traffic from the Central to Peripheral nodes.
Create a custom channel, and plug it into the wireless network simulator.
Simulate Bluetooth LE network and retrieve the statistics of the Central and Peripheral nodes.
Create a wireless network simulator.
networkSimulator = wirelessNetworkSimulator.init;
Create a Bluetooth LE node, specifying the role as "central". Specify the name and position of the node.
centralNode = bluetoothLENode("central",Name="CentralNode"); centralNode.Position = [0 0 0]; % In x-, y-, and z-coordinates in meters
Create a Bluetooth LE node, specifying the role as "peripheral". Specify the name and position of the node.
peripheralNode = bluetoothLENode("peripheral",Name="PeripheralNode"); peripheralNode.Position = [10 0 10] % In x-, y-, and z-coordinates in meters
peripheralNode =
bluetoothLENode with properties:
TransmitterPower: 20
TransmitterGain: 0
ReceiverGain: 0
ReceiverSensitivity: -100
NoiseFigure: 0
InterferenceModeling: "overlapping-adjacent-channel"
Role: "peripheral"
ConnectionConfig: [0×0 bluetoothLEConnectionConfig]
CISConfig: [0×0 bluetoothLECISConfig]
Position: [10 0 10]
Name: "PeripheralNode"
Mobility: []
Read-only properties:
ID: 2
Velocity: [0 0 0]
Add a random waypoint mobility model to the Bluetooth peripheral node. Set the shape of the node's mobility area to "circle".
addMobility(peripheralNode,BoundaryShape="circle",RefreshInterval=0.1)Create a default Bluetooth LE configuration object to share the LL connection between the Central and Peripheral nodes.
cfgConnection = bluetoothLEConnectionConfig;
Specify the connection interval and connection offset. Throughout the simulation, the object establishes LL connection events for the duration of each connection interval. The connection offset is from the beginning of the connection interval.
cfgConnection.ConnectionInterval = 0.01; % In seconds cfgConnection.ConnectionOffset = 0; % In seconds
Specify the active communication period after the connection event is established between the Central and Peripheral nodes.
cfgConnection.ActivePeriod = 0.01 % In secondscfgConnection =
bluetoothLEConnectionConfig with properties:
ConnectionInterval: 0.0100
AccessAddress: "5DA44270"
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]
Algorithm: 1
HopIncrement: 5
CRCInitialization: "012345"
SupervisionTimeout: 1
PHYMode: "LE1M"
InstantOffset: 6
ConnectionOffset: 0
ActivePeriod: 0.0100
MaxPDU: 251
TIFS: 1.5000e-04
TMCES: 1.5000e-04
Configure the connection between Central and Peripheral nodes by using the configureConnection object function of the bluetoothLEConnectionConfig object.
configureConnection(cfgConnection,centralNode,peripheralNode);
Create a networkTrafficOnOff (Wireless Network Toolbox) 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=100,PacketSize=10);
Add application traffic from the Central to the Peripheral node by using the addTrafficSource object function.
addTrafficSource(centralNode,traffic,DestinationNode=peripheralNode);
Create a Bluetooth LE network consisting of a Central and a Peripheral node.
nodes = {centralNode peripheralNode};Add the Central and Peripheral nodes to the wireless network simulator.
addNodes(networkSimulator,nodes)
Add the custom channel to the wireless network simulator.
addChannelModel(networkSimulator,@addImpairment);
Set the simulation time in seconds and run the simulation.
simulationTime = 0.5; run(networkSimulator,simulationTime)
Retrieve application, link layer (LL), and physical layer (PHY) statistics corresponding to the Central and Peripheral nodes. For more information about the statistics, see Bluetooth LE Node Statistics.
centralStats = statistics(centralNode)
centralStats = struct with fields:
Name: "CentralNode"
ID: 1
App: [1×1 struct]
LL: [1×1 struct]
PHY: [1×1 struct]
peripheralStats = statistics(peripheralNode)
peripheralStats = struct with fields:
Name: "PeripheralNode"
ID: 2
App: [1×1 struct]
LL: [1×1 struct]
PHY: [1×1 struct]
Follow these steps to create a custom channel that models Bluetooth path loss for an industrial scenario.
Create a custom function with this syntax:
rxData = customFcnName(rxInfo,txData). TherxInfoinput specifies the receiver node information as a structure, and thetxDatainput specifies the transmitted packets as a structure. The simulator automatically passes information about the receiver node and the packets transmitted by a transmitter node as inputs to the custom function. For more information about creating custom channel, see theaddChannelModel(Wireless Network Toolbox) object function.Use the
bluetoothPathLossConfigobject to set path loss configuration parameters for an industrial scenario.Calculate path loss between the Central and Peripheral nodes using the
bluetoothPathLossfunction. Specify the transmitter and receiver positions.Apply path loss to the transmitted packets.
function rxData = addImpairment(rxInfo,txData) pathlossCfg = bluetoothPathLossConfig(Environment="Industrial"); % Apply path loss and update output signal rxData = txData; % Calculate the distance between transmitter and receiver in meters distance = norm(rxData.TransmitterPosition - rxInfo.Position); pathloss = bluetoothPathLoss(distance,pathlossCfg); rxData.Power = rxData.Power-pathloss; % In dBm scale = 10.^(-pathloss/20); [numSamples,~] = size(rxData.Data); rxData.Data(1:numSamples,:) = rxData.Data(1:numSamples,:)*scale; end
Input Arguments
Bluetooth LE node, specified as a bluetoothLENode object or a vector of bluetoothLENode objects.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: addMobility(blenode,PauseDuration=0.02) sets the pause
duration for a Bluetooth LE node, after it reaches a target waypoint, to 0.02
seconds.
Mobility model, specified as "random-waypoint",
"random-walk", "constant-velocity", or an
object of a subclass of wnet.Mobility. When you provide a custom
mobility object, the function generates a copy of the mobility model object and
associates it with the node. Consequently, after the function assigns the mobility
model to the node, changes you make to the original mobility model object do not
affect the node.
If you specify a custom mobility model object, the function ignores any other mobility parameters provided as name-value arguments.
Speed range, specified as a two-element numeric vector. The function sets the speed of the Bluetooth LE node according to a continuous uniform distribution based on this range. The first element of the vector specifies the minimum speed of the node, while the second specifies the maximum speed, in meters per second.
To set the speed to a constant value, specify SpeedRange as a
two-element row vector with identical values.
Dependencies
To specify this argument, you must specify the
MobilityModel argument as
"random-waypoint" or "random-walk".
Data Types: double
Pause duration of the Bluetooth LE node after reaching a target waypoint, specified as a nonnegative scalar. Units are in seconds.
Dependencies
To specify this argument, you must specify the
MobilityModel argument as
"random-waypoint".
Data Types: double
Shape of the node mobility area, specified as "rectangle" or
"circle".
Dependencies
To specify this argument, you must specify the
MobilityModel argument as
"random-waypoint" or "random-walk".
Data Types: char | string
Center coordinates and dimensions of the mobility area, specified as a
three-element or four-element numeric vector, depending on the value of the
BoundaryShape argument. Units are in meters.
"rectangle"— Specify a four-element numeric vector of the form [xcenter ycenter length width]. The default value is [xcurrent ycurrent1010], where the first two elements specify the xy-coordinates of current node position."circle"— Specify a three-element numeric vector of the form [xcenter ycenter radius]. The default value is [xcurrent ycurrent10], where the first two elements specify the xy-coordinates of current node position.
Dependencies
To specify this argument, you must specify the
MobilityModel argument as
"random-waypoint" or "random-walk".
Data Types: double
Since R2026a
Mode of random walk, specified as "time" or
"distance".
Dependencies
To specify this argument, you must specify the
MobilityModel argument as
"random-walk".
Since R2026a
Time after which the speed and direction change, specified as a positive scalar. Units are in seconds.
Dependencies
To specify this argument, you must specify the WalkMode
argument as "time" and the MobilityModel
argument as "random-walk".
Data Types: double
Since R2026a
Distance after which the speed and direction change, specified as a positive scalar. Units are in meters.
Dependencies
To specify this argument, you must specify the WalkMode
argument as "distance" and the MobilityModel
argument as "random-walk".
Data Types: double
Since R2026a
Current node velocity in Cartesian x-, y-, and z-coordinates, specified as a numeric vector of the form [vx vy vz]. vx, vy, and vz are velocity components in the x-, y-, and z-directions, respectively. Units are in meters per second.
Dependencies
To specify this argument, you must specify the
MobilityModel argument as
"constant-velocity".
Data Types: double
Since R2026a
Refresh Interval, specified as a nonnegative scalar. This argument indicates how often the node updates its position and velocity information, with a single refresh occurring at each fixed interval. The units are in seconds.
Data Types: double
References
[1] Bluetooth Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed January 10, 2026. https://www.bluetooth.com/.
[2] Bluetooth Core Specifications Working Group. "Bluetooth Core Specification" v6.1. https://www.bluetooth.com/specifications/specs/core-specification-6-1/.
Version History
Introduced in R2023bStarting in R2026a, this feature is available in Bluetooth Toolbox and also requires a Wireless Network Toolbox license. In prior releases, the feature is available through the Communications Toolbox™ Wireless Network Simulation Library add-on.
The addMobility function supports these new name-value arguments:
MobilityModel, WalkMode,
Time,
Distance,
Velocity,
and RefreshInterval.
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.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)