Bluetooth LE Profile API document
Bluetooth LE Profile API document Rev.1.00 [May 22, 2020]
Functions

Detailed Description

Functions

ble_status_t R_BLE_L2CAP_RegisterCfPsm (ble_l2cap_cf_app_cb_t cb, uint16_t psm, uint16_t lwm)
 This function registers PSM that uses L2CAP CBFC Channel and a callback for L2CAP event. More...
 
ble_status_t R_BLE_L2CAP_DeregisterCfPsm (uint16_t psm)
 This function stops the use of the L2CAP CBFC Channel specified by the psm parameter and deregisters the callback function for L2CAP event. More...
 
ble_status_t R_BLE_L2CAP_ReqCfConn (uint16_t conn_hdl, st_ble_l2cap_conn_req_param_t *p_conn_req_param)
 This function sends a connection request for L2CAP CBFC Channel. More...
 
ble_status_t R_BLE_L2CAP_RspCfConn (st_ble_l2cap_conn_rsp_param_t *p_conn_rsp_param)
 This function replies to the connection request for L2CAP CBFC Channel from the remote device. More...
 
ble_status_t R_BLE_L2CAP_DisconnectCf (uint16_t lcid)
 This function sends a disconnection request for L2CAP CBFC Channel. More...
 
ble_status_t R_BLE_L2CAP_SendCfCredit (uint16_t lcid, uint16_t credit)
 This function sends credit to a remote device. More...
 
ble_status_t R_BLE_L2CAP_SendCfData (uint16_t conn_hdl, uint16_t lcid, uint16_t data_len, uint8_t *p_sdu)
 This function sends the data to a remote device via L2CAP CBFC Channel. More...
 

Function Documentation

◆ R_BLE_L2CAP_RegisterCfPsm()

ble_status_t R_BLE_L2CAP_RegisterCfPsm ( ble_l2cap_cf_app_cb_t  cb,
uint16_t  psm,
uint16_t  lwm 
)

This function registers PSM that uses L2CAP CBFC Channel and a callback for L2CAP event.

Only one callback is available per PSM. Configure in each PSM the Low Water Mark of the LE-Frames that the local device can receive.
When the number of the credit reaches the Low Water Mark, BLE_L2CAP_EVENT_CF_LOW_RX_CRD_IND event is notified to the application layer.
The number of PSM is defined as BLE_L2CAP_MAX_CBFC_PSM.
The result of this API call is returned by a return value.

Parameters
[in]cbCallback function for L2CAP event.

[in]psmIdentifier indicating the protocol/profile that uses L2CAP CBFC Channel.
type range description
Fixed, SIG assigned 0x0001 - 0x007F PSM defined by SIG. For more information on PSM, refer Bluetooth SIG Assigned Number (https://www.bluetooth.com/specifications/assigned-numbers).
Dynamic 0x0080 - 0x00FF Statically allocated PSM by custom protocol or dynamically allocated PSM by GATT Service.


[in]lwmLow Water Mark that indicates the LE-Frame numbers that the local device can receive.
Return values
BLE_SUCCESS(0x0000)Success
BLE_ERR_INVALID_PTR(0x0001)The cb parameter is specified as NULL.
BLE_ERR_INVALID_ARG(0x0003)The psm parameter is out of range.
BLE_ERR_CONTEXT_FULL(0x000B)More than BLE_L2CAP_MAX_CBFC_PSM+1 PSMs, callbacks has been registered.

Events
none

Message Sequence Chart

◆ R_BLE_L2CAP_DeregisterCfPsm()

ble_status_t R_BLE_L2CAP_DeregisterCfPsm ( uint16_t  psm)

This function stops the use of the L2CAP CBFC Channel specified by the psm parameter and deregisters the callback function for L2CAP event.

The result of this API call is returned by a return value.

Parameters
[in]psmPSM that is to be stopped to use the L2CAP CBFC Channel.
Set the PSM registered by R_BLE_L2CAP_RegisterCfPsm().
Return values
BLE_SUCCESS(0x0000)Success
BLE_ERR_NOT_FOUND(0x000D)The callback function allocated by the psm parameter is not found.

Events
none

◆ R_BLE_L2CAP_ReqCfConn()

ble_status_t R_BLE_L2CAP_ReqCfConn ( uint16_t  conn_hdl,
st_ble_l2cap_conn_req_param_t p_conn_req_param 
)

This function sends a connection request for L2CAP CBFC Channel.

The connection response is notified by BLE_L2CAP_EVENT_CF_CONN_CNF event.
The result of this API call is returned by a return value.

Parameters
[in]conn_hdlConnection handle identifying the remote device that the connection request is sent to.

[in]p_conn_req_paramConnection request parameters.
Return values
BLE_SUCCESS(0x0000)Success
BLE_ERR_INVALID_PTR(0x0001)The p_conn_req_param parameter is specified as NULL.
BLE_ERR_INVALID_ARG(0x0003)The mtu parameter or the mps parameter is out of range.
BLE_ERR_INVALID_STATE(0x0008)CF Channel connection has not been established.
BLE_ERR_CONTEXT_FULL(0x000B)New CF Channel can not be registered or other L2CAP Command is processing.
BLE_ERR_MEM_ALLOC_FAILED(0x000C)Insufficient memory is needed to generate this function.
BLE_ERR_INVALID_HDL(0x000E)The remote device specified by conn_hdl is not found.
BLE_ERR_NOT_YET_READY(0x0012)The psm parameter is not registered.

Events

Message Sequence Chart

◆ R_BLE_L2CAP_RspCfConn()

ble_status_t R_BLE_L2CAP_RspCfConn ( st_ble_l2cap_conn_rsp_param_t p_conn_rsp_param)

This function replies to the connection request for L2CAP CBFC Channel from the remote device.

The connection request is notified by BLE_L2CAP_EVENT_CF_CONN_IND event. The result of this API call is returned by a return value.

Parameters
[in]p_conn_rsp_paramConnection response parameters.
Return values
BLE_SUCCESS(0x0000)Success
BLE_ERR_INVALID_PTR(0x0001)The p_conn_rsp_param parameter is specified as NULL.
BLE_ERR_NOT_FOUND(0x000D)A connection request for L2CAP CBFC Channel has not been received, or CID specified by the lcid field in the p_conn_rsp_param parameter is not found.

Events

Message Sequence Chart

◆ R_BLE_L2CAP_DisconnectCf()

ble_status_t R_BLE_L2CAP_DisconnectCf ( uint16_t  lcid)

This function sends a disconnection request for L2CAP CBFC Channel.

When L2CAP CBFC Channel has been disconnected, BLE_L2CAP_EVENT_CF_DISCONN_CNF event is notified to the application layer.

Parameters
[in]lcidCID identifying the L2CAP CBFC Channel that has been disconnected.
The valid range is 0x40 - (0x40 + BLE_L2CAP_MAX_CBFC_PSM - 1).
Return values
BLE_SUCCESS(0x0000)Success
BLE_ERR_INVALID_OPERATION(0x0009)CF Channel connection has not been established.
BLE_ERR_CONTEXT_FULL(0x000B)This function was called while processing other L2CAP command.
BLE_ERR_MEM_ALLOC_FAILED(0x000C)There are no memories for L2CAP Command.
BLE_ERR_NOT_FOUND(0x000D)CID specified the lcid parameter is not found.

Events

Message Sequence Chart

◆ R_BLE_L2CAP_SendCfCredit()

ble_status_t R_BLE_L2CAP_SendCfCredit ( uint16_t  lcid,
uint16_t  credit 
)

This function sends credit to a remote device.

In L2CAP CBFC communication, if credit is 0, the remote device stops data transmission.
Therefore when processing the received data has been completed and local device affords to receive data, the remote device is notified of the number of LE-Frame that local device can receive by this function and local device can continue to receive data from the remote device.
The result of this API call is returned by a return value.

Parameters
[in]lcidCID identifying the L2CAP CBFC Channel on local device that sends credit.
[in]creditCredit to be sent to the remote device.
Return values
BLE_SUCCESS(0x0000)Success
BLE_ERR_INVALID_ARG(0x0003)The credit parameter is set to 0.
BLE_ERR_CONTEXT_FULL(0x000B)This function was called while processing other L2CAP command.
BLE_ERR_MEM_ALLOC_FAILED(0x000C)There are no memories for L2CAP Command.

Events
none

Message Sequence Chart

◆ R_BLE_L2CAP_SendCfData()

ble_status_t R_BLE_L2CAP_SendCfData ( uint16_t  conn_hdl,
uint16_t  lcid,
uint16_t  data_len,
uint8_t *  p_sdu 
)

This function sends the data to a remote device via L2CAP CBFC Channel.

When the data transmission to Controller has been completed, BLE_L2CAP_EVENT_CF_TX_DATA_CNF event is notified to the application layer.

Parameters
[in]conn_hdlConnection handle identifying the remote device to be sent the data.

[in]lcidCID identifying the L2CAP CBFC Channel on local device used in the data transmission.

[in]data_lenLength of the data.

[in]p_sduService Data Unit.
Input the data length specified by the data_len parameter to the first 2 bytes (Little Endian).
Return values
BLE_SUCCESS(0x0000)Success
BLE_ERR_INVALID_PTR(0x0001)The p_data parameter is specified as NULL.
BLE_ERR_INVALID_ARG(0x0003)The length parameter is out of range.
BLE_ERR_INVALID_STATE(0x0008)CF Channel connection has not been established or the data whose length exceeds the MTU has been sent.
BLE_ERR_ALREADY_IN_PROGRESS(0x000A)Data transmission has been already started.
BLE_ERR_CONTEXT_FULL(0x000B)L2CAP task queue is full.
BLE_ERR_MEM_ALLOC_FAILED(0x000C)There are no memories for L2CAP Command.
BLE_ERR_NOT_FOUND(0x000D)CID specified the lcid parameter is not found.
BLE_ERR_INVALID_HDL(0x000E)The remote device specified by the conn_hdl parameter is not found.

Events

Message Sequence Chart