Main Content

bleIdealReceiver

Decode Bluetooth LE PHY waveform

    Description

    [bits,accessAddr] = bleIdealReceiver(waveform) decodes the Bluetooth® low energy (LE) physical layer (PHY) waveform, waveform, generated by the bleWaveformGenerator function. The function returns the received bits, bits, and the access address, accesAddr.

    example

    [bits,accessAddr] = bleIdealReceiver(waveform,Name,Value) also specifies options using one or more name-value pair arguments. For example, 'Mode','LE2M' sets the PHY transmission mode of the desired Bluetooth LE waveform to 'LE2M'.

    example

    [___,IQsamples] = bleIdealReceiver(___) additionally returns the in-phase and quadrature (IQ) samples, IQsamples, corresponding to constant tone extension (CTE).

    example

    Examples

    collapse all

    Create an input message column vector of length 1000 containing random binary-valued transmission bits.

    txBits = randi([0 1],1000,1);

    Generate a Bluetooth LE transmit waveform from the transmission bits by using the bleWaveformGenerator function.

    txWaveform = bleWaveformGenerator(txBits);

    Pass the transmit waveform through a noisy channel and obtain the received waveform.

    snr = 30;                          % In dB
    rxWaveform = awgn(txWaveform,snr);

    Recover data bits from the received Bluetooth LE waveform. Check for the number of bit errors in the recovered bits. The returned value indicates that the function successfully decodes the Bluetooth LE waveform.

    [rxBits,accessAddr] = bleIdealReceiver(rxWaveform);
    numErr = biterr(txBits,rxBits)
    numErr = 
    0
    

    Specify the values of PHY transmission mode, channel index, samples per symbol (sps), and pulse length.

    phyMode = 'LE125K';
    chanIndex = 2;
    sps = 4;
    pulseLen = 2;

    Generate transmission bits containing random binary values.

    txBits = randi([0 1],100,1);

    Generate the Bluetooth LE waveform from the transmission bits.

    txWaveform = bleWaveformGenerator(txBits,'Mode',phyMode,...
        'SamplesPerSymbol',sps,'ChannelIndex',chanIndex, ...
        'ModulationIndex',0.49,'PulseLength',pulseLen);

    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 Bluetooth LE waveform.

    rxBits = bleIdealReceiver(txWaveform,'Mode',phyMode,...
        'SamplesPerSymbol',sps,'ChannelIndex',chanIndex, ...
        'ModulationIndex',0.49,'PulseLength',pulseLen,'NoiseVariance',2);
    isequal(txBits,rxBits)
    ans = logical
       1
    
    

    Specify a connectionless advertising channel protocol data unit (PDU) for angle of arrival (AoA) CTE.

    pduHex = '02049B0327';
    pdu = int2bit(hex2dec(pduHex),40,false);

    Generate and append cyclic redundancy check (CRC) to the PDU.

    cfgCRC = crcConfig(Polynomial='z^24+z^10+z^9+z^6+z^4+z^3+z+1', ...
        InitialConditions=int2bit(hex2dec('555551'),24), ...
        DirectMethod=true);
    pduCRC = crcGenerate(pdu,cfgCRC);

    Generate the Bluetooth LE transmit waveform.

    txWaveform = bleWaveformGenerator(pduCRC,'ChannelIndex',36, ...
        'DFPacketType','ConnectionlessCTE');

    Recover the data bits by demodulating, dewhitening, and IQ sampling for a slot duration of 2 μs.

    [bits,accAddr,iqSamples] = bleIdealReceiver(txWaveform, ...
        'ChannelIndex',36,'DFPacketType','ConnectionlessCTE');

    Input Arguments

    collapse all

    Received time-domain signal, specified as a complex-valued signal with size Ns-by-1, where Ns represents the number of received samples. The values of Ns depend on the 'Mode' and 'SamplesPerSymbol' input arguments, according to the constraints specified in this table.

    Value of 'Mode' Value of NsMultiple of
    'LE1M'

    40×sps

    sps
    'LE2M'

    48×sps

    sps
    'LE500K'

    376×sps

    2×sps
    'LE125K'

    376×sps

    8×sps

    Data Types: double | single

    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.

    Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

    Example: bleIdealReceiver(waveform,'Mode','LE2M','ChannelIndex',36)

    PHY transmission mode, specified as the comma-separated pair consisting of 'Mode' and 'LE1M', 'LE2M', 'LE500K', or 'LE125K'. This value indicates the type of PHY that the function uses to decode the received Bluetooth LE waveform.

    Data Types: char | string

    Channel index, specified as the comma-separated pair consisting of 'ChannelIndex' and an integer in the range [0, 39]. For data channels, specify this input in the range [0, 36]. This value is used by the data-dewhitening block.

    Data Types: double

    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.

    Data Types: double

    Type of direction finding packet, specified as the comma-separated pair consisting of 'DFPacketType' and 'ConnectionlessCTE', 'ConnectionCTE', or 'Disabled'.

    Data Types: char | string

    Switch and sample slot duration, specified as the comma-separated pair consisting of 'SlotDuration' and 1 or 2. Specify this value in microseconds.

    Data Types: double

    Data whiten status, specified as 'On' or 'Off'. Set this value to 'On' for the function to perform dewhitening on the demodulated bits (for 'LE1M' and 'LE2M' PHY) and the decoded bits (for 'LE500K' and 'LE125K' PHY).

    Data Types: char | string

    Modulation index, specified as a scalar in the range [0.45, 0.55]. This input specifies the modulation index that the bleWaveformGenerator function uses while performing GFSK modulation. The function uses this input to generate the GFSK trellis parameters for demodulation.

    Data Types: double

    Length of the frequency pulse shape, specified as an integer in the range [1, 4]. Units are in symbol intervals.

    Data Types: double

    Noise variance of input signal in linear scale, specified as a real positive scalar.

    Data Types: double

    Output Arguments

    collapse all

    Payload bits, returned as a column vector of maximum length 260 bytes. This output represents the recovered information bits.

    Data Types: int8

    Access address information, returned as a 32-bit column vector. The higher layers use this output to validate a packet.

    Data Types: int8

    IQ samples, returned as a scalar or a complex-valued column vector. This argument corresponds to the 8 μs value of the reference period and slot duration. If you set the value of DFPacketType argument to 'ConnectionlessCTE' or 'ConnectionCTE', then the function returns this output.

    Data Types: double

    References

    [1] Bluetooth Technology Website. “Bluetooth Technology Website | The Official Website of Bluetooth Technology.” Accessed November 22, 2021. https://www.bluetooth.com/.

    [2] Bluetooth Special Interest Group (SIG). "Bluetooth Core Specification." Version 5.3. https://www.bluetooth.com/.

    Extended Capabilities

    C/C++ Code Generation
    Generate C and C++ code using MATLAB® Coder™.

    Version History

    Introduced in R2019b