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