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