TI BLE-Stack for Bluetooth 4.2 API Documentation  3.01.00.07
Modules | Files | Functions
L2CAP

This module implements the Logical Link Control and Adaption Protocol For a detailed usage section describing how to send these commands and receive events, see the L2CAP Section of the User's Guide. More...

Modules

 L2CAP Callbacks
 
 L2CAP Constants
 
 L2CAP Data Structures
 
 L2CAP Events
 

Files

file  l2cap.h
 L2CAP layer interface.
 

Functions

void * L2CAP_bm_alloc (uint16 size)
 L2CAP implementation of the allocator functionality. More...
 
uint16 L2CAP_BuildCmdReject (uint8 *pBuf, uint8 *pCmd)
 Build Command Reject. More...
 
uint16 L2CAP_BuildConnectReq (uint8 *pBuf, uint8 *pData)
 Build Connection Request. More...
 
uint16 L2CAP_BuildInfoRsp (uint8 *pBuf, uint8 *pData)
 Build Information Response. More...
 
uint16 L2CAP_BuildParamUpdateRsp (uint8 *pBuf, uint8 *pData)
 Build Connection Parameter Update Response. More...
 
bStatus_t L2CAP_ChannelInfo (uint16 CID, l2capChannelInfo_t *pInfo)
 Get information about a given active Connection Oriented Channel. More...
 
bStatus_t L2CAP_CmdReject (uint16 connHandle, uint8 id, l2capCmdReject_t *pCmdReject)
 Send Command Reject. More...
 
bStatus_t L2CAP_ConnectReq (uint16 connHandle, uint16 psm, uint16 peerPsm)
 Send Connection Request. More...
 
bStatus_t L2CAP_ConnectRsp (uint16 connHandle, uint8 id, uint16 result)
 Send Connection Response. More...
 
bStatus_t L2CAP_ConnParamUpdateReq (uint16 connHandle, l2capParamUpdateReq_t *pUpdateReq, uint8 taskId)
 Send Connection Parameter Update Request. More...
 
bStatus_t L2CAP_ConnParamUpdateRsp (uint16 connHandle, uint8 id, l2capParamUpdateRsp_t *pUpdateRsp)
 Send Connection Parameter Update Response. More...
 
bStatus_t L2CAP_DeregisterPsm (uint8 taskId, uint16 psm)
 Deregister a Protocol/Service Multiplexer with L2CAP. More...
 
bStatus_t L2CAP_DisconnectReq (uint16 CID)
 Send Disconnection Request. More...
 
bStatus_t L2CAP_FlowCtrlCredit (uint16 CID, uint16 peerCredits)
 Send Flow Control Credit. More...
 
uint16 L2CAP_GetMTU (void)
 Get the maximum payload size that L2CAP is capable of receiving. More...
 
uint16 L2CAP_GetParamValue (void)
 Get the L2CAP parameter value. More...
 
void L2CAP_HostNumCompletedPkts (uint16 connHandle, uint16 numCompletedPkts)
 Host Number of Completed Packets. More...
 
bStatus_t L2CAP_InfoReq (uint16 connHandle, l2capInfoReq_t *pInfoReq, uint8 taskId)
 Send Information Request. More...
 
bStatus_t L2CAP_ParseConnectReq (l2capSignalCmd_t *pCmd, uint8 *pData, uint16 len)
 Parse Connection Request message. More...
 
bStatus_t L2CAP_ParseFlowCtrlCredit (l2capSignalCmd_t *pCmd, uint8 *pData, uint16 len)
 Parse Flow Control Credit message. More...
 
bStatus_t L2CAP_ParseInfoReq (l2capSignalCmd_t *pCmd, uint8 *pData, uint16 len)
 Parse Information Request message. More...
 
bStatus_t L2CAP_ParseParamUpdateReq (l2capSignalCmd_t *pCmd, uint8 *pData, uint16 len)
 Parse Connection Parameter Update Request. More...
 
bStatus_t L2CAP_PsmChannels (uint16 psm, uint8 numCIDs, uint16 *pCIDs)
 Get all active channels for a given registered PSM. More...
 
bStatus_t L2CAP_PsmInfo (uint16 psm, l2capPsmInfo_t *pInfo)
 Get information about a given registered PSM. More...
 
bStatus_t L2CAP_RegisterApp (uint8 taskId, uint16 CID)
 Register a protocol/application with an L2CAP fixed channel. More...
 
void L2CAP_RegisterFlowCtrlTask (uint8 taskId)
 Register task to recevie L2CAP Flow Control events when there are data buffers available for sending messages. More...
 
bStatus_t L2CAP_RegisterPsm (l2capPsm_t *pPsm)
 Register a Protocol/Service Multiplexer (PSM) with L2CAP. More...
 
bStatus_t L2CAP_SendData (uint16 connHandle, l2capPacket_t *pPkt)
 Send data packet over an L2CAP fixed channel established over a physical connection. More...
 
bStatus_t L2CAP_SendSDU (l2capPacket_t *pPkt)
 Send data packet over an L2CAP connection oriented channel established over a physical connection. More...
 
void L2CAP_SetBufSize (uint16 dataPktLen, uint8 numDataPkts)
 This API is used by the upper layer to set the maximum data packet size and the number of data packets allowed by the Controller. More...
 
void L2CAP_SetControllerToHostFlowCtrl (uint16 hostBuffSize, uint8 flowCtrlMode)
 Turn flow control on or off for data packets sent from the Controller to the Host. More...
 
void L2CAP_SetParamValue (uint16 value)
 Set the L2CAP parameter value. More...
 
void L2CAP_SetUserConfig (l2capUserCfg_t *pUserCfg)
 Set the user configurable variables for the L2CAP layer. More...
 

Detailed Description

This module implements the Logical Link Control and Adaption Protocol For a detailed usage section describing how to send these commands and receive events, see the L2CAP Section of the User's Guide.

Function Documentation

§ L2CAP_bm_alloc()

void* L2CAP_bm_alloc ( uint16  size)

L2CAP implementation of the allocator functionality.

Note
This function should only be called by L2CAP and the upper layer protocol/application.
Parameters
size- number of bytes to allocate from the heap.
Returns
pointer to the heap allocation
NULL if error or failure.

§ L2CAP_BuildCmdReject()

uint16 L2CAP_BuildCmdReject ( uint8 *  pBuf,
uint8 *  pCmd 
)

Build Command Reject.

Parameters
pBuf- pointer to buffer to hold command data
pCmd- pointer to command data
Returns
length of the command data

§ L2CAP_BuildConnectReq()

uint16 L2CAP_BuildConnectReq ( uint8 *  pBuf,
uint8 *  pData 
)

Build Connection Request.

Parameters
pBuf- pointer to buffer to hold command data
pData- pointer to command data
Returns
length of the command data

§ L2CAP_BuildInfoRsp()

uint16 L2CAP_BuildInfoRsp ( uint8 *  pBuf,
uint8 *  pData 
)

Build Information Response.

Parameters
pBuf- pointer to buffer to hold command data
pData- pointer to command data
Returns
length of the command data

§ L2CAP_BuildParamUpdateRsp()

uint16 L2CAP_BuildParamUpdateRsp ( uint8 *  pBuf,
uint8 *  pData 
)

Build Connection Parameter Update Response.

Parameters
pBuf- pointer to buffer to hold command data
pData- pointer to command data
Returns
length of the command data

§ L2CAP_ChannelInfo()

bStatus_t L2CAP_ChannelInfo ( uint16  CID,
l2capChannelInfo_t pInfo 
)

Get information about a given active Connection Oriented Channel.

Parameters
CID- local channel id.
pInfo- structure to copy channel info into.
Returns
SUCCESS : Operation was successful.
INVALIDPARAMETER : No such a channel.

§ L2CAP_CmdReject()

bStatus_t L2CAP_CmdReject ( uint16  connHandle,
uint8  id,
l2capCmdReject_t pCmdReject 
)

Send Command Reject.

Parameters
connHandle- connection to use
id- identifier of the request packet being rejected
pCmdReject- pointer to Command Reject to be sent
Returns
SUCCESS : Request was sent successfully.
INVALIDPARAMETER : Data can not fit into one packet.
MSG_BUFFER_NOT_AVAIL.
bleNotConnected
bleMemAllocError

§ L2CAP_ConnectReq()

bStatus_t L2CAP_ConnectReq ( uint16  connHandle,
uint16  psm,
uint16  peerPsm 
)

Send Connection Request.

Parameters
connHandle- connection to create channel on
psm- local PSM
peerPsm- peer PSM
Returns
SUCCESS : Request was sent successfully.
INVALIDPARAMETER : PSM is not registered.
MSG_BUFFER_NOT_AVAIL.
bleIncorrectMode : PSM not registered.
bleNotConnected
bleNoResources
bleMemAllocError

§ L2CAP_ConnectRsp()

bStatus_t L2CAP_ConnectRsp ( uint16  connHandle,
uint8  id,
uint16  result 
)

Send Connection Response.

Parameters
connHandle- connection handle
id- identifier received in connection request
result- L2CAP Connection Response Result Values
Returns
SUCCESS : Request was sent successfully.
INVALIDPARAMETER : PSM is not registered or Channel is not open.
MSG_BUFFER_NOT_AVAIL.
bleNotConnected
bleMemAllocError

§ L2CAP_ConnParamUpdateReq()

bStatus_t L2CAP_ConnParamUpdateReq ( uint16  connHandle,
l2capParamUpdateReq_t pUpdateReq,
uint8  taskId 
)

Send Connection Parameter Update Request.

Parameters
connHandle- connection to use
pUpdateReq- pointer to Update Request to be sent
taskId- task to be notified about result
Returns
SUCCESS : Request was sent successfully.
INVALIDPARAMETER : Data can not fit into one packet.
MSG_BUFFER_NOT_AVAIL.
bleMemAllocError
bleNotConnected
bleNoResources
bleInvalidRange :a parameter isout of range.

§ L2CAP_ConnParamUpdateRsp()

bStatus_t L2CAP_ConnParamUpdateRsp ( uint16  connHandle,
uint8  id,
l2capParamUpdateRsp_t pUpdateRsp 
)

Send Connection Parameter Update Response.

Parameters
connHandle- connection to use
id- identifier received in request
pUpdateRsp- pointer to Update Response to be sent
Returns
SUCCESS : Request was sent successfully.
INVALIDPARAMETER : Data can not fit into one packet.
MSG_BUFFER_NOT_AVAIL.
bleNotConnected
bleMemAllocError

§ L2CAP_DeregisterPsm()

bStatus_t L2CAP_DeregisterPsm ( uint8  taskId,
uint16  psm 
)

Deregister a Protocol/Service Multiplexer with L2CAP.

Parameters
taskId- task PSM belongs to.
psm- PSM to deregister.
Returns
SUCCESS : Registration was successful.
INVALIDPARAMETER : PSM or task Id is invalid.
bleIncorrectMode : PSM is in use.

§ L2CAP_DisconnectReq()

bStatus_t L2CAP_DisconnectReq ( uint16  CID)

Send Disconnection Request.

Parameters
CID- local CID to disconnect
Returns
SUCCESS : Request was sent successfully.
INVALIDPARAMETER : Channel id is invalid.
MSG_BUFFER_NOT_AVAIL.
bleNotConnected
bleNoResources
bleMemAllocError

§ L2CAP_FlowCtrlCredit()

bStatus_t L2CAP_FlowCtrlCredit ( uint16  CID,
uint16  peerCredits 
)

Send Flow Control Credit.

Parameters
CID- local CID
peerCredits- number of credits to give to peer device
Returns
SUCCESS : Request was sent successfully.
INVALIDPARAMETER : Channel is not open.
MSG_BUFFER_NOT_AVAIL.
bleNotConnected
bleInvalidRange : Credits is out of range.
bleMemAllocError

§ L2CAP_GetMTU()

uint16 L2CAP_GetMTU ( void  )

Get the maximum payload size that L2CAP is capable of receiving.

Returns
MTU size

§ L2CAP_GetParamValue()

uint16 L2CAP_GetParamValue ( void  )

Get the L2CAP parameter value.

Returns
L2CAP parameter value

§ L2CAP_HostNumCompletedPkts()

void L2CAP_HostNumCompletedPkts ( uint16  connHandle,
uint16  numCompletedPkts 
)

Host Number of Completed Packets.

This API is used by the upper layer to notify L2CAP of the number of data packets that have been completed for connection handle since this API was previously called.

Parameters
connHandle- connection handle
numCompletedPkts- number of completed packets

§ L2CAP_InfoReq()

bStatus_t L2CAP_InfoReq ( uint16  connHandle,
l2capInfoReq_t pInfoReq,
uint8  taskId 
)

Send Information Request.

Parameters
connHandle- connection to use
pInfoReq- pointer to Info Request to be sent
taskId- task to be notified about result
Returns
SUCCESS : Request was sent successfully.
INVALIDPARAMETER : Data can not fit into one packet.
MSG_BUFFER_NOT_AVAIL.
bleNotConnected
bleNoResources
bleMemAllocError

§ L2CAP_ParseConnectReq()

bStatus_t L2CAP_ParseConnectReq ( l2capSignalCmd_t pCmd,
uint8 *  pData,
uint16  len 
)

Parse Connection Request message.

Parameters
pCmd- pointer to command data to be built
pData- pointer to incoming command data to be parsed
len- length of incoming command data
Returns
SUCCESS : Command was parsed successfully.
FAILURE : Command length is invalid.

§ L2CAP_ParseFlowCtrlCredit()

bStatus_t L2CAP_ParseFlowCtrlCredit ( l2capSignalCmd_t pCmd,
uint8 *  pData,
uint16  len 
)

Parse Flow Control Credit message.

Parameters
pCmd- pointer to command data to be built
pData- pointer to incoming command data to be parsed
len- length of incoming command data
Returns
SUCCESS : Command was parsed successfully.
FAILURE : Command length is invalid.

§ L2CAP_ParseInfoReq()

bStatus_t L2CAP_ParseInfoReq ( l2capSignalCmd_t pCmd,
uint8 *  pData,
uint16  len 
)

Parse Information Request message.

Parameters
pCmd- pointer to command data to be built
pData- pointer to incoming command data to be parsed
len- length of incoming command data
Returns
SUCCESS : Command was parsed successfully.
FAILURE : Command length is invalid.

§ L2CAP_ParseParamUpdateReq()

bStatus_t L2CAP_ParseParamUpdateReq ( l2capSignalCmd_t pCmd,
uint8 *  pData,
uint16  len 
)

Parse Connection Parameter Update Request.

Parameters
pCmd- pointer to command data to be built
pData- pointer to incoming command data to be parsed
len- length of incoming command data
Returns
SUCCESS : Command was parsed successfully.
FAILURE : Command length is invalid.

§ L2CAP_PsmChannels()

bStatus_t L2CAP_PsmChannels ( uint16  psm,
uint8  numCIDs,
uint16 *  pCIDs 
)

Get all active channels for a given registered PSM.

Parameters
psm- PSM Id.
numCIDs- number of CIDs can be copied.
pCIDs- structure to copy CIDs into.
Returns
SUCCESS : Operation was successful.
INVALIDPARAMETER : PSM is not registered.

§ L2CAP_PsmInfo()

bStatus_t L2CAP_PsmInfo ( uint16  psm,
l2capPsmInfo_t pInfo 
)

Get information about a given registered PSM.

Parameters
psm- PSM Id.
pInfo- structure to copy PSM info into.
Returns
SUCCESS : Operation was successful.
INVALIDPARAMETER : PSM is not registered.

§ L2CAP_RegisterApp()

bStatus_t L2CAP_RegisterApp ( uint8  taskId,
uint16  CID 
)

Register a protocol/application with an L2CAP fixed channel.

Parameters
taskId- task to be registered with channel.
CID- fixed channel ID.
Returns
SUCCESS : Registration was successful.
INVALIDPARAMETER : Channel ID is invalid.

§ L2CAP_RegisterFlowCtrlTask()

void L2CAP_RegisterFlowCtrlTask ( uint8  taskId)

Register task to recevie L2CAP Flow Control events when there are data buffers available for sending messages.

Parameters
taskId- Application's task ID.

§ L2CAP_RegisterPsm()

bStatus_t L2CAP_RegisterPsm ( l2capPsm_t pPsm)

Register a Protocol/Service Multiplexer (PSM) with L2CAP.

Parameters
pPsm- pointer to PSM structure.
Returns
SUCCESS : Registration was successful.
INVALIDPARAMETER : Max number of channels is greater than total supported.
bleInvalidRange :PSM value is out of range.
bleInvalidMtuSize : MTU size is out of range.
bleNoResources
bleAlreadyInRequestedMode : PSM already registered.

§ L2CAP_SendData()

bStatus_t L2CAP_SendData ( uint16  connHandle,
l2capPacket_t pPkt 
)

Send data packet over an L2CAP fixed channel established over a physical connection.

Note
Packet 'pPayload' must be allocated using L2CAP_bm_alloc().
Parameters
connHandle- connection to be used.
pPkt- pointer to packet to be sent.
Returns
SUCCESS : Data was sent successfully.
INVALIDPARAMETER : Channel ID is invalid or payload is null.
MSG_BUFFER_NOT_AVAIL.
bleNotConnected
bleMemAllocError
blePending : In the middle of another transmit.
bleInvalidMtuSize : Packet length is larger than MTU size.

§ L2CAP_SendSDU()

bStatus_t L2CAP_SendSDU ( l2capPacket_t pPkt)

Send data packet over an L2CAP connection oriented channel established over a physical connection.

Note: Packet 'pPayload' must be allocated using L2CAP_bm_alloc().

Parameters
pPkt- pointer to packet to be sent.
Returns
SUCCESS : Data was sent successfully.
INVALIDPARAMETER : SDU payload is null.
bleNotConnected : Connection or Channel is down.
bleMemAllocError
blePending : In the middle of another transmit.
bleInvalidMtuSize : SDU size is larger than peer MTU.

§ L2CAP_SetBufSize()

void L2CAP_SetBufSize ( uint16  dataPktLen,
uint8  numDataPkts 
)

This API is used by the upper layer to set the maximum data packet size and the number of data packets allowed by the Controller.

Parameters
dataPktLen- data packet size
numDataPkts- number of data packets

§ L2CAP_SetControllerToHostFlowCtrl()

void L2CAP_SetControllerToHostFlowCtrl ( uint16  hostBuffSize,
uint8  flowCtrlMode 
)

Turn flow control on or off for data packets sent from the Controller to the Host.

Parameters
hostBuffSize- total data buffer available on Host
flowCtrlMode- flow control mode: TRUE or FALSE

§ L2CAP_SetParamValue()

void L2CAP_SetParamValue ( uint16  value)

Set the L2CAP parameter value.

Use this function to change the default L2CAP parameter value.

Parameters
value- new parameter value

§ L2CAP_SetUserConfig()

void L2CAP_SetUserConfig ( l2capUserCfg_t pUserCfg)

Set the user configurable variables for the L2CAP layer.

Note
This function should be called BEFORE osal_init_system().
Parameters
pUserCfg- pointer to user configuration
Copyright 2017, Texas Instruments Incorporated