Main Content

bleLLAdvertisingChannelPDUDecode

Decode BLE LL advertising channel PDU

Download Required: To use bleLLAdvertisingChannelPDUDecode, 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.

Description

example

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

example

[status,cfgLLAdv] = bleLLAdvertisingChannelPDUDecode(pdu,Name,Value) sets properties using one or more name-value pairs. Enclose each property name in quotes. For example, 'InputFormat','octets' specifies the input BLE LL advertising channel PDU in the form of octets.

Examples

collapse all

Create a BLE LL advertising channel PDU configuration object, 'cfgLLAdv', with default settings and view the corresponding applicable properties.

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.

pdu = bleLLAdvertisingChannelPDU(cfgLLAdv);

Decode the generated BLE LL advertising channel PDU. The returned status indicates decoding is successful. View the output of 'status'and 'cfgLLAdv'.

[status, cfgLLAdv] = bleLLAdvertisingChannelPDUDecode(pdu)
status = 
Success
cfgLLAdv = 
  bleLLAdvertisingChannelPDUConfig with properties:

                  PDUType: 'Advertising indication'
         ChannelSelection: 'Algorithm1'
    AdvertiserAddressType: 'Random'
        AdvertiserAddress: '0123456789AB'
          AdvertisingData: [3x2 char]

Specify a sample BLE LL advertising channel PDU in octets.

pdu = 'C409AB8967452301020106A8F1DF'; % Sample PDU in octets

Decode the specified BLE LL advertising channel PDU by specifying 'InputFormat' to 'octets'. The returned status indicates decoding is successful. View the output of 'status' and 'cfgLLData'.

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

                  PDUType: 'Scan response'
         ChannelSelection: 'Algorithm1'
    AdvertiserAddressType: 'Random'
        AdvertiserAddress: '0123456789AB'
         ScanResponseData: [3x2 char]

Specify a BLE LL advertising channel PDU containing corrupted data values.

pdu = 'D409AB89674523010201'; % Sample corrupted PDU

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

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

Input Arguments

collapse all

BLE 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.

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

Data Types: char | double | string

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is 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 Name1,Value1,...,NameN,ValueN.

Example: [status,cfgLLAdv] = bleLLAdvertisingChannelPDUDecode('pdu','InputFormat','octets')

BLE LL advertising channel PDU format, specified as 'bits' or'octets'. When specified as 'bits', the InputFormat is a binary vector. When specified as 'octets', InputFormat 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

Output Arguments

collapse all

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

Enumeration ValueMember of Enumeration ClassDecoding Status
0SuccessPacket decoding succeeded
-1 CRCFailedLink Layer PDU is corrupted
–2LLPDULengthMismatchLength field does not match with actual PDU length
–3InvalidLLSlaveLatencyInvalid slave 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 means that the BLE LL advertising channel PDU decoding failed. If the decoding fails, object cfgLLAdv displays no output.

BLE LL advertising channel configuration object, returned as a bleLLAdvertisingChannelPDUConfig object. This value represents the decoded BLE LL advertising channel PDU configuration.

References

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

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

Extended Capabilities

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

Introduced in R2019b