1 /******************************************************************************
2  *
3  *  Copyright (C) 2009-2013 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 interface file for BTA GATT client call-out functions.
22  *
23  ******************************************************************************/
24 #ifndef BTA_GATTC_CO_H
25 #define BTA_GATTC_CO_H
26 
27 #include "bta/bta_gatt_api.h"
28 #include "osi/hash_functions.h"
29 
30 /*******************************************************************************
31 **
32 ** Function         bta_gattc_co_cache_open
33 **
34 ** Description      This callout function is executed by GATTC when a GATT server
35 **                  cache is ready to be sent.
36 **
37 ** Parameter        server_bda: server bd address of this cache belongs to
38 **                  evt: call in event to be passed in when cache open is done.
39 **                  conn_id: connection ID of this cache operation attach to.
40 **                  to_save: open cache to save or to load.
41 **
42 ** Returns          void.
43 **
44 *******************************************************************************/
45 extern tBTA_GATT_STATUS bta_gattc_co_cache_open(BD_ADDR server_bda, BOOLEAN to_save, UINT8 *index);
46 
47 /*******************************************************************************
48 **
49 ** Function         bta_gattc_co_cache_close
50 **
51 ** Description      This callout function is executed by GATTC when a GATT server
52 **                  cache is written completely.
53 **
54 ** Parameter        server_bda: server bd address of this cache belongs to
55 **                  conn_id: connection ID of this cache operation attach to.
56 **
57 ** Returns          void.
58 **
59 *******************************************************************************/
60 extern void bta_gattc_co_cache_close(BD_ADDR server_bda, UINT16 conn_id);
61 
62 /*******************************************************************************
63 **
64 ** Function         bta_gattc_co_cache_save
65 **
66 ** Description      This callout function is executed by GATT when a server cache
67 **                  is available to save.
68 **
69 ** Parameter        server_bda: server bd address of this cache belongs to
70 **                  evt: call in event to be passed in when cache save is done.
71 **                  num_attr: number of attribute to be save.
72 **                  p_attr: pointer to the list of attributes to save.
73 **                  attr_index: starting attribute index of the save operation.
74 **                  conn_id: connection ID of this cache operation attach to.
75 ** Returns
76 **
77 *******************************************************************************/
78 extern void bta_gattc_co_cache_save (BD_ADDR server_bda, UINT16 num_attr,
79                               tBTA_GATTC_NV_ATTR *p_attr_list);
80 
81 /*******************************************************************************
82 **
83 ** Function         bta_gattc_co_cache_load
84 **
85 ** Description      This callout function is executed by GATT when server cache
86 **                  is required to load.
87 **
88 ** Parameter        server_bda: server bd address of this cache belongs to
89 **                  evt: call in event to be passed in when cache save is done.
90 **                  num_attr: number of attribute to be save.
91 **                  attr_index: starting attribute index of the save operation.
92 **                  conn_id: connection ID of this cache operation attach to.
93 ** Returns
94 **
95 *******************************************************************************/
96 extern tBTA_GATT_STATUS bta_gattc_co_cache_load(tBTA_GATTC_NV_ATTR *attr, UINT8 index);
97 
98 /*******************************************************************************
99 **
100 ** Function         bta_gattc_co_cache_reset
101 **
102 ** Description      This callout function is executed by GATTC to reset cache in
103 **                  application
104 **
105 ** Parameter        server_bda: server bd address of this cache belongs to
106 **
107 ** Returns          void.
108 **
109 *******************************************************************************/
110 extern void bta_gattc_co_cache_reset(BD_ADDR server_bda);
111 
112 extern size_t bta_gattc_get_cache_attr_length(UINT8 index);
113 
114 extern void bta_gattc_co_cache_addr_init(void);
115 
116 extern void bta_gattc_co_cache_addr_deinit(void);
117 
118 extern BOOLEAN bta_gattc_co_addr_in_cache(BD_ADDR bda);
119 
120 extern uint8_t bta_gattc_co_find_addr_in_cache(BD_ADDR bda);
121 
122 extern uint8_t bta_gattc_co_find_hash_in_cache(hash_key_t hash_key);
123 
124 extern UINT8 bta_gattc_co_get_addr_num(void);
125 
126 extern void bta_gattc_co_get_addr_list(BD_ADDR *addr_list);
127 
128 extern void bta_gattc_co_cache_addr_save(BD_ADDR bd_addr, hash_key_t hash_key);
129 
130 extern BOOLEAN bta_gattc_co_cache_new_assoc_list(BD_ADDR src_addr, uint8_t index);
131 
132 extern BOOLEAN bta_gattc_co_cache_append_assoc_addr(BD_ADDR src_addr, BD_ADDR assoc_addr);
133 
134 extern BOOLEAN bta_gattc_co_cache_remove_assoc_addr(BD_ADDR src_addr, BD_ADDR assoc_addr);
135 
136 uint8_t* bta_gattc_co_cache_find_src_addr(BD_ADDR assoc_addr, uint8_t *index);
137 
138 extern BOOLEAN bta_gattc_co_cache_clear_assoc_addr(BD_ADDR src_addr);
139 
140 #endif /* BTA_GATT_CO_H */
141