l2c_api.h 46 KB

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