BLE

group l2cap_le_api_functions

API’s used for LE L2CAP.

Functions

wiced_bool_t wiced_bt_l2cap_cancel_ble_connect_req(wiced_bt_device_address_t rem_bda)

Cancel a pending connection attempt to a BLE device.

Parameters

rem_bda[in] : BD Address of remote

Returns

: TRUE if connection was cancelled

wiced_bool_t wiced_bt_l2cap_update_ble_conn_params(wiced_bt_device_address_t rem_bdRa, uint16_t min_int, uint16_t max_int, uint16_t latency, uint16_t timeout)

Update BLE connection parameters.

Parameters
  • rem_bdRa[in] : Remote BD Address

  • min_int[in] : Min interval, measured in units of 1.25 ms

  • max_int[in] : Max interval, measured in units of 1.25 ms

  • latency[in] : Latency value

  • timeout[in] : Timeout value, measured in units of 10 ms

Returns

: TRUE if update started

wiced_bool_t wiced_bt_l2cap_enable_update_ble_conn_params(wiced_bt_device_address_t rem_bda, wiced_bool_t enable)

Enable or disable updating BLE connection params based on the request from the peer.

Parameters
  • rem_bda[in] Remote Bd Address

  • enable[in] TRUE to enable,FALSE to disable.

Returns

: TRUE if update started

uint8_t wiced_bt_l2cap_get_ble_conn_role(wiced_bt_device_address_t bd_addr)

This function returns the connection role.

Parameters

bd_addr[in] BD Address

Returns

link role.( 0 => HCI_ROLE_CENTRAL and 1 => HCI_ROLE_PERIPHERAL)

uint16_t wiced_bt_l2cap_le_register(uint16_t le_psm, wiced_bt_l2cap_le_appl_information_t *p_cb_information)

Other layers call this function to register L2CAP services for LE_PSM.

Parameters
  • le_psm[in] : LE PSM value

  • p_cb_information[in] : L2CAP cb info

Returns

LE_PSM to use or zero if error. Typically the LE_PSM returned is the same as was passed in, but for an outgoing-only connection a “virtual” LE_PSM is returned and should be used in the calls to wiced_bt_l2cap_le_connect_req() and wiced_bt_l2cap_le_deregister().

wiced_bool_t wiced_bt_l2cap_le_deregister(uint16_t le_psm)

Other layers call this function to deregister L2CAP services for LE_PSM.

Parameters

le_psm[in] LE PSM value

Returns

TRUE for success, FALSE for failure

uint16_t wiced_bt_l2cap_le_connect_req(uint16_t le_psm, wiced_bt_device_address_t p_bd_addr, wiced_bt_ble_address_type_t bd_addr_type, wiced_bt_ble_conn_mode_t conn_mode, uint16_t rx_mtu, uint8_t req_security, uint8_t req_encr_key_size, tDRB *p_rx_drb)

Higher layers call this function to create an L2CAP connection for LE_PSM.

Note that the connection is not established at this time, but connection establishment gets started. The callback function will be invoked when connection establishes or fails.

Parameters
  • le_psm[in] : LE PSM value

  • p_bd_addr[in] : BD Address

  • bd_addr_type[in] : BLE_ADDR_PUBLIC or BLE_ADDR_RANDOM

  • conn_mode[in] : BLE_CONN_MODE_HIGH_DUTY or BLE_CONN_MODE_LOW_DUTY

  • rx_mtu[in] : Rx MTU value (must be <= ACL_POOL_SIZE)

  • req_security[in] : Security required

  • req_encr_key_size[in] : key size

  • p_rx_drb[in] : a DRB to receive peer’s data. MUST be large enough to hold RX MTU data

Returns

the CID of the connection, or 0 if it failed to start

wiced_bool_t wiced_bt_l2cap_le_connect_rsp(wiced_bt_device_address_t p_bd_addr, uint8_t id, uint16_t lcid, uint16_t result, uint16_t rx_mtu, tDRB *p_rx_drb)

Higher layers call this function to accept an incoming LE L2CAP connection, for which they had gotten an connect indication callback.

Parameters
  • p_bd_addr[in] : BD Address

  • id[in] : ID received from wiced_bt_l2cap_le_connect_indication_cback_t callback.

  • lcid[in] : Local CID

  • result[in] : L2CAP result codes (L2CAP_CONN_RESULT)

  • rx_mtu[in] : Rx MTU value (must be <= ACL_POOL_SIZE)

  • p_rx_drb[in] : a DRB to receive peer’s data. MUST be large enough to hold RX MTU data

Returns

TRUE for success, FALSE for failure

wiced_bool_t wiced_bt_l2cap_le_disconnect_req(uint16_t lcid)

Higher layers call this function to disconnect a LE COC channel.

Parameters

lcid[in] Local CID value

Returns

TRUE if disconnect sent, else FALSE

wiced_bool_t wiced_bt_l2cap_le_disconnect_rsp(uint16_t lcid)

Higher layers call this function to acknowledge the disconnection of a LE COC channel.

Parameters

lcid[in] Local CID value

Returns

void

uint8_t wiced_bt_l2cap_le_data_write(uint16_t cid, uint8_t *p_data, uint16_t buf_len)

Send data over LE connection-oriented channel.

Parameters
  • cid[in] : CID value

  • p_data[in] : Input buffer

  • buf_len[in] : p_data buffer size

Returns

L2CAP_DATAWRITE_SUCCESS, if data accepted, else FALSE L2CAP_DATAWRITE_CONGESTED, if data accepted and the channel is congested L2CAP_DATAWRITE_FAILED, if error

wiced_bool_t wiced_bt_l2cap_le_set_user_congestion(uint16_t lcid, wiced_bool_t is_congested)

Higher layers call this function to tell if the connection is congested or not.

Parameters
  • lcid[in] : Local CID value

  • is_congested[in] : TRUE, if congested

Returns

TRUE if command processed OK

uint16_t wiced_bt_l2cap_le_get_peer_mtu(uint16_t lcid)

Higher layers call this function to get peer MTU.

Parameters

lcid[in] : Local CID value

Returns

Peer MTU or 0.

uint16_t wiced_bt_l2cap_le_determ_secur_rsp(wiced_bt_device_address_t bd_addr, uint8_t req_secur, uint8_t req_encr_key_size)

Higher layers call this function to check if the current device security settings are sufficient to continue with call establishment.

It is called by call acceptor on reception of LE Credit Based Connection Request.

Parameters
  • bd_addr[in] : BD Address

  • req_secur[in] : Security required

  • req_encr_key_size[in] : Key size

Returns

L2CAP_CONN_OK/L2CAP_BLE_CONN_BAD_AUTHENT/ L2CAP_BLE_CONN_BAD_KEY_SIZE/L2CAP_BLE_CONN_BAD_ENCRYPT/ L2CAP_CONN_NO_RESOURCES.