Common

group l2cap_common_api_functions

Commonly used API’s for both BE/EDR and LE L2CAP.

Functions

wiced_bool_t wiced_bt_l2cap_register_fixed_channel(uint16_t fixed_cid, wiced_bt_l2cap_fixed_chnl_reg_t *p_freg)

Register a fixed channel.

Parameters
  • fixed_cid[in] : Fixed Channel #

  • p_freg[in] : Channel Callbacks and config

Returns

TRUE if registered OK

wiced_bool_t wiced_bt_l2cap_connect_fixed_chnl(uint16_t fixed_cid, wiced_bt_device_address_t bd_addr, wiced_bt_ble_address_type_t ble_addr_type)

Connect an fixed signalling channel to a remote device.

Parameters
  • fixed_cid[in] : Fixed CID

  • bd_addr[in] : BD Address of remote

  • ble_addr_type[in] : Address type

Returns

TRUE if connection started

uint16_t wiced_bt_l2cap_send_fixed_chnl_data(uint16_t fixed_cid, wiced_bt_device_address_t rem_bda, uint8_t *p_data, uint16_t data_len)

Write data on a fixed signalling channel.

Parameters
  • fixed_cid[in] : Fixed CID

  • rem_bda[in] : BD Address of remote

  • p_data[in] : Pointer to data to send

  • data_len[in] : Length of data to send

Returns

L2CAP_DATAWRITE_SUCCESS, if data accepted L2CAP_DATAWRITE_FAILED, if error

wiced_bool_t wiced_bt_l2cap_remove_fixed_chnl(uint16_t fixed_cid, wiced_bt_device_address_t rem_bda)

Remove a fixed channel to a remote device.

Parameters
  • fixed_cid[in] : Fixed CID

  • rem_bda[in] : BD Address of remote Idle timeout to use (or 0xFFFF if don’t care)

Returns

TRUE if channel removed

wiced_bool_t wiced_bt_l2cap_set_fixed_channel_timeout(wiced_bt_device_address_t rem_bda, uint16_t fixed_cid, uint16_t idle_timeout)

Higher layers call this function to set the idle timeout for a fixed channel.

The “idle timeout” is the amount of time that a connection can remain up with no L2CAP channels on it. A timeout of zero means that the connection will be torn down immediately when the last channel is removed. A timeout of 0xFFFF means no timeout. Values are in seconds. A bd_addr is the remote BD address. If bd_addr = BT_BD_ANY, then the idle timeouts for all active l2cap links will be changed.

Parameters
  • rem_bda[in] : Remote BD address

  • fixed_cid[in] : Fixed CID

  • idle_timeout[in] : Idle timeout

Returns

TRUE if command succeeded, FALSE if failed

wiced_bool_t wiced_bt_l2cap_get_current_config(uint16_t lcid, wiced_bt_l2cap_cfg_information_t **pp_our_cfg, wiced_bt_l2cap_ch_cfg_bits_t *p_our_cfg_bits, wiced_bt_l2cap_cfg_information_t **pp_peer_cfg, wiced_bt_l2cap_ch_cfg_bits_t *p_peer_cfg_bits)

This function returns configurations of L2CAP channel.

Parameters
  • lcid[in] : Local CID

  • pp_our_cfg[in] : pointer of our saved configuration options

  • p_our_cfg_bits[in] : valid config in bitmap

  • pp_peer_cfg[in] : pointer of peer’s saved configuration options

  • p_peer_cfg_bits[in] : valid config in bitmap

Returns

TRUE if successful

uint16_t wiced_bt_l2cap_register(uint16_t psm, wiced_bt_l2cap_appl_information_t *p_cb_information)

Other layers call this function to register for L2CAP services.

Parameters
  • psm[in] : PSM value

  • p_cb_information[in] : L2CAP cb info

Returns

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

void wiced_bt_l2cap_deregister(uint16_t psm)

Other layers call this function to deregister for L2CAP services.

Parameters

psm[in] : PSM value

Returns

void

uint16_t wiced_bt_l2cap_allocate_psm(void)

Other layers call this function to find an unused PSM for L2CAP services.

Returns

PSM to use.

wiced_bool_t wiced_bt_l2cap_disconnect_req(uint16_t cid)

Higher layers call this function to disconnect a channel.

Parameters

cid[in] : CID value

Returns

TRUE if disconnect sent, else FALSE

wiced_bool_t wiced_bt_l2cap_disconnect_rsp(uint16_t cid)

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

Parameters

cid[in] : CID value

Returns

void

uint8_t wiced_bt_l2cap_data_write(uint16_t cid, uint8_t *p_buf, uint16_t buf_len, uint16_t flags)

Higher layers call this function to write data with extended.

Parameters
  • cid[in] : CID value

  • p_buf[in] : Input buffer

  • buf_len[in] : p_buf buffer size

  • flags[in] : refer L2CAP data write flags

Returns

refer L2CAP data write result

wiced_bool_t wiced_bt_l2cap_set_idle_timeout(uint16_t cid, uint16_t timeout, wiced_bool_t is_global)

Higher layers call this function to set the idle timeout for a connection, or for all future connections.

The “idle timeout” is the amount of time that a connection can remain up with no L2CAP channels on it. A timeout of zero means that the connection will be torn down immediately when the last channel is removed. A timeout of 0xFFFF means no timeout. Values are in seconds.

Parameters
  • cid[in] : CID value

  • timeout[in] : Timeout value

  • is_global[in] : TRUE, if global

Returns

TRUE if command succeeded, FALSE if failed

wiced_bool_t wiced_bt_l2cap_set_idle_timeout_by_bd_addr(wiced_bt_device_address_t bd_addr, uint16_t timeout, wiced_bt_transport_t transport)

Higher layers call this function to set the idle timeout for a connection.

The “idle timeout” is the amount of time that a connection can remain up with no L2CAP channels on it. A timeout of zero means that the connection will be torn down immediately when the last channel is removed. A timeout of 0xFFFF means no timeout. Values are in seconds. A bd_addr is the remote BD address. If bd_addr = BT_BD_ANY, then the idle timeouts for all active l2cap links will be changed.

note

This timeout applies to all logical channels active on the ACL link.

Parameters
  • bd_addr[in] : BD Address

  • timeout[in] : Timeout value

  • transport[in] : Transport (BR-EDR or LE)

Returns

TRUE if command succeeded, FALSE if failed

uint8_t wiced_bt_l2cap_set_trace_level(uint8_t trace_level)

This function sets the trace level for L2CAP.

If called with a value of 0xFF, it simply reads the current trace level.

Parameters

trace_level[in] Trace level

Returns

the new (current) trace level

wiced_bool_t wiced_bt_l2cap_get_bdaddrby_handle(uint16_t handle, wiced_bt_device_address_t bd_addr)

Get BD address for the given HCI handle.

Parameters
  • handle[in] : HCI handle

  • bd_addr[in] : Peer Bd Address

Returns

: TRUE if found lcb for the given handle, FALSE otherwise

uint16_t wiced_bt_l2cap_get_disconnect_reason(wiced_bt_device_address_t remote_bda, wiced_bt_transport_t transport)

This function returns the disconnect reason code.

Parameters
  • remote_bda[in] : Remote BD Address

  • transport[in] : Transport (BR-EDR or LE)

Returns

disconnect reason