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 #include "types/raw_address.h" 38 39 /******************************************************************************* 40 * BTIF CORE API 41 ******************************************************************************/ 42 43 /******************************************************************************* 44 * 45 * Function btif_init_bluetooth 46 * 47 * Description Creates BTIF task and prepares BT scheduler for startup 48 * 49 * Returns bt_status_t 50 * 51 ******************************************************************************/ 52 bt_status_t btif_init_bluetooth(void); 53 54 /******************************************************************************* 55 * 56 * Function btif_enable_bluetooth 57 * 58 * Description Performs chip power on and kickstarts OS scheduler 59 * 60 * Returns bt_status_t 61 * 62 ******************************************************************************/ 63 bt_status_t btif_enable_bluetooth(void); 64 65 /******************************************************************************* 66 * 67 * Function btif_cleanup_bluetooth 68 * 69 * Description Cleanup BTIF state. 70 * 71 * 72 * Returns void 73 * 74 ******************************************************************************/ 75 bt_status_t btif_cleanup_bluetooth(void); 76 77 /******************************************************************************* 78 * 79 * Function is_restricted_mode 80 * 81 * Description Checks if BT was enabled in restriced mode. In restricted 82 * mode, bonds that are created are marked as temporary. 83 * These bonds persist until we leave restricted mode, at 84 * which point they will be deleted from the config. Also 85 * while in restricted mode, the user can access devices 86 * that are already paired before entering restricted mode, 87 * but they cannot remove any of these devices. 88 * 89 * Returns bool 90 * 91 ******************************************************************************/ 92 bool is_restricted_mode(void); 93 94 /******************************************************************************* 95 * 96 * Function is_common_criteria_mode 97 * 98 * Description Check if BT is enabled in common criteria mode. In this 99 * mode, will use the LTK from the keystore to authenticate. 100 * 101 * Returns bool 102 * 103 ******************************************************************************/ 104 bool is_common_criteria_mode(void); 105 106 /******************************************************************************* 107 * 108 * Function get_common_criteria_config_compare_result 109 * 110 * Description Get the common criteria config compare result for confirming 111 * the config checksum compare result. When the common criteria 112 * mode doesn't enable, it should be all pass (0b11). 113 * Bit define: 114 * CONFIG_FILE_COMPARE_PASS = 0b01 115 * CONFIG_BACKUP_COMPARE_PASS = 0b10 116 * 117 * Returns int 118 * 119 ******************************************************************************/ 120 int get_common_criteria_config_compare_result(void); 121 122 /******************************************************************************* 123 * 124 * Function is_atv_device 125 * 126 * Description Returns true if the local device is an Android TV 127 * device, false if it is not. 128 * 129 * Returns bool 130 * 131 ******************************************************************************/ 132 bool is_atv_device(void); 133 134 /******************************************************************************* 135 * 136 * Function btif_get_adapter_properties 137 * 138 * Description Fetches all local adapter properties 139 * 140 ******************************************************************************/ 141 void btif_get_adapter_properties(void); 142 143 bt_property_t* property_deep_copy(const bt_property_t* prop); 144 145 /******************************************************************************* 146 * 147 * Function btif_get_adapter_property 148 * 149 * Description Fetches property value from local cache 150 * 151 ******************************************************************************/ 152 void btif_get_adapter_property(bt_property_type_t type); 153 154 /******************************************************************************* 155 * 156 * Function btif_set_adapter_property 157 * 158 * Description Updates core stack with property value and stores it in 159 * local cache 160 * 161 ******************************************************************************/ 162 void btif_set_adapter_property(bt_property_t* property); 163 164 /******************************************************************************* 165 * 166 * Function btif_get_remote_device_property 167 * 168 * Description Fetches the remote device property from the NVRAM 169 * 170 ******************************************************************************/ 171 void btif_get_remote_device_property(RawAddress remote_addr, 172 bt_property_type_t type); 173 174 /******************************************************************************* 175 * 176 * Function btif_get_remote_device_properties 177 * 178 * Description Fetches all the remote device properties from NVRAM 179 * 180 ******************************************************************************/ 181 void btif_get_remote_device_properties(RawAddress remote_addr); 182 183 /******************************************************************************* 184 * 185 * Function btif_set_remote_device_property 186 * 187 * Description Writes the remote device property to NVRAM. 188 * Currently, BT_PROPERTY_REMOTE_FRIENDLY_NAME is the only 189 * remote device property that can be set 190 * 191 ******************************************************************************/ 192 void btif_set_remote_device_property(RawAddress* remote_addr, 193 bt_property_t* property); 194 195 /******************************************************************************* 196 * BTIF DM API 197 ******************************************************************************/ 198 199 /******************************************************************************* 200 * 201 * Function btif_dm_start_discovery 202 * 203 * Description Start device discovery/inquiry 204 * 205 ******************************************************************************/ 206 void btif_dm_start_discovery(void); 207 208 /******************************************************************************* 209 * 210 * Function btif_dm_cancel_discovery 211 * 212 * Description Cancels search 213 * 214 ******************************************************************************/ 215 void btif_dm_cancel_discovery(void); 216 217 bool btif_dm_pairing_is_busy(); 218 /******************************************************************************* 219 * 220 * Function btif_dm_create_bond 221 * 222 * Description Initiate bonding with the specified device 223 * 224 ******************************************************************************/ 225 void btif_dm_create_bond(const RawAddress bd_addr, int transport); 226 227 /******************************************************************************* 228 * 229 * Function btif_dm_create_bond_out_of_band 230 * 231 * Description Initiate bonding with the specified device using OOB data. 232 * 233 ******************************************************************************/ 234 void btif_dm_create_bond_out_of_band(const RawAddress bd_addr, 235 tBT_TRANSPORT transport, 236 const bt_oob_data_t p192_data, 237 const bt_oob_data_t p256_data); 238 239 /******************************************************************************* 240 * 241 * Function btif_dm_cancel_bond 242 * 243 * Description Initiate bonding with the specified device 244 * 245 ******************************************************************************/ 246 void btif_dm_cancel_bond(const RawAddress bd_addr); 247 248 /******************************************************************************* 249 * 250 * Function btif_dm_remove_bond 251 * 252 * Description Removes bonding with the specified device 253 * 254 ******************************************************************************/ 255 void btif_dm_remove_bond(const RawAddress bd_addr); 256 257 /******************************************************************************* 258 * 259 * Function btif_dm_get_connection_state 260 * 261 * Description Returns whether the remote device is currently connected 262 * 263 * Returns 0 if not connected 264 * 265 ******************************************************************************/ 266 uint16_t btif_dm_get_connection_state(const RawAddress* bd_addr); 267 268 /******************************************************************************* 269 * 270 * Function btif_dm_pin_reply 271 * 272 * Description BT legacy pairing - PIN code reply 273 * 274 ******************************************************************************/ 275 void btif_dm_pin_reply(const RawAddress bd_addr, uint8_t accept, 276 uint8_t pin_len, bt_pin_code_t pin_code); 277 278 /******************************************************************************* 279 * 280 * Function btif_dm_passkey_reply 281 * 282 * Description BT SSP passkey reply 283 * 284 * Returns bt_status_t 285 * 286 ******************************************************************************/ 287 bt_status_t btif_dm_passkey_reply(const RawAddress* bd_addr, uint8_t accept, 288 uint32_t passkey); 289 290 /******************************************************************************* 291 * 292 * Function btif_dm_ssp_reply 293 * 294 * Description BT SSP Reply - Just Works, Numeric Comparison & Passkey 295 * Entry 296 * 297 ******************************************************************************/ 298 void btif_dm_ssp_reply(const RawAddress bd_addr, bt_ssp_variant_t variant, 299 uint8_t accept); 300 301 /******************************************************************************* 302 * 303 * Function btif_dm_get_adapter_property 304 * 305 * Description Queries the BTA for the adapter property 306 * 307 * Returns bt_status_t 308 * 309 ******************************************************************************/ 310 bt_status_t btif_dm_get_adapter_property(bt_property_t* prop); 311 312 /******************************************************************************* 313 * 314 * Function btif_dm_get_remote_services 315 * 316 * Description Start SDP to get remote services 317 * 318 * Returns bt_status_t 319 * 320 ******************************************************************************/ 321 void btif_dm_get_remote_services(const RawAddress remote_addr, int transport); 322 323 /******************************************************************************* 324 * 325 * Function btif_dut_mode_configure 326 * 327 * Description Configure Test Mode - 'enable' to 1 puts the device in test 328 * mode and 0 exits test mode 329 * 330 ******************************************************************************/ 331 void btif_dut_mode_configure(uint8_t enable); 332 333 bool btif_is_dut_mode(); 334 335 /******************************************************************************* 336 * 337 * Function btif_dut_mode_send 338 * 339 * Description Sends a HCI Vendor specific command to the controller 340 * 341 ******************************************************************************/ 342 void btif_dut_mode_send(uint16_t opcode, uint8_t* buf, uint8_t len); 343 344 void btif_ble_transmitter_test(uint8_t tx_freq, uint8_t test_data_len, 345 uint8_t packet_payload); 346 347 void btif_ble_receiver_test(uint8_t rx_freq); 348 void btif_ble_test_end(); 349 350 /******************************************************************************* 351 * 352 * Function btif_dm_read_energy_info 353 * 354 * Description Reads the energy info from controller 355 * 356 * Returns void 357 * 358 ******************************************************************************/ 359 void btif_dm_read_energy_info(); 360 361 /******************************************************************************* 362 * 363 * Function btif_config_hci_snoop_log 364 * 365 * Description enable or disable HCI snoop log 366 * 367 * Returns BT_STATUS_SUCCESS on success 368 * 369 ******************************************************************************/ 370 bt_status_t btif_config_hci_snoop_log(uint8_t enable); 371 372 /******************************************************************************* 373 * 374 * Function btif_debug_bond_event_dump 375 * 376 * Description Dump bond event information 377 * 378 * Returns void 379 * 380 ******************************************************************************/ 381 void btif_debug_bond_event_dump(int fd); 382 383 /******************************************************************************* 384 * 385 * Function btif_set_dynamic_audio_buffer_size 386 * 387 * Description Set dynamic audio buffer size 388 * 389 * Returns BT_STATUS_SUCCESS on success 390 * 391 ******************************************************************************/ 392 bt_status_t btif_set_dynamic_audio_buffer_size(int codec, int size); 393 394 /******************************************************************************* 395 * 396 * Function btif_debug_linkkey_type_dump 397 * 398 * Description Dump exchanged linkkey types information 399 * 400 * Returns void 401 * 402 ******************************************************************************/ 403 void btif_debug_linkkey_type_dump(int fd); 404 405 #endif /* BTIF_API_H */ 406