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