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.
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
.
creates a
configuration object, cfgL2CAP
= bleL2CAPFrameConfigcfgL2CAP
, for a BLE L2CAP signaling command
frame or data frame with default values.
specifies properties using one or more name-value pairs. Enclose each property name in
quotes. For example, cfgL2CAP
= bleL2CAPFrameConfig(Name,Value
)bleL2CAPFrameConfig('CommandType','Command
reject')
configures cfgL2CAP
with the type of signaling
command frame as 'Command reject'
.
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].
ChannelIdentifier
— Identifier for logical channel endpoint'0005'
(default) | four-element character vector | string scalar denoting a two-octet hexadecimal valueIdentifier 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
CommandType
— Signaling command type'Credit Based Connection request'
(default) | 'Command reject'
| 'Disconnection request'
| ...
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
SignalIdentifier
— Identifier for request-response frame exchange'01'
(default) | two-element character vector | string scalar denoting one-octet hexadecimal valueIdentifier 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
CommandRejectReason
— Reason for rejecting received signaling command frame'Command not understood'
(default) | 'Signaling MTU exceeded'
| 'Invalid CID in request'
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
SourceChannelIdentifier
— Source logical channel endpoint'0040'
(default) | four-element character vector | string scalar denoting two-octet hexadecimal valueSource 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
DestinationChannelIdentifier
— Destination logical channel endpoint'0040'
(default) | four-element character vector | string scalar denoting two-octet hexadecimal valueDestination 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
ConnectionIntervalRange
— Connection interval range[6,3200]
(default) | two-element numeric vector specified as [MIN,
MAX]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
ConnectionTimeout
— Connection supervision timeout10 (100 ms)
(default) | integer in the range [Mct, 3200]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
SlaveLatency
— Number of link layer connection events a slave can ignore0
(default) | integer in the range [0, Msl]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
ParameterUpdateResult
— Result of connection parameters update'Accepted'
(default) | 'Rejected'
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
LEPSM
— LE protocol or service multiplexer'001F'
(default) | four-element character vector | string scalar denoting two-octet hexadecimal valueLE 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
MaxTransmissionUnit
— Maximum service data unit (SDU) size23
(default) | integer in the range of [23, 65,535]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
MaxPDUPayloadSize
— Maximum protocol data unit (PDU) payload size23
(default) | integer in the range of [23, 65,535]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
Credits
— Number of LE-frames peer device can send or receive1
(default) | integer in the range of [0, 65,535]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
ConnectionResult
— Result of credit-based connection procedure'Successful'
(default) | 'LEPSM not supported'
| 'No resources available'
| ...
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
bleL2CAPFrame | Generate BLE L2CAP frame |
bleL2CAPFrameDecode | Decode BLE L2CAP frame |
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'
[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/.
You have a modified version of this example. Do you want to open this example with your edits?