bta_gattc_int.h revision 90715aad34cdead03fc22bc18891c04838e90e87
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*****************************************************************************/
38enum
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};
77typedef 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  */
99typedef struct
100{
101    BT_HDR                  hdr;
102    tBT_UUID                app_uuid;
103    tBTA_GATTC_CBACK        *p_cback;
104}tBTA_GATTC_API_REG;
105
106typedef struct
107{
108    BT_HDR                  hdr;
109    tBTA_GATTC_IF           client_if;
110}tBTA_GATTC_INT_START_IF;
111
112typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_API_DEREG;
113typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_INT_DEREG;
114
115typedef 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
124typedef tBTA_GATTC_API_OPEN tBTA_GATTC_API_CANCEL_OPEN;
125
126typedef 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
135typedef 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
148typedef struct
149{
150    BT_HDR                  hdr;
151    BOOLEAN                 is_execute;
152}tBTA_GATTC_API_EXEC;
153
154typedef 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
161typedef tGATT_CL_COMPLETE tBTA_GATTC_CMPL;
162
163typedef 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
171typedef struct
172{
173    BT_HDR              hdr;
174    tBT_UUID            *p_srvc_uuid;
175}tBTA_GATTC_API_SEARCH;
176
177typedef 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
185typedef 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
194typedef struct
195{
196    BT_HDR              hdr;
197    UINT16              mtu;
198}tBTA_GATTC_API_CFG_MTU;
199
200typedef 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
210typedef struct
211{
212    BT_HDR                  hdr;
213    BD_ADDR                 remote_bda;
214    tBTA_GATTC_IF           client_if;
215}tBTA_GATTC_ENC_CMPL;
216
217typedef 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 */
247typedef union
248{
249    UINT8               uuid128[LEN_UUID_128];
250    UINT16              uuid16;
251}tBTA_GATTC_UUID;
252
253typedef 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
268typedef 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
281typedef 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
299enum
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};
306typedef UINT8 tBTA_GATTC_STATE;
307
308typedef 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     7
346#endif
347
348typedef struct
349{
350    BOOLEAN             in_use;
351    BD_ADDR             remote_bda;
352    tBTA_GATTC_CHAR_ID  char_id;
353}tBTA_GATTC_NOTIF_REG;
354
355typedef 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 */
367typedef 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             in_use;
382    tBTA_GATTC_STATE    state;
383    tBTA_GATT_STATUS    status;
384    UINT16              reason;
385} tBTA_GATTC_CLCB;
386
387/* back ground connection tracking information */
388#if GATT_MAX_APPS <= 8
389typedef UINT8 tBTA_GATTC_CIF_MASK ;
390#elif GATT_MAX_APPS <= 16
391typedef UINT16 tBTA_GATTC_CIF_MASK;
392#elif GATT_MAX_APPS <= 32
393typedef UINT32 tBTA_GATTC_CIF_MASK;
394#endif
395
396typedef struct
397{
398    BOOLEAN                 in_use;
399    BD_ADDR                 remote_bda;
400    tBTA_GATTC_CIF_MASK     cif_mask;
401    tBTA_GATTC_CIF_MASK     cif_adv_mask;
402
403}tBTA_GATTC_BG_TCK;
404
405typedef struct
406{
407    BOOLEAN             in_use;
408    BD_ADDR             remote_bda;
409}tBTA_GATTC_CONN;
410
411enum
412{
413   BTA_GATTC_STATE_DISABLED,
414   BTA_GATTC_STATE_ENABLING,
415   BTA_GATTC_STATE_ENABLED,
416   BTA_GATTC_STATE_DISABLING
417};
418
419typedef struct
420{
421    UINT8             state;
422
423    tBTA_GATTC_CONN     conn_track[BTA_GATTC_CONN_MAX];
424    tBTA_GATTC_BG_TCK   bg_track[BTA_GATTC_KNOWN_SR_MAX];
425    tBTA_GATTC_RCB      cl_rcb[BTA_GATTC_CL_MAX];
426
427    tBTA_GATTC_CLCB     clcb[BTA_GATTC_CLCB_MAX];
428    tBTA_GATTC_SERV     known_server[BTA_GATTC_KNOWN_SR_MAX];
429
430    tSDP_DISCOVERY_DB   *p_sdp_db;
431    UINT16              sdp_conn_id;
432}tBTA_GATTC_CB;
433
434/*****************************************************************************
435**  Global data
436*****************************************************************************/
437
438/* GATTC control block */
439#if BTA_DYNAMIC_MEMORY == FALSE
440extern tBTA_GATTC_CB  bta_gattc_cb;
441#else
442extern tBTA_GATTC_CB *bta_gattc_cb_ptr;
443#define bta_gattc_cb (*bta_gattc_cb_ptr)
444#endif
445
446/*****************************************************************************
447**  Function prototypes
448*****************************************************************************/
449extern BOOLEAN bta_gattc_hdl_event(BT_HDR *p_msg);
450extern BOOLEAN bta_gattc_sm_execute(tBTA_GATTC_CLCB *p_clcb, UINT16 event, tBTA_GATTC_DATA *p_data);
451
452/* function processed outside SM */
453extern void bta_gattc_disable(tBTA_GATTC_CB *p_cb);
454extern void bta_gattc_register(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data);
455extern void bta_gattc_start_if(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data);
456extern void bta_gattc_process_api_open (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
457extern void bta_gattc_process_api_open_cancel (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
458extern void bta_gattc_deregister(tBTA_GATTC_CB *p_cb, tBTA_GATTC_RCB  *p_clreg);
459extern void bta_gattc_process_enc_cmpl(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
460
461/* function within state machine */
462extern void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
463extern void bta_gattc_open_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
464extern void bta_gattc_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
465
466extern void bta_gattc_cancel_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
467extern void bta_gattc_cancel_open_ok(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
468extern void bta_gattc_cancel_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
469
470extern void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
471
472extern void bta_gattc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
473extern void bta_gattc_close_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
474extern void bta_gattc_disc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
475
476extern void bta_gattc_start_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
477extern void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
478extern void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
479extern void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
480extern void bta_gattc_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
481extern void bta_gattc_q_cmd(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
482extern void bta_gattc_search(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
483extern void bta_gattc_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
484extern void bta_gattc_confirm(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
485extern void bta_gattc_execute(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
486extern void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
487extern void bta_gattc_ci_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
488extern void bta_gattc_ci_load(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
489extern void bta_gattc_ci_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
490extern void bta_gattc_ci_save(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
491extern void bta_gattc_cache_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
492extern void bta_gattc_ignore_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
493extern void bta_gattc_restart_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA * p_msg);
494extern void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg);
495extern void bta_gattc_cancel_bk_conn(tBTA_GATTC_API_CANCEL_OPEN *p_data);
496extern void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
497                                       BD_ADDR remote_bda, UINT16 conn_id, tBTA_TRANSPORT transport,  UINT16 mtu);
498extern void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
499extern void bta_gattc_cfg_mtu(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
500#if BLE_INCLUDED == TRUE
501extern void bta_gattc_listen(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
502extern void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
503#endif
504/* utility functions */
505extern tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_cif (UINT8 client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport);
506extern tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_conn_id (UINT16 conn_id);
507extern tBTA_GATTC_CLCB * bta_gattc_clcb_alloc(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport);
508extern void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB *p_clcb);
509extern tBTA_GATTC_CLCB * bta_gattc_find_alloc_clcb(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport);
510extern tBTA_GATTC_RCB * bta_gattc_cl_get_regcb(UINT8 client_if);
511extern tBTA_GATTC_SERV * bta_gattc_find_srcb(BD_ADDR bda);
512extern tBTA_GATTC_SERV * bta_gattc_srcb_alloc(BD_ADDR bda);
513extern tBTA_GATTC_SERV * bta_gattc_find_scb_by_cid (UINT16 conn_id);
514extern tBTA_GATTC_CLCB * bta_gattc_find_int_conn_clcb(tBTA_GATTC_DATA *p_msg);
515extern tBTA_GATTC_CLCB * bta_gattc_find_int_disconn_clcb(tBTA_GATTC_DATA *p_msg);
516
517extern BOOLEAN bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
518
519extern 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);
520extern 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);
521extern BOOLEAN bta_gattc_uuid_compare (tBT_UUID *p_src, tBT_UUID *p_tar, BOOLEAN is_precise);
522extern void bta_gattc_pack_attr_uuid(tBTA_GATTC_CACHE_ATTR   *p_attr, tBT_UUID *p_uuid);
523extern BOOLEAN bta_gattc_check_notif_registry(tBTA_GATTC_RCB  *p_clreg, tBTA_GATTC_SERV *p_srcb, tBTA_GATTC_NOTIFY  *p_notify);
524extern 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);
525extern BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if,  BD_ADDR_PTR remote_bda, BOOLEAN add, BOOLEAN is_listen);
526extern BOOLEAN bta_gattc_check_bg_conn (tBTA_GATTC_IF client_if,  BD_ADDR remote_bda, UINT8 role);
527extern UINT8 bta_gattc_num_reg_app(void);
528extern void bta_gattc_clear_notif_registration(UINT16 conn_id);
529extern tBTA_GATTC_SERV * bta_gattc_find_srvr_cache(BD_ADDR bda);
530extern BOOLEAN bta_gattc_charid_compare(tBTA_GATTC_CHAR_ID *p_src, tBTA_GATTC_CHAR_ID *p_tar);
531extern BOOLEAN bta_gattc_srvcid_compare(tBTA_GATT_SRVC_ID *p_src, tBTA_GATT_SRVC_ID *p_tar);
532extern void bta_gattc_cpygattid(tBTA_GATT_ID *p_des, tBTA_GATT_ID *p_src);
533
534/* discovery functions */
535extern void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_DISC_RES *p_data);
536extern void bta_gattc_disc_cmpl_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_STATUS status);
537extern tBTA_GATT_STATUS bta_gattc_discover_procedure(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type);
538extern tBTA_GATT_STATUS bta_gattc_discover_pri_service(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type);
539extern void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid);
540extern tBTA_GATT_STATUS bta_gattc_query_cache(UINT16 conn_id, UINT8 query_type, tBTA_GATT_SRVC_ID *p_srvc_id,
541                                              tBTA_GATT_ID *p_start_rec,tBT_UUID *p_uuid_cond,
542                                              tBTA_GATT_ID *p_output, void *p_param);
543extern tBTA_GATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV *p_srvc_cb);
544extern void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srcv, UINT16 num_attr, tBTA_GATTC_NV_ATTR *p_attr, UINT16 attr_index);
545extern BOOLEAN bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id);
546
547
548extern tBTA_GATTC_CONN * bta_gattc_conn_alloc(BD_ADDR remote_bda);
549extern tBTA_GATTC_CONN * bta_gattc_conn_find(BD_ADDR remote_bda);
550extern tBTA_GATTC_CONN * bta_gattc_conn_find_alloc(BD_ADDR remote_bda);
551extern BOOLEAN bta_gattc_conn_dealloc(BD_ADDR remote_bda);
552
553#endif /* BTA_GATTC_INT_H */
554