Function nrf_softdevice_s140::sd_ble_l2cap_ch_tx
source · pub unsafe fn sd_ble_l2cap_ch_tx(
conn_handle: u16,
local_cid: u16,
p_sdu_buf: *const ble_data_t
) -> u32
Expand description
@brief Transmit an SDU on an L2CAP channel.
@note A call to this function will require the application to keep the memory pointed by @ref ble_data_t::p_data alive until the SDU data buffer is returned in @ref BLE_L2CAP_EVT_CH_TX or @ref BLE_L2CAP_EVT_CH_SDU_BUF_RELEASED event.
@note The SoftDevice can queue up to @ref ble_l2cap_conn_cfg_t::tx_queue_size SDUs for transmission per L2CAP channel.
@note The application can keep track of the available credits for transmission by following the procedure below: - Store initial credits given by the peer in a variable. (Initial credits are provided in a @ref BLE_L2CAP_EVT_CH_SETUP event.) - Decrement the variable, which stores the currently available credits, by ceiling((@ref ble_data_t::len + 2) / tx_mps) when a call to this function returns @ref NRF_SUCCESS. (tx_mps is provided in a @ref BLE_L2CAP_EVT_CH_SETUP event.) - Increment the variable, which stores the currently available credits, by additional credits given by the peer in a @ref BLE_L2CAP_EVT_CH_CREDIT event.
@events @event{@ref BLE_L2CAP_EVT_CH_TX, The SDU is transmitted.} @endevents
@mscs @mmsc{@ref BLE_L2CAP_CH_TX_MSC} @endmscs
@param[in] conn_handle Connection Handle. @param[in] local_cid Local Channel ID of the L2CAP channel. @param[in] p_sdu_buf Pointer to the SDU data buffer.
@retval ::NRF_SUCCESS Successfully queued L2CAP SDU for transmission. @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied. @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid Connection Handle. @retval ::NRF_ERROR_INVALID_STATE Invalid State to perform operation (Setup or release is in progress for the L2CAP channel). @retval ::NRF_ERROR_NOT_FOUND CID not found. @retval ::NRF_ERROR_DATA_SIZE Invalid SDU length supplied, must not be more than @ref ble_l2cap_ch_tx_params_t::tx_mtu provided in @ref BLE_L2CAP_EVT_CH_SETUP event. @retval ::NRF_ERROR_RESOURCES Too many SDUs queued for transmission. Wait for a @ref BLE_L2CAP_EVT_CH_TX event and retry.