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