38#define L2CAP_MIN_OFFSET 13
41#define L2CAP_BCST_MIN_OFFSET 11
44#define L2CAP_PING_RESULT_OK 0
45#define L2CAP_PING_RESULT_NO_LINK 1
46#define L2CAP_PING_RESULT_NO_RESP 2
49#define L2CAP_DW_FAILED FALSE
50#define L2CAP_DW_SUCCESS TRUE
51#define L2CAP_DW_CONGESTED 2
54#define L2CAP_PRIORITY_NORMAL 0
55#define L2CAP_PRIORITY_HIGH 1
58#define L2CAP_CHNL_PRIORITY_HIGH 0
59#define L2CAP_CHNL_PRIORITY_MEDIUM 1
60#define L2CAP_CHNL_PRIORITY_LOW 2
62typedef UINT8 tL2CAP_CHNL_PRIORITY;
65#define L2CAP_CHNL_DATA_RATE_HIGH 3
66#define L2CAP_CHNL_DATA_RATE_MEDIUM 2
67#define L2CAP_CHNL_DATA_RATE_LOW 1
68#define L2CAP_CHNL_DATA_RATE_NO_TRAFFIC 0
70typedef UINT8 tL2CAP_CHNL_DATA_RATE;
74#define L2CAP_FLUSHABLE_MASK 0x0003
75#define L2CAP_FLUSHABLE_CH_BASED 0x0000
76#define L2CAP_FLUSHABLE_PKT 0x0001
77#define L2CAP_NON_FLUSHABLE_PKT 0x0002
81#define L2CAP_FLUSH_CHANS_ALL 0xffff
82#define L2CAP_FLUSH_CHANS_GET 0x0000
86#define L2CAP_MULTI_AV_CID 0
90#define L2CAP_MULTI_AV_HCI_HDR_LEN 8
93#define L2CAP_MULTI_AV_PADDING_LEN 2
97#define L2CAP_MULTI_AV_HCI_HDR_LEN_WITH_PADDING 10
101#define L2CAP_MULTI_AV_L2C_HDR_LEN 12
104#define L2CAP_ROLE_SLAVE HCI_ROLE_SLAVE
105#define L2CAP_ROLE_MASTER HCI_ROLE_MASTER
106#define L2CAP_ROLE_ALLOW_SWITCH 0x80
107#define L2CAP_ROLE_DISALLOW_SWITCH 0x40
108#define L2CAP_ROLE_CHECK_SWITCH 0xC0
113#define L2CAP_FCR_CHAN_OPT_BASIC (1 << L2CAP_FCR_BASIC_MODE)
114#define L2CAP_FCR_CHAN_OPT_ERTM (1 << L2CAP_FCR_ERTM_MODE)
115#define L2CAP_FCR_CHAN_OPT_STREAM (1 << L2CAP_FCR_STREAM_MODE)
117#define L2CAP_FCR_CHAN_OPT_ALL_MASK (L2CAP_FCR_CHAN_OPT_BASIC | L2CAP_FCR_CHAN_OPT_ERTM | L2CAP_FCR_CHAN_OPT_STREAM)
123#define L2C_INVALID_PSM(psm) (((psm) & 0x0101) != 0x0001)
124#define L2C_IS_VALID_PSM(psm) (((psm) & 0x0101) == 0x0001)
126#if (BLE_INCLUDED == TRUE)
127#define L2CAP_LE_INT_MIN 0x0006
128#define L2CAP_LE_INT_MAX 0x0C80
129#define L2CAP_LE_LATENCY_MAX 500
130#define L2CAP_LE_TIMEOUT_MIN 0x000a
131#define L2CAP_LE_TIMEOUT_MAX 0x0C80
132#define L2CAP_LE_TIMEOUT_DEFAULT 0x07D0
142#define L2CAP_FCR_BASIC_MODE 0x00
143#define L2CAP_FCR_ERTM_MODE 0x03
144#define L2CAP_FCR_STREAM_MODE 0x04
166 BOOLEAN flush_to_present;
172 BOOLEAN ext_flow_spec_present;
178#define L2CAP_CH_CFG_MASK_MTU 0x0001
179#define L2CAP_CH_CFG_MASK_QOS 0x0002
180#define L2CAP_CH_CFG_MASK_FLUSH_TO 0x0004
181#define L2CAP_CH_CFG_MASK_FCR 0x0008
182#define L2CAP_CH_CFG_MASK_FCS 0x0010
183#define L2CAP_CH_CFG_MASK_EXT_FLOW_SPEC 0x0020
185typedef UINT16 tL2CAP_CH_CFG_BITS;
197typedef void (tL2CA_CONNECT_IND_CB) (BD_ADDR, UINT16, UINT16, UINT8);
204typedef void (tL2CA_CONNECT_CFM_CB) (UINT16, UINT16);
210typedef void (tL2CA_CONNECT_PND_CB) (UINT16);
231typedef void (tL2CA_DISCONNECT_IND_CB) (UINT16, BOOLEAN);
238typedef void (tL2CA_DISCONNECT_CFM_CB) (UINT16, UINT16);
244typedef void (tL2CA_QOS_VIOLATION_IND_CB) (BD_ADDR);
251typedef void (tL2CA_DATA_IND_CB) (UINT16,
BT_HDR *);
259typedef void (tL2CA_ECHO_RSP_CB) (UINT16);
264typedef void (tL2CA_ECHO_DATA_CB) (BD_ADDR, UINT16, UINT8 *);
273typedef void (tL2CA_CONGESTION_STATUS_CB) (UINT16, BOOLEAN);
282typedef void (tL2CA_NOCP_CB) (BD_ADDR);
291typedef void (tL2CA_TX_COMPLETE_CB) (UINT16, UINT16);
300 tL2CA_CONNECT_IND_CB *pL2CA_ConnectInd_Cb;
301 tL2CA_CONNECT_CFM_CB *pL2CA_ConnectCfm_Cb;
302 tL2CA_CONNECT_PND_CB *pL2CA_ConnectPnd_Cb;
303 tL2CA_CONFIG_IND_CB *pL2CA_ConfigInd_Cb;
304 tL2CA_CONFIG_CFM_CB *pL2CA_ConfigCfm_Cb;
305 tL2CA_DISCONNECT_IND_CB *pL2CA_DisconnectInd_Cb;
306 tL2CA_DISCONNECT_CFM_CB *pL2CA_DisconnectCfm_Cb;
307 tL2CA_QOS_VIOLATION_IND_CB *pL2CA_QoSViolationInd_Cb;
308 tL2CA_DATA_IND_CB *pL2CA_DataInd_Cb;
309 tL2CA_CONGESTION_STATUS_CB *pL2CA_CongestionStatus_Cb;
310 tL2CA_TX_COMPLETE_CB *pL2CA_TxComplete_Cb;
319 UINT8 preferred_mode;
321 UINT8 user_rx_pool_id;
322 UINT8 user_tx_pool_id;
323 UINT8 fcr_rx_pool_id;
324 UINT8 fcr_tx_pool_id;
328#define L2CA_REGISTER(a,b,c) L2CA_Register(a,(tL2CAP_APPL_INFO *)b)
329#define L2CA_DEREGISTER(a) L2CA_Deregister(a)
330#define L2CA_CONNECT_REQ(a,b,c,d) L2CA_ErtmConnectReq(a,b,c)
331#define L2CA_CONNECT_RSP(a,b,c,d,e,f,g) L2CA_ErtmConnectRsp(a,b,c,d,e,f)
332#define L2CA_CONFIG_REQ(a,b) L2CA_ConfigReq(a,b)
333#define L2CA_CONFIG_RSP(a,b) L2CA_ConfigRsp(a,b)
334#define L2CA_DISCONNECT_REQ(a) L2CA_DisconnectReq(a)
335#define L2CA_DISCONNECT_RSP(a) L2CA_DisconnectRsp(a)
336#define L2CA_DATA_WRITE(a, b) L2CA_DataWrite(a, b)
360L2C_API
extern UINT16 L2CA_Register (UINT16 psm,
tL2CAP_APPL_INFO *p_cb_info);
372L2C_API
extern void L2CA_Deregister (UINT16 psm);
384L2C_API
extern UINT16 L2CA_AllocatePSM(
void);
398L2C_API
extern UINT16 L2CA_ConnectReq (UINT16 psm, BD_ADDR p_bd_addr);
411L2C_API
extern BOOLEAN L2CA_ConnectRsp (BD_ADDR p_bd_addr, UINT8
id, UINT16 lcid,
412 UINT16 result, UINT16 status);
427L2C_API
extern UINT16 L2CA_ErtmConnectReq (UINT16 psm, BD_ADDR p_bd_addr,
442L2C_API
extern BOOLEAN L2CA_ErtmConnectRsp (BD_ADDR p_bd_addr, UINT8
id, UINT16 lcid,
443 UINT16 result, UINT16 status,
455L2C_API
extern BOOLEAN L2CA_ConfigReq (UINT16 cid,
tL2CAP_CFG_INFO *p_cfg);
467L2C_API
extern BOOLEAN L2CA_ConfigRsp (UINT16 cid,
tL2CAP_CFG_INFO *p_cfg);
478L2C_API
extern BOOLEAN L2CA_DisconnectReq (UINT16 cid);
490L2C_API
extern BOOLEAN L2CA_DisconnectRsp (UINT16 cid);
503L2C_API
extern UINT8 L2CA_DataWrite (UINT16 cid,
BT_HDR *p_data);
514L2C_API
extern BOOLEAN L2CA_Ping (BD_ADDR p_bd_addr, tL2CA_ECHO_RSP_CB *p_cb);
526L2C_API
extern BOOLEAN L2CA_Echo (BD_ADDR p_bd_addr,
BT_HDR *p_data, tL2CA_ECHO_DATA_CB *p_callback);
543L2C_API
extern BOOLEAN L2CA_SetIdleTimeout (UINT16 cid, UINT16 timeout,
565L2C_API
extern BOOLEAN L2CA_SetIdleTimeoutByBdAddr(BD_ADDR bd_addr, UINT16 timeout);
577L2C_API
extern UINT8 L2CA_SetTraceLevel (UINT8 trace_level);
595L2C_API
extern UINT8 L2CA_SetDesireRole (UINT8 new_role);
606L2C_API
extern UINT16 L2CA_LocalLoopbackReq (UINT16 psm, UINT16 handle, BD_ADDR p_bd_addr);
622L2C_API
extern UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush);
636L2C_API
extern BOOLEAN L2CA_SetAclPriority (BD_ADDR bd_addr, UINT8 priority);
649L2C_API
extern BOOLEAN L2CA_FlowControl (UINT16 cid, BOOLEAN data_enabled);
660L2C_API
extern BOOLEAN L2CA_SendTestSFrame (UINT16 cid, BOOLEAN rr_or_rej,
672L2C_API
extern BOOLEAN L2CA_SetTxPriority (UINT16 cid, tL2CAP_CHNL_PRIORITY priority);
686L2C_API
extern BOOLEAN L2CA_RegForNoCPEvt(tL2CA_NOCP_CB *p_cb, BD_ADDR p_bda);
697L2C_API
extern BOOLEAN L2CA_SetChnlDataRate (UINT16 cid, tL2CAP_CHNL_DATA_RATE tx, tL2CAP_CHNL_DATA_RATE rx);
699typedef void (tL2CA_RESERVE_CMPL_CBACK) (void);
722L2C_API
extern BOOLEAN L2CA_SetFlushTimeout (BD_ADDR bd_addr, UINT16 flush_tout);
739L2C_API
extern UINT8 L2CA_DataWriteEx (UINT16 cid,
BT_HDR *p_data, UINT16 flags);
751L2C_API
extern BOOLEAN L2CA_SetChnlFlushability (UINT16 cid, BOOLEAN is_flushable);
765L2C_API
extern BOOLEAN L2CA_GetPeerFeatures (BD_ADDR bd_addr, UINT32 *p_ext_feat, UINT8 *p_chnl_mask);
779L2C_API
extern BOOLEAN L2CA_GetBDAddrbyHandle (UINT16 handle, BD_ADDR bd_addr);
792L2C_API
extern UINT8 L2CA_GetChnlFcrMode (UINT16 lcid);
806#define L2CAP_UCD_INFO_TYPE_RECEPTION 0x01
807#define L2CAP_UCD_INFO_TYPE_MTU 0x02
809typedef void (tL2CA_UCD_DISCOVER_CB) (BD_ADDR, UINT8, UINT32);
815typedef void (tL2CA_UCD_DATA_CB) (BD_ADDR,
BT_HDR *);
823typedef void (tL2CA_UCD_CONGESTION_STATUS_CB) (BD_ADDR, BOOLEAN);
829 tL2CA_UCD_DISCOVER_CB *pL2CA_UCD_Discover_Cb;
830 tL2CA_UCD_DATA_CB *pL2CA_UCD_Data_Cb;
831 tL2CA_UCD_CONGESTION_STATUS_CB *pL2CA_UCD_Congestion_Status_Cb;
858L2C_API
extern BOOLEAN L2CA_UcdDeregister ( UINT16 psm );
875L2C_API
extern BOOLEAN L2CA_UcdDiscover ( UINT16 psm, BD_ADDR rem_bda, UINT8 info_type );
894L2C_API
extern UINT16 L2CA_UcdDataWrite (UINT16 psm, BD_ADDR rem_bda,
BT_HDR *p_buf, UINT16 flags);
908L2C_API
extern BOOLEAN L2CA_UcdSetIdleTimeout ( BD_ADDR rem_bda, UINT16 timeout );
919L2C_API
extern BOOLEAN L2CA_UCDSetTxPriority ( BD_ADDR rem_bda, tL2CAP_CHNL_PRIORITY priority );
933typedef void (tL2CA_FIXED_CHNL_CB) (BD_ADDR, BOOLEAN, UINT16);
939typedef void (tL2CA_FIXED_DATA_CB) (BD_ADDR,
BT_HDR *);
945 tL2CA_FIXED_CHNL_CB *pL2CA_FixedConn_Cb;
946 tL2CA_FIXED_DATA_CB *pL2CA_FixedData_Cb;
949 UINT16 default_idle_tout;
953#if (L2CAP_NUM_FIXED_CHNLS > 0)
980L2C_API
extern BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR bd_addr);
996L2C_API
extern UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda,
BT_HDR *p_buf);
1011L2C_API
extern BOOLEAN L2CA_RemoveFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda);
1030L2C_API
extern BOOLEAN L2CA_SetFixedChannelTout (BD_ADDR rem_bda, UINT16 fixed_cid, UINT16 idle_tout);
1047L2C_API
extern BOOLEAN L2CA_GetCurrentConfig (UINT16 lcid,
1051#if (L2CAP_CORRUPT_ERTM_PKTS == TRUE)
1077L2C_API
extern UINT16 L2CA_SetupErtmTest (UINT16 cid, UINT8 type, BOOLEAN is_rx, UINT8 freq, UINT16 count);
1094L2C_API
extern void L2CA_SendPolledSFrame (UINT16 cid, UINT16 sup_type);
1111L2C_API
extern void L2CA_BypassSFrame (UINT16 cid, UINT8 count);
1116#if (BLE_INCLUDED == TRUE)
1128L2C_API
extern BOOLEAN L2CA_CancelBleConnectReq (BD_ADDR rem_bda);
1141L2C_API
extern BOOLEAN L2CA_UpdateBleConnParams (BD_ADDR rem_bdRa, UINT16 min_int, UINT16 max_int, UINT16 latency, UINT16 timeout);
1155L2C_API
extern BOOLEAN L2CA_EnableUpdateBleConnParams (BD_ADDR rem_bda, BOOLEAN enable);
1166L2C_API
extern UINT8 L2CA_GetBleConnRole (BD_ADDR bd_addr);
1177L2C_API
extern UINT16 L2CA_GetDisconnectReason (BD_ADDR remote_bda);