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