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