Main Content

bleLLDataChannelPDUDecode

Decode Bluetooth LE LL data channel PDU

Since R2019b

    Description

    example

    [status,cfgLLData,LLPayload] = bleLLDataChannelPDUDecode(dataLLPDU,CRCinit) decodes a Bluetooth® low energy (LE) link layer (LL) data channel protocol data unit (PDU), dataLLPDU, returning the decoding status, status, the Bluetooth LE LL data channel PDU configuration object, cfgLLData, and the upper-layer payload, LLPayload. The CRCinit denotes the initialization value of cyclic redundancy check (CRC).

    example

    [status,cfgLLData,LLPayload] = bleLLDataChannelPDUDecode(dataLLPDU,CRCinit, inputFormat) additionally sets the format of the Bluetooth LE LL data channel PDU.

    Examples

    collapse all

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

    cfgLLData = bleLLDataChannelPDUConfig
    cfgLLData = 
      bleLLDataChannelPDUConfig with properties:
    
                     LLID: 'Data (continuation fragment/empty)'
                     NESN: 0
           SequenceNumber: 0
                 MoreData: 0
        CRCInitialization: '012345'
    
    

    Set the LLID value to 'start fragment/complete'. Initialize the cyclic redundancy check (CRC) value to 'ED321C'.

    cfgLLData.LLID = 'Data (start fragment/complete)';
    cfgLLData.CRCInitialization = 'ED321C';
    crcInit = 'ED321C';

    Generate a Bluetooth LE LL data channel PDU with upper-layer payload in hexadecimal octets.

    dataLLPDU = bleLLDataChannelPDU(cfgLLData,'030004000A0100');

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

    [status,cfgLLData,llPayload] = bleLLDataChannelPDUDecode(dataLLPDU,crcInit)
    status = 
      blePacketDecodeStatus enumeration
    
        Success
    
    
    cfgLLData = 
      bleLLDataChannelPDUConfig with properties:
    
                     LLID: 'Data (start fragment/complete)'
                     NESN: 0
           SequenceNumber: 0
                 MoreData: 0
        CRCInitialization: 'ED321C'
    
    
    llPayload = 7x2 char array
        '03'
        '00'
        '04'
        '00'
        '0A'
        '01'
        '00'
    
    

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

    dataLLPDU = '030C00010000060000000A000000FCD2A6';

    Initialize the CRC value.

    crcInit = 'ED323C';

    Decode the specified Bluetooth LE LL data channel PDU by specifying the 'inputFormat' to 'octets'. The specified PDU is a control PDU. The returned status indicates decoding is successful. You can see the decoded configuration of the specified PDU in the 'ControlConfig' property of 'cfgLLData'.

    [status,cfgLLData,llPayload] = bleLLDataChannelPDUDecode(dataLLPDU,crcInit, ...
        'InputFormat','octets')
    status = 
      blePacketDecodeStatus enumeration
    
        Success
    
    
    cfgLLData = 
      bleLLDataChannelPDUConfig with properties:
    
                     LLID: 'Control'
                     NESN: 0
           SequenceNumber: 0
                 MoreData: 0
        CRCInitialization: 'ED323C'
            ControlConfig: [1x1 bleLLControlPDUConfig]
    
    
    llPayload =
    
      1x0 empty char array
    

    Specify a Bluetooth LE LL data channel PDU containing corrupted data values. Initialize the CRC value.

    dataLLPDU = '040C00010000060000000A00';
    crcInit = 'CD3234';

    Decode the specified Bluetooth LE LL data channel PDU. The returned status indicates that the decoding failed due to the corrupted Bluetooth LE LL data channel PDU. If the decoding fails, the reason is indicated and the object displays no properties.

    [status,cfgLLData,llPayload] = bleLLDataChannelPDUDecode(dataLLPDU,crcInit, ...
        'InputFormat','octets')
    status = 
      blePacketDecodeStatus enumeration
    
        CRCFailed
    
    
    cfgLLData = 
      bleLLDataChannelPDUConfig with properties:
    
    
    llPayload =
    
      1x0 empty char array
    

    Input Arguments

    collapse all

    Bluetooth LE LL data channel PDU, specified as one of these values:

    • 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 total number of rows.

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

    Data Types: char | string | double

    CRC initialization value, specified as a 6-element character vector or a string scalar representing 3-octet hexadecimal value.

    Data Types: char | string

    Bluetooth LE LL data 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 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 data channel PDU decoding status, returned as a nonpositive number of type blePacketDecodeStatus. This value represents the result of a Bluetooth LE LL data channel PDU decoding. Each value of this output corresponds to a member of the blePacketDecodeStatus enumeration class, which indicates the packet decoding status as 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
    -101IncompleteLLDataChannelPDUInsufficient octets in data channel PDU
    -102InvalidLLIDInvalid LLID
    -103UnsupportedLLOpCodeUnsupported opcode
    -104InvalidLLErrorCodeInvalid error code
    -105InvalidBluetoothVersionInvalid version
    -106ExpectedNonZeroPayloadNonzero payload expected
    -107MICNotSupportedPayload contains MIC

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

    Bluetooth LE LL data channel configuration object, returned as a bleLLDataChannelPDUConfig object.

    Upper-layer payload, returned as a character array where each row is the hexadecimal representation of an octet.

    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

    Version History

    Introduced in R2019b