l2c_api.h 47 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 1999-2012 Broadcom Corporation
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at:
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. ******************************************************************************/
  18. /******************************************************************************
  19. *
  20. * this file contains the L2CAP API definitions
  21. *
  22. ******************************************************************************/
  23. #ifndef L2C_API_H
  24. #define L2C_API_H
  25. #include <stdbool.h>
  26. #include "common/bt_target.h"
  27. #include "stack/l2cdefs.h"
  28. #include "stack/hcidefs.h"
  29. #include "osi/fixed_queue.h"
  30. /*****************************************************************************
  31. ** Constants
  32. *****************************************************************************/
  33. /* Define the minimum offset that L2CAP needs in a buffer. This is made up of
  34. ** HCI type(1), len(2), handle(2), L2CAP len(2) and CID(2) => 9
  35. */
  36. #define L2CAP_MIN_OFFSET 13 /* plus control(2), SDU length(2) */
  37. #define L2CAP_FCS_LEN 2 /* FCS 0 or 2 bytes */
  38. /* Minimum offset for broadcast needs another two bytes for the PSM */
  39. #define L2CAP_BCST_MIN_OFFSET 11
  40. /* ping result codes */
  41. #define L2CAP_PING_RESULT_OK 0 /* Ping reply received OK */
  42. #define L2CAP_PING_RESULT_NO_LINK 1 /* Link could not be setup */
  43. #define L2CAP_PING_RESULT_NO_RESP 2 /* Remote L2CAP did not reply */
  44. /* result code for L2CA_DataWrite() */
  45. #define L2CAP_DW_FAILED FALSE
  46. #define L2CAP_DW_SUCCESS TRUE
  47. #define L2CAP_DW_CONGESTED 2
  48. /* Values for priority parameter to L2CA_SetAclPriority */
  49. #define L2CAP_PRIORITY_NORMAL 0
  50. #define L2CAP_PRIORITY_HIGH 1
  51. /* Values for priority parameter to L2CA_SetTxPriority */
  52. #define L2CAP_CHNL_PRIORITY_HIGH 0
  53. #define L2CAP_CHNL_PRIORITY_MEDIUM 1
  54. #define L2CAP_CHNL_PRIORITY_LOW 2
  55. typedef UINT8 tL2CAP_CHNL_PRIORITY;
  56. /* Values for Tx/Rx data rate parameter to L2CA_SetChnlDataRate */
  57. #define L2CAP_CHNL_DATA_RATE_HIGH 3
  58. #define L2CAP_CHNL_DATA_RATE_MEDIUM 2
  59. #define L2CAP_CHNL_DATA_RATE_LOW 1
  60. #define L2CAP_CHNL_DATA_RATE_NO_TRAFFIC 0
  61. typedef UINT8 tL2CAP_CHNL_DATA_RATE;
  62. /* Data Packet Flags (bits 2-15 are reserved) */
  63. /* layer specific 14-15 bits are used for FCR SAR */
  64. #define L2CAP_FLUSHABLE_MASK 0x0003
  65. #define L2CAP_FLUSHABLE_CH_BASED 0x0000
  66. #define L2CAP_FLUSHABLE_PKT 0x0001
  67. #define L2CAP_NON_FLUSHABLE_PKT 0x0002
  68. /* L2CA_FlushChannel num_to_flush definitions */
  69. #define L2CAP_FLUSH_CHANS_ALL 0xffff
  70. #define L2CAP_FLUSH_CHANS_GET 0x0000
  71. /* special CID for Multi-AV for reporting congestion */
  72. #define L2CAP_MULTI_AV_CID 0
  73. /* length of the HCI header block */
  74. /* HCI header(4) + SNK count(1) + FCR bits(1) + AV data length(2) */
  75. #define L2CAP_MULTI_AV_HCI_HDR_LEN 8
  76. /* length of padding for 4 bytes align */
  77. #define L2CAP_MULTI_AV_PADDING_LEN 2
  78. /* length of the HCI header block with padding for FCR */
  79. /* HCI header(4) + SNK count(1) + FCR bits(1) + AV data length(2) + padding(2) */
  80. #define L2CAP_MULTI_AV_HCI_HDR_LEN_WITH_PADDING 10
  81. /* length of the L2CAP header block */
  82. /* HCI header(4) + L2CAP header(4) + padding(4) or control word(2) + FCS(2) */
  83. #define L2CAP_MULTI_AV_L2C_HDR_LEN 12
  84. /* definition used for L2CA_SetDesireRole */
  85. #define L2CAP_ROLE_SLAVE HCI_ROLE_SLAVE
  86. #define L2CAP_ROLE_MASTER HCI_ROLE_MASTER
  87. #define L2CAP_ROLE_ALLOW_SWITCH 0x80 /* set this bit to allow switch at create conn */
  88. #define L2CAP_ROLE_DISALLOW_SWITCH 0x40 /* set this bit to disallow switch at create conn */
  89. #define L2CAP_ROLE_CHECK_SWITCH 0xC0
  90. /* Values for 'allowed_modes' field passed in structure tL2CAP_ERTM_INFO
  91. */
  92. #define L2CAP_FCR_CHAN_OPT_BASIC (1 << L2CAP_FCR_BASIC_MODE)
  93. #define L2CAP_FCR_CHAN_OPT_ERTM (1 << L2CAP_FCR_ERTM_MODE)
  94. #define L2CAP_FCR_CHAN_OPT_STREAM (1 << L2CAP_FCR_STREAM_MODE)
  95. #define L2CAP_FCR_CHAN_OPT_ALL_MASK (L2CAP_FCR_CHAN_OPT_BASIC | L2CAP_FCR_CHAN_OPT_ERTM | L2CAP_FCR_CHAN_OPT_STREAM)
  96. /* Validity check for PSM. PSM values must be odd. Also, all PSM values must
  97. ** be assigned such that the least significant bit of the most sigificant
  98. ** octet equals zero.
  99. */
  100. #define L2C_INVALID_PSM(psm) (((psm) & 0x0101) != 0x0001)
  101. #define L2C_IS_VALID_PSM(psm) (((psm) & 0x0101) == 0x0001)
  102. #define L2C_IS_VALID_LE_PSM(psm) (((psm) > 0x0000) && ((psm) < 0x0100))
  103. /*****************************************************************************
  104. ** Type Definitions
  105. *****************************************************************************/
  106. typedef struct {
  107. #define L2CAP_FCR_BASIC_MODE 0x00
  108. #define L2CAP_FCR_ERTM_MODE 0x03
  109. #define L2CAP_FCR_STREAM_MODE 0x04
  110. UINT8 mode;
  111. UINT8 tx_win_sz;
  112. UINT8 max_transmit;
  113. UINT16 rtrans_tout;
  114. UINT16 mon_tout;
  115. UINT16 mps;
  116. } tL2CAP_FCR_OPTS;
  117. /* Define a structure to hold the configuration parameters. Since the
  118. ** parameters are optional, for each parameter there is a boolean to
  119. ** use to signify its presence or absence.
  120. */
  121. typedef struct {
  122. UINT16 result; /* Only used in confirm messages */
  123. BOOLEAN mtu_present;
  124. UINT16 mtu;
  125. BOOLEAN qos_present;
  126. FLOW_SPEC qos;
  127. BOOLEAN flush_to_present;
  128. UINT16 flush_to;
  129. BOOLEAN fcr_present;
  130. tL2CAP_FCR_OPTS fcr;
  131. BOOLEAN fcs_present; /* Optionally bypasses FCS checks */
  132. UINT8 fcs; /* '0' if desire is to bypass FCS, otherwise '1' */
  133. BOOLEAN ext_flow_spec_present;
  134. tHCI_EXT_FLOW_SPEC ext_flow_spec;
  135. UINT16 flags; /* bit 0: 0-no continuation, 1-continuation */
  136. } tL2CAP_CFG_INFO;
  137. /* Define a structure to hold the configuration parameter for LE L2CAP connection
  138. ** oriented channels.
  139. */
  140. typedef struct
  141. {
  142. UINT16 mtu;
  143. UINT16 mps;
  144. UINT16 credits;
  145. } tL2CAP_LE_CFG_INFO;
  146. /* L2CAP channel configured field bitmap */
  147. #define L2CAP_CH_CFG_MASK_MTU 0x0001
  148. #define L2CAP_CH_CFG_MASK_QOS 0x0002
  149. #define L2CAP_CH_CFG_MASK_FLUSH_TO 0x0004
  150. #define L2CAP_CH_CFG_MASK_FCR 0x0008
  151. #define L2CAP_CH_CFG_MASK_FCS 0x0010
  152. #define L2CAP_CH_CFG_MASK_EXT_FLOW_SPEC 0x0020
  153. typedef UINT16 tL2CAP_CH_CFG_BITS;
  154. /*********************************
  155. ** Callback Functions Prototypes
  156. **********************************/
  157. /* Connection indication callback prototype. Parameters are
  158. ** BD Address of remote
  159. ** Local CID assigned to the connection
  160. ** PSM that the remote wants to connect to
  161. ** Identifier that the remote sent
  162. */
  163. typedef void (tL2CA_CONNECT_IND_CB) (BD_ADDR, UINT16, UINT16, UINT8);
  164. /* Connection confirmation callback prototype. Parameters are
  165. ** Local CID
  166. ** Result - 0 = connected, non-zero means failure reason
  167. */
  168. typedef void (tL2CA_CONNECT_CFM_CB) (UINT16, UINT16);
  169. /* Connection pending callback prototype. Parameters are
  170. ** Local CID
  171. */
  172. typedef void (tL2CA_CONNECT_PND_CB) (UINT16);
  173. /* Configuration indication callback prototype. Parameters are
  174. ** Local CID assigned to the connection
  175. ** Pointer to configuration info
  176. */
  177. typedef void (tL2CA_CONFIG_IND_CB) (UINT16, tL2CAP_CFG_INFO *);
  178. /* Configuration confirm callback prototype. Parameters are
  179. ** Local CID assigned to the connection
  180. ** Pointer to configuration info
  181. */
  182. typedef void (tL2CA_CONFIG_CFM_CB) (UINT16, tL2CAP_CFG_INFO *);
  183. /* Disconnect indication callback prototype. Parameters are
  184. ** Local CID
  185. ** Boolean whether upper layer should ack this
  186. */
  187. typedef void (tL2CA_DISCONNECT_IND_CB) (UINT16, BOOLEAN);
  188. /* Disconnect confirm callback prototype. Parameters are
  189. ** Local CID
  190. ** Result
  191. */
  192. typedef void (tL2CA_DISCONNECT_CFM_CB) (UINT16, UINT16);
  193. /* QOS Violation indication callback prototype. Parameters are
  194. ** BD Address of violating device
  195. */
  196. typedef void (tL2CA_QOS_VIOLATION_IND_CB) (BD_ADDR);
  197. /* Data received indication callback prototype. Parameters are
  198. ** Local CID
  199. ** Address of buffer
  200. */
  201. typedef void (tL2CA_DATA_IND_CB) (UINT16, BT_HDR *);
  202. /* Echo response callback prototype. Note that this is not included in the
  203. ** registration information, but is passed to L2CAP as part of the API to
  204. ** actually send an echo request. Parameters are
  205. ** Result
  206. */
  207. typedef void (tL2CA_ECHO_RSP_CB) (UINT16);
  208. /* Callback function prototype to pass broadcom specific echo response */
  209. /* to the upper layer */
  210. typedef void (tL2CA_ECHO_DATA_CB) (BD_ADDR, UINT16, UINT8 *);
  211. /* Congestion status callback protype. This callback is optional. If
  212. ** an application tries to send data when the transmit queue is full,
  213. ** the data will anyways be dropped. The parameter is:
  214. ** Local CID
  215. ** TRUE if congested, FALSE if uncongested
  216. */
  217. typedef void (tL2CA_CONGESTION_STATUS_CB) (UINT16, BOOLEAN);
  218. /* Callback prototype for number of packets completed events.
  219. ** This callback notifies the application when Number of Completed Packets
  220. ** event has been received.
  221. ** This callback is originally designed for 3DG devices.
  222. ** The parameter is:
  223. ** peer BD_ADDR
  224. */
  225. typedef void (tL2CA_NOCP_CB) (BD_ADDR);
  226. /* Transmit complete callback protype. This callback is optional. If
  227. ** set, L2CAP will call it when packets are sent or flushed. If the
  228. ** count is 0xFFFF, it means all packets are sent for that CID (eRTM
  229. ** mode only). The parameters are:
  230. ** Local CID
  231. ** Number of SDUs sent or dropped
  232. */
  233. typedef void (tL2CA_TX_COMPLETE_CB) (UINT16, UINT16);
  234. /* Define the structure that applications use to register with
  235. ** L2CAP. This structure includes callback functions. All functions
  236. ** MUST be provided, with the exception of the "connect pending"
  237. ** callback and "congestion status" callback.
  238. */
  239. typedef struct {
  240. tL2CA_CONNECT_IND_CB *pL2CA_ConnectInd_Cb;
  241. tL2CA_CONNECT_CFM_CB *pL2CA_ConnectCfm_Cb;
  242. tL2CA_CONNECT_PND_CB *pL2CA_ConnectPnd_Cb;
  243. tL2CA_CONFIG_IND_CB *pL2CA_ConfigInd_Cb;
  244. tL2CA_CONFIG_CFM_CB *pL2CA_ConfigCfm_Cb;
  245. tL2CA_DISCONNECT_IND_CB *pL2CA_DisconnectInd_Cb;
  246. tL2CA_DISCONNECT_CFM_CB *pL2CA_DisconnectCfm_Cb;
  247. tL2CA_QOS_VIOLATION_IND_CB *pL2CA_QoSViolationInd_Cb;
  248. tL2CA_DATA_IND_CB *pL2CA_DataInd_Cb;
  249. tL2CA_CONGESTION_STATUS_CB *pL2CA_CongestionStatus_Cb;
  250. tL2CA_TX_COMPLETE_CB *pL2CA_TxComplete_Cb;
  251. } tL2CAP_APPL_INFO;
  252. /* Define the structure that applications use to create or accept
  253. ** connections with enhanced retransmission mode.
  254. */
  255. typedef struct {
  256. UINT8 preferred_mode;
  257. UINT8 allowed_modes;
  258. UINT16 user_rx_buf_size;
  259. UINT16 user_tx_buf_size;
  260. UINT16 fcr_rx_buf_size;
  261. UINT16 fcr_tx_buf_size;
  262. } tL2CAP_ERTM_INFO;
  263. #define L2CA_REGISTER(a,b,c) L2CA_Register(a,(tL2CAP_APPL_INFO *)b)
  264. #define L2CA_DEREGISTER(a) L2CA_Deregister(a)
  265. #define L2CA_CONNECT_REQ(a,b,c,d) L2CA_ErtmConnectReq(a,b,c)
  266. #define L2CA_CONNECT_RSP(a,b,c,d,e,f,g) L2CA_ErtmConnectRsp(a,b,c,d,e,f)
  267. #define L2CA_CONFIG_REQ(a,b) L2CA_ConfigReq(a,b)
  268. #define L2CA_CONFIG_RSP(a,b) L2CA_ConfigRsp(a,b)
  269. #define L2CA_DISCONNECT_REQ(a) L2CA_DisconnectReq(a)
  270. #define L2CA_DISCONNECT_RSP(a) L2CA_DisconnectRsp(a)
  271. #define L2CA_DATA_WRITE(a, b) L2CA_DataWrite(a, b)
  272. /*****************************************************************************
  273. ** External Function Declarations
  274. *****************************************************************************/
  275. #ifdef __cplusplus
  276. extern "C"
  277. {
  278. #endif
  279. #if (CLASSIC_BT_INCLUDED == TRUE)
  280. /*******************************************************************************
  281. **
  282. ** Function L2CA_Register
  283. **
  284. ** Description Other layers call this function to register for L2CAP
  285. ** services.
  286. **
  287. ** Returns PSM to use or zero if error. Typically, the PSM returned
  288. ** is the same as was passed in, but for an outgoing-only
  289. ** connection to a dynamic PSM, a "virtual" PSM is returned
  290. ** and should be used in the calls to L2CA_ConnectReq() and
  291. ** BTM_SetSecurityLevel().
  292. **
  293. *******************************************************************************/
  294. extern UINT16 L2CA_Register (UINT16 psm, tL2CAP_APPL_INFO *p_cb_info);
  295. /*******************************************************************************
  296. **
  297. ** Function L2CA_Deregister
  298. **
  299. ** Description Other layers call this function to deregister for L2CAP
  300. ** services.
  301. **
  302. ** Returns void
  303. **
  304. *******************************************************************************/
  305. extern void L2CA_Deregister (UINT16 psm);
  306. /*******************************************************************************
  307. **
  308. ** Function L2CA_AllocatePSM
  309. **
  310. ** Description Other layers call this function to find an unused PSM for L2CAP
  311. ** services.
  312. **
  313. ** Returns PSM to use.
  314. **
  315. *******************************************************************************/
  316. extern UINT16 L2CA_AllocatePSM(void);
  317. /*******************************************************************************
  318. **
  319. ** Function L2CA_ConnectReq
  320. **
  321. ** Description Higher layers call this function to create an L2CAP connection.
  322. ** Note that the connection is not established at this time, but
  323. ** connection establishment gets started. The callback function
  324. ** will be invoked when connection establishes or fails.
  325. **
  326. ** Returns the CID of the connection, or 0 if it failed to start
  327. **
  328. *******************************************************************************/
  329. extern UINT16 L2CA_ConnectReq (UINT16 psm, BD_ADDR p_bd_addr);
  330. /*******************************************************************************
  331. **
  332. ** Function L2CA_ConnectRsp
  333. **
  334. ** Description Higher layers call this function to accept an incoming
  335. ** L2CAP connection, for which they had gotten an connect
  336. ** indication callback.
  337. **
  338. ** Returns TRUE for success, FALSE for failure
  339. **
  340. *******************************************************************************/
  341. extern BOOLEAN L2CA_ConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid,
  342. UINT16 result, UINT16 status);
  343. /*******************************************************************************
  344. **
  345. ** Function L2CA_ErtmConnectReq
  346. **
  347. ** Description Higher layers call this function to create an L2CAP connection
  348. ** that needs to use Enhanced Retransmission Mode.
  349. ** Note that the connection is not established at this time, but
  350. ** connection establishment gets started. The callback function
  351. ** will be invoked when connection establishes or fails.
  352. **
  353. ** Returns the CID of the connection, or 0 if it failed to start
  354. **
  355. *******************************************************************************/
  356. extern UINT16 L2CA_ErtmConnectReq (UINT16 psm, BD_ADDR p_bd_addr,
  357. tL2CAP_ERTM_INFO *p_ertm_info);
  358. // This function sets the callback routines for the L2CAP connection referred to by
  359. // |local_cid|. The callback routines can only be modified for outgoing connections
  360. // established by |L2CA_ConnectReq| or accepted incoming connections. |callbacks|
  361. // must not be NULL. This function returns true if the callbacks could be updated,
  362. // false if not (e.g. |local_cid| was not found).
  363. bool L2CA_SetConnectionCallbacks(uint16_t local_cid, const tL2CAP_APPL_INFO *callbacks);
  364. /*******************************************************************************
  365. **
  366. ** Function L2CA_ErtmConnectRsp
  367. **
  368. ** Description Higher layers call this function to accept an incoming
  369. ** L2CAP connection, for which they had gotten an connect
  370. ** indication callback, and for which the higher layer wants
  371. ** to use Enhanced Retransmission Mode.
  372. **
  373. ** Returns TRUE for success, FALSE for failure
  374. **
  375. *******************************************************************************/
  376. extern BOOLEAN L2CA_ErtmConnectRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid,
  377. UINT16 result, UINT16 status,
  378. tL2CAP_ERTM_INFO *p_ertm_info);
  379. /*******************************************************************************
  380. **
  381. ** Function L2CA_ConfigReq
  382. **
  383. ** Description Higher layers call this function to send configuration.
  384. **
  385. ** Returns TRUE if configuration sent, else FALSE
  386. **
  387. *******************************************************************************/
  388. extern BOOLEAN L2CA_ConfigReq (UINT16 cid, tL2CAP_CFG_INFO *p_cfg);
  389. /*******************************************************************************
  390. **
  391. ** Function L2CA_ConfigRsp
  392. **
  393. ** Description Higher layers call this function to send a configuration
  394. ** response.
  395. **
  396. ** Returns TRUE if configuration response sent, else FALSE
  397. **
  398. *******************************************************************************/
  399. extern BOOLEAN L2CA_ConfigRsp (UINT16 cid, tL2CAP_CFG_INFO *p_cfg);
  400. /*******************************************************************************
  401. **
  402. ** Function L2CA_DisconnectReq
  403. **
  404. ** Description Higher layers call this function to disconnect a channel.
  405. **
  406. ** Returns TRUE if disconnect sent, else FALSE
  407. **
  408. *******************************************************************************/
  409. extern BOOLEAN L2CA_DisconnectReq (UINT16 cid);
  410. /*******************************************************************************
  411. **
  412. ** Function L2CA_DisconnectRsp
  413. **
  414. ** Description Higher layers call this function to acknowledge the
  415. ** disconnection of a channel.
  416. **
  417. ** Returns void
  418. **
  419. *******************************************************************************/
  420. extern BOOLEAN L2CA_DisconnectRsp (UINT16 cid);
  421. #endif ///CLASSIC_BT_INCLUDED == TRUE
  422. /*******************************************************************************
  423. **
  424. ** Function L2CA_RegisterLECoc
  425. **
  426. ** Description Other layers call this function to register for L2CAP
  427. ** Connection Oriented Channel.
  428. **
  429. ** Returns PSM to use or zero if error. Typically, the PSM returned
  430. ** is the same as was passed in, but for an outgoing-only
  431. ** connection to a dynamic PSM, a "virtual" PSM is returned
  432. ** and should be used in the calls to L2CA_ConnectLECocReq()
  433. ** and BTM_SetSecurityLevel().
  434. **
  435. *******************************************************************************/
  436. extern UINT16 L2CA_RegisterLECoc (UINT16 psm, tL2CAP_APPL_INFO *p_cb_info);
  437. /*******************************************************************************
  438. **
  439. ** Function L2CA_DeregisterLECoc
  440. **
  441. ** Description Other layers call this function to deregister for L2CAP
  442. ** Connection Oriented Channel.
  443. **
  444. ** Returns void
  445. **
  446. *******************************************************************************/
  447. extern void L2CA_DeregisterLECoc (UINT16 psm);
  448. /*******************************************************************************
  449. **
  450. ** Function L2CA_ConnectLECocReq
  451. **
  452. ** Description Higher layers call this function to create an L2CAP LE COC.
  453. ** Note that the connection is not established at this time, but
  454. ** connection establishment gets started. The callback function
  455. ** will be invoked when connection establishes or fails.
  456. **
  457. ** Returns the CID of the connection, or 0 if it failed to start
  458. **
  459. *******************************************************************************/
  460. extern UINT16 L2CA_ConnectLECocReq (UINT16 psm, BD_ADDR p_bd_addr, tL2CAP_LE_CFG_INFO *p_cfg);
  461. /*******************************************************************************
  462. **
  463. ** Function L2CA_ConnectLECocRsp
  464. **
  465. ** Description Higher layers call this function to accept an incoming
  466. ** L2CAP LE COC connection, for which they had gotten an connect
  467. ** indication callback.
  468. **
  469. ** Returns TRUE for success, FALSE for failure
  470. **
  471. *******************************************************************************/
  472. extern BOOLEAN L2CA_ConnectLECocRsp (BD_ADDR p_bd_addr, UINT8 id, UINT16 lcid, UINT16 result,
  473. UINT16 status, tL2CAP_LE_CFG_INFO *p_cfg);
  474. /*******************************************************************************
  475. **
  476. ** Function L2CA_GetPeerLECocConfig
  477. **
  478. ** Description Get peers configuration for LE Connection Oriented Channel.
  479. **
  480. ** Return value: TRUE if peer is connected
  481. **
  482. *******************************************************************************/
  483. extern BOOLEAN L2CA_GetPeerLECocConfig (UINT16 lcid, tL2CAP_LE_CFG_INFO* peer_cfg);
  484. /*******************************************************************************
  485. **
  486. ** Function L2CA_DataWrite
  487. **
  488. ** Description Higher layers call this function to write data.
  489. **
  490. ** Returns L2CAP_DW_SUCCESS, if data accepted, else FALSE
  491. ** L2CAP_DW_CONGESTED, if data accepted and the channel is congested
  492. ** L2CAP_DW_FAILED, if error
  493. **
  494. *******************************************************************************/
  495. extern UINT8 L2CA_DataWrite (UINT16 cid, BT_HDR *p_data);
  496. #if (CLASSIC_BT_INCLUDED == TRUE)
  497. /*******************************************************************************
  498. **
  499. ** Function L2CA_Ping
  500. **
  501. ** Description Higher layers call this function to send an echo request.
  502. **
  503. ** Returns TRUE if echo request sent, else FALSE.
  504. **
  505. *******************************************************************************/
  506. extern BOOLEAN L2CA_Ping (BD_ADDR p_bd_addr, tL2CA_ECHO_RSP_CB *p_cb);
  507. /*******************************************************************************
  508. **
  509. ** Function L2CA_Echo
  510. **
  511. ** Description Higher layers call this function to send an echo request
  512. ** with application-specific data.
  513. **
  514. ** Returns TRUE if echo request sent, else FALSE.
  515. **
  516. *******************************************************************************/
  517. extern BOOLEAN L2CA_Echo (BD_ADDR p_bd_addr, BT_HDR *p_data, tL2CA_ECHO_DATA_CB *p_callback);
  518. #endif ///CLASSIC_BT_INCLUDED == TRUE
  519. // Given a local channel identifier, |lcid|, this function returns the bound remote
  520. // channel identifier, |rcid|, and the ACL link handle, |handle|. If |lcid| is not
  521. // known or is invalid, this function returns false and does not modify the values
  522. // pointed at by |rcid| and |handle|. |rcid| and |handle| may be NULL.
  523. bool L2CA_GetIdentifiers(uint16_t lcid, uint16_t *rcid, uint16_t *handle);
  524. /*******************************************************************************
  525. **
  526. ** Function L2CA_SetIdleTimeout
  527. **
  528. ** Description Higher layers call this function to set the idle timeout for
  529. ** a connection, or for all future connections. The "idle timeout"
  530. ** is the amount of time that a connection can remain up with
  531. ** no L2CAP channels on it. A timeout of zero means that the
  532. ** connection will be torn down immediately when the last channel
  533. ** is removed. A timeout of 0xFFFF means no timeout. Values are
  534. ** in seconds.
  535. **
  536. ** Returns TRUE if command succeeded, FALSE if failed
  537. **
  538. *******************************************************************************/
  539. extern BOOLEAN L2CA_SetIdleTimeout (UINT16 cid, UINT16 timeout,
  540. BOOLEAN is_global);
  541. /*******************************************************************************
  542. **
  543. ** Function L2CA_SetIdleTimeoutByBdAddr
  544. **
  545. ** Description Higher layers call this function to set the idle timeout for
  546. ** a connection. The "idle timeout" is the amount of time that
  547. ** a connection can remain up with no L2CAP channels on it.
  548. ** A timeout of zero means that the connection will be torn
  549. ** down immediately when the last channel is removed.
  550. ** A timeout of 0xFFFF means no timeout. Values are in seconds.
  551. ** A bd_addr is the remote BD address. If bd_addr = BT_BD_ANY,
  552. ** then the idle timeouts for all active l2cap links will be
  553. ** changed.
  554. **
  555. ** Returns TRUE if command succeeded, FALSE if failed
  556. **
  557. ** NOTE This timeout applies to all logical channels active on the
  558. ** ACL link.
  559. *******************************************************************************/
  560. extern BOOLEAN L2CA_SetIdleTimeoutByBdAddr(BD_ADDR bd_addr, UINT16 timeout,
  561. tBT_TRANSPORT transport);
  562. /*******************************************************************************
  563. **
  564. ** Function L2CA_SetTraceLevel
  565. **
  566. ** Description This function sets the trace level for L2CAP. If called with
  567. ** a value of 0xFF, it simply reads the current trace level.
  568. **
  569. ** Returns the new (current) trace level
  570. **
  571. *******************************************************************************/
  572. extern UINT8 L2CA_SetTraceLevel (UINT8 trace_level);
  573. /*******************************************************************************
  574. **
  575. ** Function L2CA_SetDesireRole
  576. **
  577. ** Description This function sets the desire role for L2CAP.
  578. ** If the new role is L2CAP_ROLE_ALLOW_SWITCH, allow switch on
  579. ** HciCreateConnection.
  580. ** If the new role is L2CAP_ROLE_DISALLOW_SWITCH, do not allow switch on
  581. ** HciCreateConnection.
  582. **
  583. ** If the new role is a valid role (HCI_ROLE_MASTER or HCI_ROLE_SLAVE),
  584. ** the desire role is set to the new value. Otherwise, it is not changed.
  585. **
  586. ** Returns the new (current) role
  587. **
  588. *******************************************************************************/
  589. extern UINT8 L2CA_SetDesireRole (UINT8 new_role);
  590. #if (CLASSIC_BT_INCLUDED == TRUE)
  591. /*******************************************************************************
  592. **
  593. ** Function L2CA_LocalLoopbackReq
  594. **
  595. ** Description This function sets up a CID for local loopback
  596. **
  597. ** Returns CID of 0 if none.
  598. **
  599. *******************************************************************************/
  600. extern UINT16 L2CA_LocalLoopbackReq (UINT16 psm, UINT16 handle, BD_ADDR p_bd_addr);
  601. /*******************************************************************************
  602. **
  603. ** Function L2CA_FlushChannel
  604. **
  605. ** Description This function flushes none, some or all buffers queued up
  606. ** for xmission for a particular CID. If called with
  607. ** L2CAP_FLUSH_CHANS_GET (0), it simply returns the number
  608. ** of buffers queued for that CID L2CAP_FLUSH_CHANS_ALL (0xffff)
  609. ** flushes all buffers. All other values specifies the maximum
  610. ** buffers to flush.
  611. **
  612. ** Returns Number of buffers left queued for that CID
  613. **
  614. *******************************************************************************/
  615. extern UINT16 L2CA_FlushChannel (UINT16 lcid, UINT16 num_to_flush);
  616. /*******************************************************************************
  617. **
  618. ** Function L2CA_SetAclPriority
  619. **
  620. ** Description Sets the transmission priority for an ACL channel.
  621. ** (For initial implementation only two values are valid.
  622. ** L2CAP_PRIORITY_NORMAL and L2CAP_PRIORITY_HIGH).
  623. **
  624. ** Returns TRUE if a valid channel, else FALSE
  625. **
  626. *******************************************************************************/
  627. extern BOOLEAN L2CA_SetAclPriority (BD_ADDR bd_addr, UINT8 priority);
  628. /*******************************************************************************
  629. **
  630. ** Function L2CA_FlowControl
  631. **
  632. ** Description Higher layers call this function to flow control a channel.
  633. **
  634. ** data_enabled - TRUE data flows, FALSE data is stopped
  635. **
  636. ** Returns TRUE if valid channel, else FALSE
  637. **
  638. *******************************************************************************/
  639. extern BOOLEAN L2CA_FlowControl (UINT16 cid, BOOLEAN data_enabled);
  640. /*******************************************************************************
  641. **
  642. ** Function L2CA_SendTestSFrame
  643. **
  644. ** Description Higher layers call this function to send a test S-frame.
  645. **
  646. ** Returns TRUE if valid Channel, else FALSE
  647. **
  648. *******************************************************************************/
  649. extern BOOLEAN L2CA_SendTestSFrame (UINT16 cid, UINT8 sup_type,
  650. UINT8 back_track);
  651. /*******************************************************************************
  652. **
  653. ** Function L2CA_SetTxPriority
  654. **
  655. ** Description Sets the transmission priority for a channel. (FCR Mode)
  656. **
  657. ** Returns TRUE if a valid channel, else FALSE
  658. **
  659. *******************************************************************************/
  660. extern BOOLEAN L2CA_SetTxPriority (UINT16 cid, tL2CAP_CHNL_PRIORITY priority);
  661. /*******************************************************************************
  662. **
  663. ** Function L2CA_RegForNoCPEvt
  664. **
  665. ** Description Register callback for Number of Completed Packets event.
  666. **
  667. ** Input Param p_cb - callback for Number of completed packets event
  668. ** p_bda - BT address of remote device
  669. **
  670. ** Returns
  671. **
  672. *******************************************************************************/
  673. extern BOOLEAN L2CA_RegForNoCPEvt(tL2CA_NOCP_CB *p_cb, BD_ADDR p_bda);
  674. /*******************************************************************************
  675. **
  676. ** Function L2CA_SetChnlDataRate
  677. **
  678. ** Description Sets the tx/rx data rate for a channel.
  679. **
  680. ** Returns TRUE if a valid channel, else FALSE
  681. **
  682. *******************************************************************************/
  683. extern BOOLEAN L2CA_SetChnlDataRate (UINT16 cid, tL2CAP_CHNL_DATA_RATE tx, tL2CAP_CHNL_DATA_RATE rx);
  684. typedef void (tL2CA_RESERVE_CMPL_CBACK) (void);
  685. /*******************************************************************************
  686. **
  687. ** Function L2CA_SetFlushTimeout
  688. **
  689. ** Description This function set the automatic flush time out in Baseband
  690. ** for ACL-U packets.
  691. ** BdAddr : the remote BD address of ACL link. If it is BT_DB_ANY
  692. ** then the flush time out will be applied to all ACL link.
  693. ** FlushTimeout: flush time out in ms
  694. ** 0x0000 : No automatic flush
  695. ** L2CAP_NO_RETRANSMISSION : No retransmission
  696. ** 0x0002 - 0xFFFE : flush time out, if (flush_tout*8)+3/5)
  697. ** <= HCI_MAX_AUTO_FLUSH_TOUT (in 625us slot).
  698. ** Otherwise, return FALSE.
  699. ** L2CAP_NO_AUTOMATIC_FLUSH : No automatic flush
  700. **
  701. ** Returns TRUE if command succeeded, FALSE if failed
  702. **
  703. ** NOTE This flush timeout applies to all logical channels active on the
  704. ** ACL link.
  705. *******************************************************************************/
  706. extern BOOLEAN L2CA_SetFlushTimeout (BD_ADDR bd_addr, UINT16 flush_tout);
  707. #endif ///CLASSIC_BT_INCLUDED == TRUE
  708. /*******************************************************************************
  709. **
  710. ** Function L2CA_DataWriteEx
  711. **
  712. ** Description Higher layers call this function to write data with extended
  713. ** flags.
  714. ** flags : L2CAP_FLUSHABLE_CH_BASED
  715. ** L2CAP_FLUSHABLE_PKT
  716. ** L2CAP_NON_FLUSHABLE_PKT
  717. **
  718. ** Returns L2CAP_DW_SUCCESS, if data accepted, else FALSE
  719. ** L2CAP_DW_CONGESTED, if data accepted and the channel is congested
  720. ** L2CAP_DW_FAILED, if error
  721. **
  722. *******************************************************************************/
  723. extern UINT8 L2CA_DataWriteEx (UINT16 cid, BT_HDR *p_data, UINT16 flags);
  724. /*******************************************************************************
  725. **
  726. ** Function L2CA_SetChnlFlushability
  727. **
  728. ** Description Higher layers call this function to set a channels
  729. ** flushability flags
  730. **
  731. ** Returns TRUE if CID found, else FALSE
  732. **
  733. *******************************************************************************/
  734. extern BOOLEAN L2CA_SetChnlFlushability (UINT16 cid, BOOLEAN is_flushable);
  735. /*******************************************************************************
  736. **
  737. ** Function L2CA_GetPeerFeatures
  738. **
  739. ** Description Get a peers features and fixed channel map
  740. **
  741. ** Parameters: BD address of the peer
  742. ** Pointers to features and channel mask storage area
  743. **
  744. ** Return value: TRUE if peer is connected
  745. **
  746. *******************************************************************************/
  747. extern BOOLEAN L2CA_GetPeerFeatures (BD_ADDR bd_addr, UINT32 *p_ext_feat, UINT8 *p_chnl_mask);
  748. /*******************************************************************************
  749. **
  750. ** Function L2CA_GetBDAddrbyHandle
  751. **
  752. ** Description Get BD address for the given HCI handle
  753. **
  754. ** Parameters: HCI handle
  755. ** BD address of the peer
  756. **
  757. ** Return value: TRUE if found lcb for the given handle, FALSE otherwise
  758. **
  759. *******************************************************************************/
  760. extern BOOLEAN L2CA_GetBDAddrbyHandle (UINT16 handle, BD_ADDR bd_addr);
  761. #if (CLASSIC_BT_INCLUDED == TRUE)
  762. /*******************************************************************************
  763. **
  764. ** Function L2CA_GetChnlFcrMode
  765. **
  766. ** Description Get the channel FCR mode
  767. **
  768. ** Parameters: Local CID
  769. **
  770. ** Return value: Channel mode
  771. **
  772. *******************************************************************************/
  773. extern UINT8 L2CA_GetChnlFcrMode (UINT16 lcid);
  774. #endif ///CLASSIC_BT_INCLUDED == TRUE
  775. /*******************************************************************************
  776. **
  777. ** UCD callback prototypes
  778. **
  779. *******************************************************************************/
  780. /* UCD discovery. Parameters are
  781. ** BD Address of remote
  782. ** Data Type
  783. ** Data
  784. */
  785. #define L2CAP_UCD_INFO_TYPE_RECEPTION 0x01
  786. #define L2CAP_UCD_INFO_TYPE_MTU 0x02
  787. typedef void (tL2CA_UCD_DISCOVER_CB) (BD_ADDR, UINT8, UINT32);
  788. /* UCD data received. Parameters are
  789. ** BD Address of remote
  790. ** Pointer to buffer with data
  791. */
  792. typedef void (tL2CA_UCD_DATA_CB) (BD_ADDR, BT_HDR *);
  793. /* Congestion status callback protype. This callback is optional. If
  794. ** an application tries to send data when the transmit queue is full,
  795. ** the data will anyways be dropped. The parameter is:
  796. ** remote BD_ADDR
  797. ** TRUE if congested, FALSE if uncongested
  798. */
  799. typedef void (tL2CA_UCD_CONGESTION_STATUS_CB) (BD_ADDR, BOOLEAN);
  800. /* UCD registration info (the callback addresses and PSM)
  801. */
  802. typedef struct {
  803. tL2CA_UCD_DISCOVER_CB *pL2CA_UCD_Discover_Cb;
  804. tL2CA_UCD_DATA_CB *pL2CA_UCD_Data_Cb;
  805. tL2CA_UCD_CONGESTION_STATUS_CB *pL2CA_UCD_Congestion_Status_Cb;
  806. } tL2CAP_UCD_CB_INFO;
  807. /*******************************************************************************
  808. **
  809. ** Function L2CA_UcdRegister
  810. **
  811. ** Description Register PSM on UCD.
  812. **
  813. ** Parameters: tL2CAP_UCD_CB_INFO
  814. **
  815. ** Return value: TRUE if successs
  816. **
  817. *******************************************************************************/
  818. extern BOOLEAN L2CA_UcdRegister ( UINT16 psm, tL2CAP_UCD_CB_INFO *p_cb_info );
  819. /*******************************************************************************
  820. **
  821. ** Function L2CA_UcdDeregister
  822. **
  823. ** Description Deregister PSM on UCD.
  824. **
  825. ** Parameters: PSM
  826. **
  827. ** Return value: TRUE if successs
  828. **
  829. *******************************************************************************/
  830. extern BOOLEAN L2CA_UcdDeregister ( UINT16 psm );
  831. /*******************************************************************************
  832. **
  833. ** Function L2CA_UcdDiscover
  834. **
  835. ** Description Discover UCD of remote device.
  836. **
  837. ** Parameters: PSM
  838. ** BD_ADDR of remote device
  839. ** info_type : L2CAP_UCD_INFO_TYPE_RECEPTION
  840. ** L2CAP_UCD_INFO_TYPE_MTU
  841. **
  842. **
  843. ** Return value: TRUE if successs
  844. **
  845. *******************************************************************************/
  846. extern BOOLEAN L2CA_UcdDiscover ( UINT16 psm, BD_ADDR rem_bda, UINT8 info_type );
  847. /*******************************************************************************
  848. **
  849. ** Function L2CA_UcdDataWrite
  850. **
  851. ** Description Send UCD to remote device
  852. **
  853. ** Parameters: PSM
  854. ** BD Address of remote
  855. ** Pointer to buffer of type BT_HDR
  856. ** flags : L2CAP_FLUSHABLE_CH_BASED
  857. ** L2CAP_FLUSHABLE_PKT
  858. ** L2CAP_NON_FLUSHABLE_PKT
  859. **
  860. ** Return value L2CAP_DW_SUCCESS, if data accepted
  861. ** L2CAP_DW_FAILED, if error
  862. **
  863. *******************************************************************************/
  864. extern UINT16 L2CA_UcdDataWrite (UINT16 psm, BD_ADDR rem_bda, BT_HDR *p_buf, UINT16 flags);
  865. /*******************************************************************************
  866. **
  867. ** Function L2CA_UcdSetIdleTimeout
  868. **
  869. ** Description Set UCD Idle timeout.
  870. **
  871. ** Parameters: BD Addr
  872. ** Timeout in second
  873. **
  874. ** Return value: TRUE if successs
  875. **
  876. *******************************************************************************/
  877. extern BOOLEAN L2CA_UcdSetIdleTimeout ( BD_ADDR rem_bda, UINT16 timeout );
  878. /*******************************************************************************
  879. **
  880. ** Function L2CA_UCDSetTxPriority
  881. **
  882. ** Description Sets the transmission priority for a connectionless channel.
  883. **
  884. ** Returns TRUE if a valid channel, else FALSE
  885. **
  886. *******************************************************************************/
  887. extern BOOLEAN L2CA_UCDSetTxPriority ( BD_ADDR rem_bda, tL2CAP_CHNL_PRIORITY priority );
  888. /*******************************************************************************
  889. **
  890. ** Fixed Channel callback prototypes
  891. **
  892. *******************************************************************************/
  893. /* Fixed channel connected and disconnected. Parameters are
  894. ** channel
  895. ** BD Address of remote
  896. ** TRUE if channel is connected, FALSE if disconnected
  897. ** Reason for connection failure
  898. ** transport : physical transport, BR/EDR or LE
  899. */
  900. typedef void (tL2CA_FIXED_CHNL_CB) (UINT16, BD_ADDR, BOOLEAN, UINT16, tBT_TRANSPORT);
  901. /* Signalling data received. Parameters are
  902. ** channel
  903. ** BD Address of remote
  904. ** Pointer to buffer with data
  905. */
  906. typedef void (tL2CA_FIXED_DATA_CB) (UINT16, BD_ADDR, BT_HDR *);
  907. /* Congestion status callback protype. This callback is optional. If
  908. ** an application tries to send data when the transmit queue is full,
  909. ** the data will anyways be dropped. The parameter is:
  910. ** remote BD_ADDR
  911. ** TRUE if congested, FALSE if uncongested
  912. */
  913. typedef void (tL2CA_FIXED_CONGESTION_STATUS_CB) (BD_ADDR, BOOLEAN);
  914. /* Fixed channel registration info (the callback addresses and channel config)
  915. */
  916. typedef struct {
  917. tL2CA_FIXED_CHNL_CB *pL2CA_FixedConn_Cb;
  918. tL2CA_FIXED_DATA_CB *pL2CA_FixedData_Cb;
  919. tL2CA_FIXED_CONGESTION_STATUS_CB *pL2CA_FixedCong_Cb;
  920. tL2CAP_FCR_OPTS fixed_chnl_opts;
  921. UINT16 default_idle_tout;
  922. tL2CA_TX_COMPLETE_CB *pL2CA_FixedTxComplete_Cb; /* fixed channel tx complete callback */
  923. } tL2CAP_FIXED_CHNL_REG;
  924. #if (L2CAP_NUM_FIXED_CHNLS > 0)
  925. /*******************************************************************************
  926. **
  927. ** Function L2CA_RegisterFixedChannel
  928. **
  929. ** Description Register a fixed channel.
  930. **
  931. ** Parameters: Fixed Channel #
  932. ** Channel Callbacks and config
  933. **
  934. ** Return value: TRUE if registered OK
  935. **
  936. *******************************************************************************/
  937. extern BOOLEAN L2CA_RegisterFixedChannel (UINT16 fixed_cid, tL2CAP_FIXED_CHNL_REG *p_freg);
  938. /*******************************************************************************
  939. **
  940. ** Function L2CA_ConnectFixedChnl
  941. **
  942. ** Description Connect an fixed signalling channel to a remote device.
  943. **
  944. ** Parameters: Fixed CID
  945. ** BD Address of remote
  946. ** BD Address type
  947. **
  948. ** Return value: TRUE if connection started
  949. **
  950. *******************************************************************************/
  951. extern BOOLEAN L2CA_ConnectFixedChnl (UINT16 fixed_cid, BD_ADDR bd_addr, tBLE_ADDR_TYPE bd_addr_type, BOOLEAN is_aux);
  952. /*******************************************************************************
  953. **
  954. ** Function L2CA_SendFixedChnlData
  955. **
  956. ** Description Write data on a fixed signalling channel.
  957. **
  958. ** Parameters: Fixed CID
  959. ** BD Address of remote
  960. ** Pointer to buffer of type BT_HDR
  961. **
  962. ** Return value L2CAP_DW_SUCCESS, if data accepted
  963. ** L2CAP_DW_FAILED, if error
  964. **
  965. *******************************************************************************/
  966. extern UINT16 L2CA_SendFixedChnlData (UINT16 fixed_cid, BD_ADDR rem_bda, BT_HDR *p_buf);
  967. /*******************************************************************************
  968. **
  969. ** Function L2CA_RemoveFixedChnl
  970. **
  971. ** Description Remove a fixed channel to a remote device.
  972. **
  973. ** Parameters: Fixed CID
  974. ** BD Address of remote
  975. ** Idle timeout to use (or 0xFFFF if don't care)
  976. **
  977. ** Return value: TRUE if channel removed
  978. **
  979. *******************************************************************************/
  980. extern BOOLEAN L2CA_RemoveFixedChnl (UINT16 fixed_cid, BD_ADDR rem_bda);
  981. /*******************************************************************************
  982. **
  983. ** Function L2CA_SetFixedChannelTout
  984. **
  985. ** Description Higher layers call this function to set the idle timeout for
  986. ** a fixed channel. The "idle timeout" is the amount of time that
  987. ** a connection can remain up with no L2CAP channels on it.
  988. ** A timeout of zero means that the connection will be torn
  989. ** down immediately when the last channel is removed.
  990. ** A timeout of 0xFFFF means no timeout. Values are in seconds.
  991. ** A bd_addr is the remote BD address. If bd_addr = BT_BD_ANY,
  992. ** then the idle timeouts for all active l2cap links will be
  993. ** changed.
  994. **
  995. ** Returns TRUE if command succeeded, FALSE if failed
  996. **
  997. *******************************************************************************/
  998. extern BOOLEAN L2CA_SetFixedChannelTout (BD_ADDR rem_bda, UINT16 fixed_cid, UINT16 idle_tout);
  999. #endif /* (L2CAP_NUM_FIXED_CHNLS > 0) */
  1000. #if (CLASSIC_BT_INCLUDED == TRUE)
  1001. /*******************************************************************************
  1002. **
  1003. ** Function L2CA_GetCurrentConfig
  1004. **
  1005. ** Description This function returns configurations of L2CAP channel
  1006. ** pp_our_cfg : pointer of our saved configuration options
  1007. ** p_our_cfg_bits : valid config in bitmap
  1008. ** pp_peer_cfg: pointer of peer's saved configuration options
  1009. ** p_peer_cfg_bits : valid config in bitmap
  1010. **
  1011. ** Returns TRUE if successful
  1012. **
  1013. *******************************************************************************/
  1014. extern BOOLEAN L2CA_GetCurrentConfig (UINT16 lcid,
  1015. tL2CAP_CFG_INFO **pp_our_cfg, tL2CAP_CH_CFG_BITS *p_our_cfg_bits,
  1016. tL2CAP_CFG_INFO **pp_peer_cfg, tL2CAP_CH_CFG_BITS *p_peer_cfg_bits);
  1017. #endif ///CLASSIC_BT_INCLUDED == TRUE
  1018. #if (BLE_INCLUDED == TRUE)
  1019. /*******************************************************************************
  1020. **
  1021. ** Function L2CA_CancelBleConnectReq
  1022. **
  1023. ** Description Cancel a pending connection attempt to a BLE device.
  1024. **
  1025. ** Parameters: BD Address of remote
  1026. **
  1027. ** Return value: TRUE if connection was cancelled
  1028. **
  1029. *******************************************************************************/
  1030. extern BOOLEAN L2CA_CancelBleConnectReq (BD_ADDR rem_bda);
  1031. /*******************************************************************************
  1032. **
  1033. ** Function L2CA_UpdateBleConnParams
  1034. **
  1035. ** Description Update BLE connection parameters.
  1036. **
  1037. ** Parameters: BD Address of remote
  1038. **
  1039. ** Return value: TRUE if update started
  1040. **
  1041. *******************************************************************************/
  1042. extern BOOLEAN L2CA_UpdateBleConnParams (BD_ADDR rem_bdRa, UINT16 min_int,
  1043. UINT16 max_int, UINT16 latency, UINT16 timeout);
  1044. /*******************************************************************************
  1045. **
  1046. ** Function L2CA_EnableUpdateBleConnParams
  1047. **
  1048. ** Description Update BLE connection parameters.
  1049. **
  1050. ** Parameters: BD Address of remote
  1051. ** enable flag
  1052. **
  1053. ** Return value: TRUE if update started
  1054. **
  1055. *******************************************************************************/
  1056. extern BOOLEAN L2CA_EnableUpdateBleConnParams (BD_ADDR rem_bda, BOOLEAN enable);
  1057. /*******************************************************************************
  1058. **
  1059. ** Function L2CA_GetBleConnRole
  1060. **
  1061. ** Description This function returns the connection role.
  1062. **
  1063. ** Returns link role.
  1064. **
  1065. *******************************************************************************/
  1066. extern UINT8 L2CA_GetBleConnRole (BD_ADDR bd_addr);
  1067. #endif /* (BLE_INCLUDED == TRUE) */
  1068. /*******************************************************************************
  1069. **
  1070. ** Function L2CA_GetDisconnectReason
  1071. **
  1072. ** Description This function returns the disconnect reason code.
  1073. **
  1074. ** Parameters: BD Address of remote
  1075. ** Physical transport for the L2CAP connection (BR/EDR or LE)
  1076. **
  1077. ** Returns disconnect reason
  1078. **
  1079. *******************************************************************************/
  1080. extern UINT16 L2CA_GetDisconnectReason (BD_ADDR remote_bda, tBT_TRANSPORT transport);
  1081. extern BOOLEAN L2CA_CheckIsCongest(UINT16 fixed_cid, BD_ADDR addr);
  1082. #define L2CA_GET_ATT_NUM 0
  1083. #define L2CA_ADD_BTC_NUM 1
  1084. #define L2CA_DECREASE_BTC_NUM 2
  1085. #define L2CA_ADD_BTU_NUM 3
  1086. #define L2CA_DECREASE_BTU_NUM 4
  1087. #define L2CA_BUFF_INI 5
  1088. #define L2CA_BUFF_DEINIT 6
  1089. typedef struct {
  1090. UINT16 conn_id;
  1091. UINT16 * get_num;
  1092. } tl2c_buff_param_t;
  1093. extern void l2ble_update_att_acl_pkt_num(UINT8 type, tl2c_buff_param_t *param);
  1094. #ifdef __cplusplus
  1095. }
  1096. #endif
  1097. #endif /* L2C_API_H */