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