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