RA Flexible Software Package Documentation  Release v5.6.0

 

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...
 

Detailed Description

Data Structures

struct  st_ble_l2cap_conn_req_param_t
 L2CAP CBFC Channel connection request parameters. More...
 
struct  st_ble_l2cap_conn_rsp_param_t
 L2CAP CBFC Channel connection response parameters. More...
 
struct  st_ble_l2cap_cf_conn_evt_t
 L2CAP CBFC Channel connection parameters. More...
 
struct  st_ble_l2cap_cf_data_evt_t
 Sent/Received Data parameters. More...
 
struct  st_ble_l2cap_cf_credit_evt_t
 Credit parameters of local or remote device. More...
 
struct  st_ble_l2cap_cf_disconn_evt_t
 Disconnection parameters. More...
 
struct  st_ble_l2cap_rej_evt_t
 Command Reject parameters. More...
 
struct  st_ble_l2cap_cf_evt_data_t
 st_ble_l2cap_cf_evt_data_t is the type of the data notified in a L2CAP Event. More...
 

Macros

#define BLE_L2CAP_MAX_CBFC_PSM
 The maximum number of callbacks that host stack can register.
 
#define BLE_L2CAP_CF_RSP_SUCCESS
 Notify the remote device that the connection can be established.
 
#define BLE_L2CAP_CF_RSP_RFSD_INSF_AUTH
 Notify the remote device that the connection can not be established because of insufficient authentication.
 
#define BLE_L2CAP_CF_RSP_RFSD_INSF_AUTRZ
 Notify the remote device that the connection can not be established because of insufficient Authorization.
 
#define BLE_L2CAP_CF_RSP_RFSD_INSF_ENC_KEY
 Notify the remote device that the connection can not be established because of Encryption Key Size.
 
#define BLE_L2CAP_CF_RSP_RFSD_INSF_ENC
 Notify the remote device that the connection can not be established because of Encryption.
 
#define BLE_L2CAP_CF_RSP_RFSD_UNAC_PARAM
 Notify the remote device that the connection can not be established because the parameters is unacceptable to local device.
 

Typedefs

typedef void(* ble_l2cap_cf_app_cb_t) (uint16_t event_type, ble_status_t event_result, st_ble_l2cap_cf_evt_data_t *p_event_data)
 ble_l2cap_cf_app_cb_t is the L2CAP Event callback function type. More...
 

Enumerations

enum  e_r_ble_l2cap_cf_evt_t
 L2CAP Event Identifier. More...
 

Data Structure Documentation

◆ st_ble_l2cap_conn_req_param_t

struct st_ble_l2cap_conn_req_param_t

L2CAP CBFC Channel connection request parameters.

Data Fields
uint16_t local_psm Identifier indicating the protocol/profile that uses L2CAP CBFC Channel on local device.
uint16_t remote_psm Identifier indicating the protocol/profile that uses L2CAP CBFC Channel on remote device.
uint16_t mtu MTU size(byte) receivable on L2CAP CBFC Channel.
uint16_t mps MPS size(byte) receivable on L2CAP CBFC Channel.
uint16_t credit The number of LE-Frame that local device can receive.

◆ st_ble_l2cap_conn_rsp_param_t

struct st_ble_l2cap_conn_rsp_param_t

L2CAP CBFC Channel connection response parameters.

Data Fields
uint16_t lcid CID identifying the L2CAP CBFC Channel on local device. The valid range is 0x40-0x40 + BLE_L2CAP_MAX_CBFC_PSM - 1.
uint16_t response The response to the connection request. Select one of the following.
macro description
BLE_L2CAP_CF_RSP_SUCCESS(0x0000) Notify the remote device that the connection can be established.
BLE_L2CAP_CF_RSP_RFSD_INSF_AUTH(0x0005) Notify the remote device that the connection can not be established because of insufficient authentication.
BLE_L2CAP_CF_RSP_RFSD_INSF_AUTRZ(0x0006) Notify the remote device that the connection can not be established because of insufficient Authorization.
BLE_L2CAP_CF_RSP_RFSD_INSF_ENC_KEY(0x0007) Notify the remote device that the connection can not be established because of Encryption Key Size.
BLE_L2CAP_CF_RSP_RFSD_INSF_ENC(0x0008) Notify the remote device that the connection can not be established because of Encryption.
BLE_L2CAP_CF_RSP_RFSD_UNAC_PARAM(0x000B) Notify the remote device that the connection can not be established because the parameters is unacceptable to local device.
uint16_t mtu MTU(byte) of packet that L2CAP CBFC Channel on local device can receive.
uint16_t mps MPS(byte) of packet that L2CAP CBFC Channel on local device can receive.
uint16_t credit The number of LE-Frame that L2CAP CBFC Channel on local device can receive.

◆ st_ble_l2cap_cf_conn_evt_t

struct st_ble_l2cap_cf_conn_evt_t

L2CAP CBFC Channel connection parameters.

Data Fields
uint16_t cid CID identifying the L2CAP CBFC Channel.
uint16_t psm PSM allocated by the cid field.
uint16_t mtu MTU of local (specified in BLE_L2CAP_EVENT_CF_CONN_IND) / remote (notified in BLE_L2CAP_EVENT_CF_CONN_CNF) device.
uint16_t mps MPS of local (specified in BLE_L2CAP_EVENT_CF_CONN_IND) / remote (notified in BLE_L2CAP_EVENT_CF_CONN_CNF) device.
uint16_t credit Credit of local (specified in BLE_L2CAP_EVENT_CF_CONN_IND) / remote (notified in BLE_L2CAP_EVENT_CF_CONN_CNF) device.

◆ st_ble_l2cap_cf_data_evt_t

struct st_ble_l2cap_cf_data_evt_t

Sent/Received Data parameters.

Data Fields
uint16_t cid CID identifying the L2CAP CBFC Channel that has sent or received the data .
uint16_t psm PSM allocated by the cid field.
uint16_t data_len Data length.
uint8_t * p_data Sent/Received data.

◆ st_ble_l2cap_cf_credit_evt_t

struct st_ble_l2cap_cf_credit_evt_t

Credit parameters of local or remote device.

Data Fields
uint16_t cid CID identifying the L2CAP CBFC Channel.
uint16_t psm PSM allocated by the cid field.
uint16_t credit Current credit of local/remote device.

◆ st_ble_l2cap_cf_disconn_evt_t

struct st_ble_l2cap_cf_disconn_evt_t

Disconnection parameters.

Data Fields
uint16_t cid CID identifying the L2CAP CBFC Channel that has been disconnected.

◆ st_ble_l2cap_rej_evt_t

struct st_ble_l2cap_rej_evt_t

Command Reject parameters.

Data Fields
uint16_t reason The reason that the remote device has sent Command Reject.
uint16_t data_1 Optional information about the reason that the remote device has sent Command Reject.
uint16_t data_2 Optional information about the reason that the remote device has sent Command Reject.

◆ st_ble_l2cap_cf_evt_data_t

struct st_ble_l2cap_cf_evt_data_t

st_ble_l2cap_cf_evt_data_t is the type of the data notified in a L2CAP Event.

Data Fields
uint16_t conn_hdl Connection handle identifying the remote device.
uint16_t param_len The size of L2CAP Event parameters.
void * p_param L2CAP Event parameters. This parameter differs in each L2CAP Event.

Typedef Documentation

◆ ble_l2cap_cf_app_cb_t

ble_l2cap_cf_app_cb_t

ble_l2cap_cf_app_cb_t is the L2CAP Event callback function type.

Parameters
[in]event_typeThe type of L2CAP Event.
[in]event_resultThe result of L2CAP Event
[in]p_event_dataData notified by L2CAP Event.
Returns
none

Enumeration Type Documentation

◆ e_r_ble_l2cap_cf_evt_t

L2CAP Event Identifier.

Enumerator
BLE_L2CAP_EVENT_CF_CONN_CNF 

After the connection request for L2CAP CBFC Channel has been sent with R_BLE_L2CAP_ReqCfConn(), when the L2CAP CBFC Channel connection response has been received, BLE_L2CAP_EVENT_CF_CONN_CNF event occurs.

Event Code: 0x5001

result:

BLE_SUCCESS(0x0000) Success
BLE_ERR_RSP_TIMEOUT(0x0011) L2CAP Command timeout.
BLE_ERR_L2CAP_PSM_NOT_SUPPORTED(0x4002) PSM specified by R_BLE_L2CAP_ReqCfConn() is not supported.
BLE_ERR_L2CAP_NO_RESOURCE(0x4004) No resource for connection.
BLE_ERR_L2CAP_INSUF_AUTHEN(0x4005) Insufficient authentication.
BLE_ERR_L2CAP_INSUF_AUTHOR(0x4006) Insufficient authorization.
BLE_ERR_L2CAP_INSUF_ENC_KEY_SIZE(0x4007) Insufficient encryption key size.
BLE_ERR_L2CAP_REFUSE_INSUF_ENC(0x4008) Insufficient encryption.
BLE_ERR_L2CAP_REFUSE_INVALID_SCID(0x4009) Invalid Source CID.
BLE_ERR_L2CAP_REFUSE_SCID_ALREADY_ALLOC(0x400A) Source CID already allocated.
BLE_ERR_L2CAP_REFUSE_UNACCEPTABLE_PARAM(0x400B) Unacceptable parameters.

Event Data:

st_ble_l2cap_cf_conn_evt_t

BLE_L2CAP_EVENT_CF_CONN_IND 

When a connection request for L2CPA CBFC Channel has been received from a remote device, BLE_L2CAP_EVENT_CF_CONN_IND event occurs.

Event Code: 0x5002

result:

BLE_SUCCESS(0x0000) Success
BLE_ERR_NOT_FOUND(0x000D) CF connection request has not been received or lcid not found.
BLE_ERR_L2CAP_PSM_NOT_SUPPORTED(0x4002) PSM specified by R_BLE_L2CAP_ReqCfConn() is not supported.

Event Data:

st_ble_l2cap_cf_conn_evt_t

BLE_L2CAP_EVENT_CF_DISCONN_CNF 

After local device has sent a disconnection request for L2CAP CBFC Channel by R_BLE_L2CAP_DisconnectCf(), when the local device has received the response, BLE_L2CAP_EVENT_CF_DISCONN_CNF event occurs.

Event Code: 0x5003

result:

BLE_SUCCESS(0x0000) Success

Event Data:

st_ble_l2cap_cf_disconn_evt_t

BLE_L2CAP_EVENT_CF_DISCONN_IND 

When local device has received a disconnection request for L2CAP CBFC Channel from the remote device, BLE_L2CAP_EVENT_CF_DISCONN_IND event occurs.
Host stack automatically replies the to the disconnection request.

Event Code: 0x5004

result:

BLE_SUCCESS(0x0000) Success

Event Data:

st_ble_l2cap_cf_disconn_evt_t

BLE_L2CAP_EVENT_CF_RX_DATA_IND 

When local device has received data on L2CAP CBFC Channel, BLE_L2CAP_EVENT_CF_RX_DATA_IND event occurs.

Event Code: 0x5005

result:

BLE_SUCCESS(0x0000) Success

Event Data:

st_ble_l2cap_cf_data_evt_t

BLE_L2CAP_EVENT_CF_LOW_RX_CRD_IND 

When the credit of the L2CAP CBFC Channel has reached the Low Water Mark, BLE_L2CAP_EVENT_CF_LOW_RX_CRD_IND event occurs.

Event Code: 0x5006

result:

BLE_SUCCESS(0x0000) Success

Event Data:

st_ble_l2cap_cf_credit_evt_t

BLE_L2CAP_EVENT_CF_TX_CRD_IND 

When local device has received credit from a remote device, BLE_L2CAP_EVENT_CF_TX_CRD_IND event occurs.

Event Code: 0x5007

result:

BLE_SUCCESS(0x0000) Success

Event Data:

st_ble_l2cap_cf_credit_evt_t

BLE_L2CAP_EVENT_CF_TX_DATA_CNF 

When the data transmission has been completed from host stack to Controller, BLE_L2CAP_EVENT_CF_TX_DATA_CNF event occurs.

Event Code: 0x5008

result:

BLE_SUCCESS(0x0000) Success
BLE_ERR_DISCONNECTED(0x000F) While transmitting data, L2CAP CBFC Channel has been disconnected.

Event Data:

st_ble_l2cap_cf_data_evt_t

BLE_L2CAP_EVENT_CMD_REJ 

When local device has received Command Reject PDU, BLE_L2CAP_EVENT_CMD_REJ event occurs.

Event Code: 0x5009

result:

BLE_SUCCESS(0x0000) Success

Event Data:

st_ble_l2cap_rej_evt_t

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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ 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.