Mistake on this page? Email us
Data Structures | Macros | Typedefs

Data Structures

struct  l2cCocReg_t
 Connection oriented channel registration structure. More...
 
struct  l2cCocConnectInd_t
 Connection oriented channel connect indication structure. More...
 
struct  l2cCocDisconnectInd_t
 Connection oriented channel disconnect indication structure. More...
 
struct  l2cCocDataInd_t
 Connection oriented channel data indication structure. More...
 
struct  l2cCocDataCnf_t
 Connection oriented channel disconnect indication structure. More...
 
union  l2cCocEvt_t
 Connection oriented channel event structure. More...
 
struct  l2cCfg_t
 Configurable parameters. More...
 

Macros

#define L2C_COC_REG_ID_NONE   0
 Invalid channel registration ID for connection oriented channels.
 
#define L2C_COC_CID_NONE   0
 Invalid channel ID for connection oriented channels.
 
#define L2C_SIGNAL_ID_INVALID   0
 Invalid signal identifier.
 
#define L2C_PAYLOAD_START   (HCI_ACL_HDR_LEN + L2C_HDR_LEN)
 Start of L2CAP payload in an HCI ACL packet buffer.
 
#define L2C_SIG_PKT_BASE_LEN   (HCI_ACL_HDR_LEN + L2C_HDR_LEN + L2C_SIG_HDR_LEN)
 L2CAP signaling packet base length, including HCI header.
 
#define L2C_LE_SDU_PKT_BASE_LEN   (HCI_ACL_HDR_LEN + L2C_HDR_LEN + L2C_LE_SDU_HDR_LEN)
 L2CAP LE SDU packet base length, including HCI header.
 
#define L2C_SIG_RSP_FLAG   0x01
 Signaling response code flag.
 

Typedefs

typedef uint16_t l2cCocRegId_t
 Connection oriented channel registration ID.
 
typedef void(* l2cDataCback_t) (uint16_t handle, uint16_t len, uint8_t *pPacket)
 This callback function sends a received L2CAP packet to the client. More...
 
typedef void(* l2cCtrlCback_t) (wsfMsgHdr_t *pMsg)
 This callback function sends control messages to the client. More...
 
typedef void(* l2cCocCback_t) (l2cCocEvt_t *pMsg)
 This callback function sends data and other events to connection oriented channels clients. More...
 
typedef uint16_t(* l2cCocAuthorCback_t) (dmConnId_t connId, l2cCocRegId_t regId, uint16_t psm)
 This callback function is used for authoriztion of connection oriented channels. More...
 

L2CAP Control Callback Events

Control callback message events

#define L2C_CTRL_FLOW_ENABLE_IND   0
 Data flow enabled.
 
#define L2C_CTRL_FLOW_DISABLE_IND   1
 Data flow disabled.
 

L2CAP COC Channel Roles

Connection oriented channel initiator/acceptor role

#define L2C_COC_ROLE_NONE   0x00
 No role (unallocated)
 
#define L2C_COC_ROLE_INITIATOR   0x01
 Channel initiator.
 
#define L2C_COC_ROLE_ACCEPTOR   0x02
 Channel acceptor.
 

L2CAP COC Data Confirm Codes

Connection oriented channel data confirm status values

#define L2C_COC_DATA_SUCCESS   0
 Data request successful.
 
#define L2C_COC_DATA_ERR_MEMORY   1
 Out of memory.
 
#define L2C_COC_DATA_ERR_OVERFLOW   2
 Transaction overflow.
 

L2CAP COC Callback Events

Connection oriented channel callback events.

enum  { L2C_COC_CONNECT_IND = L2C_COC_CBACK_START, L2C_COC_DISCONNECT_IND, L2C_COC_DATA_IND, L2C_COC_DATA_CNF }
 COC callback events. More...
 
#define L2C_COC_CBACK_START   0x70
 L2C callback event starting value.
 
#define L2C_COC_CBACK_CBACK_END   L2C_COC_DATA_CNF
 L2C callback event ending value.
 

L2CAP Initialization

Initialization and registration functions

void L2cInit (void)
 Initialize L2C subsystem. More...
 
void L2cMasterInit (void)
 Initialize L2C for operation as a Bluetooth LE master. More...
 
void L2cSlaveInit (void)
 Initialize L2C for operation as a Bluetooth LE slave. More...
 

L2CAP CID Functions

Register and send data over a CID

void L2cRegister (uint16_t cid, l2cDataCback_t dataCback, l2cCtrlCback_t ctrlCback)
 called by the L2C client, such as ATT or SMP, to register for the given CID. More...
 
void L2cDataReq (uint16_t cid, uint16_t handle, uint16_t len, uint8_t *pL2cPacket)
 Send an L2CAP data packet on the given CID. More...
 
void L2cDmSigReq (uint16_t handle, uint8_t code, uint16_t len, uint8_t *pParam)
 Build and send a signaling packet. More...
 

L2CAP COC Functions

Connection Oriented Channels Functions

void L2cCocInit (void)
 Initialize L2C connection oriented channel subsystem. More...
 
l2cCocRegId_t L2cCocRegister (l2cCocCback_t cback, l2cCocReg_t *pReg)
 Register to use a connection oriented channel, as either a channel acceptor, initiator, or both. If registering as channel acceptor then the PSM is specified. After registering a connection can be established by the client using this registration instance. More...
 
void L2cCocDeregister (l2cCocRegId_t regId)
 Deregister and deallocate a connection oriented channel registration instance. This function should only be called if there are no active channels using this registration instance. More...
 
uint16_t L2cCocConnectReq (dmConnId_t connId, l2cCocRegId_t regId, uint16_t psm)
 Initiate a connection to the given peer PSM. More...
 
void L2cCocDisconnectReq (uint16_t cid)
 Disconnect the channel for the given CID. More...
 
void L2cCocDataReq (uint16_t cid, uint16_t len, uint8_t *pPayload)
 Send an L2CAP data packet on the given connection oriented CID. More...
 
void L2cCocErrorTest (uint16_t result)
 For testing purposes only. More...
 
void L2cCocCreditSendTest (uint16_t cid, uint16_t credits)
 For testing purposes only. More...
 

L2CAP Connection Parameter Update Functions

void L2cDmConnUpdateReq (uint16_t handle, hciConnSpec_t *pConnSpec)
 For internal use only. This function is called by DM to send an L2CAP connection update request. More...
 
void L2cDmConnUpdateRsp (uint8_t identifier, uint16_t handle, uint16_t result)
 For internal use only. This function is called by DM to send an L2CAP connection update response. More...
 

L2CAP Packet Constants

#define L2C_HDR_LEN   4
 L2CAP packet header length.
 
#define L2C_MIN_MTU   23
 Minimum packet payload MTU for LE.
 
#define L2C_SIG_HDR_LEN   4
 L2CAP signaling command header length.
 
#define L2C_LE_SDU_HDR_LEN   2
 L2CAP LE SDU data header length.
 

L2CAP Parameter Lengths

Signaling packet parameter lengths

#define L2C_SIG_CONN_UPDATE_REQ_LEN   8
 Connection update request length.
 
#define L2C_SIG_CONN_UPDATE_RSP_LEN   2
 Connection update response length.
 
#define L2C_SIG_CMD_REJ_LEN   2
 Command reject length.
 
#define L2C_SIG_DISCONN_REQ_LEN   4
 Disconnection request length.
 
#define L2C_SIG_DISCONN_RSP_LEN   4
 Disconnection response length.
 
#define L2C_SIG_LE_CONN_REQ_LEN   10
 LE connection request length.
 
#define L2C_SIG_LE_CONN_RSP_LEN   10
 LE connection response length.
 
#define L2C_SIG_FLOW_CTRL_CREDIT_LEN   4
 Flow control credit lenghth.
 

L2CAP Connection Identifiers

BLE Defined Connection Identifiers (CID)

#define L2C_CID_ATT   0x0004
 CID for attribute protocol.
 
#define L2C_CID_LE_SIGNALING   0x0005
 CID for LE signaling.
 
#define L2C_CID_SMP   0x0006
 CID for security manager protocol.
 

L2CAP Signaling Codes

#define L2C_SIG_CMD_REJ   0x01
 Comand reject.
 
#define L2C_SIG_DISCONNECT_REQ   0x06
 Disconnect request.
 
#define L2C_SIG_DISCONNECT_RSP   0x07
 Disconnect response.
 
#define L2C_SIG_CONN_UPDATE_REQ   0x12
 Connection parameter update request.
 
#define L2C_SIG_CONN_UPDATE_RSP   0x13
 Connection parameter update response.
 
#define L2C_SIG_LE_CONNECT_REQ   0x14
 LE credit based connection request.
 
#define L2C_SIG_LE_CONNECT_RSP   0x15
 LE credit based connection response.
 
#define L2C_SIG_FLOW_CTRL_CREDIT   0x16
 LE flow control credit.
 

L2CAP Command Rejection Codes

BLE defined Command rejection reason codes

#define L2C_REJ_NOT_UNDERSTOOD   0x0000
 Command not understood.
 
#define L2C_REJ_MTU_EXCEEDED   0x0001
 Signaling MTU exceeded.
 
#define L2C_REJ_INVALID_CID   0x0002
 Invalid CID in request.
 

L2CAP Connection Parameter Update Result Codes

BLE defined result codes

#define L2C_CONN_PARAM_ACCEPTED   0x0000
 Connection parameters accepted.
 
#define L2C_CONN_PARAM_REJECTED   0x0001
 Connection parameters rejected.
 

L2CAP Connection Result Codes

BLE defined result codes

#define L2C_CONN_SUCCESS   0x0000
 Connection successful.
 
#define L2C_CONN_NONE   0x0001
 No connection result value available.
 
#define L2C_CONN_FAIL_PSM   0x0002
 Connection refused LE_PSM not supported.
 
#define L2C_CONN_FAIL_RES   0x0004
 Connection refused no resources available.
 
#define L2C_CONN_FAIL_AUTH   0x0005
 Connection refused insufficient authentication.
 
#define L2C_CONN_FAIL_AUTHORIZ   0x0006
 Connection refused insufficient authorization.
 
#define L2C_CONN_FAIL_KEY_SIZE   0x0007
 Connection refused insufficient encryption key size.
 
#define L2C_CONN_FAIL_ENC   0x0008
 Connection Refused insufficient encryption.
 
#define L2C_CONN_FAIL_INVALID_SCID   0x0009
 Connection refused invalid source CID.
 
#define L2C_CONN_FAIL_ALLOCATED_SCID   0x000A
 Connection refused source CID already allocated.
 
#define L2C_CONN_FAIL_UNACCEPT_PARAM   0x000B
 Connection refused unacceptable parameters.
 

L2CAP Interal Connection Result Codes

Proprietary codes not sent in any L2CAP packet.

#define L2C_CONN_FAIL_TIMEOUT   0xF000
 Request timeout.
 

L2CAP Signaling Parameter Value Ranges

#define L2C_PSM_MIN   0x0001
 PSM minimum.
 
#define L2C_PSM_MAX   0x00FF
 PSM maximum.
 
#define L2C_CID_DYN_MIN   0x0040
 CID dynamic minimum.
 
#define L2C_CID_DYN_MAX   0x007F
 CID dynamic maximum.
 
#define L2C_MTU_MIN   0x0017
 MTU minimum.
 
#define L2C_MPS_MIN   0x0017
 MPS minimum.
 
#define L2C_MPS_MAX   0xFFFD
 MPS maximum.
 
#define L2C_CREDITS_MAX   0xFFFF
 Credits maximum.
 

Detailed Description

Typedef Documentation

typedef void(* l2cDataCback_t) (uint16_t handle, uint16_t len, uint8_t *pPacket)

This callback function sends a received L2CAP packet to the client.

Parameters
handleThe connection handle.
lenThe length of the L2CAP payload data in pPacket.
pPacketA buffer containing the packet.
Returns
None.

Definition at line 202 of file l2c_api.h.

typedef void(* l2cCtrlCback_t) (wsfMsgHdr_t *pMsg)

This callback function sends control messages to the client.

Parameters
pMsgPointer to message structure.
Returns
None.

Definition at line 213 of file l2c_api.h.

typedef void(* l2cCocCback_t) (l2cCocEvt_t *pMsg)

This callback function sends data and other events to connection oriented channels clients.

Parameters
pMsgPointer to message structure.
Returns
None.

Definition at line 225 of file l2c_api.h.

typedef uint16_t(* l2cCocAuthorCback_t) (dmConnId_t connId, l2cCocRegId_t regId, uint16_t psm)

This callback function is used for authoriztion of connection oriented channels.

Parameters
connIdDM connection ID.
regIdThe registration instance requiring authorization.
psmThe PSM of the registration instance.
Returns
L2C_CONN_SUCCESS if authorization is successful, any other value for failure.

Definition at line 238 of file l2c_api.h.

Enumeration Type Documentation

anonymous enum

COC callback events.

Enumerator
L2C_COC_CONNECT_IND 

Channel connect indication.

L2C_COC_DISCONNECT_IND 

Channel disconnect indication.

L2C_COC_DATA_IND 

Received data indication.

L2C_COC_DATA_CNF 

Transmit data confirm.

Definition at line 77 of file l2c_api.h.

78 {
79  L2C_COC_CONNECT_IND = L2C_COC_CBACK_START, /*!< \brief Channel connect indication */
80  L2C_COC_DISCONNECT_IND, /*!< \brief Channel disconnect indication */
81  L2C_COC_DATA_IND, /*!< \brief Received data indication */
82  L2C_COC_DATA_CNF /*!< \brief Transmit data confirm */
83 };
Received data indication.
Definition: l2c_api.h:81
Transmit data confirm.
Definition: l2c_api.h:82
Channel connect indication.
Definition: l2c_api.h:79
#define L2C_COC_CBACK_START
L2C callback event starting value.
Definition: l2c_api.h:75
Channel disconnect indication.
Definition: l2c_api.h:80

Function Documentation

void L2cInit ( void  )

Initialize L2C subsystem.

Returns
None.
void L2cMasterInit ( void  )

Initialize L2C for operation as a Bluetooth LE master.

Returns
None.
void L2cSlaveInit ( void  )

Initialize L2C for operation as a Bluetooth LE slave.

Returns
None.
void L2cRegister ( uint16_t  cid,
l2cDataCback_t  dataCback,
l2cCtrlCback_t  ctrlCback 
)

called by the L2C client, such as ATT or SMP, to register for the given CID.

Parameters
cidchannel identifier.
dataCbackCallback function for L2CAP data received for this CID.
ctrlCbackCallback function for control events for this CID.
Returns
None.
void L2cDataReq ( uint16_t  cid,
uint16_t  handle,
uint16_t  len,
uint8_t *  pL2cPacket 
)

Send an L2CAP data packet on the given CID.

Parameters
cidThe channel identifier.
handleThe connection handle. The client receives this handle from DM.
lenThe length of the payload data in pPacket.
pL2cPacketA buffer containing the packet.
Returns
None.
void L2cDmSigReq ( uint16_t  handle,
uint8_t  code,
uint16_t  len,
uint8_t *  pParam 
)

Build and send a signaling packet.

Parameters
handleThe connection handle.
codeType of command.
lenLength of the parameter.
pParamparameters of command to send.
Returns
None.
void L2cCocInit ( void  )

Initialize L2C connection oriented channel subsystem.

Returns
None.
l2cCocRegId_t L2cCocRegister ( l2cCocCback_t  cback,
l2cCocReg_t pReg 
)

Register to use a connection oriented channel, as either a channel acceptor, initiator, or both. If registering as channel acceptor then the PSM is specified. After registering a connection can be established by the client using this registration instance.

Parameters
cbackClient callback function.
pRegRegistration parameter structure.
Returns
Registration instance ID or L2C_COC_REG_ID_NONE if registration failed.
void L2cCocDeregister ( l2cCocRegId_t  regId)

Deregister and deallocate a connection oriented channel registration instance. This function should only be called if there are no active channels using this registration instance.

Parameters
regIdRegistration instance ID.
Returns
None.
uint16_t L2cCocConnectReq ( dmConnId_t  connId,
l2cCocRegId_t  regId,
uint16_t  psm 
)

Initiate a connection to the given peer PSM.

Parameters
connIdDM connection ID.
regIdThe associated registration instance.
psmPeer PSM.
Returns
Local CID or L2C_COC_CID_NONE none if failure.
void L2cCocDisconnectReq ( uint16_t  cid)

Disconnect the channel for the given CID.

Parameters
cidChannel ID.
Returns
None.
void L2cCocDataReq ( uint16_t  cid,
uint16_t  len,
uint8_t *  pPayload 
)

Send an L2CAP data packet on the given connection oriented CID.

Parameters
cidThe local channel identifier.
lenThe length of the payload data in pPacket.
pPayloadPacket payload data.
Returns
None.
void L2cCocErrorTest ( uint16_t  result)

For testing purposes only.

Parameters
resultResult code
Returns
None.
void L2cCocCreditSendTest ( uint16_t  cid,
uint16_t  credits 
)

For testing purposes only.

Parameters
cidThe local channel identifier.
creditsCredits to send.
Returns
None.
void L2cDmConnUpdateReq ( uint16_t  handle,
hciConnSpec_t pConnSpec 
)

For internal use only. This function is called by DM to send an L2CAP connection update request.

Parameters
handleThe connection handle.
pConnSpecPointer to the connection specification structure.
Returns
None.
void L2cDmConnUpdateRsp ( uint8_t  identifier,
uint16_t  handle,
uint16_t  result 
)

For internal use only. This function is called by DM to send an L2CAP connection update response.

Parameters
identifierIdentifier value previously passed from L2C to DM.
handleThe connection handle.
resultConnection update response result.
Returns
None.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.