TI BLE Stack API Documentation  2.03.08
Functions
L2CAP API Functions

Functions

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_SendData (uint16 connHandle, l2capPacket_t *pPkt)
 Send data packet over an L2CAP fixed channel established over a physical connection. More...
 
bStatus_t L2CAP_RegisterPsm (l2capPsm_t *pPsm)
 Register a Protocol/Service Multiplexer (PSM) with L2CAP. More...
 
bStatus_t L2CAP_DeregisterPsm (uint8 taskId, uint16 psm)
 Deregister a Protocol/Service Multiplexer with L2CAP. More...
 
bStatus_t L2CAP_PsmInfo (uint16 psm, l2capPsmInfo_t *pInfo)
 Get information about a given registered PSM. More...
 
bStatus_t L2CAP_PsmChannels (uint16 psm, uint8 numCIDs, uint16 *pCIDs)
 Get all active channels for a given registered PSM. More...
 
bStatus_t L2CAP_ChannelInfo (uint16 CID, l2capChannelInfo_t *pInfo)
 Get information about a given active Connection Oriented Channel. 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_DisconnectReq (uint16 CID)
 Send Disconnection Request. More...
 
bStatus_t L2CAP_FlowCtrlCredit (uint16 CID, uint16 peerCredits)
 Send Flow Control Credit. More...
 
bStatus_t L2CAP_SendSDU (l2capPacket_t *pPkt)
 Send data packet over an L2CAP connection oriented channel established over a physical connection. More...
 
bStatus_t L2CAP_CmdReject (uint16 connHandle, uint8 id, l2capCmdReject_t *pCmdReject)
 Send Command Reject. More...
 
bStatus_t L2CAP_InfoReq (uint16 connHandle, l2capInfoReq_t *pInfoReq, uint8 taskId)
 Send Information Request. 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...
 
void L2CAP_SetUserConfig (l2capUserCfg_t *pUserCfg)
 Set the user configurable variables for the L2CAP layer. 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...
 
uint16 L2CAP_GetMTU (void)
 Get the maximum payload size that L2CAP is capable of receiving. More...
 
void * L2CAP_bm_alloc (uint16 size)
 L2CAP implementation of the allocator functionality. More...
 

Detailed Description

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_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: No HCI buffer is available.
bleNotConnected: Connection is down.
bleMemAllocError: Memory allocation error occurred.

§ 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: No HCI buffer is available.
bleIncorrectMode: PSM not registered.
bleNotConnected: Connection is down.
bleNoResources: No available resource.
bleMemAllocError: Memory allocation error occurred.

§ 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- outcome of connection request: 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: No HCI buffer is available.
bleNotConnected: Connection is down.
bleMemAllocError: Memory allocation error occurred.

§ 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: No HCI buffer is available.
bleMemAllocError: Memory allocation error occurred.
bleNotConnected: Connection is down.
bleNoResources: No available resource.
bleInvalidRange: a parameter is out or 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: No HCI buffer is available.
bleNotConnected: Connection is down.
bleMemAllocError: Memory allocation error occurred.

§ 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: No HCI buffer is available.
bleNotConnected: Connection is down.
bleNoResources: No available resource.
bleMemAllocError: Memory allocation error occurred.

§ 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: No HCI buffer is available.
bleNotConnected: Connection is down.
bleInvalidRange - Credits is out of range.
bleMemAllocError: Memory allocation error occurred.

§ L2CAP_GetMTU()

uint16 L2CAP_GetMTU ( void  )

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

Returns
MTU size

§ 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: No HCI buffer is available.
bleNotConnected: Connection is down.
bleNoResources: No available resource.
bleMemAllocError: Memory allocation error occurred.

§ 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.

taskId - Application's task ID.

Returns
none

§ 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: Out of resources.
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: No HCI buffer is available.
bleNotConnected: Connection is down.
bleMemAllocError: Memory allocation error occurred.
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: Memory allocation error occurred.
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
Returns
none

§ 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
Returns
none