123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304 |
- #ifndef L2CAP_INTERNAL_H
- #define L2CAP_INTERNAL_H
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- #include "hci.h"
- #include "l2cap.h"
- #define FIX_CHANNEL( CID ) ( (CID) == L2CAP_CID_GENERIC ||\
- (CID) == L2CAP_CID_SIG ||\
- (CID) == L2CAP_CID_ATT ||\
- (CID) == L2CAP_CID_SMP )
- #define CID_TO_INDEX( CID ) ( (CID) - BASE_DYNAMIC_CID )
- #define FCID_TO_INDEX( CID ) ( (CID) - L2CAP_CID_ATT )
- #define FIX_CHANNEL_REC( CID ) ( l2capFixedChannels[FCID_TO_INDEX( CID )] )
- #define SIGNAL_HDR_SIZE 4
- #define SIGNAL_DATA_SIZE ( L2CAP_SIG_MTU_SIZE - SIGNAL_HDR_SIZE )
- #define L2CAP_CLOSED 0x00
- #define L2CAP_W4_ECHO_RSP 0x01
- #define L2CAP_W4_INFO_RSP 0x02
- #define L2CAP_W4_PARAM_UPDATE_RSP 0x03
- typedef struct
- {
-
- uint8 state;
- uint16 CID;
- uint8 id;
-
- uint16 connHandle;
-
- uint8 taskId;
-
- uint8 timerId;
- } l2capChannel_t;
- typedef struct
- {
- uint16 CID;
- uint8 taskId;
- } l2capFixedChannel_t;
- typedef struct
- {
- uint8 opcode;
- uint8 id;
- uint16 len;
- } l2capSignalHdr_t;
- typedef uint16 (*pfnL2CAPBuildCmd_t)( uint8 *pBuf, uint8 *pData );
- extern uint8 l2capTaskID;
- extern l2capChannel_t l2capChannels[];
- extern l2capFixedChannel_t l2capFixedChannels[];
- extern bStatus_t l2capSendCmd( uint16 connHandle, uint8 opcode, uint8 id,
- uint8 *pCmd, pfnL2CAPBuildCmd_t pfnBuildCmd );
- extern bStatus_t l2capSendReq( uint16 connHandle, uint8 opcode, uint8 *pReq,
- pfnL2CAPBuildCmd_t pfnBuildCmd, uint8 state, uint8 taskId );
- extern uint16 l2capBuildEchoReq( uint8 *pBuf, uint8 *pCmd );
- extern uint16 l2capBuildInfoReq( uint8 *pBuf, uint8 *pCmd );
- extern uint16 l2capBuildParamUpdateReq( uint8 *pBuf, uint8 *pData );
- extern bStatus_t l2capEncapSendData( uint16 connHandle, l2capPacket_t *pPkt );
- extern uint8 l2capParsePacket( l2capPacket_t *pPkt, hciDataEvent_t *pHciMsg );
- extern void l2capParseSignalHdr( l2capSignalHdr_t *pHdr, uint8 *pData );
- extern uint16 l2capBuildEchoRsp( uint8 *pBuf, uint8 *pCmd );
- extern bStatus_t l2capParseCmdReject( l2capSignalCmd_t *pCmd, uint8 *pData, uint16 len );
- extern bStatus_t l2capParseEchoRsp( l2capSignalCmd_t *pCmd, uint8 *pData, uint16 len );
- extern bStatus_t l2capParseInfoRsp( l2capSignalCmd_t *pCmd, uint8 *pData, uint16 len );
- extern bStatus_t l2capParseParamUpdateRsp( l2capSignalCmd_t *pCmd, uint8 *pData, uint16 len );
- extern l2capChannel_t *l2capFindLocalId( uint8 id );
- extern void l2capFreeChannel( l2capChannel_t *pChannel );
- extern void l2capStopTimer( l2capChannel_t *pChannel );
- extern void l2capHandleRxError( uint16 connHandle );
- extern bStatus_t l2capNotifyData( uint8 taskId, uint16 connHandle, l2capPacket_t *pPkt );
- extern void l2capNotifySignal( uint8 taskId, uint16 connHandle, uint8 status,
- uint8 opcode, uint8 id, l2capSignalCmd_t *pCmd );
- extern void *L2CAP_Fragment_bm_alloc( uint16 size );
- extern uint8 L2CAP_Fragment_SendDataPkt( uint16 connHandle, uint8 fragFlg,uint16 pktLen, uint8 *pBuf );
- #define l2capInfoRsp( connHandle, id, pInfoRsp ) l2capSendCmd( (connHandle), L2CAP_INFO_RSP, (id),\
- (uint8 *)(pInfoRsp), L2CAP_BuildInfoRsp )
- #define l2capEchoRsp( connHandle, id, pEchoRsp ) l2capSendCmd( (connHandle), L2CAP_ECHO_RSP, (id),\
- (uint8 *)(pEchoRsp), l2capBuildEchoRsp )
- #ifdef __cplusplus
- }
- #endif
- #endif
|