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