Main Content

bleL2CAPFrameConfig

Bluetooth LE L2CAP frame configuration parameters

    Description

    The bleL2CAPFrameConfig parameterizes the bleL2CAPFrame function to generate a Bluetooth® low energy (LE) logical link control and adaptation protocol (L2CAP) signaling frame or data frame.

    Creation

    Description

    cfgL2CAP = bleL2CAPFrameConfig creates a default configuration object, cfgL2CAP, for a Bluetooth LE L2CAP signaling command frame or data frame.

    example

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

    example

    Properties

    expand all

    Note

    For more information about the Bluetooth LE 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 4-element character vector or a string scalar denoting a 2-octet hexadecimal value. This property specifies the local name representing a logical channel endpoint. Use this value to identify the command and data frames. The command frames use '0005' as the 'ChannelIdentifier'. The 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. Specify this property 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'

    Dependencies

    To enable this property, set the ChannelIdentifier property to '0005'.

    Data Types: char | string

    Identifier for a request-response frame exchange, specified as a 2-element character vector or string scalar denoting a 1-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. Specify this property 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 4-element character vector or string scalar denoting a 2-octet hexadecimal value. This property specifies the source channel endpoint from which the object send or receives request. When the channel is created using the credit-based connection procedure, the object sends the data packets flowing to the sender of the request to this value.

    Data Types: char | string

    Destination logical channel endpoint, specified as a 4-element character vector or string scalar denoting a 2-octet hexadecimal value. This property specifies the destination channel endpoint from which the object send or receives request. When the channel is created using the credit-based connection procedure, the object sends the data packets flowing to the destination of the request to this value.

    Data Types: char | string

    Connection interval range, specified as a 2-element numeric vector in the form of [MIN, MAX]. MIN and MAX specify the minimum and the maximum value of this property, respectively. Specify MIN and MAX values 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+PeripheralLatency)×(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 Peripheral 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.

    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 CommandType property and specifies the result after updating the connection parameters.

    Data Types: char | string

    LE protocol or service multiplexer, specified as a 4-element character vector or a string scalar denoting a 2-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 the 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. Specify this property 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

    Examples

    collapse all

    Create a default Bluetooth LE L2CAP frame configuration object.

    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.

    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 Bluetooth LE L2CAP frame configuration object, 'cfgL2CAP', by setting the value of channel identifier as '0004'using name-value pairs. This configuration object sets properties to generate a Bluetooth LE L2CAP data frame (B-frame).

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

    Create a Bluetooth LE L2CAP configuration object to generate a L2CAP data frame (B-frame). Set the value of channel identifier as'0004'.

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

    Generate a Bluetooth LE L2CAP data frame (B-frame), specifying the service data unit (SDU) from ATT as '0A0100'.

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

    Decode the generated Bluetooth LE L2CAP data frame (B-frame). The returned status indicates decoding was successful.

    [status,cfgL2CAPRx,SDU] = bleL2CAPFrameDecode(l2capFrame)
    status = 
      blePacketDecodeStatus enumeration
    
        Success
    
    
    cfgL2CAPRx = 
      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, 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