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