bleCSWaveform
Syntax
Description
generates a Bluetooth® low energy (LE) channel sounding (CS) physical layer (PHY) waveform from the
configuration specified by csPHYWaveform
= bleCSWaveform(cfgChannelSounding
)cfgChannelSounding
.
[
additionally generates a 32-bit access address for the Bluetooth LE device from the CS
deterministic random bit generator (DRBG) function.csPHYWaveform
,accessAddress
] = bleCSWaveform(cfgChannelSounding
)
Examples
Generate and Visualize Bluetooth LE Channel Sounding PHY Waveform
Generate and visualize a Bluetooth LE CS PHY waveform by using this CS procedure.
Using this example, you can:
Generate a CS PHY waveform at the Initiator.
Add propagation delay and additive white Gaussian noise (AWGN) to the generated CS PHY waveform.
Receive the noisy waveform at the Reflector, and generate a response waveform.
Add propagation delay and AWGN to the generated response waveform.
Receive the noisy response waveform at the Initiator.
Visualize the time-domain CS PHY waveforms at the Initiator and Reflector.
Configure CS PHY and Simulation Parameters
Specify the noise power spectral density (Eb/No), samples per symbol, and the speed of light.
EbNo = 30; % In dB sps = 8; lightSpeedConst = physconst("LightSpeed"); % In m/s
Specify the PHY transmission mode.
phyMode = "LE1M";
Specify the operating mode for CS PHY waveform generation.
stepMode = 0;
Specify the type of optional sequence in the CS SYNC packet format.
sequenceType = "Sounding Sequence";
Specify the optional sounding sequence length.
sequenceLength = 32; % In bits
Specify the duration of the CS tone.
toneDuration = 20; % In microseconds
Specify the distance between the Initiator and the Reflector devices.
distance = randi([2 80],1,1); % In meters
Compute the waveform propagation time between the Initiator and Reflector devices.
propagationTime = distance/lightSpeedConst; % In seconds
Calculate the sampling frequency (in Hz) of the generated waveform.
sampleRate = sps*1e6*(1 + 1*(phyMode=="LE2M")); % In Hz
Set the signal-to-noise ratio (SNR).
snr = EbNo - 10*log10(sps);
Create and configure a Bluetooth LE CS configuration object for the Initiator.
cfgObjectI = bleCSConfig(Mode=phyMode, ... SamplesPerSymbol=sps, ... DeviceRole="Initiator", ... SequenceLength=sequenceLength, ... SequenceType=sequenceType, ... StepMode=stepMode, ... ToneDuration=toneDuration);
Create and configure a Bluetooth LE CS configuration object for the Reflector.
cfgObjectR = bleCSConfig(Mode=phyMode, ... SamplesPerSymbol=sps, ... DeviceRole="Reflector", ... SequenceLength=sequenceLength, ... SequenceType=sequenceType, ... StepMode=stepMode, ... ToneDuration=toneDuration);
Create a variable fractional delay object by using the dsp.VariableFractionalDelay
(DSP System Toolbox) System object™.
timeDelay = dsp.VariableFractionalDelay;
Specify the number of samples to delay, based on the distance between the Initiator and Reflector devices.
samplesToDelay = propagationTime*sampleRate;
Set the configuration to display the time-domain CS PHY waveform.
timeDomainScope = timescope(SampleRate=sampleRate, ... ChannelNames={'Initiator','Reflector'}, ... LayoutDimensions=[2 1]); timeDomainScope.YLimits=[-1.25 1.25]; timeDomainScope.Title = "Initiator View"; timeDomainScope.ActiveDisplay = 2; timeDomainScope.YLimits=[-1.25 1.25]; timeDomainScope.Title = "Reflector View";
Set the configuration to display the frequency spectrum of the generated CS PHY waveform.
frequencyScope = spectrumAnalyzer(SampleRate=sampleRate);
Simulate and Visualize CS PHY Waveforms
Generate the Bluetooth LE CS PHY waveform at the Initiator.
waveformInitI = bleCSWaveform(cfgObjectI);
Compute the length of the generated Bluetooth LE CS waveform.
packetLength = length(waveformInitI)
packetLength = 352
Plot the Bluetooth LE CS waveform at the Initiator.
frequencyScope(waveformInitI) release(frequencyScope)
Add propagation delay to the generated waveform.
delayWaveformI = timeDelay([waveformInitI; zeros(ceil(samplesToDelay),1)],samplesToDelay);
Specify the time-domain waveform at the Initiator.
initiatorView = [waveformInitI; zeros(ceil(samplesToDelay),1)];
Add AWGN to the delayed waveform.
noisyWaveformI = awgn(delayWaveformI,snr,"measured");
Specify the time-domain waveform at the Reflector.
reflectorView = noisyWaveformI;
Display the time-domain view of the CS PHY waveform at the Initiator and the Reflector.
timeDomainScope(initiatorView,reflectorView) release(timeDomainScope)
The Reflector, upon receiving the CS waveform, completes the current task and then begins transmitting a response waveform (which might involve calculating processing delay).
Specify the idle wait time the Reflector must observe before initiating its response. Set the idle wait time of the Reflector by determining the number of frames it should wait.
idleFrames = randsrc(1,1,1:4);
Specify the number of idle samples of the Reflector in integer multiples of the received waveform.
idleSamples = idleFrames*packetLength;
Generate and plot the Bluetooth LE CS response waveform at the Reflector.
waveformInitR = bleCSWaveform(cfgObjectR); frequencyScope(waveformInitR) release(frequencyScope)
Specify the time-domain waveform at the Reflector.
reflectorView = [reflectorView; zeros(idleSamples,1); waveformInitR; zeros(ceil(samplesToDelay),1)];
Add propagation delay to the generated response waveform.
delayWaveformR = timeDelay([waveformInitR; zeros(ceil(samplesToDelay),1)],samplesToDelay);
Add AWGN to the delayed waveform.
noisyWaveformR = awgn(delayWaveformR,snr,"measured");
Specify the time-domain waveform at the Initiator.
initiatorView = [initiatorView; zeros(idleSamples,1); noisyWaveformR];
Display the time-domain view of the CS PHY waveform at the Initiator and the Reflector.
timeDomainScope(initiatorView,reflectorView) release(timeDomainScope)
Compute Length of Bluetooth LE CS PHY Waveform
Specify the operating step mode for CS waveform generation.
stepMode = 0;
Specify the duration of the CS tone.
toneDuration = 40; % In microseconds
Specify the sequence type and sequence length of the optional field.
sequenceType = "Random Sequence"; sequenceLength = 128; % In bits
Specify the samples per symbol and PHY transmission mode.
sps = 8;
phyMode = "LE1M";
Specify the role of the Bluetooth LE device as "Reflector"
or "Initiator"
.
deviceRole = "Reflector";
Calculate the length of the Bluetooth LE CS PHY waveform from the specified configuration.
multiFactor = 1 + 1*(phyMode=="LE2M"); lengthPreamble = 8*multiFactor; lengthAccessAddress = 32; lengthTrailer = 4; lengthGaurdDuration = 10*multiFactor; lengthTone = toneDuration*2*multiFactor; % One duration each for CS tone and extension slot switch stepMode case 0 lengthOfWaveform = sps*(lengthPreamble + lengthAccessAddress + lengthTrailer) + sps*(lengthGaurdDuration + 80)*(deviceRole=="Reflector"); case 1 lengthOfWaveform = sps*(lengthPreamble + lengthAccessAddress + lengthTrailer + sequenceLength*multiFactor); case 2 lengthOfWaveform = sps*lengthTone; case 3 lengthOfWaveform = sps*(lengthPreamble + lengthAccessAddress + lengthTrailer + sequenceLength*multiFactor + lengthGaurdDuration + lengthTone); end
Create and configure a Bluetooth LE CS configuration object for the Reflector.
cfgChannelSounding = bleCSConfig(DeviceRole=deviceRole, ... Mode=phyMode, ... SamplesPerSymbol=sps, ... SequenceLength=sequenceLength, ... SequenceType=sequenceType, ... StepMode=stepMode, ... ToneDuration=toneDuration);
Generate the Bluetooth LE CS PHY waveform at the Reflector.
csPHYWaveform = bleCSWaveform(cfgChannelSounding);
Display the size and length of the generated waveform and note that both values are same.
numel(csPHYWaveform)
ans = 1072
lengthOfWaveform
lengthOfWaveform = 1072
Input Arguments
cfgChannelSounding
— Bluetooth LE CS PHY waveform configuration parameters
bleCSConfig
object
Bluetooth LE CS PHY waveform configuration parameters, specified as a bleCSConfig
object.
Output Arguments
csPHYWaveform
— Bluetooth LE CS PHY waveform
complex-valued time-domain waveform
Bluetooth LE CS PHY waveform, returned as a complex-valued time-domain waveform of
the size Ns-by-1, where Ns specifies the number of
received samples. This table shows how the value of Ns for the
Initiator and Reflector devices depends on the values of the Mode
,
StepMode
, ToneDuration
and SamplesPerSymbol
properties of the bleCSConfig
object.
Value of Mode
| Value of StepMode | Value of Ns (Initiator) | Value of Ns (Reflector) |
---|---|---|---|
"LE1M" | 0 |
|
|
1 |
|
| |
2 | SamplesPerSymbol × ToneDuration
× 2 | SamplesPerSymbol × ToneDuration
× 2 | |
3 | SamplesPerSymbol × (44 +
SequenceLength + GD +
(ToneDuration × 2)) | SamplesPerSymbol × (44 +
SequenceLength + GD +
(ToneDuration × 2)) | |
"LE2M" | 0 |
|
|
1 |
|
| |
2 | SamplesPerSymbol × ToneDuration
× 2 × 2 | SamplesPerSymbol × ToneDuration
× 2 × 2 | |
3 | SamplesPerSymbol × (52 +
SequenceLength + (GD × 2) +
(ToneDuration × 2 × 2)) | SamplesPerSymbol × (52 +
SequenceLength + (GD × 2) +
(ToneDuration × 2 × 2)) |
GD is the guard time in the CS SYNC packet. Regardless of the
Mode
value you specify, the value of GD is 10
microseconds.
The ToneDuration
value specifies the duration of the CS tone in
microseconds. This table shows how the value of ToneDuration
depends on the value of the StepMode
property.
Value of StepMode
| Value of ToneDuration
|
---|---|
0 |
|
1 | Not applicable |
2 |
|
3 |
|
The value of SequenceLength
specifies the length of the sequence in the optional field
of the CS SYNC packet. You can set the type of sequence in the optional field by
configuring the SequenceType
property of the bleCSConfig
object as "Sounding Sequence"
or
"Random Sequence"
. This table shows how the value of
SequenceLength
depends on the value of the
SequenceType
property.
Value of SequenceType
| Value of SequenceLength
|
---|---|
"Sounding Sequence" | 32 or 96 |
"Random Sequence" | 32, 64, 96, or 128 |
Because the data rate in LE2M is double that of LE1M, the function uses a multiplicative factor of 2 to compute the value of Ns at the Initiator and Reflector.
Data Types: double
accessAddress
— Access address generated from CS DRBG function
32-bit column vector
Access address generated from the CS DRBG function, returned as a 32-bit column vector. For more information about the access address and its selection rules, see Sections 3.13.4 and 3.13.5 of [2].
Data Types: double
References
[1] Bluetooth Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed June 22, 2024. https://www.bluetooth.com/.
[2] Bluetooth Core Specifications Working Group. "Bluetooth Core Specification" v6.0. https://www.bluetooth.com/specifications/specs/core-specification-6-0/.
Version History
Introduced in R2024b
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)