Home | History | Annotate | Download | only in gatt
      1 /******************************************************************************
      2  *
      3  *  Copyright (C) 2003-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 is the private file for the file transfer client (FTC).
     22  *
     23  ******************************************************************************/
     24 #ifndef BTA_GATTC_INT_H
     25 #define BTA_GATTC_INT_H
     26 
     27 #include "bt_target.h"
     28 
     29 #include "osi/include/fixed_queue.h"
     30 #include "bta_sys.h"
     31 #include "bta_gatt_api.h"
     32 
     33 #include "bt_common.h"
     34 
     35 /*****************************************************************************
     36 **  Constants and data types
     37 *****************************************************************************/
     38 enum
     39 {
     40     BTA_GATTC_API_OPEN_EVT   = BTA_SYS_EVT_START(BTA_ID_GATTC),
     41     BTA_GATTC_INT_OPEN_FAIL_EVT,
     42     BTA_GATTC_API_CANCEL_OPEN_EVT,
     43     BTA_GATTC_INT_CANCEL_OPEN_OK_EVT,
     44 
     45     BTA_GATTC_API_READ_EVT,
     46     BTA_GATTC_API_WRITE_EVT,
     47     BTA_GATTC_API_EXEC_EVT,
     48     BTA_GATTC_API_CFG_MTU_EVT,
     49 
     50     BTA_GATTC_API_CLOSE_EVT,
     51 
     52     BTA_GATTC_API_SEARCH_EVT,
     53     BTA_GATTC_API_CONFIRM_EVT,
     54     BTA_GATTC_API_READ_MULTI_EVT,
     55     BTA_GATTC_API_REFRESH_EVT,
     56 
     57     BTA_GATTC_INT_CONN_EVT,
     58     BTA_GATTC_INT_DISCOVER_EVT,
     59     BTA_GATTC_DISCOVER_CMPL_EVT,
     60     BTA_GATTC_OP_CMPL_EVT,
     61     BTA_GATTC_INT_DISCONN_EVT,
     62 
     63     BTA_GATTC_INT_START_IF_EVT,
     64     BTA_GATTC_API_REG_EVT,
     65     BTA_GATTC_API_DEREG_EVT,
     66     BTA_GATTC_API_LISTEN_EVT,
     67     BTA_GATTC_API_BROADCAST_EVT,
     68     BTA_GATTC_API_DISABLE_EVT,
     69     BTA_GATTC_ENC_CMPL_EVT
     70 };
     71 typedef UINT16 tBTA_GATTC_INT_EVT;
     72 
     73 #define BTA_GATTC_SERVICE_CHANGED_LEN    4
     74 
     75 /* max client application GATTC can support */
     76 #ifndef     BTA_GATTC_CL_MAX
     77 #define     BTA_GATTC_CL_MAX    32
     78 #endif
     79 
     80 /* max known devices GATTC can support */
     81 #ifndef     BTA_GATTC_KNOWN_SR_MAX
     82 #define     BTA_GATTC_KNOWN_SR_MAX    10
     83 #endif
     84 
     85 #define BTA_GATTC_CONN_MAX      GATT_MAX_PHY_CHANNEL
     86 
     87 #ifndef BTA_GATTC_CLCB_MAX
     88     #define BTA_GATTC_CLCB_MAX      GATT_CL_MAX_LCB
     89 #endif
     90 
     91 #define BTA_GATTC_WRITE_PREPARE          GATT_WRITE_PREPARE
     92 
     93 
     94 /* internal strucutre for GATTC register API  */
     95 typedef struct
     96 {
     97     BT_HDR                  hdr;
     98     tBT_UUID                app_uuid;
     99     tBTA_GATTC_CBACK        *p_cback;
    100 }tBTA_GATTC_API_REG;
    101 
    102 typedef struct
    103 {
    104     BT_HDR                  hdr;
    105     tBTA_GATTC_IF           client_if;
    106 }tBTA_GATTC_INT_START_IF;
    107 
    108 typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_API_DEREG;
    109 typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_INT_DEREG;
    110 
    111 typedef struct
    112 {
    113     BT_HDR                  hdr;
    114     BD_ADDR                 remote_bda;
    115     tBTA_GATTC_IF           client_if;
    116     BOOLEAN                 is_direct;
    117     tBTA_TRANSPORT          transport;
    118 } tBTA_GATTC_API_OPEN;
    119 
    120 typedef tBTA_GATTC_API_OPEN tBTA_GATTC_API_CANCEL_OPEN;
    121 
    122 typedef struct
    123 {
    124     BT_HDR                  hdr;
    125     tBTA_GATT_AUTH_REQ      auth_req;
    126     UINT16                  handle;
    127     tBTA_GATTC_EVT          cmpl_evt;
    128 } tBTA_GATTC_API_READ;
    129 
    130 typedef struct
    131 {
    132     BT_HDR                  hdr;
    133     tBTA_GATT_AUTH_REQ      auth_req;
    134     UINT16                  handle;
    135     tBTA_GATTC_EVT          cmpl_evt;
    136     tBTA_GATTC_WRITE_TYPE   write_type;
    137     UINT16                  offset;
    138     UINT16                  len;
    139     UINT8                   *p_value;
    140 }tBTA_GATTC_API_WRITE;
    141 
    142 typedef struct
    143 {
    144     BT_HDR                  hdr;
    145     BOOLEAN                 is_execute;
    146 }tBTA_GATTC_API_EXEC;
    147 
    148 typedef struct
    149 {
    150     BT_HDR                  hdr;
    151     UINT16                  handle;
    152 } tBTA_GATTC_API_CONFIRM;
    153 
    154 typedef tGATT_CL_COMPLETE tBTA_GATTC_CMPL;
    155 
    156 typedef struct
    157 {
    158     BT_HDR                  hdr;
    159     UINT8                   op_code;
    160     tGATT_STATUS            status;
    161     tBTA_GATTC_CMPL         *p_cmpl;
    162 }tBTA_GATTC_OP_CMPL;
    163 
    164 typedef struct
    165 {
    166     BT_HDR              hdr;
    167     tBT_UUID            *p_srvc_uuid;
    168 }tBTA_GATTC_API_SEARCH;
    169 
    170 typedef struct
    171 {
    172     BT_HDR                  hdr;
    173     tBTA_GATT_AUTH_REQ      auth_req;
    174     UINT8                   num_attr;
    175     UINT16                  handles[GATT_MAX_READ_MULTI_HANDLES];
    176 }tBTA_GATTC_API_READ_MULTI;
    177 
    178 typedef struct
    179 {
    180     BT_HDR                  hdr;
    181     BD_ADDR_PTR             remote_bda;
    182     tBTA_GATTC_IF           client_if;
    183     BOOLEAN                 start;
    184 } tBTA_GATTC_API_LISTEN;
    185 
    186 
    187 typedef struct
    188 {
    189     BT_HDR              hdr;
    190     UINT16              mtu;
    191 }tBTA_GATTC_API_CFG_MTU;
    192 
    193 typedef struct
    194 {
    195     BT_HDR                  hdr;
    196     BD_ADDR                 remote_bda;
    197     tBTA_GATTC_IF           client_if;
    198     UINT8                   role;
    199     tBT_TRANSPORT           transport;
    200     tGATT_DISCONN_REASON    reason;
    201 }tBTA_GATTC_INT_CONN;
    202 
    203 typedef struct
    204 {
    205     BT_HDR                  hdr;
    206     BD_ADDR                 remote_bda;
    207     tBTA_GATTC_IF           client_if;
    208 }tBTA_GATTC_ENC_CMPL;
    209 
    210 typedef union
    211 {
    212     BT_HDR                      hdr;
    213     tBTA_GATTC_API_REG          api_reg;
    214     tBTA_GATTC_API_DEREG        api_dereg;
    215     tBTA_GATTC_API_OPEN         api_conn;
    216     tBTA_GATTC_API_CANCEL_OPEN  api_cancel_conn;
    217     tBTA_GATTC_API_READ         api_read;
    218     tBTA_GATTC_API_SEARCH       api_search;
    219     tBTA_GATTC_API_WRITE        api_write;
    220     tBTA_GATTC_API_CONFIRM      api_confirm;
    221     tBTA_GATTC_API_EXEC         api_exec;
    222     tBTA_GATTC_API_READ_MULTI   api_read_multi;
    223     tBTA_GATTC_API_CFG_MTU      api_mtu;
    224     tBTA_GATTC_OP_CMPL          op_cmpl;
    225     tBTA_GATTC_INT_CONN         int_conn;
    226     tBTA_GATTC_ENC_CMPL         enc_cmpl;
    227 
    228     tBTA_GATTC_INT_START_IF     int_start_if;
    229     tBTA_GATTC_INT_DEREG        int_dereg;
    230     /* if peripheral role is supported */
    231     tBTA_GATTC_API_LISTEN       api_listen;
    232 
    233 } tBTA_GATTC_DATA;
    234 
    235 
    236 /* GATT server cache on the client */
    237 
    238 typedef struct
    239 {
    240     tBT_UUID            uuid;
    241     UINT16              s_handle;
    242     UINT16              e_handle;
    243     // this field is set only for characteristic
    244     UINT16              char_decl_handle;
    245     BOOLEAN             is_primary;
    246     tBTA_GATT_CHAR_PROP property;
    247 }tBTA_GATTC_ATTR_REC;
    248 
    249 
    250 #define BTA_GATTC_MAX_CACHE_CHAR    40
    251 #define BTA_GATTC_ATTR_LIST_SIZE    (BTA_GATTC_MAX_CACHE_CHAR * sizeof(tBTA_GATTC_ATTR_REC))
    252 
    253 #ifndef BTA_GATTC_CACHE_SRVR_SIZE
    254     #define BTA_GATTC_CACHE_SRVR_SIZE   600
    255 #endif
    256 
    257 enum
    258 {
    259     BTA_GATTC_IDLE_ST = 0,      /* Idle  */
    260     BTA_GATTC_W4_CONN_ST,       /* Wait for connection -  (optional) */
    261     BTA_GATTC_CONN_ST,          /* connected state */
    262     BTA_GATTC_DISCOVER_ST       /* discover is in progress */
    263 };
    264 typedef UINT8 tBTA_GATTC_STATE;
    265 
    266 typedef struct
    267 {
    268     BOOLEAN             in_use;
    269     BD_ADDR             server_bda;
    270     BOOLEAN             connected;
    271 
    272 #define BTA_GATTC_SERV_IDLE     0
    273 #define BTA_GATTC_SERV_LOAD     1
    274 #define BTA_GATTC_SERV_SAVE     2
    275 #define BTA_GATTC_SERV_DISC     3
    276 #define BTA_GATTC_SERV_DISC_ACT 4
    277 
    278     UINT8               state;
    279 
    280     list_t              *p_srvc_cache;  /* list of tBTA_GATTC_SERVICE */
    281     UINT8               update_count;   /* indication received */
    282     UINT8               num_clcb;       /* number of associated CLCB */
    283 
    284 
    285     tBTA_GATTC_ATTR_REC *p_srvc_list;
    286     UINT8               cur_srvc_idx;
    287     UINT8               cur_char_idx;
    288     UINT8               next_avail_idx;
    289     UINT8               total_srvc;
    290     UINT8               total_char;
    291 
    292     UINT8               srvc_hdl_chg;   /* service handle change indication pending */
    293     UINT16              attr_index;     /* cahce NV saving/loading attribute index */
    294 
    295     UINT16              mtu;
    296 } tBTA_GATTC_SERV;
    297 
    298 #ifndef BTA_GATTC_NOTIF_REG_MAX
    299 #define BTA_GATTC_NOTIF_REG_MAX     15
    300 #endif
    301 
    302 typedef struct
    303 {
    304     BOOLEAN             in_use;
    305     BD_ADDR             remote_bda;
    306     UINT16              handle;
    307 }tBTA_GATTC_NOTIF_REG;
    308 
    309 typedef struct
    310 {
    311     tBTA_GATTC_CBACK        *p_cback;
    312     BOOLEAN                 in_use;
    313     tBTA_GATTC_IF           client_if;      /* client interface with BTE stack for this application */
    314     UINT8                   num_clcb;       /* number of associated CLCB */
    315     BOOLEAN                 dereg_pending;
    316     tBT_UUID                app_uuid;
    317     tBTA_GATTC_NOTIF_REG    notif_reg[BTA_GATTC_NOTIF_REG_MAX];
    318 }tBTA_GATTC_RCB;
    319 
    320 /* client channel is a mapping between a BTA client(cl_id) and a remote BD address */
    321 typedef struct
    322 {
    323     UINT16              bta_conn_id;    /* client channel ID, unique for clcb */
    324     BD_ADDR             bda;
    325     tBTA_TRANSPORT      transport;      /* channel transport */
    326     tBTA_GATTC_RCB      *p_rcb;         /* pointer to the registration CB */
    327     tBTA_GATTC_SERV     *p_srcb;    /* server cache CB */
    328     tBTA_GATTC_DATA     *p_q_cmd;   /* command in queue waiting for execution */
    329 
    330 #define BTA_GATTC_NO_SCHEDULE       0
    331 #define BTA_GATTC_DISC_WAITING      0x01
    332 #define BTA_GATTC_REQ_WAITING       0x10
    333 
    334     UINT8               auto_update; /* auto update is waiting */
    335     BOOLEAN             disc_active;
    336     BOOLEAN             in_use;
    337     tBTA_GATTC_STATE    state;
    338     tBTA_GATT_STATUS    status;
    339     UINT16              reason;
    340 } tBTA_GATTC_CLCB;
    341 
    342 /* back ground connection tracking information */
    343 #if GATT_MAX_APPS <= 8
    344 typedef UINT8 tBTA_GATTC_CIF_MASK ;
    345 #elif GATT_MAX_APPS <= 16
    346 typedef UINT16 tBTA_GATTC_CIF_MASK;
    347 #elif GATT_MAX_APPS <= 32
    348 typedef UINT32 tBTA_GATTC_CIF_MASK;
    349 #endif
    350 
    351 typedef struct
    352 {
    353     BOOLEAN                 in_use;
    354     BD_ADDR                 remote_bda;
    355     tBTA_GATTC_CIF_MASK     cif_mask;
    356     tBTA_GATTC_CIF_MASK     cif_adv_mask;
    357 
    358 }tBTA_GATTC_BG_TCK;
    359 
    360 typedef struct
    361 {
    362     BOOLEAN             in_use;
    363     BD_ADDR             remote_bda;
    364 }tBTA_GATTC_CONN;
    365 
    366 enum
    367 {
    368    BTA_GATTC_STATE_DISABLED,
    369    BTA_GATTC_STATE_ENABLING,
    370    BTA_GATTC_STATE_ENABLED,
    371    BTA_GATTC_STATE_DISABLING
    372 };
    373 
    374 typedef struct
    375 {
    376     UINT8             state;
    377 
    378     tBTA_GATTC_CONN     conn_track[BTA_GATTC_CONN_MAX];
    379     tBTA_GATTC_BG_TCK   bg_track[BTA_GATTC_KNOWN_SR_MAX];
    380     tBTA_GATTC_RCB      cl_rcb[BTA_GATTC_CL_MAX];
    381 
    382     tBTA_GATTC_CLCB     clcb[BTA_GATTC_CLCB_MAX];
    383     tBTA_GATTC_SERV     known_server[BTA_GATTC_KNOWN_SR_MAX];
    384 }tBTA_GATTC_CB;
    385 
    386 /*****************************************************************************
    387 **  Global data
    388 *****************************************************************************/
    389 
    390 /* GATTC control block */
    391 #if BTA_DYNAMIC_MEMORY == FALSE
    392 extern tBTA_GATTC_CB  bta_gattc_cb;
    393 #else
    394 extern tBTA_GATTC_CB *bta_gattc_cb_ptr;
    395 #define bta_gattc_cb (*bta_gattc_cb_ptr)
    396 #endif
    397 
    398 /*****************************************************************************
    399 **  Function prototypes
    400 *****************************************************************************/
    401 extern BOOLEAN bta_gattc_hdl_event(BT_HDR *p_msg);
    402 extern BOOLEAN bta_gattc_sm_execute(tBTA_GATTC_CLCB *p_clcb, UINT16 event, tBTA_GATTC_DATA *p_data);
    403 
    404 /* function processed outside SM */
    405 extern void bta_gattc_disable(tBTA_GATTC_CB *p_cb);
    406 extern void bta_gattc_register(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data);
    407 extern void bta_gattc_start_if(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data);
    408 extern void bta_gattc_process_api_open (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
    409 extern void bta_gattc_process_api_open_cancel (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
    410 extern void bta_gattc_deregister(tBTA_GATTC_CB *p_cb, tBTA_GATTC_RCB  *p_clreg);
    411 extern void bta_gattc_process_enc_cmpl(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
    412 
    413 /* function within state machine */
    414 extern void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    415 extern void bta_gattc_open_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    416 extern void bta_gattc_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    417 
    418 extern void bta_gattc_cancel_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    419 extern void bta_gattc_cancel_open_ok(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    420 extern void bta_gattc_cancel_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    421 
    422 extern void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    423 
    424 extern void bta_gattc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    425 extern void bta_gattc_close_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    426 extern void bta_gattc_disc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    427 
    428 extern void bta_gattc_start_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    429 extern void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    430 extern void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    431 extern void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    432 extern void bta_gattc_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    433 extern void bta_gattc_q_cmd(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    434 extern void bta_gattc_search(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    435 extern void bta_gattc_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    436 extern void bta_gattc_confirm(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    437 extern void bta_gattc_execute(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    438 extern void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    439 extern void bta_gattc_ci_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    440 extern void bta_gattc_ci_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    441 extern void bta_gattc_ignore_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    442 extern void bta_gattc_restart_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA * p_msg);
    443 extern void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg);
    444 extern void bta_gattc_cancel_bk_conn(tBTA_GATTC_API_CANCEL_OPEN *p_data);
    445 extern void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
    446                                        BD_ADDR remote_bda, UINT16 conn_id, tBTA_TRANSPORT transport,  UINT16 mtu);
    447 extern void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
    448 extern void bta_gattc_cfg_mtu(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    449 #if BLE_INCLUDED == TRUE
    450 extern void bta_gattc_listen(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
    451 extern void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
    452 #endif
    453 /* utility functions */
    454 extern tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_cif (UINT8 client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport);
    455 extern tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_conn_id (UINT16 conn_id);
    456 extern tBTA_GATTC_CLCB * bta_gattc_clcb_alloc(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport);
    457 extern void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB *p_clcb);
    458 extern tBTA_GATTC_CLCB * bta_gattc_find_alloc_clcb(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport);
    459 extern tBTA_GATTC_RCB * bta_gattc_cl_get_regcb(UINT8 client_if);
    460 extern tBTA_GATTC_SERV * bta_gattc_find_srcb(BD_ADDR bda);
    461 extern tBTA_GATTC_SERV * bta_gattc_srcb_alloc(BD_ADDR bda);
    462 extern tBTA_GATTC_SERV * bta_gattc_find_scb_by_cid (UINT16 conn_id);
    463 extern tBTA_GATTC_CLCB * bta_gattc_find_int_conn_clcb(tBTA_GATTC_DATA *p_msg);
    464 extern tBTA_GATTC_CLCB * bta_gattc_find_int_disconn_clcb(tBTA_GATTC_DATA *p_msg);
    465 
    466 extern BOOLEAN bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    467 
    468 extern BOOLEAN bta_gattc_uuid_compare (const tBT_UUID *p_src, const tBT_UUID *p_tar, BOOLEAN is_precise);
    469 extern BOOLEAN bta_gattc_check_notif_registry(tBTA_GATTC_RCB  *p_clreg, tBTA_GATTC_SERV *p_srcb, tBTA_GATTC_NOTIFY  *p_notify);
    470 extern BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if,  BD_ADDR_PTR remote_bda, BOOLEAN add, BOOLEAN is_listen);
    471 extern BOOLEAN bta_gattc_check_bg_conn (tBTA_GATTC_IF client_if,  BD_ADDR remote_bda, UINT8 role);
    472 extern UINT8 bta_gattc_num_reg_app(void);
    473 extern void bta_gattc_clear_notif_registration(tBTA_GATTC_SERV *p_srcb, UINT16 conn_id, UINT16 start_handle, UINT16 end_handle);
    474 extern tBTA_GATTC_SERV * bta_gattc_find_srvr_cache(BD_ADDR bda);
    475 
    476 /* discovery functions */
    477 extern void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_DISC_RES *p_data);
    478 extern void bta_gattc_disc_cmpl_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_STATUS status);
    479 extern tBTA_GATT_STATUS bta_gattc_discover_procedure(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type);
    480 extern tBTA_GATT_STATUS bta_gattc_discover_pri_service(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type);
    481 extern void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid);
    482 extern const list_t* bta_gattc_get_services(UINT16 conn_id);
    483 extern const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle(UINT16 conn_id, UINT16 handle);
    484 tBTA_GATTC_CHARACTERISTIC*  bta_gattc_get_characteristic_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle);
    485 extern tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic(UINT16 conn_id, UINT16 handle);
    486 extern tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor(UINT16 conn_id, UINT16 handle);
    487 extern void bta_gattc_get_gatt_db(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, btgatt_db_element_t **db, int *count);
    488 extern tBTA_GATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV *p_srvc_cb);
    489 extern void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srcv, UINT16 num_attr, tBTA_GATTC_NV_ATTR *attr);
    490 extern void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id);
    491 extern void bta_gattc_reset_discover_st(tBTA_GATTC_SERV *p_srcb, tBTA_GATT_STATUS status);
    492 
    493 extern tBTA_GATTC_CONN * bta_gattc_conn_alloc(BD_ADDR remote_bda);
    494 extern tBTA_GATTC_CONN * bta_gattc_conn_find(BD_ADDR remote_bda);
    495 extern tBTA_GATTC_CONN * bta_gattc_conn_find_alloc(BD_ADDR remote_bda);
    496 extern BOOLEAN bta_gattc_conn_dealloc(BD_ADDR remote_bda);
    497 
    498 extern bool bta_gattc_cache_load(tBTA_GATTC_CLCB *p_clcb);
    499 extern void bta_gattc_cache_reset(BD_ADDR server_bda);
    500 
    501 #endif /* BTA_GATTC_INT_H */
    502