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