• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2009-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 #ifndef BTIF_STORAGE_H
20 #define BTIF_STORAGE_H
21 
22 #include "data_types.h"
23 #include "bt_types.h"
24 
25 #include <utils/Log.h>
26 
27 /*******************************************************************************
28 **  Constants & Macros
29 ********************************************************************************/
30 #define BTIF_STORAGE_FILL_PROPERTY(p_prop, t, l, p_v) \
31          (p_prop)->type = t;(p_prop)->len = l; (p_prop)->val = (p_v);
32 
33 #define  BTIF_STORAGE_MAX_ALLOWED_REMOTE_DEVICE 512
34 
35 /*******************************************************************************
36 **  Functions
37 ********************************************************************************/
38 
39 /*******************************************************************************
40 **
41 ** Function         btif_storage_get_adapter_property
42 **
43 ** Description      BTIF storage API - Fetches the adapter property->type
44 **                  from NVRAM and fills property->val.
45 **                  Caller should provide memory for property->val and
46 **                  set the property->val
47 **
48 ** Returns          BT_STATUS_SUCCESS if the fetch was successful,
49 **                  BT_STATUS_FAIL otherwise
50 **
51 *******************************************************************************/
52 bt_status_t btif_storage_get_adapter_property(bt_property_t *property);
53 
54 /*******************************************************************************
55 **
56 ** Function         btif_storage_set_adapter_property
57 **
58 ** Description      BTIF storage API - Stores the adapter property
59 **                  to NVRAM
60 **
61 ** Returns          BT_STATUS_SUCCESS if the store was successful,
62 **                  BT_STATUS_FAIL otherwise
63 **
64 *******************************************************************************/
65 bt_status_t btif_storage_set_adapter_property(bt_property_t *property);
66 
67 /*******************************************************************************
68 **
69 ** Function         btif_storage_get_remote_device_property
70 **
71 ** Description      BTIF storage API - Fetches the remote device property->type
72 **                  from NVRAM and fills property->val.
73 **                  Caller should provide memory for property->val and
74 **                  set the property->val
75 **
76 ** Returns          BT_STATUS_SUCCESS if the fetch was successful,
77 **                  BT_STATUS_FAIL otherwise
78 **
79 *******************************************************************************/
80 bt_status_t btif_storage_get_remote_device_property(bt_bdaddr_t *remote_bd_addr,
81                                                     bt_property_t *property);
82 
83 /*******************************************************************************
84 **
85 ** Function         btif_storage_set_remote_device_property
86 **
87 ** Description      BTIF storage API - Stores the remote device property
88 **                  to NVRAM
89 **
90 ** Returns          BT_STATUS_SUCCESS if the store was successful,
91 **                  BT_STATUS_FAIL otherwise
92 **
93 *******************************************************************************/
94 bt_status_t btif_storage_set_remote_device_property(bt_bdaddr_t *remote_bd_addr,
95                                                     bt_property_t *property);
96 
97 /*******************************************************************************
98 **
99 ** Function         btif_storage_add_remote_device
100 **
101 ** Description      BTIF storage API - Adds a newly discovered device to NVRAM
102 **                  along with the timestamp. Also, stores the various
103 **                  properties - RSSI, BDADDR, NAME (if found in EIR)
104 **
105 ** Returns          BT_STATUS_SUCCESS if the store was successful,
106 **                  BT_STATUS_FAIL otherwise
107 **
108 *******************************************************************************/
109 bt_status_t btif_storage_add_remote_device(bt_bdaddr_t *remote_bd_addr,
110                                            uint32_t num_properties,
111                                            bt_property_t *properties);
112 
113 /*******************************************************************************
114 **
115 ** Function         btif_storage_add_bonded_device
116 **
117 ** Description      BTIF storage API - Adds the newly bonded device to NVRAM
118 **                  along with the link-key, Key type and Pin key length
119 **
120 ** Returns          BT_STATUS_SUCCESS if the store was successful,
121 **                  BT_STATUS_FAIL otherwise
122 **
123 *******************************************************************************/
124 bt_status_t btif_storage_add_bonded_device(bt_bdaddr_t *remote_bd_addr,
125                                            LINK_KEY link_key,
126                                            uint8_t key_type,
127                                            uint8_t pin_length);
128 
129 /*******************************************************************************
130 **
131 ** Function         btif_storage_remove_bonded_device
132 **
133 ** Description      BTIF storage API - Deletes the bonded device from NVRAM
134 **
135 ** Returns          BT_STATUS_SUCCESS if the deletion was successful,
136 **                  BT_STATUS_FAIL otherwise
137 **
138 *******************************************************************************/
139 bt_status_t btif_storage_remove_bonded_device(bt_bdaddr_t *remote_bd_addr);
140 
141 /*******************************************************************************
142 **
143 ** Function         btif_storage_remove_bonded_device
144 **
145 ** Description      BTIF storage API - Deletes the bonded device from NVRAM
146 **
147 ** Returns          BT_STATUS_SUCCESS if the deletion was successful,
148 **                  BT_STATUS_FAIL otherwise
149 **
150 *******************************************************************************/
151 bt_status_t btif_storage_load_bonded_devices(void);
152 
153 /*******************************************************************************
154 **
155 ** Function         btif_storage_read_hl_apps_cb
156 **
157 ** Description      BTIF storage API - Read HL application control block from NVRAM
158 **
159 ** Returns          BT_STATUS_SUCCESS if the operation was successful,
160 **                  BT_STATUS_FAIL otherwise
161 **
162 *******************************************************************************/
163 bt_status_t btif_storage_read_hl_apps_cb(char *value, int value_size);
164 
165 /*******************************************************************************
166 **
167 ** Function         btif_storage_write_hl_apps_cb
168 **
169 ** Description      BTIF storage API - Write HL application control block to NVRAM
170 **
171 ** Returns          BT_STATUS_SUCCESS if the operation was successful,
172 **                  BT_STATUS_FAIL otherwise
173 **
174 *******************************************************************************/
175 bt_status_t btif_storage_write_hl_apps_cb(char *value, int value_size);
176 
177 /*******************************************************************************
178 **
179 ** Function         btif_storage_read_hl_apps_cb
180 **
181 ** Description      BTIF storage API - Read HL application configuration from NVRAM
182 **
183 ** Returns          BT_STATUS_SUCCESS if the operation was successful,
184 **                  BT_STATUS_FAIL otherwise
185 **
186 *******************************************************************************/
187 bt_status_t btif_storage_read_hl_app_data(UINT8 app_idx, char *value, int value_size);
188 
189 /*******************************************************************************
190 **
191 ** Function         btif_storage_write_hl_app_data
192 **
193 ** Description      BTIF storage API - Write HL application configuration to NVRAM
194 **
195 ** Returns          BT_STATUS_SUCCESS if the operation was successful,
196 **                  BT_STATUS_FAIL otherwise
197 **
198 *******************************************************************************/
199 bt_status_t btif_storage_write_hl_app_data(UINT8 app_idx, char *value, int value_size);
200 
201 /*******************************************************************************
202 **
203 ** Function         btif_storage_read_hl_mdl_data
204 **
205 ** Description      BTIF storage API - Read HL application MDL configuration from NVRAM
206 **
207 ** Returns          BT_STATUS_SUCCESS if the operation was successful,
208 **                  BT_STATUS_FAIL otherwise
209 **
210 *******************************************************************************/
211 bt_status_t btif_storage_read_hl_mdl_data(UINT8 app_idx, char *value, int value_size);
212 
213 /*******************************************************************************
214 **
215 ** Function         btif_storage_write_hl_mdl_data
216 **
217 ** Description      BTIF storage API - Write HL application MDL configuration from NVRAM
218 **
219 ** Returns          BT_STATUS_SUCCESS if the operation was successful,
220 **                  BT_STATUS_FAIL otherwise
221 **
222 *******************************************************************************/
223 bt_status_t btif_storage_write_hl_mdl_data(UINT8 app_idx, char *value, int value_size);
224 
225 /*******************************************************************************
226 **
227 ** Function         btif_storage_add_hid_device_info
228 **
229 ** Description      BTIF storage API - Adds the hid information of bonded hid devices-to NVRAM
230 **
231 ** Returns          BT_STATUS_SUCCESS if the store was successful,
232 **                  BT_STATUS_FAIL otherwise
233 **
234 *******************************************************************************/
235 
236 bt_status_t btif_storage_add_hid_device_info(bt_bdaddr_t *remote_bd_addr,
237                                                     UINT16 attr_mask, UINT8 sub_class,
238                                                     UINT8 app_id, UINT16 vendor_id,
239                                                     UINT16 product_id, UINT16 version,
240                                                     UINT8 ctry_code, UINT16 ssr_max_latency,
241                                                     UINT16 ssr_min_tout, UINT16 dl_len, UINT8 *dsc_list);
242 
243 /*******************************************************************************
244 **
245 ** Function         btif_storage_load_bonded_hid_info
246 **
247 ** Description      BTIF storage API - Loads hid info for all the bonded devices from NVRAM
248 **                  and adds those devices  to the BTA_HH.
249 **
250 ** Returns          BT_STATUS_SUCCESS if successful, BT_STATUS_FAIL otherwise
251 **
252 *******************************************************************************/
253 bt_status_t btif_storage_load_bonded_hid_info(void);
254 
255 /*******************************************************************************
256 **
257 ** Function         btif_storage_remove_hid_info
258 **
259 ** Description      BTIF storage API - Deletes the bonded hid device info from NVRAM
260 **
261 ** Returns          BT_STATUS_SUCCESS if the deletion was successful,
262 **                  BT_STATUS_FAIL otherwise
263 **
264 *******************************************************************************/
265 bt_status_t btif_storage_remove_hid_info(bt_bdaddr_t *remote_bd_addr);
266 
267 /*******************************************************************************
268 **
269 ** Function         btif_storage_load_autopair_device_list
270 **
271 ** Description      BTIF storage API - Populates auto pair device list
272 **
273 ** Returns          BT_STATUS_SUCCESS if the auto pair blacklist is successfully populated
274 **                  BT_STATUS_FAIL otherwise
275 **
276 *******************************************************************************/
277 bt_status_t btif_storage_load_autopair_device_list();
278 
279 /*******************************************************************************
280 **
281 ** Function         btif_storage_is_device_autopair_blacklisted
282 **
283 ** Description      BTIF storage API  Checks if the given device is blacklisted for auto pairing
284 **
285 ** Returns          TRUE if the device is found in the auto pair blacklist
286 **                  FALSE otherwise
287 **
288 *******************************************************************************/
289 
290 BOOLEAN  btif_storage_is_device_autopair_blacklisted(bt_bdaddr_t *remote_bd_addr);
291 
292 /*******************************************************************************
293 **
294 ** Function         btif_storage_add_device_to_autopair_blacklist
295 **
296 ** Description      BTIF storage API - Add a remote device to the auto pairing blacklist
297 **
298 ** Returns          BT_STATUS_SUCCESS if the device is successfully added to the auto pair blacklist
299 **                  BT_STATUS_FAIL otherwise
300 **
301 *******************************************************************************/
302 
303 bt_status_t btif_storage_add_device_to_autopair_blacklist(bt_bdaddr_t *remote_bd_addr);
304 
305 /*******************************************************************************
306 **
307 ** Function         btif_storage_is_fixed_pin_zeros_keyboard
308 **
309 ** Description      BTIF storage API - checks if this device has fixed PIN key device list
310 **
311 ** Returns          TRUE   if the device is found in the fixed pin keyboard device list
312 **                  FALSE otherwise
313 **
314 *******************************************************************************/
315 BOOLEAN btif_storage_is_fixed_pin_zeros_keyboard(bt_bdaddr_t *remote_bd_addr);
316 
317 #if (BLE_INCLUDED == TRUE)
318 bt_status_t btif_storage_add_ble_bonding_key( bt_bdaddr_t *remote_bd_addr,
319                                               char *key,
320                                               uint8_t key_type,
321                                               uint8_t key_length);
322 bt_status_t btif_storage_get_ble_bonding_key(bt_bdaddr_t *remote_bd_addr,
323                                              UINT8 key_type,
324                                              char *key_value,
325                                              int key_length);
326 
327 bt_status_t btif_storage_add_ble_local_key(char *key,
328                                            uint8_t key_type,
329                                            uint8_t key_length);
330 bt_status_t btif_storage_remove_ble_bonding_keys(bt_bdaddr_t *remote_bd_addr);
331 bt_status_t btif_storage_remove_ble_local_keys(void);
332 bt_status_t btif_storage_get_ble_local_key(UINT8 key_type,
333                                            char *key_value,
334                                            int key_len);
335 
336 bt_status_t btif_storage_get_remote_addr_type(bt_bdaddr_t *remote_bd_addr,
337                                               int *addr_type);
338 
339 bt_status_t btif_storage_set_remote_addr_type(bt_bdaddr_t *remote_bd_addr,
340                                               UINT8 addr_type);
341 
342 #endif
343 /*******************************************************************************
344 **
345 ** Function         btif_storage_get_remote_version
346 **
347 ** Description      Fetch remote version info on cached remote device
348 **
349 ** Returns          BT_STATUS_SUCCESS if found
350 **                  BT_STATUS_FAIL otherwise
351 **
352 *******************************************************************************/
353 
354 bt_status_t btif_storage_get_remote_version(const bt_bdaddr_t *remote_bd_addr,
355                                   bt_remote_version_t *p_ver);
356 
357 /*******************************************************************************
358 **
359 ** Function         btif_storage_set_dmt_support_type
360 **
361 ** Description      Sets DMT support status for a remote device
362 **
363 ** Returns          BT_STATUS_SUCCESS if config update is successful
364 **                  BT_STATUS_FAIL otherwise
365 **
366 *******************************************************************************/
367 
368 bt_status_t btif_storage_set_dmt_support_type(const bt_bdaddr_t *remote_bd_addr,
369                                                    BOOLEAN dmt_supported);
370 
371 
372 
373 /*******************************************************************************
374 **
375 ** Function         btif_storage_is_dmt_supported_device
376 **
377 ** Description      checks if a device supports Dual mode topology
378 **
379 ** Returns         TRUE if remote supports DMT else FALSE
380 **
381 *******************************************************************************/
382 
383 BOOLEAN btif_storage_is_dmt_supported_device(const bt_bdaddr_t *remote_bd_addr);
384 
385 
386 #endif /* BTIF_STORAGE_H */
387