Infineon Logo AIROC BTSDK v4.4 - Documentation
 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
wiced_bt_l2c.h File Reference

Bluetooth L2CAP Application Programming Interface. More...

Data Structures

struct  wiced_bt_l2cap_fcr_options_t
 Structure for Enhanced Retransmission Mode Options Refer to Volume 3, Part A, section 5.4 of BT Core specification for details. More...
 
struct  wiced_bt_l2cap_cfg_information_t
 Define a structure to hold the configuration parameters. More...
 
struct  wiced_bt_l2cap_appl_information_t
 Define the structure that applications use to register with L2CAP. More...
 
struct  wiced_bt_l2cap_le_appl_information_t
 Define the structure that applications use to register with LE L2CAP. More...
 
struct  wiced_bt_l2cap_fixed_chnl_reg_t
 Fixed channel registration info (the callback addresses and channel config) More...
 
struct  wiced_bt_l2cap_ecrb_cb_ptrs_t
 Structure containing application ECRB callbacks. More...
 

Macros

#define L2CAP_MINIMUM_OFFSET   13
 Minimum offset that L2CAP needs in a buffer. More...
 
#define L2CAP_BLE_CONN_MIN_OFFSET   9
 HCI type(1), len(2), handle(2), L2CAP len(2) and CID(2)
 
#define L2CAP_DEFAULT_BLE_CB_POOL_ID   0xFF
 Use the default HCI ACL buffer pool.
 
#define L2CAP_BLE_COC_SDU_OFFSET   4
 to provide upper layer some minimal offset possibly required to process incoming packets
 
#define L2CAP_BROADCAST_MIN_OFFSET   11
 Minimum offset for broadcast needs another two bytes for the PSM.
 
L2CAP ping result

Ping result codes.

#define L2CAP_PING_RESULT_OK   0
 Ping reply received OK.
 
#define L2CAP_PING_RESULT_NO_LINK   1
 Link could not be setup.
 
#define L2CAP_PING_RESULT_NO_RESPONSE   2
 Remote L2CAP did not reply.
 
L2CAP data write result

Result codes for wiced_bt_l2cap_data_write()

#define L2CAP_DATAWRITE_FAILED   FALSE
 If data not accepted and error.
 
#define L2CAP_DATAWRITE_SUCCESS   TRUE
 If data accepted.
 
#define L2CAP_DATAWRITE_CONGESTED   2
 if data accepted and the channel is congested
 
L2CAP data write flags

Flushable/Non Flushable flags parameter used in a call wiced_bt_l2cap_data_write()

#define L2CAP_FLUSHABLE_MASK   0x0001
 L2CAP Flushable mask.
 
#define L2CAP_NON_FLUSHABLE_PACKET   0x0000
 Non Flushable flag.
 
#define L2CAP_FLUSHABLE_PACKET   0x0001
 Flushable flag.
 
L2CAP PSM

Validity check for PSM. PSM values must be odd. Also, all PSM values must be assigned such that the least significant bit of the most sigificant octet equals zero.

#define L2C_INVALID_PSM(psm)   (((psm) & 0x0101) != 0x0001)
 Returns true on invalid PSM.
 
#define L2C_IS_VALID_PSM(psm)   (((psm) & 0x0101) == 0x0001)
 Returns true on valid PSM.
 
L2CAP channel configuration

L2CAP channel configured field bitmap. Used for wiced_bt_l2cap_ch_cfg_bits_t

#define L2CAP_CH_CFG_MASK_MTU   0x0001
 MTU channel configuration bit mask.
 
#define L2CAP_CH_CFG_MASK_QOS   0x0002
 QOS channel configuration bit mask.
 
#define L2CAP_CH_CFG_MASK_FLUSH_TO   0x0004
 Flush to channel configuration bit mask.
 
#define L2CAP_CH_CFG_MASK_FCR   0x0008
 FCR channel configuration bit mask.
 
#define L2CAP_CH_CFG_MASK_FCS   0x0010
 FCS channel configuration bit mask.
 
#define L2CAP_CH_CFG_MASK_EXT_FLOW_SPEC   0x0020
 Extended flow specification channel configuration bit mask.
 
L2CAP LE PSM

Validity check for LE_PSM. Fixed LE_PSMs are in the range 0x0001 - 0x007F. Dynamic LE_PSM are in the range 0x0080 - 0x00FF. The values 0x0000 and 0x0100 - 0xFFFF are reserved.

#define MINIMIUM_DYNAMIC_LE_PSM   0x0080
 First application dynamic PSM allowed.
 
#define MAXIMUM_LE_PSM   0x00FF
 LE PSM range limit.
 
#define L2C_BLE_INVALID_PSM(le_psm)   (!(le_psm) || (le_psm) > MAXIMUM_LE_PSM)
 Returns true on invalid LE PSM.
 
#define L2C_BLE_IS_VALID_PSM(le_psm)   (((le_psm) != 0) && ((le_psm) <= MAXIMUM_LE_PSM))
 Returns true on valid LE PSM.
 

Typedefs

typedef uint16_t wiced_bt_l2cap_ch_cfg_bits_t
 Channel configuration fields in bit map. More...
 
typedef void( wiced_bt_l2cap_connected_cback_t )(wiced_bt_device_address_t bd_addr, uint16_t local_cid, uint16_t peer_mtu)
 Connection established callback prototype. More...
 
typedef void( wiced_bt_l2cap_disconnect_indication_cback_t )(uint16_t local_cid, uint16_t reason, wiced_bool_t ack)
 Disconnect indication callback prototype. More...
 
typedef void( wiced_bt_l2cap_disconnect_confirm_cback_t )(uint16_t local_cid, uint16_t result)
 Disconnect confirm callback prototype. More...
 
typedef void( wiced_bt_l2cap_data_indication_cback_t )(uint16_t local_cid, tDRB *p_drb)
 Data received indication callback prototype. More...
 
typedef void( wiced_bt_l2cap_tx_complete_cback_t )(uint16_t local_cid, void *p_data)
 Transmit complete callback protype. More...
 
typedef void( wiced_bt_l2cap_fixed_chnl_cback_t )(wiced_bt_device_address_t bd_addr, wiced_bool_t connected, uint16_t reason, wiced_bt_transport_t transport)
 Fixed channel connected and disconnected. More...
 
typedef void( wiced_bt_l2cap_fixed_data_cback_t )(wiced_bt_device_address_t bd_addr, uint8_t *p_data, uint16_t data_len)
 Signalling data received. More...
 
typedef void( wiced_bt_l2cap_le_connect_indication_cback_t )(wiced_bt_device_address_t bd_addr, uint16_t local_cid, uint16_t psm, uint8_t id, uint16_t mtu_peer)
 LE Connection indication callback prototype. More...
 
typedef void( wiced_bt_l2cap_drb_release_cb )(tDRB *p_drb)
 User DRB may be released callback prototype. More...
 
typedef void( wiced_bt_l2cap_le_connect_confirm_cback_t )(uint16_t local_cid, uint16_t result, uint16_t mtu_peer)
 LE Connection confirmation callback prototype. More...
 
typedef void( wiced_bt_l2cap_ecrb_connect_ind )(wiced_bt_device_address_t peer_addr, wiced_bt_transport_t transport, uint16_t psm, wiced_bt_ecrb_cid_list_t lcids, uint8_t id, uint16_t peer_mtu)
 ECRB Application callback for incoming connection requests.
 
typedef void( wiced_bt_l2cap_ecrb_confirm_cb )(uint16_t lcid, uint16_t result, uint16_t peer_mtu)
 ECRB Application callback for outging connection confirms.
 
typedef void( wiced_bt_l2cap_ecrb_mtu_changed_cb )(uint16_t lcid, uint16_t new_mtu, uint16_t new_mps)
 ECRB Application callback for channel MTU size change.
 

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. More...
 
wiced_bool_t wiced_bt_l2cap_deregister_fixed_channel (uint16_t fixed_cid)
 De-register a fixed channel. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
wiced_bool_t wiced_bt_l2cap_ecrb_register (uint16_t psm, wiced_bt_l2cap_ecrb_cb_ptrs_t *p_ecrb_callbacks)
 Application calls this function to register support for enhanced credit-based channels. More...
 
wiced_bool_t wiced_bt_l2cap_ecrb_deregister (uint16_t psm)
 Application calls this function to deregister support for enhanced credit-based channels. More...
 
int wiced_bt_l2cap_ecrb_connect_req (uint16_t psm, wiced_bt_transport_t transport, wiced_bt_device_address_t bd_addr, wiced_bt_ble_address_type_t bd_addr_type, wiced_bt_ble_conn_mode_t conn_mode, uint16_t our_rx_mtu, uint16_t our_rx_mps, int num_channels, tDRB **p_rx_drb_list, wiced_bt_ecrb_cid_list_t lcid_list)
 Higher layers call this function to create up to 5 credit-based L2CAP connections on the same PSM. More...
 
void wiced_bt_l2cap_ecrb_ConnectRsp (uint16_t result, uint8_t trans_id, int16_t our_rx_mtu, uint16_t our_rx_mps, wiced_bt_ecrb_cid_list_t lcid_list, tDRB **p_rx_drb_list)
 Higher layers call this function to accept incoming Enhanced Credit-based L2CAP channel establishment, for which they had gotten a connect indication callback. More...
 
wiced_bool_t wiced_bt_l2cap_ecrb_reconfigure (uint16_t new_rx_mtu, int16_t new_rx_mps, int num_channels, wiced_bt_ecrb_cid_list_t lcid_list, tDRB **p_rx_drb_list)
 Higher layers call this function to reconfigure the MTU and or MPS of Enhanced Credit-based L2CAP channels. More...
 
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. More...
 
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. More...
 
void wiced_bt_l2cap_deregister (uint16_t psm)
 Other layers call this function to deregister for L2CAP services. More...
 
uint16_t wiced_bt_l2cap_allocate_psm (void)
 Other layers call this function to find an unused PSM for L2CAP services. More...
 
wiced_bool_t wiced_bt_l2cap_disconnect_req (uint16_t cid)
 Higher layers call this function to disconnect a channel. More...
 
wiced_bool_t wiced_bt_l2cap_disconnect_rsp (uint16_t cid)
 Higher layers call this function to acknowledge the disconnection of a channel. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
wiced_bool_t wiced_bt_l2cap_cancel_ble_connect_req (wiced_bt_device_address_t rem_bda)
 Cancel a pending connection attempt to a LE device. More...
 
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 LE connection parameters. More...
 
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 LE connection params based on the request from the peer. More...
 
uint8_t wiced_bt_l2cap_get_ble_conn_role (wiced_bt_device_address_t bd_addr)
 This function returns the connection role. More...
 
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. More...
 
wiced_bool_t wiced_bt_l2cap_le_deregister (uint16_t le_psm)
 Other layers call this function to deregister L2CAP services for LE_PSM. More...
 
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. More...
 
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. More...
 
wiced_bool_t wiced_bt_l2cap_le_disconnect_req (uint16_t lcid)
 Higher layers call this function to disconnect a LE COC channel. More...
 
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. More...
 
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. More...
 
wiced_bool_t wiced_bt_l2cap_le_set_user_congestion (uint16_t lcid, wiced_bool_t flow_off_peer)
 App can call this function to flow control data reception from the peer (flow controlled channels only, viz LE COC, ECRB channels) To stop sending credits/flow off the remote peer set flow_off_peer to WICED_TRUE To resume sending credits/flow on set flow_off_peer to WICED_FALSE. More...
 
uint16_t wiced_bt_l2cap_le_get_peer_mtu (uint16_t lcid)
 Higher layers call this function to get peer MTU. More...
 
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. More...
 
int wiced_bt_l2cap_get_num_queued_tx_packets (wiced_bt_device_address_t bd_addr, uint16_t lcid, int *p_fragments_with_controller)
 Utility function to get the number of packets queued to tx. More...
 

Detailed Description

Bluetooth L2CAP Application Programming Interface.

Logical Link Control and Adaptation Layer Protocol, referred to as L2CAP, provides connection oriented and connectionless data services to upper layer protocols with protocol multiplexing capability and segmentation and reassembly operation.

Typedef Documentation

typedef void( wiced_bt_l2cap_connected_cback_t)(wiced_bt_device_address_t bd_addr, uint16_t local_cid, uint16_t peer_mtu)

Connection established callback prototype.

Parameters
bd_addr: BD Address of remote
local_cid: Local CID assigned to the connection
peer_mtu: Peer MTU
Returns
void
typedef void( wiced_bt_l2cap_data_indication_cback_t)(uint16_t local_cid, tDRB *p_drb)

Data received indication callback prototype.

Parameters
local_cid: Local CID
p_drb: Pointer to the data received buffer, check tDRB
Note
: Application is expected to use the data in the callback. Applications should not attempt to free/release the p_drb pointer in this callback, since the buffer will be reused to receive the next incoming packet
Returns
void
typedef void( wiced_bt_l2cap_disconnect_confirm_cback_t)(uint16_t local_cid, uint16_t result)

Disconnect confirm callback prototype.

Parameters
local_cid: Local CID
result: Result
Returns
void
typedef void( wiced_bt_l2cap_disconnect_indication_cback_t)(uint16_t local_cid, uint16_t reason, wiced_bool_t ack)

Disconnect indication callback prototype.

Parameters
local_cid: Local CID
ack: Boolean whether upper layer should ack this
Returns
void
typedef void( wiced_bt_l2cap_drb_release_cb)(tDRB *p_drb)

User DRB may be released callback prototype.

This function address is passed in when the user provides a DRB for an eRTM or LE-COC channel. It is called when the DRB can be released, i.e. at the end of the connection.

Parameters
p_drb: Address of the DRB that can be released
Returns
void
typedef void( wiced_bt_l2cap_fixed_chnl_cback_t)(wiced_bt_device_address_t bd_addr, wiced_bool_t connected, uint16_t reason, wiced_bt_transport_t transport)

Fixed channel connected and disconnected.

Parameters
bd_addr: BD Address of remote
connected: TRUE if channel is connected, FALSE if disconnected
reason: Reason for connection failure
transport: Bluetooth Transport (BR/EDR or LE)
Returns
void
typedef void( wiced_bt_l2cap_fixed_data_cback_t)(wiced_bt_device_address_t bd_addr, uint8_t *p_data, uint16_t data_len)

Signalling data received.

Parameters
bd_addr: BD Address of remote
p_buff: Pointer to data
data_len: Data length
Returns
void
typedef void( wiced_bt_l2cap_le_connect_confirm_cback_t)(uint16_t local_cid, uint16_t result, uint16_t mtu_peer)

LE Connection confirmation callback prototype.

Parameters
local_cid: Local CID
result: Result - 0 = connected, non-zero means failure reason
mtu_peer: MTU of the peer
Returns
void
typedef void( wiced_bt_l2cap_le_connect_indication_cback_t)(wiced_bt_device_address_t bd_addr, uint16_t local_cid, uint16_t psm, uint8_t id, uint16_t mtu_peer)

LE Connection indication callback prototype.

Parameters
bd_addr: BD Address of remote
local_cid: Local CID assigned to the connection
psm: PSM that the remote wants to connect to
id: Identifier that the remote sent
mtu_peer: MTU of the peer
Returns
void
typedef void( wiced_bt_l2cap_tx_complete_cback_t)(uint16_t local_cid, void *p_data)

Transmit complete callback protype.

This callback is optional. If set, L2CAP will call it when packets are sent or flushed. If the count is 0xFFFF, it means all packets are sent for that CID (eRTM mode only).

Parameters
local_cid: Local CID
p_buff: Pointer to the data that was sent
Returns
void

Function Documentation

int wiced_bt_l2cap_get_num_queued_tx_packets ( wiced_bt_device_address_t  bd_addr,
uint16_t  lcid,
int *  p_fragments_with_controller 
)

Utility function to get the number of packets queued to tx.

Parameters
[in]bd_addrbluetooth address of the peer device
[in]lcid: local_cid
[out]p_fragments_with_controller: fragments with the controller
Returns
number of packets queued to tx