nRF51 SDK - S130 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
L2CAP Application command request encoders and command response decoders

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 requried prior to all operations on the CID.

Parameters
[in]cidL2CAP CID.
[in]p_bufPointer to beginning of command response packet.
[in,out]p_buf_lenin: Size of p_buf buffer. out: Length of encoded command packet.
Return values
NRF_SUCCESSEncoding success.
NRF_ERROR_NULLEncoding failure. NULL pointer supplied.
NRF_ERROR_INVALID_LENGTHEncoding 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
0x73 - sd_ble_gap_adv_start for packet format, ble_l2cap_cid_register_req_enc for command request encoder.
Parameters
[in]p_bufPointer to beginning of command response packet.
[in]packet_lenLength (in bytes) of response packet.
[out]p_result_codeCommand result code.
Return values
NRF_SUCCESSDecoding success.
NRF_ERROR_NULLDecoding failure. NULL pointer supplied.
NRF_ERROR_INVALID_LENGTHDecoding failure. Incorrect buffer length.
NRF_ERROR_INVALID_DATADecoding 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]cidL2CAP CID.
[in]p_bufPointer to beginning of command response packet.
[in,out]p_buf_lenin: Size of p_buf buffer. out: Length of encoded command packet.
Return values
NRF_SUCCESSEncoding success.
NRF_ERROR_NULLEncoding failure. NULL pointer supplied.
NRF_ERROR_INVALID_LENGTHEncoding 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
0x73 - sd_ble_gap_adv_start for packet format, ble_l2cap_cid_unregister_req_enc for command request encoder.
Parameters
[in]p_bufPointer to beginning of command response packet.
[in]packet_lenLength (in bytes) of response packet.
[out]p_result_codeCommand result code.
Return values
NRF_SUCCESSDecoding success.
NRF_ERROR_NULLDecoding failure. NULL pointer supplied.
NRF_ERROR_INVALID_LENGTHDecoding failure. Incorrect buffer length.
NRF_ERROR_INVALID_DATADecoding 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. Please see the documentation of sd_ble_tx_buffer_count_get for more details.
Parameters
[in]conn_handleConnection Handle.
[in]p_l2cap_headerPointer to a packet header containing length and CID.
[in]p_dataPointer to the data to be transmitted.
[in]p_bufPointer to beginning of command response packet.
[in,out]p_buf_lenin: 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.
BLE_ERROR_NO_TX_BUFFERS Not enough application buffers available.
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
0x73 - sd_ble_gap_adv_start for packet format, ble_l2cap_tx_req_enc for command request encoder.
Parameters
[in]p_bufPointer to beginning of command response packet.
[in]packet_lenLength (in bytes) of response packet.
[out]p_result_codeCommand result code.
Return values
NRF_SUCCESSDecoding success.
NRF_ERROR_NULLDecoding failure. NULL pointer supplied.
NRF_ERROR_INVALID_LENGTHDecoding failure. Incorrect buffer length.
NRF_ERROR_INVALID_DATADecoding failure. Decoded operation code does not match expected operation code.