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 dl_len, UINT8 *dsc_list); 240 241/******************************************************************************* 242** 243** Function btif_storage_load_bonded_hid_info 244** 245** Description BTIF storage API - Loads hid info for all the bonded devices from NVRAM 246** and adds those devices to the BTA_HH. 247** 248** Returns BT_STATUS_SUCCESS if successful, BT_STATUS_FAIL otherwise 249** 250*******************************************************************************/ 251bt_status_t btif_storage_load_bonded_hid_info(void); 252 253/******************************************************************************* 254** 255** Function btif_storage_remove_hid_info 256** 257** Description BTIF storage API - Deletes the bonded hid device info from NVRAM 258** 259** Returns BT_STATUS_SUCCESS if the deletion was successful, 260** BT_STATUS_FAIL otherwise 261** 262*******************************************************************************/ 263bt_status_t btif_storage_remove_hid_info(bt_bdaddr_t *remote_bd_addr); 264 265/******************************************************************************* 266** 267** Function btif_storage_load_autopair_device_list 268** 269** Description BTIF storage API - Populates auto pair device list 270** 271** Returns BT_STATUS_SUCCESS if the auto pair blacklist is successfully populated 272** BT_STATUS_FAIL otherwise 273** 274*******************************************************************************/ 275bt_status_t btif_storage_load_autopair_device_list(); 276 277/******************************************************************************* 278** 279** Function btif_storage_is_device_autopair_blacklisted 280** 281** Description BTIF storage API Checks if the given device is blacklisted for auto pairing 282** 283** Returns TRUE if the device is found in the auto pair blacklist 284** FALSE otherwise 285** 286*******************************************************************************/ 287 288BOOLEAN btif_storage_is_device_autopair_blacklisted(bt_bdaddr_t *remote_bd_addr); 289 290/******************************************************************************* 291** 292** Function btif_storage_add_device_to_autopair_blacklist 293** 294** Description BTIF storage API - Add a remote device to the auto pairing blacklist 295** 296** Returns BT_STATUS_SUCCESS if the device is successfully added to the auto pair blacklist 297** BT_STATUS_FAIL otherwise 298** 299*******************************************************************************/ 300 301bt_status_t btif_storage_add_device_to_autopair_blacklist(bt_bdaddr_t *remote_bd_addr); 302 303/******************************************************************************* 304** 305** Function btif_storage_is_fixed_pin_zeros_keyboard 306** 307** Description BTIF storage API - checks if this device has fixed PIN key device list 308** 309** Returns TRUE if the device is found in the fixed pin keyboard device list 310** FALSE otherwise 311** 312*******************************************************************************/ 313BOOLEAN btif_storage_is_fixed_pin_zeros_keyboard(bt_bdaddr_t *remote_bd_addr); 314 315#if (BLE_INCLUDED == TRUE) 316bt_status_t btif_storage_add_ble_bonding_key( bt_bdaddr_t *remote_bd_addr, 317 char *key, 318 uint8_t key_type, 319 uint8_t key_length); 320bt_status_t btif_storage_get_ble_bonding_key(bt_bdaddr_t *remote_bd_addr, 321 UINT8 key_type, 322 char *key_value, 323 int key_length); 324 325bt_status_t btif_storage_add_ble_local_key(char *key, 326 uint8_t key_type, 327 uint8_t key_length); 328bt_status_t btif_storage_remove_ble_bonding_keys(bt_bdaddr_t *remote_bd_addr); 329bt_status_t btif_storage_remove_ble_local_keys(void); 330bt_status_t btif_storage_get_ble_local_key(UINT8 key_type, 331 char *key_value, 332 int key_len); 333 334bt_status_t btif_storage_get_remote_addr_type(bt_bdaddr_t *remote_bd_addr, 335 int *addr_type); 336 337bt_status_t btif_storage_set_remote_addr_type(bt_bdaddr_t *remote_bd_addr, 338 UINT8 addr_type); 339 340#endif 341/******************************************************************************* 342** 343** Function btif_storage_get_remote_version 344** 345** Description Fetch remote version info on cached remote device 346** 347** Returns BT_STATUS_SUCCESS if found 348** BT_STATUS_FAIL otherwise 349** 350*******************************************************************************/ 351 352bt_status_t btif_storage_get_remote_version(const bt_bdaddr_t *remote_bd_addr, 353 bt_remote_version_t *p_ver); 354#endif /* BTIF_STORAGE_H */ 355