1 /****************************************************************************** 2 * 3 * Copyright 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 /******************************************************************************* 20 * 21 * Filename: btif_api.h 22 * 23 * Description: Main API header file for all BTIF functions accessed 24 * from main bluetooth HAL. All HAL extensions will not 25 * require headerfiles as they would be accessed through 26 * callout/callins. 27 * 28 ******************************************************************************/ 29 30 #ifndef BTIF_API_H 31 #define BTIF_API_H 32 33 #include <hardware/bluetooth.h> 34 35 #include "btif_common.h" 36 #include "btif_dm.h" 37 38 /******************************************************************************* 39 * BTIF CORE API 40 ******************************************************************************/ 41 42 /******************************************************************************* 43 * 44 * Function btif_init_bluetooth 45 * 46 * Description Creates BTIF task and prepares BT scheduler for startup 47 * 48 * Returns bt_status_t 49 * 50 ******************************************************************************/ 51 bt_status_t btif_init_bluetooth(void); 52 53 /******************************************************************************* 54 * 55 * Function btif_enable_bluetooth 56 * 57 * Description Performs chip power on and kickstarts OS scheduler 58 * 59 * Returns bt_status_t 60 * 61 ******************************************************************************/ 62 bt_status_t btif_enable_bluetooth(void); 63 64 /******************************************************************************* 65 * 66 * Function btif_disable_bluetooth 67 * 68 * Description Inititates shutdown of Bluetooth system. 69 * Any active links will be dropped and device entering 70 * non connectable/discoverable mode 71 * 72 * Returns void 73 * 74 ******************************************************************************/ 75 bt_status_t btif_disable_bluetooth(void); 76 77 /******************************************************************************* 78 * 79 * Function btif_cleanup_bluetooth 80 * 81 * Description Cleanup BTIF state. 82 * 83 * 84 * Returns void 85 * 86 ******************************************************************************/ 87 bt_status_t btif_cleanup_bluetooth(void); 88 89 /******************************************************************************* 90 * 91 * Function is_restricted_mode 92 * 93 * Description Checks if BT was enabled in restriced mode. In restricted 94 * mode, bonds that are created are marked as temporary. 95 * These bonds persist until we leave restricted mode, at 96 * which point they will be deleted from the config. Also 97 * while in restricted mode, the user can access devices 98 * that are already paired before entering restricted mode, 99 * but they cannot remove any of these devices. 100 * 101 * Returns bool 102 * 103 ******************************************************************************/ 104 bool is_restricted_mode(void); 105 106 /******************************************************************************* 107 * 108 * Function is_niap_mode_ 109 * 110 * Description Checks if BT was enabled in single user mode. In this 111 * mode, use of keystore for key attestation of LTK is limitee 112 * to this mode defined by UserManager. 113 * 114 * Returns bool 115 * 116 ******************************************************************************/ 117 bool is_niap_mode(void); 118 119 /******************************************************************************* 120 * 121 * Function get_niap_config_compare_result 122 * 123 * Description Get the niap config compare result for confirming the config 124 * checksum compare result. When the niap mode doesn't enable, 125 * it should be all pass (0b11). 126 * Bit define: 127 * CONFIG_FILE_COMPARE_PASS = 0b01 128 * CONFIG_BACKUP_COMPARE_PASS = 0b10 129 * 130 * Returns int 131 * 132 ******************************************************************************/ 133 int get_niap_config_compare_result(void); 134 135 /******************************************************************************* 136 * 137 * Function btif_get_adapter_properties 138 * 139 * Description Fetches all local adapter properties 140 * 141 * Returns bt_status_t 142 * 143 ******************************************************************************/ 144 bt_status_t btif_get_adapter_properties(void); 145 146 /******************************************************************************* 147 * 148 * Function btif_get_adapter_property 149 * 150 * Description Fetches property value from local cache 151 * 152 * Returns bt_status_t 153 * 154 ******************************************************************************/ 155 bt_status_t btif_get_adapter_property(bt_property_type_t type); 156 157 /******************************************************************************* 158 * 159 * Function btif_set_adapter_property 160 * 161 * Description Updates core stack with property value and stores it in 162 * local cache 163 * 164 * Returns bt_status_t 165 * 166 ******************************************************************************/ 167 bt_status_t btif_set_adapter_property(const bt_property_t* property); 168 169 /******************************************************************************* 170 * 171 * Function btif_get_remote_device_property 172 * 173 * Description Fetches the remote device property from the NVRAM 174 * 175 * Returns bt_status_t 176 * 177 ******************************************************************************/ 178 bt_status_t btif_get_remote_device_property(RawAddress* remote_addr, 179 bt_property_type_t type); 180 181 /******************************************************************************* 182 * 183 * Function btif_get_remote_device_properties 184 * 185 * Description Fetches all the remote device properties from NVRAM 186 * 187 * Returns bt_status_t 188 * 189 ******************************************************************************/ 190 bt_status_t btif_get_remote_device_properties(RawAddress* remote_addr); 191 192 /******************************************************************************* 193 * 194 * Function btif_set_remote_device_property 195 * 196 * Description Writes the remote device property to NVRAM. 197 * Currently, BT_PROPERTY_REMOTE_FRIENDLY_NAME is the only 198 * remote device property that can be set 199 * 200 * Returns bt_status_t 201 * 202 ******************************************************************************/ 203 bt_status_t btif_set_remote_device_property(RawAddress* remote_addr, 204 const bt_property_t* property); 205 206 /******************************************************************************* 207 * 208 * Function btif_get_remote_service_record 209 * 210 * Description Looks up the service matching uuid on the remote device 211 * and fetches the SCN and service_name if the UUID is found 212 * 213 * Returns bt_status_t 214 * 215 ******************************************************************************/ 216 bt_status_t btif_get_remote_service_record(const RawAddress& remote_addr, 217 const bluetooth::Uuid& uuid); 218 219 /******************************************************************************* 220 * BTIF DM API 221 ******************************************************************************/ 222 223 /******************************************************************************* 224 * 225 * Function btif_dm_start_discovery 226 * 227 * Description Start device discovery/inquiry 228 * 229 * 230 * Returns bt_status_t 231 * 232 ******************************************************************************/ 233 bt_status_t btif_dm_start_discovery(void); 234 235 /******************************************************************************* 236 * 237 * Function btif_dm_cancel_discovery 238 * 239 * Description Cancels search 240 * 241 * Returns bt_status_t 242 * 243 ******************************************************************************/ 244 bt_status_t btif_dm_cancel_discovery(void); 245 246 /******************************************************************************* 247 * 248 * Function btif_dm_create_bond 249 * 250 * Description Initiate bonding with the specified device 251 * 252 * Returns bt_status_t 253 * 254 ******************************************************************************/ 255 bt_status_t btif_dm_create_bond(const RawAddress* bd_addr, int transport); 256 257 /******************************************************************************* 258 * 259 * Function btif_dm_create_bond_out_of_band 260 * 261 * Description Initiate bonding with the specified device using OOB data. 262 * 263 * Returns bt_status_t 264 * 265 ******************************************************************************/ 266 bt_status_t btif_dm_create_bond_out_of_band( 267 const RawAddress* bd_addr, int transport, 268 const bt_out_of_band_data_t* oob_data); 269 270 /******************************************************************************* 271 * 272 * Function btif_dm_cancel_bond 273 * 274 * Description Initiate bonding with the specified device 275 * 276 * Returns bt_status_t 277 * 278 ******************************************************************************/ 279 bt_status_t btif_dm_cancel_bond(const RawAddress* bd_addr); 280 281 /******************************************************************************* 282 * 283 * Function btif_dm_remove_bond 284 * 285 * Description Removes bonding with the specified device 286 * 287 * Returns bt_status_t 288 * 289 ******************************************************************************/ 290 bt_status_t btif_dm_remove_bond(const RawAddress* bd_addr); 291 292 /******************************************************************************* 293 * 294 * Function btif_dm_get_connection_state 295 * 296 * Description Returns whether the remote device is currently connected 297 * 298 * Returns 0 if not connected 299 * 300 ******************************************************************************/ 301 uint16_t btif_dm_get_connection_state(const RawAddress* bd_addr); 302 303 /******************************************************************************* 304 * 305 * Function btif_dm_pin_reply 306 * 307 * Description BT legacy pairing - PIN code reply 308 * 309 * Returns bt_status_t 310 * 311 ******************************************************************************/ 312 bt_status_t btif_dm_pin_reply(const RawAddress* bd_addr, uint8_t accept, 313 uint8_t pin_len, bt_pin_code_t* pin_code); 314 315 /******************************************************************************* 316 * 317 * Function btif_dm_passkey_reply 318 * 319 * Description BT SSP passkey reply 320 * 321 * Returns bt_status_t 322 * 323 ******************************************************************************/ 324 bt_status_t btif_dm_passkey_reply(const RawAddress* bd_addr, uint8_t accept, 325 uint32_t passkey); 326 327 /******************************************************************************* 328 * 329 * Function btif_dm_ssp_reply 330 * 331 * Description BT SSP Reply - Just Works, Numeric Comparison & Passkey 332 * Entry 333 * 334 * Returns bt_status_t 335 * 336 ******************************************************************************/ 337 bt_status_t btif_dm_ssp_reply(const RawAddress* bd_addr, 338 bt_ssp_variant_t variant, uint8_t accept, 339 uint32_t passkey); 340 341 /******************************************************************************* 342 * 343 * Function btif_dm_get_adapter_property 344 * 345 * Description Queries the BTA for the adapter property 346 * 347 * Returns bt_status_t 348 * 349 ******************************************************************************/ 350 bt_status_t btif_dm_get_adapter_property(bt_property_t* prop); 351 352 /******************************************************************************* 353 * 354 * Function btif_dm_get_remote_services 355 * 356 * Description Start SDP to get remote services 357 * 358 * Returns bt_status_t 359 * 360 ******************************************************************************/ 361 bt_status_t btif_dm_get_remote_service_record(const RawAddress& remote_addr, 362 const bluetooth::Uuid& uuid); 363 364 /******************************************************************************* 365 * 366 * Function btif_dm_get_remote_services 367 * 368 * Description Start SDP to get remote services 369 * 370 * Returns bt_status_t 371 * 372 ******************************************************************************/ 373 bt_status_t btif_dm_get_remote_services(const RawAddress& remote_addr); 374 375 /******************************************************************************* 376 * 377 * Function btif_dm_get_remote_services_by_transport 378 * 379 * Description Start SDP to get remote services by transport 380 * 381 * Returns bt_status_t 382 * 383 ******************************************************************************/ 384 bt_status_t btif_dm_get_remote_services_by_transport(RawAddress* remote_addr, 385 int transport); 386 387 /******************************************************************************* 388 * 389 * Function btif_dut_mode_configure 390 * 391 * Description Configure Test Mode - 'enable' to 1 puts the device in test 392 * mode and 0 exits test mode 393 * 394 * Returns BT_STATUS_SUCCESS on success 395 * 396 ******************************************************************************/ 397 bt_status_t btif_dut_mode_configure(uint8_t enable); 398 399 /******************************************************************************* 400 * 401 * Function btif_dut_mode_send 402 * 403 * Description Sends a HCI Vendor specific command to the controller 404 * 405 * Returns BT_STATUS_SUCCESS on success 406 * 407 ******************************************************************************/ 408 bt_status_t btif_dut_mode_send(uint16_t opcode, uint8_t* buf, uint8_t len); 409 410 /******************************************************************************* 411 * 412 * Function btif_le_test_mode 413 * 414 * Description Sends a HCI BLE Test command to the Controller 415 * 416 * Returns BT_STATUS_SUCCESS on success 417 * 418 ******************************************************************************/ 419 bt_status_t btif_le_test_mode(uint16_t opcode, uint8_t* buf, uint8_t len); 420 421 /******************************************************************************* 422 * 423 * Function btif_dm_read_energy_info 424 * 425 * Description Reads the energy info from controller 426 * 427 * Returns void 428 * 429 ******************************************************************************/ 430 void btif_dm_read_energy_info(); 431 432 /******************************************************************************* 433 * 434 * Function btif_config_hci_snoop_log 435 * 436 * Description enable or disable HCI snoop log 437 * 438 * Returns BT_STATUS_SUCCESS on success 439 * 440 ******************************************************************************/ 441 bt_status_t btif_config_hci_snoop_log(uint8_t enable); 442 443 /******************************************************************************* 444 * 445 * Function btif_debug_bond_event_dump 446 * 447 * Description Dump bond event information 448 * 449 * Returns void 450 * 451 ******************************************************************************/ 452 void btif_debug_bond_event_dump(int fd); 453 454 #endif /* BTIF_API_H */ 455