L2CAP transfer#

The L2CAP data channel component is used to transfer data through the link layer. The component serves as an API to access the L2CAP data transfer functionalites.

Modules#

callbacks_s

sl_bt_l2cap_transfer_transfer_s

Enumerations#

enum
SL_BT_L2CAP_TRANSFER_MODE_RECEIVE = 0
SL_BT_L2CAP_TRANSFER_MODE_TRANSMIT = 1
SL_BT_L2CAP_TRANSFER_MODE_INACTIVE = 2
}

Define sender and receiver sides.

Typedefs#

typedef uint16_t(*
sl_bt_l2cap_transfer_data_received_cb_t)(sl_bt_l2cap_transfer_transfer_handle_t transfer_object, uint32_t offset, uint16_t size, uint8_t *data)
typedef void(*
sl_bt_l2cap_transfer_transfer_finished_cb_t)(sl_bt_l2cap_transfer_transfer_handle_t transfer_object, sl_status_t error_code)
typedef void(*
sl_bt_l2cap_transfer_data_transmit_cb_t)(sl_bt_l2cap_transfer_transfer_handle_t transfer_object, uint32_t offset, uint32_t size, uint8_t **data, uint32_t *data_size)
typedef void(*
sl_bt_l2cap_transfer_channel_opened_cb_t)(sl_bt_l2cap_transfer_transfer_handle_t transfer_object)
typedef struct callbacks_s

Callback functions used by the transfer object.

Transfer structure that is used for the L2CAP data channels.

Functions#

sl_status_t
sl_bt_l2cap_transfer_start_data_transfer(sl_bt_l2cap_transfer_transfer_t *transfer, bool open_channel)
sl_status_t
sl_bt_l2cap_transfer_increase_credit(sl_bt_l2cap_transfer_transfer_t *transfer, uint16_t credit)
sl_status_t
sl_bt_l2cap_transfer_abort_transfer(sl_bt_l2cap_transfer_transfer_t *transfer)
sl_status_t
sl_bt_l2cap_transfer_check_progress(sl_bt_l2cap_transfer_transfer_t *transfer)
sl_status_t
sl_bt_l2cap_transfer_open_prior_channel(sl_bt_l2cap_transfer_transfer_t *transfer)

Enumeration Documentation#

sl_bt_l2cap_transfer_transfer_mode_t#

sl_bt_l2cap_transfer_transfer_mode_t

Define sender and receiver sides.

Enumerator
SL_BT_L2CAP_TRANSFER_MODE_RECEIVE

Transfer side is responding to data receive events.

SL_BT_L2CAP_TRANSFER_MODE_TRANSMIT

Transfer side is initiating data transfer.

SL_BT_L2CAP_TRANSFER_MODE_INACTIVE

Transfer side is inactive - closing.


Definition at line 63 of file common/l2cap_transfer/inc/sl_bt_l2cap_transfer.h

Typedef Documentation#

sl_bt_l2cap_transfer_transfer_handle_t#

typedef struct sl_bt_l2cap_transfer_transfer_s* sl_bt_l2cap_transfer_transfer_handle_t

Forward declaration.


Definition at line 70 of file common/l2cap_transfer/inc/sl_bt_l2cap_transfer.h

sl_bt_l2cap_transfer_data_received_cb_t#

typedef uint16_t(* sl_bt_l2cap_transfer_data_received_cb_t) (sl_bt_l2cap_transfer_transfer_handle_t transfer_object, uint32_t offset, uint16_t size, uint8_t *data) )(sl_bt_l2cap_transfer_transfer_handle_t transfer_object, uint32_t offset, uint16_t size, uint8_t *data)
Parameters
[in]transfer_object

Active transfer

[in]offset

Current data offset

[in]size

Size of the incoming data

[in]data

Incoming data

Callback is invoked when data on L2CAP channel is received.

Returns

  • credit Requested credit that should be sent to the other side


Definition at line 85 of file common/l2cap_transfer/inc/sl_bt_l2cap_transfer.h

sl_bt_l2cap_transfer_transfer_finished_cb_t#

typedef void(* sl_bt_l2cap_transfer_transfer_finished_cb_t) (sl_bt_l2cap_transfer_transfer_handle_t transfer_object, sl_status_t error_code) )(sl_bt_l2cap_transfer_transfer_handle_t transfer_object, sl_status_t error_code)
Parameters
[in]transfer_object

Active transfer

[in]error_code

SL_STATUS type error code

Callback is invoked when data transfer on L2CAP channel is finished.


Definition at line 96 of file common/l2cap_transfer/inc/sl_bt_l2cap_transfer.h

sl_bt_l2cap_transfer_data_transmit_cb_t#

typedef void(* sl_bt_l2cap_transfer_data_transmit_cb_t) (sl_bt_l2cap_transfer_transfer_handle_t transfer_object, uint32_t offset, uint32_t size, uint8_t **data, uint32_t *data_size) )(sl_bt_l2cap_transfer_transfer_handle_t transfer_object, uint32_t offset, uint32_t size, uint8_t **data, uint32_t *data_size)
Parameters
[in]transfer_object

Active transfer

[in]offset

Current offset of requested data

[in]size

Maximum size of requested data

[out]data

Pointer of pointer to data

[out]data_size

Size of the provided data

Callback for data transmission on L2CAP channel. Called when data is about to transmit on the channel to provide the next data packet.


Definition at line 109 of file common/l2cap_transfer/inc/sl_bt_l2cap_transfer.h

sl_bt_l2cap_transfer_channel_opened_cb_t#

typedef void(* sl_bt_l2cap_transfer_channel_opened_cb_t) (sl_bt_l2cap_transfer_transfer_handle_t transfer_object) )(sl_bt_l2cap_transfer_transfer_handle_t transfer_object)
Parameters
[in]transfer_object

Active transfer

Callback is invoked when a channel is opened.


Definition at line 120 of file common/l2cap_transfer/inc/sl_bt_l2cap_transfer.h

sl_bt_l2cap_transfer_callbacks_t#

typedef struct callbacks_s sl_bt_l2cap_transfer_callbacks_t

Callback functions used by the transfer object.


Definition at line 128 of file common/l2cap_transfer/inc/sl_bt_l2cap_transfer.h

sl_bt_l2cap_transfer_transfer_t#

typedef struct sl_bt_l2cap_transfer_transfer_s sl_bt_l2cap_transfer_transfer_t

Transfer structure that is used for the L2CAP data channels.


Definition at line 147 of file common/l2cap_transfer/inc/sl_bt_l2cap_transfer.h

Function Documentation#

sl_bt_l2cap_transfer_start_data_transfer#

sl_status_t sl_bt_l2cap_transfer_start_data_transfer (sl_bt_l2cap_transfer_transfer_t * transfer, bool open_channel)
Parameters
[in]transfer

Active transfer object. Mandatory settings are:

  • callbacks

  • connection,

  • max_pdu,

  • max_sdu,

  • data,

  • data_length,

  • mode

  • spsm

[in]open_channel

If true - this transfer will initiate the L2CAP channel opening

Start data transfer process. Both sides should call this function and decide which side will send the open request.

It is important that the transfer object shall be well configured to create a valid open request.


Definition at line 197 of file common/l2cap_transfer/inc/sl_bt_l2cap_transfer.h

sl_bt_l2cap_transfer_increase_credit#

sl_status_t sl_bt_l2cap_transfer_increase_credit (sl_bt_l2cap_transfer_transfer_t * transfer, uint16_t credit)
Parameters
[in]transfer

Targeted transfer object - name of the transfer

[in]credit

The credit value, i.e., the additional number of PDUs the peer channel endpoint can send. Range: 1 to 65535.

API call to send credit to the initiator.

Returns

  • SL_STATUS_OK if successful. Error code otherwise


Definition at line 209 of file common/l2cap_transfer/inc/sl_bt_l2cap_transfer.h

sl_bt_l2cap_transfer_abort_transfer#

sl_status_t sl_bt_l2cap_transfer_abort_transfer (sl_bt_l2cap_transfer_transfer_t * transfer)
Parameters
[in]transfer

Targeted transfer object - name of the transfer

API call to abort L2CAP data transfer - will invoke a close channel event

Returns

  • SL_STATUS_OK if successful. Error code otherwise


Definition at line 219 of file common/l2cap_transfer/inc/sl_bt_l2cap_transfer.h

sl_bt_l2cap_transfer_check_progress#

sl_status_t sl_bt_l2cap_transfer_check_progress (sl_bt_l2cap_transfer_transfer_t * transfer)
Parameters
[in]transfer

Targeted transfer object - name of the transfer

Check if a transfer is in progress


Definition at line 230 of file common/l2cap_transfer/inc/sl_bt_l2cap_transfer.h

sl_bt_l2cap_transfer_open_prior_channel#

sl_status_t sl_bt_l2cap_transfer_open_prior_channel (sl_bt_l2cap_transfer_transfer_t * transfer)
Parameters
[in]transfer

Targeted transfer object

Open prior channel

Returns

  • status of the operation


Definition at line 239 of file common/l2cap_transfer/inc/sl_bt_l2cap_transfer.h

Macro Definition Documentation#

SL_BT_L2CAP_TRANSFER_CONFIG_ACCEPT_PRIOR_CHANNELS#

#define SL_BT_L2CAP_TRANSFER_CONFIG_ACCEPT_PRIOR_CHANNELS
Value:
1

Definition at line 45 of file common/l2cap_transfer/config/sl_bt_l2cap_transfer_config.h

SL_BT_L2CAP_TRANSFER_CONFIG_PRIOR_CHANNEL_COUNT#

#define SL_BT_L2CAP_TRANSFER_CONFIG_PRIOR_CHANNEL_COUNT
Value:
SL_BT_CONFIG_MAX_CONNECTIONS

Definition at line 49 of file common/l2cap_transfer/config/sl_bt_l2cap_transfer_config.h

SL_BT_L2CAP_TRANSFER_MIN_SDU#

#define SL_BT_L2CAP_TRANSFER_MIN_SDU
Value:
23

Channel parameter limit definitions.


Definition at line 53 of file common/l2cap_transfer/inc/sl_bt_l2cap_transfer.h

SL_BT_L2CAP_TRANSFER_MAX_SDU#

#define SL_BT_L2CAP_TRANSFER_MAX_SDU
Value:
65533

Definition at line 54 of file common/l2cap_transfer/inc/sl_bt_l2cap_transfer.h

SL_BT_L2CAP_TRANSFER_MIN_PDU#

#define SL_BT_L2CAP_TRANSFER_MIN_PDU
Value:
23

Definition at line 55 of file common/l2cap_transfer/inc/sl_bt_l2cap_transfer.h

SL_BT_L2CAP_TRANSFER_MAX_PDU#

#define SL_BT_L2CAP_TRANSFER_MAX_PDU
Value:
252

Definition at line 56 of file common/l2cap_transfer/inc/sl_bt_l2cap_transfer.h