Infineon Logo AIROC BTSDK v4.9 - Documentation
 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Logical Link Control and Adaptation Protocol (L2CAP)

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. 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 Bluetooth 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_ertm_information_t
 Structure that applications use to create or accept connections with enhanced retransmission mode. 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...
 

Modules

 BR/EDR
 API's used for BR/EDR L2CAP.
 
 Common
 Commonly used API's for both BE/EDR and LE L2CAP.
 
 LE
 API's used for LE L2CAP.
 

Macros

#define L2CAP_ECRB_MAX_CHANNELS_PER_CMD   5
 ECRB Max Channels per Command.
 
#define L2CAP_ECRB_MIN_MTU   64
 ECRB Min MTU.
 
#define L2CAP_ECRB_MIN_MPS   64
 ECRB Min MPS.
 
#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.
 

Typedefs

typedef uint16_t wiced_bt_l2cap_ch_cfg_bits_t
 Channel configuration fields in bit map. More...
 
typedef uint8_t wiced_bt_l2cap_chnl_priority_t
 Values for priority parameter to wiced_bt_l2cap_set_tx_priority(). 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...
 

L2CAP connection result codes

L2CAP connection result codes.

#define L2CAP_CONN_OK   0
 Connection OK.
 
#define L2CAP_CONN_PENDING   1
 Connection Pending.
 
#define L2CAP_CONN_NO_PSM   2
 Connection NO PSM.
 
#define L2CAP_CONN_SECURITY_BLOCK   3
 Connection Security Block.
 
#define L2CAP_CONN_NO_RESOURCES   4
 Connection NO Resource.
 
#define L2CAP_CONN_BAD_CTLR_ID   5
 Bad Controller ID. More...
 
#define L2CAP_BLE_CONN_BAD_AUTHENT   5
 LE Connection Bad Authentication.
 
#define L2CAP_BLE_CONN_BAD_AUTHORIZ   6
 LE Connection Bad Autherization.
 
#define L2CAP_BLE_CONN_BAD_KEY_SIZE   7
 LE Connection Bad key size.
 
#define L2CAP_BLE_CONN_BAD_ENCRYPT   8
 LE Connection Bad Encryption.
 

L2CAP ECRB Result Code

L2CAP ECRB Result Code

#define L2CAP_ECRB_ALL_CONNS_SUCCESSFUL   0x0000
 All Connections Successful.
 
#define L2CAP_ECRB_ALL_CONNS_REFUSED   0x0002
 All Connections Refused.
 
#define L2CAP_ECRB_SOME_CONNS_REFUSED   0x0004
 Some Connections Refused.
 
#define L2CAP_ECRB_INSUFF_AUTHENTICATION   0x0005
 Insufficient Authentication.
 
#define L2CAP_ECRB_INSUFF_AUTHORIZATION   0x0006
 Insufficient Autherization.
 
#define L2CAP_ECRB_INSUFF_KEY_SIZE   0x0007
 Insufficient Key size.
 
#define L2CAP_ECRB_INSUFF_ENCRYPTION   0x0008
 Insufficient Encryption.
 
#define L2CAP_ECRB_INVALID_SOURCE_CID   0x0009
 Invalid Source CID.
 
#define L2CAP_ECRB_SOURCE_CID_IN_USE   0x000A
 Source CID in Used.
 
#define L2CAP_ECRB_UNACCEPTABLE_PARAMS   0x000B
 Unacceptable Params.
 
#define L2CAP_ECRB_INVALID_PARAMS   0x000C
 Invalid Params.
 
#define L2CAP_ECRB_RECONFIG_SUCCESSFUL   0x0000
 Reconfiguration Successful.
 
#define L2CAP_ECRB_RECONFIG_FAIL_BAD_MTU   0x0001
 Reconfiguration fail : Bad MTU.
 
#define L2CAP_ECRB_RECONFIG_FAIL_BAD_MPS   0x0002
 Reconfiguration fail : Bad MPS.
 
#define L2CAP_ECRB_RECONFIG_FAIL_BAD_DCID   0x0003
 Reconfiguration fail : Bad DCID.
 
#define L2CAP_ECRB_RECONFIG_FAIL_OTHER   0x0004
 Reconfiguration fail : Other Reason.
 
#define L2CAP_ECRB_NOT_SUPPORTED_BY_PEER   0xF000
 Not Supported by Peer.
 

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 FCR Mode

L2CAP FCR mode configuring options and allowed modes bit mask. From below, first 3 used as a field wiced_bt_l2cap_fcr_options_t::mode and reamining used as a bit mask field wiced_bt_l2cap_ertm_information_t::allowed_modes

#define L2CAP_FCR_BASIC_MODE   0x00
 Basic mode (no FCR)
 
#define L2CAP_FCR_ERTM_MODE   0x03
 ERTM mode.
 
#define L2CAP_FCR_STREAM_MODE   0x04
 Streaming mode.
 
#define L2CAP_FCR_CHAN_OPT_BASIC   (1 << L2CAP_FCR_BASIC_MODE)
 Basic mode (no FCR) bit mask.
 
#define L2CAP_FCR_CHAN_OPT_ERTM   (1 << L2CAP_FCR_ERTM_MODE)
 ERTM mode bit mask.
 
#define L2CAP_FCR_CHAN_OPT_STREAM   (1 << L2CAP_FCR_STREAM_MODE)
 Streaming mode bit mask.
 
#define L2CAP_FCR_CHAN_OPT_ALL_MASK   (L2CAP_FCR_CHAN_OPT_BASIC | L2CAP_FCR_CHAN_OPT_ERTM | L2CAP_FCR_CHAN_OPT_STREAM)
 Mask for all modes Basic, ERTM and Streaming.
 

L2CAP flush channels

L2CAP flush channel and num_to_flush parameter used in a call wiced_bt_l2cap_flush_channel()

#define L2CAP_FLUSH_CHANNELS_ALL   0xffff
 To flush all queued buffers.
 
#define L2CAP_FLUSH_CHANNELS_GET   0x0000
 To get queued buffers to flush.
 

L2CAP role

L2CAP role and new_role parameter used in a call wiced_bt_l2cap_set_desire_role()

Note
L2CAP_ROLE_SCATTERNET_ALLOWED bit is used to prevent l2CAP to Automatically perform role switch (for both Incoming and outgoing) ACL connections.
#define L2CAP_ROLE_PERIPHERAL   HCI_ROLE_PERIPHERAL
 L2CAP Peripheral role.
 
#define L2CAP_ROLE_CENTRAL   HCI_ROLE_CENTRAL
 L2CAP Central role.
 
#define L2CAP_ROLE_ALLOW_SWITCH   0x80
 set this bit to allow switch at create conn
 
#define L2CAP_ROLE_DISALLOW_SWITCH   0x40
 set this bit to disallow switch at create conn
 
#define L2CAP_ROLE_CHECK_SWITCH   0xC0
 To check the switch to allow or disallow.
 
#define L2CAP_ROLE_SCATTERNET_ALLOWED   0x20
 set this bit to allow scatternet
 

L2CAP ACL Priority Value

Values for priority parameter to wiced_bt_l2cap_set_acl_priority() and wiced_bt_l2cap_set_acl_priority_ext().

#define L2CAP_PRIORITY_NORMAL   0
 Set ACL priority as normal.
 
#define L2CAP_PRIORITY_HIGH   1
 Set ACL priority as high.
 

L2CAP ACL Priority Direction

Values for direction parameter to wiced_bt_l2cap_set_acl_priority_ext()

#define L2CAP_DIRECTION_IGNORE   0
 Set ACL priority direction as ignore.
 
#define L2CAP_DIRECTION_DATA_SOURCE   1
 Set ACL priority direction as source.
 
#define L2CAP_DIRECTION_DATA_SINK   2
 Set ACL priority direction as sink.
 

L2CAP transmission channel priority

L2CAP channel transmission priority. Used for wiced_bt_l2cap_chnl_priority_t

#define L2CAP_CHNL_PRIORITY_HIGH   0
 Transmission priority as high for a channel (FCR Mode)
 
#define L2CAP_CHNL_PRIORITY_MEDIUM   1
 Transmission priority as medium for a channel (FCR Mode)
 
#define L2CAP_CHNL_PRIORITY_LOW   2
 Transmission priority as low for a channel (FCR Mode)
 

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.
 

Detailed Description

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.

Macro Definition Documentation

#define L2CAP_CONN_BAD_CTLR_ID   5

Bad Controller ID.

Note
AMP related
#define L2CAP_MINIMUM_OFFSET   13

Minimum offset that L2CAP needs in a buffer.

This is made up of HCI type(1), len(2), handle(2), L2CAP len(2), CID(2), control(2) and SDU length(2)

Typedef Documentation

Channel configuration fields in bit map.

Refer L2CAP channel configuration

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_buff: Pointer to the data
buf_len: Length of the data
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