Create a wireless network simulator.
Create a Bluetooth LE node, specifying the role as "central
". Specify the position of the node.
centralNode =
bluetoothLENode with properties:
TransmitterPower: 20
TransmitterGain: 0
ReceiverRange: 100
ReceiverGain: 0
ReceiverSensitivity: -100
NoiseFigure: 0
InterferenceFidelity: 0
Name: "Node1"
Position: [0 0 0]
Read-only properties:
Role: "central"
ConnectionConfig: [1×1 bluetoothLEConnectionConfig]
PeripheralCount: 0
TransmitBuffer: [1×1 struct]
ID: 1
Create a Bluetooth LE node, specifying the role as "peripheral
". Specify the position of the node.
peripheralNode =
bluetoothLENode with properties:
TransmitterPower: 20
TransmitterGain: 0
ReceiverRange: 100
ReceiverGain: 0
ReceiverSensitivity: -100
NoiseFigure: 0
InterferenceFidelity: 0
Name: "Node2"
Position: [10 0 0]
Read-only properties:
Role: "peripheral"
ConnectionConfig: [1×1 bluetoothLEConnectionConfig]
TransmitBuffer: [1×1 struct]
ID: 2
Create a Bluetooth LE configuration object, specifying the connection interval and active period for the connection.
Configure the link layer (LL) connection between the Central and Peripheral nodes.
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. Add application traffic from the Central to the Peripheral node by using the addTrafficSource
object function.
Create a WLAN node to introduce interference in the network by using the helperInterferingWLANNode
helper object. Specify the position of the WLAN node. Specify the transmitter power and frequency of operation of the WLAN node. Specify the signal periodicity in which the WLAN node transmits the signal.
Create a Bluetooth LE network consisting of a Central node, a Peripheral node, and a WLAN node.
Add a listener for an event by using the addlistener
function. This function attaches the listener to the source of the event, which is a handle object. When an event is triggered, the addlistener
function invokes the callback function.
Assume that when the number of retransmitted packets in the Bluetooth LE network is greater than 100 and when the packet loss ratio is greater than 0.2, the used (good) channels list is updated to use only channels 1-10. This function is implemented in the callback function channelMapUpdateFcn. To check statistics and update the channels at the end of each connection event, create a listener at the Central node for the ConnectionEventEnded
event. Because the Central node classifies and updates the channel map for all of the Peripheral nodes, a listener is created at the Central node.
Create a function handle to display the updated list of used channels for Bluetooth LE communication.
To display the updated list of channels after the Central node updates the channel map, create a listener at the Central node for the ChannelMapUpdated
event. The listener returns the source node object and the event data. The event data is a structure containing the event information that triggered the listener.
Add the Central, Peripheral, and WLAN nodes to the wireless network simulator.
Set the simulation time and run the simulation.
Custom channel model is not added. Using free space path loss (fspl) model as the default channel model.
Retrieve application, link layer (LL) , and physical layer (PHY) statistics related to the source, relay, and destination nodes by using the statistics
object function. For more information about the statistics, see Bluetooth LE Node Statistics.
centralStats = struct with fields:
Name: "Node1"
ID: 1
App: [1×1 struct]
LL: [1×1 struct]
PHY: [1×1 struct]
peripheralStats = struct with fields:
Name: "Node2"
ID: 2
App: [1×1 struct]
LL: [1×1 struct]
PHY: [1×1 struct]
The callback function of the ConnectionEventEnded
event channelMapUpdateFcn retrieves the statistics corresponding to the Bluetooth LE node object. This function checks whether these conditions are true.
If the conditions are true, the function updates the channel map in the Bluetooth LE node object to use Bluetooth LE channels 1-10 by using the updateChannelList
object function of the bluetoothLENode
object.