L2CAP Connection Oriented Channels#
L2CAP Connection Oriented Channels.
The commands and events in this class provide Logical Link Control and Adaptation Protocol (L2CAP) credit-based logical channels.
An L2CAP credit-based logical channel is a logical link identified by a channel identifier (the cid
parameter in the commands and events of this API class). These channels use a credit-based flow control mechanism. The credit can be configured at the channel opening and later dynamically updated on the channel.
The Simplified Protocol/Service Multiplexer (SPSM) of a channel specifies the protocol or services the channel implements. It can be a value for a fixed service assigned by the Bluetooth SIG or a dynamically-allocated value and used with services defined in the GATT Server. The dynamically-assigned value may be used to support multiple implementations of a particular protocol. See the Bluetooth core specification for more details. The application specifies the SPSM value in a channel open request in the spsm
parameter of the sl_bt_l2cap_open_le_channel command.
Each of the local and peer channel endpoints must specify the maximum Service Data Unit (SDU) size (the 'MTU' field of the L2CAP packets in the Bluetooth Core specification) that it can receive on the channel. The application specifies the maximum Service Data Unit size (the max_sdu
parameter in commands and events) of the local channel endpoint.
Each channel endpoint has a maximum PDU payload Size that the L2CAP layer can receive in a single data packet on the channel. The maximum PDU payload size supported by the stack for local channel endpoints is 252 bytes, which is the maximum data length the sl_bt_evt_l2cap_channel_data event can support. The application specifies the max PDU payload size (the max_pdu
parameter in commands and events). Additionally, the application is responsible for handling the segmentation from SDU to PDU and reassembly from PDU to SDU.
Modules#
sl_bt_evt_l2cap_le_channel_open_request
sl_bt_evt_l2cap_le_channel_open_response
sl_bt_evt_l2cap_channel_credit
sl_bt_evt_l2cap_channel_closed
sl_bt_evt_l2cap_command_rejected
Enumerations#
Defines possible result values in the responses to credit based channel connection requests.
Describes why a request command was rejected.
Describes which of the request commands has been rejected.
Functions#
Macros#
Enumeration Documentation#
sl_bt_l2cap_connection_result_t#
sl_bt_l2cap_connection_result_t
Defines possible result values in the responses to credit based channel connection requests.
Enumerator | |
---|---|
sl_bt_l2cap_connection_result_successful | (0x0) Connection successful |
sl_bt_l2cap_connection_result_spsm_not_supported | (0x2) Connection refused - SPSM not supported |
sl_bt_l2cap_connection_result_no_resources_available | (0x4) Connection refused - no resources available |
sl_bt_l2cap_connection_result_insufficient_authentication | (0x5) Connection refused - insufficient authentication |
sl_bt_l2cap_connection_result_insufficient_authorization | (0x6) Connection refused - insufficient authorization |
sl_bt_l2cap_connection_result_encryption_key_size_too_short | (0x7) Connection refused - encryption key size too short |
sl_bt_l2cap_connection_result_insufficient_encryption | (0x8) Connection refused - insufficient encryption |
sl_bt_l2cap_connection_result_invalid_source_cid | (0x9) Connection refused - invalid Source CID |
sl_bt_l2cap_connection_result_source_cid_already_allocated | (0xa) Connection refused - Source CID already allocated |
sl_bt_l2cap_connection_result_unacceptable_parameters | (0xb) Connection refused - unacceptable parameters |
13741
of file /mnt/raid/workspaces/ws.pY3F1RWXq/overlay/gsdk/protocol/bluetooth/build_release/bt_api/sw/bgapi/inc/sl_bt_api.h
sl_bt_l2cap_command_reject_reason_t#
sl_bt_l2cap_command_reject_reason_t
Describes why a request command was rejected.
Enumerator | |
---|---|
sl_bt_l2cap_command_not_understood | (0x0) Command not understood e.g., unknown command code |
sl_bt_l2cap_signaling_mtu_exceeded | (0x1) Command size has exceeded the signaling MTU size |
sl_bt_l2cap_invalid_cid_request | (0x2) An invalid CID is included in the command |
13812
of file /mnt/raid/workspaces/ws.pY3F1RWXq/overlay/gsdk/protocol/bluetooth/build_release/bt_api/sw/bgapi/inc/sl_bt_api.h
sl_bt_l2cap_command_code_t#
sl_bt_l2cap_command_code_t
Describes which of the request commands has been rejected.
Enumerator | |
---|---|
sl_bt_l2cap_disconnection_request | (0x6) A disconnection request |
sl_bt_l2cap_le_connection_request | (0x14) An LE credit-based connection request |
sl_bt_l2cap_flow_control_credit | (0x16) A Flow Control Credit packet |
13825
of file /mnt/raid/workspaces/ws.pY3F1RWXq/overlay/gsdk/protocol/bluetooth/build_release/bt_api/sw/bgapi/inc/sl_bt_api.h
Function Documentation#
sl_bt_l2cap_open_le_channel#
sl_status_t sl_bt_l2cap_open_le_channel (uint8_t connection, uint16_t spsm, uint16_t max_sdu, uint16_t max_pdu, uint16_t credit, uint16_t * cid)
[in] | connection | The connection handle |
[in] | spsm | The protocol/services implemented by the local channel endpoint |
[in] | max_sdu | The Maximum Service Data Unit size the local channel endpoint can accept Range: 23 to 65533. |
[in] | max_pdu | The maximum PDU payload size the local channel endpoint can accept Range: 23 to 252. |
[in] | credit | The initial credit value of the local channel endpoint, i.e., number of PDUs the peer channel endpoint can send |
[out] | cid | The channel identifier |
Create and configure an L2CAP channel on a Bluetooth connection using the LE credit based connection request packet. Event sl_bt_evt_l2cap_le_channel_open_response or sl_bt_evt_l2cap_command_rejected will be received after the peer device responded to the request.
Returns
SL_STATUS_OK if successful. Error code otherwise.
Events
sl_bt_evt_l2cap_command_rejected - Triggered when the peer device rejected the connection request. Typically a legacy peer device that does not support the feature could send this response. When this event is received under the context of opening a channel using this command, the stack automatically closes the local channel and the user application should clean up the resources associated to the channel identifier.
sl_bt_evt_l2cap_le_channel_open_response - Triggered when an LE credit-based connection response has been received in response to this command. If the result code in
errorcode
of the event is not equal to sl_bt_l2cap_connection_result_successful, it means that connection request was rejected by the peer device. In this case, the stack automatically closes the local channel and the user application should clean up the resources associated to the channel identifier.sl_bt_evt_l2cap_channel_closed - Triggered when an LE credit-based connection response has not been received within 30 seconds after this command has been issued.
14077
of file /mnt/raid/workspaces/ws.pY3F1RWXq/overlay/gsdk/protocol/bluetooth/build_release/bt_api/sw/bgapi/inc/sl_bt_api.h
sl_bt_l2cap_send_le_channel_open_response#
sl_status_t sl_bt_l2cap_send_le_channel_open_response (uint8_t connection, uint16_t cid, uint16_t max_sdu, uint16_t max_pdu, uint16_t credit, uint16_t errorcode)
[in] | connection | The connection handle |
[in] | cid | The channel identifier |
[in] | max_sdu | The Maximum Service Data Unit size the local channel endpoint can accept Range: 23 to 65533. |
[in] | max_pdu | The maximum PDU payload size the local channel endpoint can accept Range:23 to 252. |
[in] | credit | The initial credit value of the local channel endpoint, i.e., number of PDUs that the peer channel endpoint can send |
[in] | errorcode | Enum sl_bt_l2cap_connection_result_t. An L2CAP error code as the outcome of the connection request |
Send an LE credit-based connection response to an LE credit-based connection request received in the sl_bt_evt_l2cap_le_channel_open_request event. Result code sl_bt_l2cap_connection_result_successful in errorcode
implies that the logical channel is established and data can be sent or received on the channel.
To reject the connection request, use a result code other than sl_bt_l2cap_connection_result_successful in errorcode
. Other parameters in this command are ignored in this case. The stack automatically closes the local channel and the user application should clean up the resources associated to the channel identifier.
Returns
SL_STATUS_OK if successful. Error code otherwise.
14118
of file /mnt/raid/workspaces/ws.pY3F1RWXq/overlay/gsdk/protocol/bluetooth/build_release/bt_api/sw/bgapi/inc/sl_bt_api.h
sl_bt_l2cap_channel_send_data#
sl_status_t sl_bt_l2cap_channel_send_data (uint8_t connection, uint16_t cid, size_t data_len, const uint8_t * data)
[in] | connection | The connection handle |
[in] | cid | The channel identifier |
[in] | data_len | Length of data in |
[in] | data | Data to be sent. The data length must not be greater than the lesser of the peer channel endpoint max_pdu and 252 bytes, which is the maximum data length this command can send. |
Send data to the peer channel endpoint on a Bluetooth connection. If the SDU length is larger than max_pdu size or 250 bytes, the application should fragment the SDU into multiple K-frames and call this command once for each K-frame.
The first K-frame of the SDU should start with 2 bytes of SDU length followed with payload. Therefore, the first K-frame contains PDU length minus 2 bytes of the actual payload. All subsequent K-frames of the same SDU contain PDU length of the payload. The sum of the payload lengths for K-frames should be equal to the specified SDU length.
Returns
SL_STATUS_OK if successful. Error code otherwise.
14148
of file /mnt/raid/workspaces/ws.pY3F1RWXq/overlay/gsdk/protocol/bluetooth/build_release/bt_api/sw/bgapi/inc/sl_bt_api.h
sl_bt_l2cap_channel_send_credit#
sl_status_t sl_bt_l2cap_channel_send_credit (uint8_t connection, uint16_t cid, uint16_t credit)
[in] | connection | The connection handle |
[in] | cid | The channel identifier |
[in] | credit | The credit value, i.e., the additional number of PDUs the peer channel endpoint can send Range: 1 to 65535. |
Send flow control credits to the peer channel endpoint indicating that the local channel endpoint is capable of receiving more data.
Returns
SL_STATUS_OK if successful. Error code otherwise.
14170
of file /mnt/raid/workspaces/ws.pY3F1RWXq/overlay/gsdk/protocol/bluetooth/build_release/bt_api/sw/bgapi/inc/sl_bt_api.h
sl_bt_l2cap_close_channel#
sl_status_t sl_bt_l2cap_close_channel (uint8_t connection, uint16_t cid)
[in] | connection | The connection handle |
[in] | cid | The channel identifier |
Send a disconnect request to close a credit-based logical channel.
Returns
SL_STATUS_OK if successful. Error code otherwise.
Events
sl_bt_evt_l2cap_channel_closed - Triggered when an credit-based logical channel is closed in response to this command.
14188
of file /mnt/raid/workspaces/ws.pY3F1RWXq/overlay/gsdk/protocol/bluetooth/build_release/bt_api/sw/bgapi/inc/sl_bt_api.h
Macro Definition Documentation#
sl_bt_cmd_l2cap_open_le_channel_id#
#define sl_bt_cmd_l2cap_open_le_channel_idValue:
0x01430020
13726
of file /mnt/raid/workspaces/ws.pY3F1RWXq/overlay/gsdk/protocol/bluetooth/build_release/bt_api/sw/bgapi/inc/sl_bt_api.h
sl_bt_cmd_l2cap_send_le_channel_open_response_id#
#define sl_bt_cmd_l2cap_send_le_channel_open_response_idValue:
0x02430020
13727
of file /mnt/raid/workspaces/ws.pY3F1RWXq/overlay/gsdk/protocol/bluetooth/build_release/bt_api/sw/bgapi/inc/sl_bt_api.h
sl_bt_cmd_l2cap_channel_send_data_id#
#define sl_bt_cmd_l2cap_channel_send_data_idValue:
0x03430020
13728
of file /mnt/raid/workspaces/ws.pY3F1RWXq/overlay/gsdk/protocol/bluetooth/build_release/bt_api/sw/bgapi/inc/sl_bt_api.h
sl_bt_cmd_l2cap_channel_send_credit_id#
#define sl_bt_cmd_l2cap_channel_send_credit_idValue:
0x04430020
13729
of file /mnt/raid/workspaces/ws.pY3F1RWXq/overlay/gsdk/protocol/bluetooth/build_release/bt_api/sw/bgapi/inc/sl_bt_api.h
sl_bt_cmd_l2cap_close_channel_id#
#define sl_bt_cmd_l2cap_close_channel_idValue:
0x05430020
13730
of file /mnt/raid/workspaces/ws.pY3F1RWXq/overlay/gsdk/protocol/bluetooth/build_release/bt_api/sw/bgapi/inc/sl_bt_api.h
sl_bt_rsp_l2cap_open_le_channel_id#
#define sl_bt_rsp_l2cap_open_le_channel_idValue:
0x01430020
13731
of file /mnt/raid/workspaces/ws.pY3F1RWXq/overlay/gsdk/protocol/bluetooth/build_release/bt_api/sw/bgapi/inc/sl_bt_api.h
sl_bt_rsp_l2cap_send_le_channel_open_response_id#
#define sl_bt_rsp_l2cap_send_le_channel_open_response_idValue:
0x02430020
13732
of file /mnt/raid/workspaces/ws.pY3F1RWXq/overlay/gsdk/protocol/bluetooth/build_release/bt_api/sw/bgapi/inc/sl_bt_api.h
sl_bt_rsp_l2cap_channel_send_data_id#
#define sl_bt_rsp_l2cap_channel_send_data_idValue:
0x03430020
13733
of file /mnt/raid/workspaces/ws.pY3F1RWXq/overlay/gsdk/protocol/bluetooth/build_release/bt_api/sw/bgapi/inc/sl_bt_api.h
sl_bt_rsp_l2cap_channel_send_credit_id#
#define sl_bt_rsp_l2cap_channel_send_credit_idValue:
0x04430020
13734
of file /mnt/raid/workspaces/ws.pY3F1RWXq/overlay/gsdk/protocol/bluetooth/build_release/bt_api/sw/bgapi/inc/sl_bt_api.h
sl_bt_rsp_l2cap_close_channel_id#
#define sl_bt_rsp_l2cap_close_channel_idValue:
0x05430020
13735
of file /mnt/raid/workspaces/ws.pY3F1RWXq/overlay/gsdk/protocol/bluetooth/build_release/bt_api/sw/bgapi/inc/sl_bt_api.h