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 #include "bta_sys.h"
     29 #include "bta_gatt_api.h"
     30 #include "bta_gattc_ci.h"
     31 #include "bta_gattc_co.h"
     32 
     33 #include "gki.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 
     49     BTA_GATTC_API_CLOSE_EVT,
     50 
     51     BTA_GATTC_API_SEARCH_EVT,
     52     BTA_GATTC_API_CONFIRM_EVT,
     53     BTA_GATTC_API_READ_MULTI_EVT,
     54     BTA_GATTC_API_REFRESH_EVT,
     55 
     56     BTA_GATTC_INT_CONN_EVT,
     57     BTA_GATTC_INT_DISCOVER_EVT,
     58     BTA_GATTC_DISCOVER_CMPL_EVT,
     59     BTA_GATTC_OP_CMPL_EVT,
     60     BTA_GATTC_INT_DISCONN_EVT,
     61 
     62     /* for cache loading/saving */
     63     BTA_GATTC_START_CACHE_EVT,
     64     BTA_GATTC_CI_CACHE_OPEN_EVT,
     65     BTA_GATTC_CI_CACHE_LOAD_EVT,
     66     BTA_GATTC_CI_CACHE_SAVE_EVT,
     67 
     68     BTA_GATTC_INT_START_IF_EVT,
     69     BTA_GATTC_API_REG_EVT,
     70     BTA_GATTC_API_DEREG_EVT,
     71     BTA_GATTC_INT_DEREG_EVT
     72 
     73 };
     74 typedef UINT16 tBTA_GATTC_INT_EVT;
     75 
     76 /* max client application GATTC can support */
     77 #ifndef     BTA_GATTC_CL_MAX
     78 #define     BTA_GATTC_CL_MAX    32
     79 #endif
     80 
     81 /* max known devices GATTC can support */
     82 #ifndef     BTA_GATTC_KNOWN_SR_MAX
     83 #define     BTA_GATTC_KNOWN_SR_MAX    10
     84 #endif
     85 
     86 #define BTA_GATTC_CONN_MAX      GATT_MAX_PHY_CHANNEL
     87 
     88 #ifndef BTA_GATTC_CLCB_MAX
     89     #define BTA_GATTC_CLCB_MAX      GATT_CL_MAX_LCB
     90 #endif
     91 
     92 #define BTA_GATTC_WRITE_PREPARE          GATT_WRITE_PREPARE
     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_GATTC_API_OPEN;
    118 
    119 typedef tBTA_GATTC_API_OPEN tBTA_GATTC_API_CANCEL_OPEN;
    120 
    121 typedef struct
    122 {
    123     BT_HDR                  hdr;
    124     tBTA_GATT_AUTH_REQ      auth_req;
    125     tBTA_GATT_SRVC_ID       srvc_id;
    126     tBTA_GATT_ID            char_id;
    127     tBT_UUID                descr_type;
    128 } tBTA_GATTC_API_READ;
    129 
    130 typedef struct
    131 {
    132     BT_HDR                  hdr;
    133     tBTA_GATT_AUTH_REQ      auth_req;
    134     tBTA_GATT_SRVC_ID       srvc_id;
    135     tBTA_GATT_ID            char_id;
    136     tBT_UUID                descr_type;
    137     tBTA_GATTC_WRITE_TYPE   write_type;
    138     UINT16                  offset;
    139     UINT16                  len;
    140     UINT8                   *p_value;
    141 }tBTA_GATTC_API_WRITE;
    142 
    143 typedef struct
    144 {
    145     BT_HDR                  hdr;
    146     BOOLEAN                 is_execute;
    147 }tBTA_GATTC_API_EXEC;
    148 
    149 typedef struct
    150 {
    151     BT_HDR                  hdr;
    152     tBTA_GATT_SRVC_ID       srvc_id;
    153     tBTA_GATT_ID            char_id;
    154 } tBTA_GATTC_API_CONFIRM;
    155 
    156 typedef tGATT_CL_COMPLETE tBTA_GATTC_CMPL;
    157 
    158 typedef struct
    159 {
    160     BT_HDR                  hdr;
    161     UINT8                   op_code;
    162     tGATT_STATUS            status;
    163     tBTA_GATTC_CMPL         *p_cmpl;
    164 }tBTA_GATTC_OP_CMPL;
    165 
    166 typedef struct
    167 {
    168     BT_HDR              hdr;
    169     tBT_UUID            srvc_uuid;
    170 }tBTA_GATTC_API_SEARCH;
    171 
    172 typedef struct
    173 {
    174     BT_HDR                  hdr;
    175     tBTA_GATT_AUTH_REQ      auth_req;
    176     UINT8                   num_attr;
    177     tBTA_GATTC_ATTR_ID      *p_id_list;
    178 }tBTA_GATTC_API_READ_MULTI;
    179 
    180 typedef union
    181 {
    182     BT_HDR                      hdr;
    183     tBTA_GATTC_API_REG          api_reg;
    184     tBTA_GATTC_API_DEREG        api_dereg;
    185     tBTA_GATTC_API_OPEN         api_conn;
    186     tBTA_GATTC_API_CANCEL_OPEN  api_cancel_conn;
    187     tBTA_GATTC_API_READ         api_read;
    188     tBTA_GATTC_API_SEARCH       api_search;
    189     tBTA_GATTC_API_WRITE        api_write;
    190     tBTA_GATTC_API_CONFIRM      api_confirm;
    191     tBTA_GATTC_API_EXEC         api_exec;
    192     tBTA_GATTC_API_READ_MULTI   api_read_multi;
    193     tBTA_GATTC_OP_CMPL          op_cmpl;
    194     tBTA_GATTC_CI_EVT           ci_open;
    195     tBTA_GATTC_CI_EVT           ci_save;
    196     tBTA_GATTC_CI_LOAD          ci_load;
    197 
    198     tBTA_GATTC_INT_START_IF     int_start_if;
    199     tBTA_GATTC_INT_DEREG        int_dereg;
    200 
    201 } tBTA_GATTC_DATA;
    202 
    203 
    204 /* GATT server cache on the client */
    205 typedef union
    206 {
    207     UINT8               uuid128[LEN_UUID_128];
    208     UINT16              uuid16;
    209 }tBTA_GATTC_UUID;
    210 
    211 typedef struct gattc_attr_cache
    212 {
    213     tBTA_GATTC_UUID         *p_uuid;
    214     struct                  gattc_attr_cache *p_next;
    215     UINT16                  uuid_len;
    216     UINT16                  attr_handle;
    217     UINT8                   inst_id;
    218     tBTA_GATT_CHAR_PROP     property; /* if characteristic, it is char property;
    219                                          if included service, flag primary,
    220                                          if descriptor, not used */
    221     tBTA_GATTC_ATTR_TYPE    attr_type;
    222 // btla-specific ++
    223 } __attribute__((packed)) tBTA_GATTC_CACHE_ATTR;
    224 // btla-specific --
    225 
    226 typedef struct gattc_svc_cache
    227 {
    228     tBTA_GATT_SRVC_ID       service_uuid;
    229     tBTA_GATTC_CACHE_ATTR   *p_attr;
    230     tBTA_GATTC_CACHE_ATTR   *p_last_attr;
    231     UINT16                  s_handle;
    232     UINT16                  e_handle;
    233     struct                  gattc_svc_cache *p_next;
    234 // btla-specific ++
    235 } __attribute__((packed)) tBTA_GATTC_CACHE;
    236 // btla-specific --
    237 
    238 typedef struct
    239 {
    240     tBT_UUID            uuid;
    241     UINT16              s_handle;
    242     UINT16              e_handle;
    243     BOOLEAN             is_primary;
    244     UINT8               srvc_inst_id;
    245     tBTA_GATT_CHAR_PROP property;
    246 }tBTA_GATTC_ATTR_REC;
    247 
    248 
    249 #define BTA_GATTC_MAX_CACHE_CHAR    40
    250 #define BTA_GATTC_ATTR_LIST_SIZE    (BTA_GATTC_MAX_CACHE_CHAR * sizeof(tBTA_GATTC_ATTR_REC))
    251 
    252 #ifndef BTA_GATTC_CACHE_SRVR_SIZE
    253     #define BTA_GATTC_CACHE_SRVR_SIZE   600
    254 #endif
    255 
    256 enum
    257 {
    258     BTA_GATTC_IDLE_ST = 0,      /* Idle  */
    259     BTA_GATTC_W4_CONN_ST,       /* Wait for connection -  (optional) */
    260     BTA_GATTC_CONN_ST,          /* connected state */
    261     BTA_GATTC_DISCOVER_ST       /* discover is in progress */
    262 };
    263 typedef UINT8 tBTA_GATTC_STATE;
    264 
    265 typedef struct
    266 {
    267     BOOLEAN             in_use;
    268     BD_ADDR             server_bda;
    269     BOOLEAN             connected;
    270 
    271 #define BTA_GATTC_SERV_IDLE     0
    272 #define BTA_GATTC_SERV_LOAD     1
    273 #define BTA_GATTC_SERV_SAVE     2
    274 #define BTA_GATTC_SERV_DISC     3
    275 #define BTA_GATTC_SERV_DISC_ACT 4
    276 
    277     UINT8               state;
    278 
    279     tBTA_GATTC_CACHE    *p_srvc_cache;
    280     tBTA_GATTC_CACHE    *p_cur_srvc;
    281     BUFFER_Q            cache_buffer;   /* buffer queue used for storing the cache data */
    282     UINT8               *p_free;        /* starting point to next available byte */
    283     UINT16              free_byte;      /* number of available bytes in server cache buffer */
    284     UINT8               update_count;   /* indication received */
    285     UINT8               num_clcb;       /* number of associated CLCB */
    286 
    287 
    288     tBTA_GATTC_ATTR_REC *p_srvc_list;
    289     UINT8               cur_srvc_idx;
    290     UINT8               cur_char_idx;
    291     UINT8               next_avail_idx;
    292     UINT8               total_srvc;
    293     UINT8               total_char;
    294 
    295     UINT8               srvc_hdl_chg;   /* service handle change indication pending */
    296     UINT16              attr_index;     /* cahce NV saving/loading attribute index */
    297 
    298 } tBTA_GATTC_SERV;
    299 
    300 #ifndef BTA_GATTC_NOTIF_REG_MAX
    301 #define BTA_GATTC_NOTIF_REG_MAX     4
    302 #endif
    303 
    304 typedef struct
    305 {
    306     BOOLEAN             in_use;
    307     BD_ADDR             remote_bda;
    308     tBTA_GATTC_CHAR_ID  char_id;
    309 }tBTA_GATTC_NOTIF_REG;
    310 
    311 typedef struct
    312 {
    313     tBTA_GATTC_CBACK        *p_cback;
    314     BOOLEAN                 in_use;
    315     tBTA_GATTC_IF           client_if;      /* client interface with BTE stack for this application */
    316     UINT8                   num_clcb;       /* number of associated CLCB */
    317     BOOLEAN                 dereg_pending;
    318     tBT_UUID                app_uuid;
    319     tBTA_GATTC_NOTIF_REG    notif_reg[BTA_GATTC_NOTIF_REG_MAX];
    320 }tBTA_GATTC_RCB;
    321 
    322 /* client channel is a mapping between a BTA client(cl_id) and a remote BD address */
    323 typedef struct
    324 {
    325     UINT16              bta_conn_id;    /* client channel ID, unique for clcb */
    326     BD_ADDR             bda;
    327     tBTA_GATTC_RCB      *p_rcb;         /* pointer to the registration CB */
    328     tBTA_GATTC_SERV     *p_srcb;    /* server cache CB */
    329     tBTA_GATTC_DATA     *p_q_cmd;   /* command in queue waiting for execution */
    330 
    331 #define BTA_GATTC_NO_SCHEDULE       0
    332 #define BTA_GATTC_DISC_WAITING      0x01
    333 #define BTA_GATTC_REQ_WAITING       0x10
    334 
    335     UINT8               auto_update; /* auto update is waiting */
    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 typedef struct
    367 {
    368     tBTA_GATTC_CONN     conn_track[BTA_GATTC_CONN_MAX];
    369     tBTA_GATTC_BG_TCK   bg_track[BTA_GATTC_KNOWN_SR_MAX];
    370     tBTA_GATTC_RCB      cl_rcb[BTA_GATTC_CL_MAX];
    371 
    372     tBTA_GATTC_CLCB     clcb[BTA_GATTC_CLCB_MAX];
    373     tBTA_GATTC_SERV     known_server[BTA_GATTC_KNOWN_SR_MAX];
    374 
    375     tSDP_DISCOVERY_DB   *p_sdp_db;
    376     UINT16              sdp_conn_id;
    377 }tBTA_GATTC_CB;
    378 
    379 /*****************************************************************************
    380 **  Global data
    381 *****************************************************************************/
    382 
    383 /* GATTC control block */
    384 #if BTA_DYNAMIC_MEMORY == FALSE
    385 extern tBTA_GATTC_CB  bta_gattc_cb;
    386 #else
    387 extern tBTA_GATTC_CB *bta_gattc_cb_ptr;
    388 #define bta_gattc_cb (*bta_gattc_cb_ptr)
    389 #endif
    390 
    391 /*****************************************************************************
    392 **  Function prototypes
    393 *****************************************************************************/
    394 extern BOOLEAN bta_gattc_hdl_event(BT_HDR *p_msg);
    395 extern void bta_gattc_sm_execute(tBTA_GATTC_CLCB *p_clcb, UINT16 event, tBTA_GATTC_DATA *p_data);
    396 
    397 /* function processed outside SM */
    398 extern void bta_gattc_register(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data);
    399 extern void bta_gattc_start_if(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data);
    400 extern void bta_gattc_process_api_open (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
    401 extern void bta_gattc_process_api_open_cancel (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
    402 extern void bta_gattc_deregister(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data);
    403 extern void bta_gattc_int_deregister(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data);
    404 
    405 /* function within state machine */
    406 extern void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    407 extern void bta_gattc_open_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    408 extern void bta_gattc_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    409 
    410 extern void bta_gattc_cancel_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    411 extern void bta_gattc_cancel_open_ok(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    412 extern void bta_gattc_cancel_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    413 
    414 extern void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    415 
    416 extern void bta_gattc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    417 extern void bta_gattc_close_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    418 extern void bta_gattc_disc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    419 
    420 extern void bta_gattc_start_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    421 extern void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    422 extern void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    423 extern void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    424 extern void bta_gattc_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    425 extern void bta_gattc_q_cmd(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    426 extern void bta_gattc_search(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    427 extern void bta_gattc_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    428 extern void bta_gattc_confirm(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    429 extern void bta_gattc_execute(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    430 extern void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    431 extern void bta_gattc_ci_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    432 extern void bta_gattc_ci_load(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    433 extern void bta_gattc_ci_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    434 extern void bta_gattc_ci_save(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    435 extern void bta_gattc_cache_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    436 extern void bta_gattc_ignore_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    437 extern void bta_gattc_restart_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA * p_msg);
    438 extern void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg);
    439 extern void bta_gattc_cancel_bk_conn(tBTA_GATTC_API_CANCEL_OPEN *p_data);
    440 extern void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
    441                                        BD_ADDR remote_bda, UINT16 conn_id);
    442 extern void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
    443 
    444 /* utility functions */
    445 extern tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_cif (UINT8 client_if, BD_ADDR remote_bda);
    446 extern tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_conn_id (UINT16 conn_id);
    447 extern tBTA_GATTC_CLCB * bta_gattc_clcb_alloc(tBTA_GATTC_IF client_if, BD_ADDR remote_bda);
    448 extern void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB *p_clcb);
    449 extern tBTA_GATTC_CLCB * bta_gattc_find_alloc_clcb(tBTA_GATTC_IF client_if, BD_ADDR remote_bda);
    450 extern tBTA_GATTC_RCB * bta_gattc_cl_get_regcb(UINT8 client_if);
    451 extern tBTA_GATTC_SERV * bta_gattc_find_srcb(BD_ADDR bda);
    452 extern tBTA_GATTC_SERV * bta_gattc_srcb_alloc(BD_ADDR bda);
    453 extern tBTA_GATTC_SERV * bta_gattc_find_scb_by_cid (UINT16 conn_id);
    454 extern BOOLEAN bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    455 
    456 extern UINT16 bta_gattc_id2handle(tBTA_GATTC_SERV *p_srcb, tBTA_GATT_SRVC_ID *p_service_id, tBTA_GATT_ID *p_char_id, tBT_UUID descr_uuid);
    457 extern BOOLEAN bta_gattc_handle2id(tBTA_GATTC_SERV *p_srcb, UINT16 handle, tBTA_GATT_SRVC_ID *service_id, tBTA_GATT_ID *char_id, tBT_UUID *p_type);
    458 extern BOOLEAN bta_gattc_uuid_compare (tBT_UUID src, tBT_UUID tar, BOOLEAN is_precise);
    459 extern void bta_gattc_pack_attr_uuid(tBTA_GATTC_CACHE_ATTR   *p_attr, tBT_UUID *p_uuid);
    460 extern BOOLEAN bta_gattc_check_notif_registry(tBTA_GATTC_RCB  *p_clreg, tBTA_GATTC_SERV *p_srcb, tBTA_GATTC_NOTIFY  *p_notify);
    461 extern tBTA_GATT_STATUS bta_gattc_pack_read_cb_data(tBTA_GATTC_SERV *p_srcb, tBT_UUID descr_uuid, tGATT_VALUE *p_attr, tBTA_GATT_READ_VAL *p_value);
    462 extern BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if,  BD_ADDR_PTR remote_bda, BOOLEAN add, BOOLEAN is_listen);
    463 extern BOOLEAN bta_gattc_check_bg_conn (tBTA_GATTC_IF client_if,  BD_ADDR remote_bda, UINT8 role);
    464 extern UINT8 bta_gattc_num_reg_app(void);
    465 extern void bta_gattc_clear_notif_registration(UINT16 conn_id);
    466 extern tBTA_GATTC_SERV * bta_gattc_find_srvr_cache(BD_ADDR bda);
    467 extern BOOLEAN bta_gattc_charid_compare(tBTA_GATTC_CHAR_ID *p_src, tBTA_GATTC_CHAR_ID *p_tar);
    468 extern BOOLEAN bta_gattc_srvcid_compare(tBTA_GATT_SRVC_ID *p_src, tBTA_GATT_SRVC_ID *p_tar);
    469 extern void bta_gattc_cpygattid(tBTA_GATT_ID *p_des, tBTA_GATT_ID *p_src);
    470 
    471 /* discovery functions */
    472 extern void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_DISC_RES *p_data);
    473 extern void bta_gattc_disc_cmpl_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_STATUS status);
    474 extern tBTA_GATT_STATUS bta_gattc_discover_procedure(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type);
    475 extern tBTA_GATT_STATUS bta_gattc_discover_pri_service(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type);
    476 extern void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID uuid);
    477 extern tBTA_GATT_STATUS bta_gattc_query_cache(UINT16 conn_id, UINT8 query_type, tBTA_GATT_SRVC_ID *p_srvc_id,
    478                                               tBTA_GATT_ID *p_start_rec,tBT_UUID *p_uuid_cond,
    479                                               tBTA_GATT_ID *p_output, void *p_property);
    480 extern tBTA_GATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV *p_srvc_cb);
    481 extern void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srcv, UINT16 num_attr, tBTA_GATTC_NV_ATTR *p_attr, UINT16 attr_index);
    482 extern BOOLEAN bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id);
    483 
    484 
    485 extern tBTA_GATTC_CONN * bta_gattc_conn_alloc(BD_ADDR remote_bda);
    486 extern tBTA_GATTC_CONN * bta_gattc_conn_find(BD_ADDR remote_bda);
    487 extern tBTA_GATTC_CONN * bta_gattc_conn_find_alloc(BD_ADDR remote_bda);
    488 extern BOOLEAN bta_gattc_conn_dealloc(BD_ADDR remote_bda);
    489 
    490 #endif /* BTA_GATTC_INT_H */
    491