Main Content

bleLLAdvertisingChannelPDUDecode

Decode Bluetooth LE LL advertising channel PDU

Since R2019b

    Description

    example

    [status,cfgLLAdv] = bleLLAdvertisingChannelPDUDecode(advLLPDU)decodes the specified Bluetooth® low energy (LE) link layer (LL) advertising channel protocol data unit (PDU), advLLPDU, returning the decoding status, status, and the corresponding Bluetooth LE LL advertising channel PDU configuration object, cfgLLAdv.

    example

    [status,cfgLLAdv] = bleLLAdvertisingChannelPDUDecode(advLLPDU,inputFormat) additionally specifies the format of the Bluetooth LE LL advertising channel PDU.

    Examples

    collapse all

    Create a default Bluetooth LE LL advertising channel PDU configuration object.

    cfgLLAdv = bleLLAdvertisingChannelPDUConfig
    cfgLLAdv = 
      bleLLAdvertisingChannelPDUConfig with properties:
    
                      PDUType: 'Advertising indication'
             ChannelSelection: 'Algorithm1'
        AdvertiserAddressType: 'Random'
            AdvertiserAddress: '0123456789AB'
              AdvertisingData: [3x2 char]
    
    

    Generate the BLE LL advertising channel PDU from the corresponding configuration object.

    advLLpdu = bleLLAdvertisingChannelPDU(cfgLLAdv);

    Decode the generated Bluetooth LE LL advertising channel PDU. The returned status indicates decoding is successful.

    [status,cfgLLAdv] = bleLLAdvertisingChannelPDUDecode(advLLpdu)
    status = 
      blePacketDecodeStatus enumeration
    
        Success
    
    
    cfgLLAdv = 
      bleLLAdvertisingChannelPDUConfig with properties:
    
                      PDUType: 'Advertising indication'
             ChannelSelection: 'Algorithm1'
        AdvertiserAddressType: 'Random'
            AdvertiserAddress: '0123456789AB'
              AdvertisingData: [3x2 char]
    
    

    Specify a sample Bluetooth LE LL advertising channel PDU in octets.

    advLLpdu = 'C409AB8967452301020106A8F1DF';

    Decode the specified Bluetooth LE LL advertising channel PDU by specifying 'InputFormat' to 'octets'. The returned status indicates decoding is successful.

    [status, cfgLLAdv] = bleLLAdvertisingChannelPDUDecode(advLLpdu, ...
        'InputFormat','octets')
    status = 
      blePacketDecodeStatus enumeration
    
        Success
    
    
    cfgLLAdv = 
      bleLLAdvertisingChannelPDUConfig with properties:
    
                      PDUType: 'Scan response'
        AdvertiserAddressType: 'Random'
            AdvertiserAddress: '0123456789AB'
             ScanResponseData: [3x2 char]
    
    

    Specify a Bluetooth LE LL advertising channel PDU containing corrupted data values.

    pdu = 'D409AB89674523010201';

    Decode the specified Bluetooth LE LL advertising channel PDU. The returned status indicates that the decoding failed due to the corrupted input Bluetooth LE LL advertising channel PDU. In case of failed decoding, the reason of failure is indicated and the object displays no properties.

    [status,cfgLLAdv] = bleLLAdvertisingChannelPDUDecode(pdu, ...
        'InputFormat','octets')
    status = 
      blePacketDecodeStatus enumeration
    
        CRCFailed
    
    
    cfgLLAdv = 
      bleLLAdvertisingChannelPDUConfig with properties:
    
    

    Input Arguments

    collapse all

    Bluetooth LE LL advertising channel PDU, specified as one of these types:

    • Character vector — This vector represents octets in hexadecimal format.

    • String scalar — This scalar represents octets in hexadecimal format.

    • Numeric vector of elements in the range [0,255] — This vector represents octets in decimal format.

    • n-by-2 character array — Each row represents an octet in hexadecimal format. n represents number of rows.

    • Binary vector — This vector represents the Bluetooth LE LL advertising channel PDU bits.

    Data Types: char | string | double

    Bluetooth LE LL advertising channel PDU format, specified as 'bits' or 'octets'. When specified as 'bits', this input is a binary vector. When specified as 'octets', this input is a numeric vector representing octets in the decimal format or a character array or a string scalar representing octets in hexadecimal format.

    Data Types: char | string | double

    Output Arguments

    collapse all

    Bluetooth LE LL advertising channel PDU decoding status, returned as a nonpositive number of type blePacketDecodeStatus. This value represents the result of Bluetooth LE LL advertising channel PDU decoding. Each value of this output corresponds to a member of the blePacketDecodeStatus enumeration class, which indicates the packet decoding status shown in this table.

    Value of statusMember of Enumeration ClassDecoding Status
    0SuccessPacket decoding succeeded
    -1 CRCFailedLink Layer PDU is corrupted
    –2LLPDULengthMismatchLength field does not match with actual PDU length
    –3InvalidLLPeripheralLatencyInvalid Peripheral latency
    –4InvalidLLConnectionTimeoutInvalid connection timeout
    –5InvalidLLWindowSizeInvalid window size
    –6InvalidLLWindowOffsetInvalid window offset
    –7InvalidLLConnectionIntervalInvalid connection interval
    –8InvalidLLChannelMapInvalid channel map
    –51IncompleteLLAdvertisingChannelPDUInsufficient octets in advertising channel PDU
    –52InvalidLLHopIncrementInvalid hop increment value
    –53InvalidLLAdvertisingDataLengthInvalid advertising data
    –54InvalidLLScanResponseDataLengthInvalid scan response data
    –55UnsupportedLLAdvertisingPDUTypeUnsupported advertising channel PDU

    An enumeration value other than 0 implies failed Bluetooth LE LL advertising channel PDU decoding. If the decoding fails, the cfgLLAdv argument displays no output.

    Bluetooth LE LL advertising channel configuration object, returned as a bleLLAdvertisingChannelPDUConfig object.

    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