Bluetooth Full Duplex Data and Voice Transmission in MATLAB
This example shows you how to model a full duplex communication in a Bluetooth® piconet having WLAN interference and supporting the adaptive frequency hopping (AFH) functionality using the Bluetooth® Toolbox. Using this example, you can:
Create and configure a Bluetooth piconet with basic rate (BR) physical layer (PHY) mode.
Configure asynchronous connection-oriented (ACL) logical transport and synchronous connection-oriented (SCO) logical transport to simultaneously transmit data and voice packets, respectively.
Add WLAN interference and additive white Gaussian noise (AWGN) to the Bluetooth BR waveform.
View packet error rate (PER) of each Bluetooth node in the presence of WLAN interference and AFH.
Visualize the power spectral density of Bluetooth BR waveforms in the presence of WLAN interference and AFH.
Add your own channel classification algorithm to analyze the simulation results.
Bluetooth Specifications
Bluetooth technology operates in 2.4 GHz industrial, scientific, and medical (ISM) band and shares it with other wireless technologies like ZigBee and WLAN. The Bluetooth Core Specification [ 2 ] defined by the Special Interest Group (SIG) specifies two PHY modes: the mandatory BR and the optional enhanced data rate (EDR). The Bluetooth BR/EDR radio implements a 1600 hops/s frequency hopping spread spectrum (FHSS) technique. The radio hops in a pseudo-random way on 79 designated Bluetooth channels. Each Bluetooth channel has a bandwidth of 1 MHz. Each channel is centered at (2402 + k) MHz, where k = 0, 1, ... 78. The modulation technique on the payload for BR and EDR mode is Gaussian frequency shift-keying (GFSK) and differential phase shift-keying (DPSK), respectively. The baud rate is 1 MSymbols/s. The Bluetooth BR/EDR radio uses a time-division duplex (TDD) scheme in which data transmission occurs in one direction at one time. The transmission alternates in two directions, one after the other.
Bluetooth and WLAN radios often operate in the same physical scenario and in the same device. Therefore, Bluetooth and WLAN transmissions can interfere with each other, thus impacting the performance and reliability of both the networks. To mitigate this interference, the IEEE 802.15.2 Task Group [2] recommends using the AFH technique. To study AFH and the coexistence of Bluetooth with WLAN, see Bluetooth-WLAN Coexistence.
For more information about the Bluetooth BR/EDR radio and the protocol stack, see Bluetooth Protocol Stack. For more information about Bluetooth BR/EDR packet structures, see Bluetooth Packet Structure.
Logical Transports
The Bluetooth system supports point-to-point or point-to-multipoint connections called as piconets. Each piconet consists of a node in the role of Central, with other nodes in the Peripheral role. The Central and Peripheral exchange data over multiple logical transports. These logical transports are:
SCO: The Central and Peripheral exchange SCO packets at regular intervals in the reserved slots. The Bluetooth nodes use SCO logical transport to exchange periodic data such as audio streaming. This logical transport does not support retransmissions.
Extended synchronous connection-oriented (eSCO): The Bluetooth nodes use eSCO to exchange periodic data such as audio streaming. This logical transport supports retransmissions.
ACL: The Bluetooth nodes use ACL to exchange asynchronous data such as a file transfer protocol (FTP). During each poll interval, the Central polls the ACL logical transport of a Peripheral at least once.
Active peripheral broadcast (APB): The Bluetooth nodes use ASB logical transport to send messages from the Central to all of the Peripherals in a piconet. This logical transport supports unidirectional traffic with no acknowledgments.
Connectionless peripheral broadcast (CPB): The Central node uses a CSB logical transport to send profile broadcast data to multiple Peripherals. This logical transport supports unidirectional traffic with no acknowledgments.
This example supports ACL and SCO logical transports between a Central and Peripherals by considering data as random bits of 0s and 1s. This figure shows the communication between a Central and three Peripherals in a piconet over ACL and SCO logical transports.
Bluetooth uses reserved time slots for communication between the nodes. The duration of each slot is 625 microseconds. The Central node initiates the transmission in even slots and extends the transmission to odd slots when transmitting a multislot packet. The Peripheral node initiates the transmission in odd slots and extends the transmission to even slots when transmitting a multislot packet.
Configure Simulation Parameters
This section shows how to configure the simulation parameters for the Bluetooth piconet, the wireless channel, and WLAN interference.
Bluetooth Piconet
The NumPeripherals
parameter specifies the number of Peripherals in the Bluetooth piconet. The LinkTraffic
parameter specifies the type of traffic over Bluetooth logical transports between a Central and the respective Peripheral. This table maps LinkTraffic
to different logical transports.
If the Central communicates with multiple Peripherals, LinkTraffic
must be a vector.
The SequenceType
parameter specifies the type of frequency hopping algorithm that the Bluetooth node uses. When you set SequenceType
to 'Connection adaptive'
, the Bluetooth channels are classified as good or bad periodically based on the PER of each Bluetooth channel. To classify the Bluetooth channels, you can use the classifyChannels object function.
simulationParameters = struct; % Set the simulation time in microseconds simulationTime = 3*1e6; % Enable or disable the visualization in the example enableVisualization = true; % Configure the number of Peripherals in the piconet simulationParameters.NumPeripherals =1; % Specify the positions of Bluetooth nodes in the form of n-by-3 array. % where n represents the number of nodes in the piconet. Each row specifies % the cartesian coordinates of a nodes starting from Central and followed % by Peripherals. simulationParameters.NodePositions = [10 0 0; 20 0 0]; % Configure the logical links between the Central and Peripherals % Each element represents the logical link between the Central and the % respective Peripheral. If the Central is connected to multiple % Peripherals, this value must be a row vector. simulationParameters.LinkTraffic = 1; % Configure the frequency hopping sequence as 'Connection basic' or % 'Connection adaptive' simulationParameters.SequenceType =
'Connection adaptive'; % To enable an ACL logical transport, set linkTraffic to 1 or 3. Specify % the ACL packet type as 'DM1', 'DH1', 'DM3', 'DH3', 'DM5', or 'DH5'. simulationParameters.ACLPacketType =
'DM1'; % To enable a SCO logical transport, set linkTraffic to 2 or 3. Specify the % SCO packet type as 'HV1', 'HV2', or 'HV3' for the respective Peripheral that % has SCO link traffic. Here, 1 represents the Peripheral number, and 'HV3' % represents the corresponding SCO packet type used by Peripheral 1. simulationParameters.SCOPacketType = {1, 'HV3'};
Wireless Channel and WLAN Interference
Configure the wireless channel by using the helperBluetoothChannel helper object. You can set the EbNo
value for the AWGN channel. To generate the WLAN signal interference, use the helperBluetoothGenerateWLANWaveform helper function. Specify the sources of WLAN interference by using the WLANInterference
parameter. Use one of these options to specify the source of the WLAN interference.
'Generated'
: To add a WLAN Toolbox™ signal, select this option. Perform the steps shown in further exploration to add the signal from the WLAN Toolbox™.'BasebandFile'
: To add a WLAN signal from a baseband file (.bb
), select this option. You can specify the file name using theWLANBBFilename
input argument. If you do not specify the.bb
file, the example uses the default.bb
file,'WLANNonHTDSSS.bb'
, to add the WLAN signal.
The 'None'
option implies that no WLAN signal is added. AWGN is present throughout the simulation.
% Configure wireless channel parameters simulationParameters.EbNo = 22; % Ratio of energy per bit (Eb) to spectral noise density (No) in dB % Configure the WLAN interference % Specify the WLAN interference as 'Generated', 'BasebandFile', or 'None'. % To use the 'wlanBBFilename' option, set wlanInterference to 'BasebandFile'. simulationParameters.WLANInterference ='BasebandFile'; simulationParameters.WLANBBFilename = 'WLANNonHTDSSS.bb'; % Signal to interference ratio in dB simulationParameters.SIR = [-15 -16];
Channel Classification Parameters
Classify the Bluetooth channels as good or bad by using the helperBluetoothChannelClassification helper object only when the SequenceType
is 'Connection adaptive'
. The example classifies the Bluetooth channels by using these parameters.
PERThreshold
: PER thresholdClassificationInterval
: Periodicity (in slots) of channel classificationRxStatusCount
: Maximum number of received packets status maintained for each channelMinRxCountToClassify
: Minimum number of received packets status for each channel to classify a channel as good or badPreferredMinimumGoodChannels
: Preferred number of good channels required to communicate between the Central and Peripherals
You can add your own classification algorithm by customizing the classifyChannels object function of the helperBluetoothChannelClassification helper object.
simulationParameters.PERThreshold =50; % Packet error rate simulationParameters.ClassificationInterval =
3000; % In slots simulationParameters.RxStatusCount =
10; % Maximum Rx packets status simulationParameters.MinRxCountToClassify =
4; % Minimum packets received simulationParameters.PreferredMinimumGoodChannels =
20; % Preferred number of good channels
Create Bluetooth Piconet
Specify the total number of Bluetooth nodes in the piconet. Set the role of the nodes as Central or Peripheral. To create a Bluetooth piconet from the configured parameters, use the helperBluetoothCreatePiconet helper function.
% Set the default random number generator ('twister' type with seed value 0). % The seed value controls the pattern of random number generation. For high % fidelity simulation results, change the seed value and average the % results over multiple simulations. rng('default'); % Specify Tx power, in dBm simulationParameters.TxPower = 20; % Specify the Bluetooth node receiver range (in meters) simulationParameters.ReceiverRange = 40; % Set the total number of nodes in the piconet (one Central and multiple % Peripherals) numNodes = simulationParameters.NumPeripherals + 1; % Create a Bluetooth piconet bluetoothNodes = helperBluetoothCreatePiconet(simulationParameters);
To visualize the Bluetooth waveforms, create the dsp.SpectrumAnalyzer
System object™.
% View the Bluetooth waveforms using the spectrum analyzer spectrumAnalyzer = dsp.SpectrumAnalyzer(... 'ViewType','Spectrum and spectrogram', ... 'TimeResolutionSource','Property', ... 'TimeResolution',0.0005, ... % In seconds 'SampleRate',bluetoothNodes{1}.PHY.SamplesPerSymbol*1e6, ... % In Hz 'TimeSpanSource','Property', ... 'TimeSpan',0.05, ... % In seconds 'FrequencyResolutionMethod','WindowLength', ... 'WindowLength',512, ... % In samples 'AxesLayout','Horizontal', ... 'FrequencyOffset',2441*1e6, ... 'ColorLimits',[-20 15]);
Simulation
Simulate the Bluetooth piconet using the configured parameters. Visualize the plot of the PER of each Bluetooth node in the piconet. Visualize the power spectral density of the Bluetooth waveforms by using the dsp.SpectrumAnalyzer
System object. You can also calculate the baseband layer statistics (total transmitted packets, total received packets, and total dropped packets) and channel classification statistics at each Bluetooth node. When the sequence type is set to 'Connection adaptive'
, t
he Bluetooth node updates the channel classification statistics.
% Current simulation time in microseconds curTime = 0; % Elapsed time in microseconds elapsedTime = 0; % Next invoke times of all of the nodes in microseconds nextInvokeTimes = zeros(1, numNodes); if enableVisualization % Plot the PER perFigure = figure("Name","PER of Each Bluetooth Node",'Tag','BluetoothPERPlot'); perAxes = axes(perFigure); % Add annotations to the figure ylim(perAxes, [0 1]); xlabel(perAxes, 'Simulation Time (in Microseconds)'); ylabel(perAxes, 'PER'); title(perAxes, 'PER of Each Bluetooth Node'); % Plot the PER line for each Bluetooth node [perPlots, legendStr] = deal(cell(1, numNodes)); for plotIdx = 1:numNodes hold on perPlots{plotIdx} = plot(perAxes, curTime, 0); if plotIdx == 1 legendStr{1} = ['\color[rgb]{' num2str(perPlots{plotIdx}.Color) '} Central']; else legendStr{plotIdx} = ['\color[rgb]{' num2str(perPlots{plotIdx}.Color) '} Peripheral-' num2str(plotIdx-1)]; end end % Add a legend to the figure legend(perAxes, legendStr,'Location','northeastoutside','Box','on'); if ~strcmpi(simulationParameters.WLANInterference, 'None') % Generate the WLAN waveform for visualization wlanWaveform = helperBluetoothGenerateWLANWaveform(... simulationParameters.WLANInterference, simulationParameters.WLANBBFilename); end end % Run the simulation while(curTime < simulationTime) % Simulate the Bluetooth nodes for nodeIdx = 1:numNodes % Push the data into the node pushData(bluetoothNodes{nodeIdx}, ... simulationParameters.ACLPacketType, simulationParameters.SCOPacketType); % Run the Bluetooth node instance nextInvokeTimes(nodeIdx) = runNode(bluetoothNodes{nodeIdx}, elapsedTime); if enableVisualization if ~isempty(findobj('Tag', 'BluetoothPERPlot')) % Update and plot the PER perPlots{nodeIdx}.XData = [perPlots{nodeIdx}.XData curTime]; if isempty(bluetoothNodes{nodeIdx}.PHY.PER) per = 0; else per = bluetoothNodes{nodeIdx}.PHY.PER; end perPlots{nodeIdx}.YData = [perPlots{nodeIdx}.YData per]; end end end % Update the current simulation time curTime = curTime + elapsedTime; % Distribute any transmitted packets from each node into the receiving % buffers of the other nodes [isPacketDistributed, txBuffer] = helperBluetoothDistributePackets(bluetoothNodes); % Update visualization if enableVisualization for txIdx = 1:numel(txBuffer) channelWaveform = txBuffer{txIdx}.Waveform(1:txBuffer{txIdx}.NumSamples); if ~strcmpi(simulationParameters.WLANInterference, 'None') % Add WLAN interference to the channel waveform channelWaveform = channelWaveform + wlanWaveform(1:txBuffer{txIdx}.NumSamples); end % Plot the Bluetooth waveform spectrumAnalyzer(channelWaveform); end end % If packets are distributed to the receiver nodes, run the nodes to % check the packet reception buffer. if isPacketDistributed elapsedTime = 0; % Advance the simulation time to the next event at a node else elapsedTime = min(nextInvokeTimes(nextInvokeTimes ~= -1)); end end
ans = 1x79 logical array
0 1 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
release(spectrumAnalyzer);
The preceding spectrum analyzer plot shows the spectrum of the Bluetooth waveform distorted with WLAN interference (in the frequency domain) and passed through the AWGN channel. The right-side plot shows the overlapping of Bluetooth packets with the interfering WLAN signal.
The plot "PER of Each Bluetooth Node" shows the PER of each node in the Bluetooth piconet with respect to the simulation time.
To see the baseband layer statistics for each Bluetooth node, explore the statisticsAtEachNode
variable. To see the channel classification statistics for each Central-Peripheral pair, inspect the classificationStats
variable. The channel classification statistics are valid when sequenceType
is set to 'Connection adaptive'
. Get the baseband layer and channel classification statistics of each Bluetooth node in the piconet.
% Get the baseband layer and channel classification statistics of each Bluetooth node in the piconet
[statisticsAtEachNode, classificationStats] = helperBluetoothFullDuplexStatistics(bluetoothNodes)
statisticsAtEachNode=2×19 table
TotalRxPackets TotalTxPackets TxACLPackets TxACLOneSlotPackets TxACLThreeSlotPackets TxACLFiveSlotPackets RetransmittedACLPackets RxSlotsWithNoPacket TxSCOPackets RxACLPackets RxACLOneSlotPackets RxACLThreeSlotPackets RxACLFiveSlotPackets RxSCOPackets TotalRxFailedPackets ACKedACLPackets ACKedSCOPackets DroppedPackets DroppedLMPMessages
______________ ______________ ____________ ___________________ _____________________ ____________________ _______________________ ___________________ ____________ ____________ ___________________ _____________________ ____________________ ____________ ____________________ _______________ _______________ ______________ __________________
Central 1402 2401 {7x2 double} {7x2 double} {7x2 double} {7x2 double} {7x2 double} 998 {7x2 double} {7x2 double} {7x2 double} {7x2 double} {7x2 double} {7x2 double} 124 {7x2 double} {7x2 double} 254 0
Peripheral1 2291 1444 {7x2 double} {7x2 double} {7x2 double} {7x2 double} {7x2 double} 0 {7x2 double} {7x2 double} {7x2 double} {7x2 double} {7x2 double} {7x2 double} 296 {7x2 double} {7x2 double} 551 0
classificationStats=1×3 table
LTAddress ClassificationCount ChannelMap
_________ ___________________ __________________________________________________________________________
1 1 {[0 1 1 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 ... ]}
This example enables you to configure and simulate a full duplex data and voice communication in a Bluetooth piconet with WLAN interference. The example uses AFH to mitigate WLAN interference by classifying channels as good or bad based on the PER value. The performance of full duplex communication is analyzed by visualizing the impact of WLAN interference on each Bluetooth node.
Further Exploration
To add the WLAN signal using the features of the WLAN Toolbox™, set the value of wlanInterference to 'Generated'. Use this code to add the WLAN signal.
Add the WLAN signal generated using the features of the WLAN Toolbox™ as static signal interference to Bluetooth. To enable this, set wlanInterference
value as 'Generated', add your custom signal generation code in function. Use this sample code snippet in WLAN signal generation using features of WLAN Toolbox™.
% % WLAN waveform to interfere with Bluetooth waveforms can be % % modified by using the features of the WLAN Toolbox(TM). % psduLength = 1000; % % % Create configuration object for WLAN waveform (802.11b) % cfgNHT = wlanNonHTConfig('Modulation','DSSS', ... % 'PSDULength', psduLength); % % % Create random PSDU % psdu = randi([0 1], cfgNHT.PSDULength*8, 1); % % % Generate WLAN waveform % wlanWaveform = wlanWaveformGenerator(psdu, cfgNHT);
You can add your custom signal generation code in the helperBluetoothGenerateWLANWaveform helper function. You can also write the respective signal WLAN spectrum masks and register to the WLANSpectrum
property of the helperBluetoothChannel helper object as a function pointer.
Appendix
The example uses these helpers:
helperBluetoothFullDuplexNode: Configure and simulate Bluetooth node
helperBluetoothBaseband: Configure and simulate Bluetooth baseband layer
helperBluetoothLogicalTransports: Configure logical transports between Bluetooth nodes
helperBluetoothSlotTimer: Manage Bluetooth clock and the timing of slots
helperBluetoothPHY: Configure and simulate Bluetooth PHY layer
helperBluetoothChannel: Configure and simulate Bluetooth wireless channel
helperBluetoothGenerateWLANWaveform: Generate WLAN waveform to be added as an interference to Bluetooth waveforms
helperBluetoothCreatePiconet: Create Bluetooth piconet using the Bluetooth nodes
helperBluetoothFullDuplexStatistics: Return statistics of each Bluetooth node in the Bluetooth piconet
helperBluetoothQueue: Create an object for Bluetooth queue functionality
Selected Bibliography
Bluetooth Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed November 29, 2021. https://www.bluetooth.com/.
Bluetooth Special Interest Group (SIG). "Bluetooth Core Specification." Version 5.3. https://www.bluetooth.com.
IEEE® Standard 802.15.2™. "Coexistence of Wireless Personal Area Networks with Other Wireless Devices Operating in Unlicensed Frequency Bands." IEEE Recommended Practice for Information technology - Telecommunications and information exchange between systems - Local and metropolitan area networks - Specific requirements; IEEE Computer Society.