Ideal receiver for BLE PHY waveform
Download Required: To use bleIdealReceiver, first download Communications Toolbox™ Library for the Bluetooth® Protocol. For more information, see Get and Manage Add-Ons. Alternatively, see Communications Toolbox Library for the Bluetooth Protocol File Exchange.
Create an input message column vector of length 1000 containing random binary values. Generate a BLE transmit waveform from the transmission bits by using the
txBits = randi([0 1],1000,1); txWaveform = bleWaveformGenerator(txBits);
Pass the transmit waveform through a noisy channel and obtain the received waveform.
snr = 30; % specified in dB rxWaveform = awgn(txWaveform,snr);
Recover data bits from the received BLE waveform using
bleIdealReceiver. Check for the number of bit errors in the recovered bits. The returned value indicates that the BLE waveform was successfully decoded.
[rxBits,accessAddr] = bleIdealReceiver(rxWaveform); numErr = biterr(txBits,rxBits)
numErr = 0
Specify the values of PHY generating mode, channel index and samples per symbol (sps).
phyMode = 'LE125K'; chanIndex = 2; sps = 4;
Generate transmission bits containing random binary values. Obtain the BLE transmit waveform from the transmission bits and the specified name-value pairs using the
txBits = randi([0 1],100,1); txWaveform = bleWaveformGenerator(txBits,'Mode',phyMode,... 'SamplesPerSymbol',sps,'ChannelIndex',chanIndex);
Recover the data bits, and then compare them with the transmission bits. The recovered data bits match the transmission bits, indicating there are no errors in the decoded BLE waveform.
rxBits = bleIdealReceiver(txWaveform,'Mode',phyMode,... 'SamplesPerSymbol',sps,'ChannelIndex',chanIndex); isequal(txBits,rxBits)
ans = logical 1
Specify a connectionless advertising channel protocol data unit (PDU) for angle of arrival (AoA) CTE.
pduHex = '02049B0327'; pdu = de2bi(hex2dec(pduHex),40)';
Generate and append cyclic redundancy check (CRC) to the PDU.
crcGen = comm.CRCGenerator('z^24+z^10+z^9+z^6+z^4+z^3+z+1',... 'InitialConditions',de2bi(hex2dec('555551'),'left-msb',24),... 'DirectMethod',true); pduCRC = crcGen(pdu);
Generate the BLE transmit waveform using specified name-value pair arguments.
txWaveform = bleWaveformGenerator(pduCRC,'ChannelIndex',36,... 'DFPacketType','ConnectionlessCTE');
Recover the data bits by demodulating, dewhitening, and IQ sampling for a slot duration of 2 .
[bits,accAddr,iqSamples] = bleIdealReceiver(txWaveform,... 'ChannelIndex',36,'DFPacketType','ConnectionlessCTE');
waveform— Received time-domain signal
Received time-domain signal, specified as a complex-valued signal with size
Ns represents the number of received
samples. The values of Ns depend on the
name-value pairs, according to the constraints specified in this table. For example, if
the value of
'LE1M' and the value of
'SamplesPerSymbol' is 4 then the value of
Ns must be greater than or equal to 160 and
a multiple of
|Value of ||Value of Ns||Multiple of|
comma-separated pairs of
the argument name and
Value is the corresponding value.
Name must appear inside quotes. You can specify several name and value
pair arguments in any order as
'Mode'— PHY transmission mode
PHY transmission mode, specified as the comma-separated pair consisting of
'LE125K'. This value indicates
the type of PHY used to decode the received BLE waveform.
'ChannelIndex'— Channel Index
37(default) | integer in the range [0, 39]
Channel index, specified as the comma-separated pair consisting of
'ChannelIndex' and an integer in the range [0, 39]. For data
channels, this value must be in the range [0, 36]. This value is used by the
'SamplesPerSymbol'— Samples per symbol
8(default) | positive integer
Samples per symbol, specified as the comma-separated pair consisting of
'SamplesPerSymbol' and a positive integer. The object uses this
value for Gaussian frequency shift keying (GFSK) modulation.
'DFPacketType'— Type of direction finding packet
Type of direction finding packet, specified as the comma-separated pair consisting
'SlotDuration'— Switch and sample slot duration
Switch and sample slot duration, specified as the comma-separated pair consisting
This value must be expressed in microseconds.
bits— Payload bits
Payload bits, returned as a column vector of maximum length 260 bytes. This output represents the recovered information bits.
accessAddr— Access address information
Access address information, returned as a 32-bit column vector. This output is used by the higher layers for validating a packet.
IQsamples— IQ samples
IQ samples, specified as a complex-valued column vector. This argument corresponds
to the 8 μs value of the reference period and slot duration. If the value of 'DFPacketType' argument is
'ConnectionCTE', then the
function returns this argument.
 Bluetooth Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed November 22, 2019. https://www.bluetooth.com/.
 Bluetooth Special Interest Group (SIG). "Bluetooth Core Specification." Version 5.1. https://www.bluetooth.com/.