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