Functions
Functions
BLE » Logical Link Control and Adaptation Protocol (L2CAP)

## Functions
uint16_t | ble_l2cap_lecb_conn_create (uint8_t conn_idx, const lecb_conn_req_t *p_conn_req)
| Create the LE credit based connection. More...
uint16_t | ble_l2cap_lecb_conn_cfm (uint8_t conn_idx, const lecb_cfm_conn_t *p_cfm_conn)
| Confirm the LE credit based connection after receiving the connection request packet from the peer device. More...
uint16_t | ble_l2cap_lecb_disconnect (uint8_t conn_idx, uint16_t local_cid)
| Disconnect the LE credit based connection. More...
uint16_t | ble_l2cap_lecb_credits_add (uint8_t conn_idx, const lecb_add_credits_t *p_add_credits)
| Send a LE Flow Control Credit packet when the device is capable of receiving additional LE-frames (for example after the device has processed the sdu). More...
uint16_t | ble_l2cap_lecb_sdu_send (uint8_t conn_idx, const lecb_sdu_t *p_sdu)
| Send an SDU packet to the peer device. More...
uint16_t | ble_l2cap_lecb_cb_register (uint16_t le_psm, const l2cap_lecb_cb_fun_t *p_cb)
| Register the callback for the PSM. More...

## Detailed Description

## Function Documentation

## ◆ ble_l2cap_lecb_cb_register()

uint16_t ble_l2cap_lecb_cb_register | ( | uint16_t | le_psm,
|  | const l2cap_lecb_cb_fun_t * | p_cb
| ) |  |

Register the callback for the PSM.

Parameters

  [in] | le_psm | The le_psm number.
  [in] | p_cb | Pointer to the callback structure.

Return values

  SDK_SUCCESS | The callback is successfully registered to the BLE stack.
  SDK_ERR_INVALID_PARAM | Invalid parameter supplied.
  SDK_ERR_INVALID_PSM_EXCEEDED_MAX_PSM_NUM | The maximum PSM number limit is exceeded.

## ◆ ble_l2cap_lecb_conn_cfm()

uint16_t ble_l2cap_lecb_conn_cfm | ( | uint8_t | conn_idx,
|  | const lecb_cfm_conn_t * | p_cfm_conn
| ) |  |

Confirm the LE credit based connection after receiving the connection request packet from the peer device.

Note
  This function should be invoked in the handle of callback l2cap_lecb_cb_fun_t::app_l2cap_lecb_conn_req_cb. And after the COC created, the callback l2cap_lecb_cb_fun_t::app_l2cap_lecb_conn_cb should be called.

Parameters

  [in] | conn_idx | ACL connection index. The first ACL connection index is 0 and the index will be increased one by one.
  [in] | p_cfm_conn | Pointer to the LE Credit Based Connection Confirm structure.

Return values

  SDK_SUCCESS | The LE Credit Based connection confirmation is successfully set to the BLE stack.
  SDK_ERR_POINTER_NULL | Invalid pointer supplied.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_INVALID_PARAM | Invalid parameter supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_l2cap_lecb_conn_create()

uint16_t ble_l2cap_lecb_conn_create | ( | uint8_t | conn_idx,
|  | const lecb_conn_req_t * | p_conn_req
| ) |  |

Create the LE credit based connection.

Note
  After the COC created, the callback l2cap_lecb_cb_fun_t::app_l2cap_lecb_conn_cb will be called.

Parameters

  [in] | conn_idx | ACL connection index. The first ACL connection index is 0, and the index will be increased one by one.
  [in] | p_conn_req | Pointer to the LE Credit Based Connection Request structure.

Return values

  SDK_SUCCESS | The LE Credit Based connection request is successfully set to the BLE stack.
  SDK_ERR_POINTER_NULL | Invalid pointer supplied.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_l2cap_lecb_credits_add()

uint16_t ble_l2cap_lecb_credits_add | ( | uint8_t | conn_idx,
|  | const lecb_add_credits_t * | p_add_credits
| ) |  |

Send a LE Flow Control Credit packet when the device is capable of receiving additional LE-frames (for example after the device has processed the sdu).

Parameters

  [in] | conn_idx | ACL connection index, the first ACL connection index is 0, and increased one by one.
  [in] | p_add_credits | Pointer to the LE Flow Control Credit structure.

Return values

  SDK_SUCCESS | LE Flow Control Credit packet is successfully set to the BLE stack.
  SDK_ERR_POINTER_NULL | Invalid pointer supplied.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_l2cap_lecb_disconnect()

uint16_t ble_l2cap_lecb_disconnect | ( | uint8_t | conn_idx,
|  | uint16_t | local_cid
| ) |  |

Disconnect the LE credit based connection.

Note
  After COC disconnected, the callback l2cap_lecb_cb_fun_t::app_l2cap_lecb_disconn_cb should be called.

Parameters

  [in] | conn_idx | ACL connection index. The first ACL connection index is 0 and the index will be increased one by one.
  [in] | local_cid | The local source channel ID.

Return values

  SDK_SUCCESS | LE Credit Based disconnection request is successfully set to the BLE stack.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.

## ◆ ble_l2cap_lecb_sdu_send()

uint16_t ble_l2cap_lecb_sdu_send | ( | uint8_t | conn_idx,
|  | const lecb_sdu_t * | p_sdu
| ) |  |

Send an SDU packet to the peer device.

Parameters

  [in] | conn_idx | ACL connection index. The first ACL connection index is 0 and the index will be increased one by one.
  [in] | p_sdu | Pointer to the sdu packet structure.

Return values

  SDK_SUCCESS | The sdu packet is successfully set to the BLE stack.
  SDK_ERR_POINTER_NULL | Invalid pointer supplied.
  SDK_ERR_INVALID_CONN_IDX | Invalid connection index supplied.
  SDK_ERR_NO_RESOURCES | Not enough resources.