bleL2CAPFrameConfig

Configuration object for BLE L2CAP frame

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

The bleL2CAPFrameConfig creates a configuration object for Bluetooth low energy (BLE) logical link control and adaptation protocol (L2CAP) signaling frame or data frame using the default and specified values. You can configure a BLE L2CAP signaling frame or data frame using the applicable properties of bleL2CAPFrameConfig.

Creation

Description

example

cfgL2CAP = bleL2CAPFrameConfig creates a configuration object, cfgL2CAP, for a BLE L2CAP signaling command frame or data frame with default values.

example

cfgL2CAP = bleL2CAPFrameConfig(Name,Value) specifies properties using one or more name-value pairs. Enclose each property name in quotes. For example, bleL2CAPFrameConfig('CommandType','Command reject') configures cfgL2CAP with the type of signaling command frame as 'Command reject'.

Properties

expand all

Note

For more information about BLE L2CAP frame properties and their respective values, see volume 3, part A, section 3 of the Bluetooth Core Specification [2].

Identifier for a logical channel endpoint, specified as a four-element character vector or a string scalar denoting a two-octet hexadecimal value. The 'ChannelIdentifier' denotes the local name representing a logical channel endpoint. This property is used to identify the command and data frames. Command frames use '0005' as the 'ChannelIdentifier'. L2CAP B-frames use fixed 'ChannelIdentifier', '0004' for attribute protocol (ATT) and '0006' for security manager protocol (SMP).

Data Types: char | string

Signaling command type, specified as a character vector or a string scalar. You can specify CommandType as one of these values:

  • 'Command reject'

  • 'Disconnection request'

  • 'Disconnection response'

  • 'Connection Parameter Update request'

  • 'Connection Parameter Update response'

  • 'Credit Based Connection request'

  • 'Credit Based Connection response'

  • 'Flow Control Credit'

This property is applicable only when the value of ChannelIdentifier is set to '0005' (signaling channel identifier).

Data Types: char | string

Identifier for a request-response frame exchange, specified as a two-element character vector or string scalar denoting a one-octet hexadecimal value. The requesting device sets the value of this property and the responding device uses the same value in its response. The value of this property cannot be set to '00'.

Data Types: char | string

Reason for rejecting the received signaling command frame, specified as a character vector or a string scalar. You can specify CommandRejectReason as one of these values:

  • 'Command not understood'

  • 'Signaling MTU exceeded'

  • 'Invalid CID in request'

This property specifies the reason for rejecting a signaling command frame.

Data Types: char | string

Source logical channel endpoint, specified as a four-element character vector or string scalar denoting a two-octet hexadecimal value. This property specifies the source channel endpoint from which the request is sent or a response is received. When the channel is created using credit-based connection procedure, data packets flowing to the sender of the request are sent to the SourceChannelIdentifier.

Data Types: char | string

Destination logical channel endpoint, specified as a four-element character vector or string scalar denoting a two-octet hexadecimal value. This property specifies the destination channel endpoint from which the request is sent or a response is received. When the channel is created using credit-based connection procedure, data packets flowing to the destination of the request are sent to the DestinationChannelIdentifier.

Data Types: char | string

Connection interval range, specified as a two-element numeric vector in the form of [MIN, MAX]. MIN and MAX specify the minimum and the maximum value of the ConnectionIntervalRange respectively. You can specify the value of MIN and MAX in the range [6, 3200]. MIN must be less than or equal to MAX. Each unit for MIN or MAX is taken as 1.25 ms so the resultant value is in the range [7.5 ms, 4.0 s].

Data Types: double

Connection supervision timeout, specified as an integer in the range [Mct, 3200], where Mct is the larger of 10 and ((1+SlaveLatency)×(ConnectionInterval×1.25)×2)/10. This property indicates the timeout for a connection if no valid packet is received within this time. Each unit is taken as 10 ms so that the resultant connection timeout, (ConnectionInterval×10), is in the range [100 ms, 32.0s].

Data Types: double

Number of link layer connection events a slave can ignore, specified as an integer in the range [0, Msl], where Msl is the lesser of 499 and ((ConnectionTimeout×10)/((ConnectionInterval×1.25)×2))-1. This property indicates the number of connection events that a slave can ignore.

Data Types: double

Result of the connection parameters update, specified as 'Accepted' or 'Rejected'. This property indicates the response to the 'Connection Parameter Update Request' value of the property CommandType and specifies the result after updating the connection parameters.

Data Types: char | string

LE protocol or service multiplexer, specified as a four-element character vector or a string scalar denoting a two-octet hexadecimal value. The value of this property is a unique number specified by the Special Interest Group (SIG) for each protocol. The SIG assigns the value of this property within the range [0x0001, 0x007F] for a set of existing protocols. The SIG dynamically assigns the value of this property in the range [0x0080, 0x00FF] to the implemented protocols.

Data Types: char | string

Maximum service data unit (SDU) size, specified as an integer in the range of [23, 65,535] octets. This property specifies the maximum acceptable SDU size for the upper-layer entity.

Data Types: double

Maximum protocol data unit (PDU) payload size, specified as an integer in the range of [23, 65,535] octets. This property specifies the maximum acceptable payload data for the L2CAP layer entity.

Data Types: double

Number of LE-frames peer device can send or receive, specified as an integer in the range of [0, 65,535] octets. This property indicates the number of LE-frames that the peer device can send or receive. If the value of CommandType property is set to 'Flow control credit', then this property cannot be set to 0.

Data Types: double

Result of the credit-based connection procedure, specified as a character vector or a string scalar. You can specify ConnectionResult as one of these values:

  • 'Successful'

  • 'LEPSM not supported'

  • 'No resources available'

  • 'Insufficient authentication'

  • 'Insufficient authorization'

  • 'Insufficient encryption key size'

  • 'Insufficient encryption'

  • 'Invalid Source CID'

  • 'Source CID already allocated'

  • 'Unacceptable parameters'

This property indicates the outcome of the connection request.

Data Types: char | string

Object Functions

expand all

bleL2CAPFrameGenerate BLE L2CAP frame
bleL2CAPFrameDecodeDecode BLE L2CAP frame

Examples

collapse all

Create a BLE L2CAP frame configuration object, 'cfgL2CAP', using default properties. View the corresponding applicable properties. This configuration object generates a BLE L2CAP signaling frame of type 'Credit based connection request'.

cfgL2CAP = bleL2CAPFrameConfig
cfgL2CAP = 
  bleL2CAPFrameConfig with properties:

          ChannelIdentifier: '0005'
                CommandType: 'Credit based connection request'
           SignalIdentifier: '01'
    SourceChannelIdentifier: '0040'
                      LEPSM: '001F'
        MaxTransmissionUnit: 23
          MaxPDUPayloadSize: 23
                    Credits: 1

Set the value of credits to 10. View the corresponding properties of 'cfgL2CAP'.

cfgL2CAP.Credits            = 10
cfgL2CAP = 
  bleL2CAPFrameConfig with properties:

          ChannelIdentifier: '0005'
                CommandType: 'Credit based connection request'
           SignalIdentifier: '01'
    SourceChannelIdentifier: '0040'
                      LEPSM: '001F'
        MaxTransmissionUnit: 23
          MaxPDUPayloadSize: 23
                    Credits: 10

Create a BLE L2CAP frame configuration object, 'cfgL2CAP', by setting the value of channel identifier as '0004'using name-value pairs. View the corresponding applicable properties. This configuration object generates a BLE L2CAP data frame (B-frame).

cfgL2CAP = bleL2CAPFrameConfig('ChannelIdentifier','0004')
cfgL2CAP = 
  bleL2CAPFrameConfig with properties:

    ChannelIdentifier: '0004'

Create a BLE L2CAP configuration object, 'bleL2CAPFrameConfig', to generate a BLE L2CAP data frame (B-frame). Set the value of channel identifier as'0004' and view the corresponding applicable properties.

cfgTx = bleL2CAPFrameConfig('ChannelIdentifier','0004')
cfgTx = 
  bleL2CAPFrameConfig with properties:

    ChannelIdentifier: '0004'

Generate a BLE L2CAP data frame (B-frame) with service data unit (SDU) from ATT specified as '0A0100'.

l2capFrame = bleL2CAPFrame(cfgTx,"0A0100")
l2capFrame = 7x2 char array
    '03'
    '00'
    '04'
    '00'
    '0A'
    '01'
    '00'

Decode the generated BLE L2CAP data frame (B-frame). The returned status indicates decoding was successful. View the output of 'status', 'cfgRx' and 'SDU'.

[status, cfgRx, SDU] = bleL2CAPFrameDecode(l2capFrame)
status = 
Success
cfgRx = 
  bleL2CAPFrameConfig with properties:

    ChannelIdentifier: '0004'

SDU = 3x2 char array
    '0A'
    '01'
    '00'

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