Modules#

sl_bt_evt_l2cap_le_channel_open_request

sl_bt_evt_l2cap_le_channel_open_response

sl_bt_evt_l2cap_channel_data

sl_bt_evt_l2cap_channel_credit

sl_bt_evt_l2cap_channel_closed

sl_bt_evt_l2cap_command_rejected

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.

Enumerations#

enum
sl_bt_l2cap_connection_result_successful = 0x0
sl_bt_l2cap_connection_result_spsm_not_supported = 0x2
sl_bt_l2cap_connection_result_no_resources_available = 0x4
sl_bt_l2cap_connection_result_insufficient_authentication = 0x5
sl_bt_l2cap_connection_result_insufficient_authorization = 0x6
sl_bt_l2cap_connection_result_encryption_key_size_too_short = 0x7
sl_bt_l2cap_connection_result_insufficient_encryption = 0x8
sl_bt_l2cap_connection_result_invalid_source_cid = 0x9
sl_bt_l2cap_connection_result_source_cid_already_allocated = 0xa
sl_bt_l2cap_connection_result_unacceptable_parameters = 0xb
}

Defines possible result values in the responses to credit based channel connection requests.

enum
sl_bt_l2cap_command_not_understood = 0x0
sl_bt_l2cap_signaling_mtu_exceeded = 0x1
sl_bt_l2cap_invalid_cid_request = 0x2
}

Describes why a request command was rejected.

enum
sl_bt_l2cap_disconnection_request = 0x6
sl_bt_l2cap_le_connection_request = 0x14
sl_bt_l2cap_flow_control_credit = 0x16
}

Describes which of the request commands has been rejected.

Functions#

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)
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)
sl_status_t
sl_bt_l2cap_channel_send_data(uint8_t connection, uint16_t cid, size_t data_len, const uint8_t *data)
sl_status_t
sl_bt_l2cap_channel_send_credit(uint8_t connection, uint16_t cid, uint16_t credit)
sl_status_t
sl_bt_l2cap_close_channel(uint8_t connection, uint16_t cid)

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
sl_bt_l2cap_connection_result_spsm_not_supported
sl_bt_l2cap_connection_result_no_resources_available
sl_bt_l2cap_connection_result_insufficient_authentication
sl_bt_l2cap_connection_result_insufficient_authorization
sl_bt_l2cap_connection_result_encryption_key_size_too_short
sl_bt_l2cap_connection_result_insufficient_encryption
sl_bt_l2cap_connection_result_invalid_source_cid
sl_bt_l2cap_connection_result_source_cid_already_allocated
sl_bt_l2cap_connection_result_unacceptable_parameters

Definition at line 13164 of file /mnt/raid/workspaces/ws.vHmYkJajL/overlay/gsdk/protocol/bluetooth/build_debug/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
sl_bt_l2cap_signaling_mtu_exceeded
sl_bt_l2cap_invalid_cid_request

Definition at line 13235 of file /mnt/raid/workspaces/ws.vHmYkJajL/overlay/gsdk/protocol/bluetooth/build_debug/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
sl_bt_l2cap_le_connection_request
sl_bt_l2cap_flow_control_credit

Definition at line 13248 of file /mnt/raid/workspaces/ws.vHmYkJajL/overlay/gsdk/protocol/bluetooth/build_debug/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)
Parameters
[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 will be received after the peer device responded to the request.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.

Events


Definition at line 13484 of file /mnt/raid/workspaces/ws.vHmYkJajL/overlay/gsdk/protocol/bluetooth/build_debug/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)
Parameters
[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. Other parameters in this command are ignored if errorcode indicates that the request was rejected.

Returns

  • SL_STATUS_OK if successful. Error code otherwise.


Definition at line 13523 of file /mnt/raid/workspaces/ws.vHmYkJajL/overlay/gsdk/protocol/bluetooth/build_debug/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)
Parameters
[in]connection

The connection handle

[in]cid

The channel identifier

[in]data_len

Length of data in data

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


Definition at line 13553 of file /mnt/raid/workspaces/ws.vHmYkJajL/overlay/gsdk/protocol/bluetooth/build_debug/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)
Parameters
[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.


Definition at line 13575 of file /mnt/raid/workspaces/ws.vHmYkJajL/overlay/gsdk/protocol/bluetooth/build_debug/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)
Parameters
[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


Definition at line 13593 of file /mnt/raid/workspaces/ws.vHmYkJajL/overlay/gsdk/protocol/bluetooth/build_debug/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_id
Value:
0x01430020

Definition at line 13149 of file /mnt/raid/workspaces/ws.vHmYkJajL/overlay/gsdk/protocol/bluetooth/build_debug/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_id
Value:
0x02430020

Definition at line 13150 of file /mnt/raid/workspaces/ws.vHmYkJajL/overlay/gsdk/protocol/bluetooth/build_debug/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_id
Value:
0x03430020

Definition at line 13151 of file /mnt/raid/workspaces/ws.vHmYkJajL/overlay/gsdk/protocol/bluetooth/build_debug/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_id
Value:
0x04430020

Definition at line 13152 of file /mnt/raid/workspaces/ws.vHmYkJajL/overlay/gsdk/protocol/bluetooth/build_debug/bt_api/sw/bgapi/inc/sl_bt_api.h

sl_bt_cmd_l2cap_close_channel_id#

#define sl_bt_cmd_l2cap_close_channel_id
Value:
0x05430020

Definition at line 13153 of file /mnt/raid/workspaces/ws.vHmYkJajL/overlay/gsdk/protocol/bluetooth/build_debug/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_id
Value:
0x01430020

Definition at line 13154 of file /mnt/raid/workspaces/ws.vHmYkJajL/overlay/gsdk/protocol/bluetooth/build_debug/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_id
Value:
0x02430020

Definition at line 13155 of file /mnt/raid/workspaces/ws.vHmYkJajL/overlay/gsdk/protocol/bluetooth/build_debug/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_id
Value:
0x03430020

Definition at line 13156 of file /mnt/raid/workspaces/ws.vHmYkJajL/overlay/gsdk/protocol/bluetooth/build_debug/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_id
Value:
0x04430020

Definition at line 13157 of file /mnt/raid/workspaces/ws.vHmYkJajL/overlay/gsdk/protocol/bluetooth/build_debug/bt_api/sw/bgapi/inc/sl_bt_api.h

sl_bt_rsp_l2cap_close_channel_id#

#define sl_bt_rsp_l2cap_close_channel_id
Value:
0x05430020

Definition at line 13158 of file /mnt/raid/workspaces/ws.vHmYkJajL/overlay/gsdk/protocol/bluetooth/build_debug/bt_api/sw/bgapi/inc/sl_bt_api.h