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_API_LISTEN_EVT,
     72     BTA_GATTC_API_DISABLE_EVT
     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 
     95 /* internal strucutre for GATTC register API  */
     96 typedef struct
     97 {
     98     BT_HDR                  hdr;
     99     tBT_UUID                app_uuid;
    100     tBTA_GATTC_CBACK        *p_cback;
    101 }tBTA_GATTC_API_REG;
    102 
    103 typedef struct
    104 {
    105     BT_HDR                  hdr;
    106     tBTA_GATTC_IF           client_if;
    107 }tBTA_GATTC_INT_START_IF;
    108 
    109 typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_API_DEREG;
    110 typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_INT_DEREG;
    111 
    112 typedef struct
    113 {
    114     BT_HDR                  hdr;
    115     BD_ADDR                 remote_bda;
    116     tBTA_GATTC_IF           client_if;
    117     BOOLEAN                 is_direct;
    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     tBTA_GATT_SRVC_ID       srvc_id;
    127     tBTA_GATT_ID            char_id;
    128     tBTA_GATT_ID            *p_descr_type;
    129 } tBTA_GATTC_API_READ;
    130 
    131 typedef struct
    132 {
    133     BT_HDR                  hdr;
    134     tBTA_GATT_AUTH_REQ      auth_req;
    135     tBTA_GATT_SRVC_ID       srvc_id;
    136     tBTA_GATT_ID            char_id;
    137     tBTA_GATT_ID            *p_descr_type;
    138     tBTA_GATTC_WRITE_TYPE   write_type;
    139     UINT16                  offset;
    140     UINT16                  len;
    141     UINT8                   *p_value;
    142 }tBTA_GATTC_API_WRITE;
    143 
    144 typedef struct
    145 {
    146     BT_HDR                  hdr;
    147     BOOLEAN                 is_execute;
    148 }tBTA_GATTC_API_EXEC;
    149 
    150 typedef struct
    151 {
    152     BT_HDR                  hdr;
    153     tBTA_GATT_SRVC_ID       srvc_id;
    154     tBTA_GATT_ID            char_id;
    155 } tBTA_GATTC_API_CONFIRM;
    156 
    157 typedef tGATT_CL_COMPLETE tBTA_GATTC_CMPL;
    158 
    159 typedef struct
    160 {
    161     BT_HDR                  hdr;
    162     UINT8                   op_code;
    163     tGATT_STATUS            status;
    164     tBTA_GATTC_CMPL         *p_cmpl;
    165 }tBTA_GATTC_OP_CMPL;
    166 
    167 typedef struct
    168 {
    169     BT_HDR              hdr;
    170     tBT_UUID            *p_srvc_uuid;
    171 }tBTA_GATTC_API_SEARCH;
    172 
    173 typedef struct
    174 {
    175     BT_HDR                  hdr;
    176     tBTA_GATT_AUTH_REQ      auth_req;
    177     UINT8                   num_attr;
    178     tBTA_GATTC_ATTR_ID      *p_id_list;
    179 }tBTA_GATTC_API_READ_MULTI;
    180 
    181 typedef struct
    182 {
    183     BT_HDR                  hdr;
    184     BD_ADDR_PTR             remote_bda;
    185     tBTA_GATTC_IF           client_if;
    186     BOOLEAN                 start;
    187 } tBTA_GATTC_API_LISTEN;
    188 
    189 typedef struct
    190 {
    191     BT_HDR                  hdr;
    192     BD_ADDR                 remote_bda;
    193     tBTA_GATTC_IF           client_if;
    194     UINT8                   role;
    195     tGATT_DISCONN_REASON    reason;
    196 }tBTA_GATTC_INT_CONN;
    197 
    198 typedef union
    199 {
    200     BT_HDR                      hdr;
    201     tBTA_GATTC_API_REG          api_reg;
    202     tBTA_GATTC_API_DEREG        api_dereg;
    203     tBTA_GATTC_API_OPEN         api_conn;
    204     tBTA_GATTC_API_CANCEL_OPEN  api_cancel_conn;
    205     tBTA_GATTC_API_READ         api_read;
    206     tBTA_GATTC_API_SEARCH       api_search;
    207     tBTA_GATTC_API_WRITE        api_write;
    208     tBTA_GATTC_API_CONFIRM      api_confirm;
    209     tBTA_GATTC_API_EXEC         api_exec;
    210     tBTA_GATTC_API_READ_MULTI   api_read_multi;
    211     tBTA_GATTC_OP_CMPL          op_cmpl;
    212     tBTA_GATTC_CI_EVT           ci_open;
    213     tBTA_GATTC_CI_EVT           ci_save;
    214     tBTA_GATTC_CI_LOAD          ci_load;
    215     tBTA_GATTC_INT_CONN         int_conn;
    216 
    217     tBTA_GATTC_INT_START_IF     int_start_if;
    218     tBTA_GATTC_INT_DEREG        int_dereg;
    219     /* if peripheral role is supported */
    220     tBTA_GATTC_API_LISTEN       api_listen;
    221 
    222 } tBTA_GATTC_DATA;
    223 
    224 
    225 /* GATT server cache on the client */
    226 typedef union
    227 {
    228     UINT8               uuid128[LEN_UUID_128];
    229     UINT16              uuid16;
    230 }tBTA_GATTC_UUID;
    231 
    232 typedef struct gattc_attr_cache
    233 {
    234     tBTA_GATTC_UUID         *p_uuid;
    235     struct                  gattc_attr_cache *p_next;
    236     UINT16                  uuid_len;
    237     UINT16                  attr_handle;
    238     UINT8                   inst_id;
    239     tBTA_GATT_CHAR_PROP     property; /* if characteristic, it is char property;
    240                                          if included service, flag primary,
    241                                          if descriptor, not used */
    242     tBTA_GATTC_ATTR_TYPE    attr_type;
    243 // btla-specific ++
    244 } __attribute__((packed)) tBTA_GATTC_CACHE_ATTR;
    245 // btla-specific --
    246 
    247 typedef struct gattc_svc_cache
    248 {
    249     tBTA_GATT_SRVC_ID       service_uuid;
    250     tBTA_GATTC_CACHE_ATTR   *p_attr;
    251     tBTA_GATTC_CACHE_ATTR   *p_last_attr;
    252     UINT16                  s_handle;
    253     UINT16                  e_handle;
    254     struct                  gattc_svc_cache *p_next;
    255     tBTA_GATTC_CACHE_ATTR   *p_cur_char;
    256 // btla-specific ++
    257 } __attribute__((packed)) tBTA_GATTC_CACHE;
    258 // btla-specific --
    259 
    260 typedef struct
    261 {
    262     tBT_UUID            uuid;
    263     UINT16              s_handle;
    264     UINT16              e_handle;
    265     BOOLEAN             is_primary;
    266     UINT8               srvc_inst_id;
    267     tBTA_GATT_CHAR_PROP property;
    268 }tBTA_GATTC_ATTR_REC;
    269 
    270 
    271 #define BTA_GATTC_MAX_CACHE_CHAR    40
    272 #define BTA_GATTC_ATTR_LIST_SIZE    (BTA_GATTC_MAX_CACHE_CHAR * sizeof(tBTA_GATTC_ATTR_REC))
    273 
    274 #ifndef BTA_GATTC_CACHE_SRVR_SIZE
    275     #define BTA_GATTC_CACHE_SRVR_SIZE   600
    276 #endif
    277 
    278 enum
    279 {
    280     BTA_GATTC_IDLE_ST = 0,      /* Idle  */
    281     BTA_GATTC_W4_CONN_ST,       /* Wait for connection -  (optional) */
    282     BTA_GATTC_CONN_ST,          /* connected state */
    283     BTA_GATTC_DISCOVER_ST       /* discover is in progress */
    284 };
    285 typedef UINT8 tBTA_GATTC_STATE;
    286 
    287 typedef struct
    288 {
    289     BOOLEAN             in_use;
    290     BD_ADDR             server_bda;
    291     BOOLEAN             connected;
    292 
    293 #define BTA_GATTC_SERV_IDLE     0
    294 #define BTA_GATTC_SERV_LOAD     1
    295 #define BTA_GATTC_SERV_SAVE     2
    296 #define BTA_GATTC_SERV_DISC     3
    297 #define BTA_GATTC_SERV_DISC_ACT 4
    298 
    299     UINT8               state;
    300 
    301     tBTA_GATTC_CACHE    *p_srvc_cache;
    302     tBTA_GATTC_CACHE    *p_cur_srvc;
    303     BUFFER_Q            cache_buffer;   /* buffer queue used for storing the cache data */
    304     UINT8               *p_free;        /* starting point to next available byte */
    305     UINT16              free_byte;      /* number of available bytes in server cache buffer */
    306     UINT8               update_count;   /* indication received */
    307     UINT8               num_clcb;       /* number of associated CLCB */
    308 
    309 
    310     tBTA_GATTC_ATTR_REC *p_srvc_list;
    311     UINT8               cur_srvc_idx;
    312     UINT8               cur_char_idx;
    313     UINT8               next_avail_idx;
    314     UINT8               total_srvc;
    315     UINT8               total_char;
    316 
    317     UINT8               srvc_hdl_chg;   /* service handle change indication pending */
    318     UINT16              attr_index;     /* cahce NV saving/loading attribute index */
    319 
    320 } tBTA_GATTC_SERV;
    321 
    322 #ifndef BTA_GATTC_NOTIF_REG_MAX
    323 #define BTA_GATTC_NOTIF_REG_MAX     4
    324 #endif
    325 
    326 typedef struct
    327 {
    328     BOOLEAN             in_use;
    329     BD_ADDR             remote_bda;
    330     tBTA_GATTC_CHAR_ID  char_id;
    331 }tBTA_GATTC_NOTIF_REG;
    332 
    333 typedef struct
    334 {
    335     tBTA_GATTC_CBACK        *p_cback;
    336     BOOLEAN                 in_use;
    337     tBTA_GATTC_IF           client_if;      /* client interface with BTE stack for this application */
    338     UINT8                   num_clcb;       /* number of associated CLCB */
    339     BOOLEAN                 dereg_pending;
    340     tBT_UUID                app_uuid;
    341     tBTA_GATTC_NOTIF_REG    notif_reg[BTA_GATTC_NOTIF_REG_MAX];
    342 }tBTA_GATTC_RCB;
    343 
    344 /* client channel is a mapping between a BTA client(cl_id) and a remote BD address */
    345 typedef struct
    346 {
    347     UINT16              bta_conn_id;    /* client channel ID, unique for clcb */
    348     BD_ADDR             bda;
    349     tBTA_GATTC_RCB      *p_rcb;         /* pointer to the registration CB */
    350     tBTA_GATTC_SERV     *p_srcb;    /* server cache CB */
    351     tBTA_GATTC_DATA     *p_q_cmd;   /* command in queue waiting for execution */
    352 
    353 #define BTA_GATTC_NO_SCHEDULE       0
    354 #define BTA_GATTC_DISC_WAITING      0x01
    355 #define BTA_GATTC_REQ_WAITING       0x10
    356 
    357     UINT8               auto_update; /* auto update is waiting */
    358     BOOLEAN             in_use;
    359     tBTA_GATTC_STATE    state;
    360     tBTA_GATT_STATUS    status;
    361     UINT16              reason;
    362 } tBTA_GATTC_CLCB;
    363 
    364 /* back ground connection tracking information */
    365 #if GATT_MAX_APPS <= 8
    366 typedef UINT8 tBTA_GATTC_CIF_MASK ;
    367 #elif GATT_MAX_APPS <= 16
    368 typedef UINT16 tBTA_GATTC_CIF_MASK;
    369 #elif GATT_MAX_APPS <= 32
    370 typedef UINT32 tBTA_GATTC_CIF_MASK;
    371 #endif
    372 
    373 typedef struct
    374 {
    375     BOOLEAN                 in_use;
    376     BD_ADDR                 remote_bda;
    377     tBTA_GATTC_CIF_MASK     cif_mask;
    378     tBTA_GATTC_CIF_MASK     cif_adv_mask;
    379 
    380 }tBTA_GATTC_BG_TCK;
    381 
    382 typedef struct
    383 {
    384     BOOLEAN             in_use;
    385     BD_ADDR             remote_bda;
    386 }tBTA_GATTC_CONN;
    387 
    388 enum
    389 {
    390    BTA_GATTC_STATE_DISABLED,
    391    BTA_GATTC_STATE_ENABLING,
    392    BTA_GATTC_STATE_ENABLED,
    393    BTA_GATTC_STATE_DISABLING
    394 };
    395 
    396 typedef struct
    397 {
    398     UINT8             state;
    399 
    400     tBTA_GATTC_CONN     conn_track[BTA_GATTC_CONN_MAX];
    401     tBTA_GATTC_BG_TCK   bg_track[BTA_GATTC_KNOWN_SR_MAX];
    402     tBTA_GATTC_RCB      cl_rcb[BTA_GATTC_CL_MAX];
    403 
    404     tBTA_GATTC_CLCB     clcb[BTA_GATTC_CLCB_MAX];
    405     tBTA_GATTC_SERV     known_server[BTA_GATTC_KNOWN_SR_MAX];
    406 
    407     tSDP_DISCOVERY_DB   *p_sdp_db;
    408     UINT16              sdp_conn_id;
    409 }tBTA_GATTC_CB;
    410 
    411 /*****************************************************************************
    412 **  Global data
    413 *****************************************************************************/
    414 
    415 /* GATTC control block */
    416 #if BTA_DYNAMIC_MEMORY == FALSE
    417 extern tBTA_GATTC_CB  bta_gattc_cb;
    418 #else
    419 extern tBTA_GATTC_CB *bta_gattc_cb_ptr;
    420 #define bta_gattc_cb (*bta_gattc_cb_ptr)
    421 #endif
    422 
    423 /*****************************************************************************
    424 **  Function prototypes
    425 *****************************************************************************/
    426 extern BOOLEAN bta_gattc_hdl_event(BT_HDR *p_msg);
    427 extern void bta_gattc_sm_execute(tBTA_GATTC_CLCB *p_clcb, UINT16 event, tBTA_GATTC_DATA *p_data);
    428 
    429 /* function processed outside SM */
    430 extern void bta_gattc_disable(tBTA_GATTC_CB *p_cb);
    431 extern void bta_gattc_register(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data);
    432 extern void bta_gattc_start_if(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data);
    433 extern void bta_gattc_process_api_open (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
    434 extern void bta_gattc_process_api_open_cancel (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
    435 extern void bta_gattc_deregister(tBTA_GATTC_CB *p_cb, tBTA_GATTC_RCB  *p_clreg);
    436 
    437 /* function within state machine */
    438 extern void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    439 extern void bta_gattc_open_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    440 extern void bta_gattc_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    441 
    442 extern void bta_gattc_cancel_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    443 extern void bta_gattc_cancel_open_ok(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    444 extern void bta_gattc_cancel_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    445 
    446 extern void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    447 
    448 extern void bta_gattc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    449 extern void bta_gattc_close_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    450 extern void bta_gattc_disc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    451 
    452 extern void bta_gattc_start_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    453 extern void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    454 extern void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    455 extern void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    456 extern void bta_gattc_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    457 extern void bta_gattc_q_cmd(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    458 extern void bta_gattc_search(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    459 extern void bta_gattc_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    460 extern void bta_gattc_confirm(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    461 extern void bta_gattc_execute(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    462 extern void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    463 extern void bta_gattc_ci_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    464 extern void bta_gattc_ci_load(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    465 extern void bta_gattc_ci_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    466 extern void bta_gattc_ci_save(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    467 extern void bta_gattc_cache_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    468 extern void bta_gattc_ignore_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    469 extern void bta_gattc_restart_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA * p_msg);
    470 extern void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg);
    471 extern void bta_gattc_cancel_bk_conn(tBTA_GATTC_API_CANCEL_OPEN *p_data);
    472 extern void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
    473                                        BD_ADDR remote_bda, UINT16 conn_id);
    474 extern void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
    475 #if BLE_INCLUDED == TRUE
    476 extern void bta_gattc_listen(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
    477 #endif
    478 /* utility functions */
    479 extern tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_cif (UINT8 client_if, BD_ADDR remote_bda);
    480 extern tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_conn_id (UINT16 conn_id);
    481 extern tBTA_GATTC_CLCB * bta_gattc_clcb_alloc(tBTA_GATTC_IF client_if, BD_ADDR remote_bda);
    482 extern void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB *p_clcb);
    483 extern tBTA_GATTC_CLCB * bta_gattc_find_alloc_clcb(tBTA_GATTC_IF client_if, BD_ADDR remote_bda);
    484 extern tBTA_GATTC_RCB * bta_gattc_cl_get_regcb(UINT8 client_if);
    485 extern tBTA_GATTC_SERV * bta_gattc_find_srcb(BD_ADDR bda);
    486 extern tBTA_GATTC_SERV * bta_gattc_srcb_alloc(BD_ADDR bda);
    487 extern tBTA_GATTC_SERV * bta_gattc_find_scb_by_cid (UINT16 conn_id);
    488 extern tBTA_GATTC_CLCB * bta_gattc_find_int_conn_clcb(tBTA_GATTC_DATA *p_msg);
    489 extern tBTA_GATTC_CLCB * bta_gattc_find_int_disconn_clcb(tBTA_GATTC_DATA *p_msg);
    490 
    491 extern BOOLEAN bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
    492 
    493 extern UINT16 bta_gattc_id2handle(tBTA_GATTC_SERV *p_srcb, tBTA_GATT_SRVC_ID *p_service_id, tBTA_GATT_ID *p_char_id, tBTA_GATT_ID *p_descr_uuid);
    494 extern BOOLEAN bta_gattc_handle2id(tBTA_GATTC_SERV *p_srcb, UINT16 handle, tBTA_GATT_SRVC_ID *service_id, tBTA_GATT_ID *char_id, tBTA_GATT_ID *p_type);
    495 extern BOOLEAN bta_gattc_uuid_compare (tBT_UUID *p_src, tBT_UUID *p_tar, BOOLEAN is_precise);
    496 extern void bta_gattc_pack_attr_uuid(tBTA_GATTC_CACHE_ATTR   *p_attr, tBT_UUID *p_uuid);
    497 extern BOOLEAN bta_gattc_check_notif_registry(tBTA_GATTC_RCB  *p_clreg, tBTA_GATTC_SERV *p_srcb, tBTA_GATTC_NOTIFY  *p_notify);
    498 extern tBTA_GATT_STATUS bta_gattc_pack_read_cb_data(tBTA_GATTC_SERV *p_srcb, tBT_UUID *p_descr_uuid, tGATT_VALUE *p_attr, tBTA_GATT_READ_VAL *p_value);
    499 extern BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if,  BD_ADDR_PTR remote_bda, BOOLEAN add, BOOLEAN is_listen);
    500 extern BOOLEAN bta_gattc_check_bg_conn (tBTA_GATTC_IF client_if,  BD_ADDR remote_bda, UINT8 role);
    501 extern UINT8 bta_gattc_num_reg_app(void);
    502 extern void bta_gattc_clear_notif_registration(UINT16 conn_id);
    503 extern tBTA_GATTC_SERV * bta_gattc_find_srvr_cache(BD_ADDR bda);
    504 extern BOOLEAN bta_gattc_charid_compare(tBTA_GATTC_CHAR_ID *p_src, tBTA_GATTC_CHAR_ID *p_tar);
    505 extern BOOLEAN bta_gattc_srvcid_compare(tBTA_GATT_SRVC_ID *p_src, tBTA_GATT_SRVC_ID *p_tar);
    506 extern void bta_gattc_cpygattid(tBTA_GATT_ID *p_des, tBTA_GATT_ID *p_src);
    507 
    508 /* discovery functions */
    509 extern void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_DISC_RES *p_data);
    510 extern void bta_gattc_disc_cmpl_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_STATUS status);
    511 extern tBTA_GATT_STATUS bta_gattc_discover_procedure(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type);
    512 extern tBTA_GATT_STATUS bta_gattc_discover_pri_service(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type);
    513 extern void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid);
    514 extern tBTA_GATT_STATUS bta_gattc_query_cache(UINT16 conn_id, UINT8 query_type, tBTA_GATT_SRVC_ID *p_srvc_id,
    515                                               tBTA_GATT_ID *p_start_rec,tBT_UUID *p_uuid_cond,
    516                                               tBTA_GATT_ID *p_output, void *p_param);
    517 extern tBTA_GATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV *p_srvc_cb);
    518 extern void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srcv, UINT16 num_attr, tBTA_GATTC_NV_ATTR *p_attr, UINT16 attr_index);
    519 extern BOOLEAN bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id);
    520 
    521 
    522 extern tBTA_GATTC_CONN * bta_gattc_conn_alloc(BD_ADDR remote_bda);
    523 extern tBTA_GATTC_CONN * bta_gattc_conn_find(BD_ADDR remote_bda);
    524 extern tBTA_GATTC_CONN * bta_gattc_conn_find_alloc(BD_ADDR remote_bda);
    525 extern BOOLEAN bta_gattc_conn_dealloc(BD_ADDR remote_bda);
    526 
    527 #endif /* BTA_GATTC_INT_H */
    528