L2CAP Application command request encoders and command response decoders

nRF5 SDK v12.1.0

L2CAP Application command request encoders and command response decoders. More...

Functions

uint32_t ble_l2cap_cid_register_req_enc (uint16_t cid, uint8_t *const p_buf, uint32_t *const p_buf_len)
Register a CID with L2CAP. More...
uint32_t ble_l2cap_cid_register_rsp_dec (uint8_t const *const p_buf, uint32_t packet_len, uint32_t *const p_result_code)
Decodes response to sd_ble_l2cap_cid_register command. More...
uint32_t ble_l2cap_cid_unregister_req_enc (uint16_t cid, uint8_t *const p_buf, uint32_t *const p_buf_len)
Unregister a CID with L2CAP. More...
uint32_t ble_l2cap_cid_unregister_rsp_dec (uint8_t const *const p_buf, uint32_t packet_len, uint32_t *const p_result_code)
Decodes response to sd_ble_l2cap_cid_unregister command. More...
uint32_t ble_l2cap_tx_req_enc (uint16_t conn_handle, ble_l2cap_header_t const *const p_l2cap_header, uint8_t const *const p_data, uint8_t *const p_buf, uint32_t *const p_buf_len)
Transmit an L2CAP packet. More...
uint32_t ble_l2cap_tx_rsp_dec (uint8_t const *const p_buf, uint32_t packet_len, uint32_t *const p_result_code)
Decodes response to sd_ble_l2cap_tx command. More...

Detailed Description

L2CAP Application command request encoders and command response decoders.

Function Documentation

uint32_t ble_l2cap_cid_register_req_enc ( uint16_t cid ,
uint8_t *const p_buf ,
uint32_t *const p_buf_len
)

Register a CID with L2CAP.

This registers a higher protocol layer with the L2CAP multiplexer, and is required prior to all operations on the CID.

Parameters
[in] cid L2CAP CID.
[in] p_buf Pointer to beginning of command response packet.
[in,out] p_buf_len in: Size of p_buf buffer. out: Length of encoded command packet.
Return values
NRF_SUCCESS Encoding success.
NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
uint32_t ble_l2cap_cid_register_rsp_dec ( uint8_t const *const p_buf ,
uint32_t packet_len ,
uint32_t *const p_result_code
)

Decodes response to sd_ble_l2cap_cid_register command.

See Also
ble_l2cap_cid_register_req_enc for command request encoder.
Parameters
[in] p_buf Pointer to beginning of command response packet.
[in] packet_len Length (in bytes) of response packet.
[out] p_result_code Command result code.
Return values
NRF_SUCCESS Decoding success.
NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected operation code.
uint32_t ble_l2cap_cid_unregister_req_enc ( uint16_t cid ,
uint8_t *const p_buf ,
uint32_t *const p_buf_len
)

Unregister a CID with L2CAP.

This unregisters a previously registered higher protocol layer with the L2CAP multiplexer.

Parameters
[in] cid L2CAP CID.
[in] p_buf Pointer to beginning of command response packet.
[in,out] p_buf_len in: Size of p_buf buffer. out: Length of encoded command packet.
Return values
NRF_SUCCESS Encoding success.
NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
uint32_t ble_l2cap_cid_unregister_rsp_dec ( uint8_t const *const p_buf ,
uint32_t packet_len ,
uint32_t *const p_result_code
)

Decodes response to sd_ble_l2cap_cid_unregister command.

See Also
ble_l2cap_cid_unregister_req_enc for command request encoder.
Parameters
[in] p_buf Pointer to beginning of command response packet.
[in] packet_len Length (in bytes) of response packet.
[out] p_result_code Command result code.
Return values
NRF_SUCCESS Decoding success.
NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected operation code.
uint32_t ble_l2cap_tx_req_enc ( uint16_t conn_handle ,
ble_l2cap_header_t const *const p_l2cap_header ,
uint8_t const *const p_data ,
uint8_t *const p_buf ,
uint32_t *const p_buf_len
)

Transmit an L2CAP packet.

Note
It is important to note that a call to this function will consume an application buffer , and will therefore generate a BLE_EVT_TX_COMPLETE event when the packet has been transmitted. See the documentation of sd_ble_tx_packet_count_get for more details.
Parameters
[in] conn_handle Connection handle.
[in] p_l2cap_header Pointer to a packet header containing length and CID.
[in] p_data Pointer to the data to be transmitted.
[in] p_buf Pointer to beginning of command response packet.
[in,out] p_buf_len in: Size of p_buf buffer. out: Length of encoded command packet.
Returns
NRF_SUCCESS Successfully queued an L2CAP packet for transmission.
NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, CIDs must be registered beforehand with sd_ble_l2cap_cid_register .
NRF_ERROR_NOT_FOUND CID not found.
NRF_ERROR_NO_MEM Not enough memory to complete operation.
NRF_ERROR_DATA_SIZE Invalid data size(s) supplied, see BLE_L2CAP_MTU_DEF .
uint32_t ble_l2cap_tx_rsp_dec ( uint8_t const *const p_buf ,
uint32_t packet_len ,
uint32_t *const p_result_code
)

Decodes response to sd_ble_l2cap_tx command.

See Also
ble_l2cap_tx_req_enc for command request encoder.
Parameters
[in] p_buf Pointer to beginning of command response packet.
[in] packet_len Length (in bytes) of response packet.
[out] p_result_code Command result code.
Return values
NRF_SUCCESS Decoding success.
NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match expected operation code.