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 btif_get_adapter_properties 91 ** 92 ** Description Fetches all local adapter properties 93 ** 94 ** Returns bt_status_t 95 ** 96 *******************************************************************************/ 97 bt_status_t btif_get_adapter_properties(void); 98 99 /******************************************************************************* 100 ** 101 ** Function btif_get_adapter_property 102 ** 103 ** Description Fetches property value from local cache 104 ** 105 ** Returns bt_status_t 106 ** 107 *******************************************************************************/ 108 bt_status_t btif_get_adapter_property( bt_property_type_t type); 109 110 /******************************************************************************* 111 ** 112 ** Function btif_set_adapter_property 113 ** 114 ** Description Updates core stack with property value and stores it in 115 ** local cache 116 ** 117 ** Returns bt_status_t 118 ** 119 *******************************************************************************/ 120 bt_status_t btif_set_adapter_property( const bt_property_t *property); 121 122 /******************************************************************************* 123 ** 124 ** Function btif_get_remote_device_property 125 ** 126 ** Description Fetches the remote device property from the NVRAM 127 ** 128 ** Returns bt_status_t 129 ** 130 *******************************************************************************/ 131 bt_status_t btif_get_remote_device_property( bt_bdaddr_t *remote_addr, 132 bt_property_type_t type); 133 134 /******************************************************************************* 135 ** 136 ** Function btif_get_remote_device_properties 137 ** 138 ** Description Fetches all the remote device properties from NVRAM 139 ** 140 ** Returns bt_status_t 141 ** 142 *******************************************************************************/ 143 bt_status_t btif_get_remote_device_properties( bt_bdaddr_t *remote_addr); 144 145 /******************************************************************************* 146 ** 147 ** Function btif_set_remote_device_property 148 ** 149 ** Description Writes the remote device property to NVRAM. 150 ** Currently, BT_PROPERTY_REMOTE_FRIENDLY_NAME is the only 151 ** remote device property that can be set 152 ** 153 ** Returns bt_status_t 154 ** 155 *******************************************************************************/ 156 bt_status_t btif_set_remote_device_property( bt_bdaddr_t *remote_addr, 157 const bt_property_t *property); 158 159 /******************************************************************************* 160 ** 161 ** Function btif_get_remote_service_record 162 ** 163 ** Description Looks up the service matching uuid on the remote device 164 ** and fetches the SCN and service_name if the UUID is found 165 ** 166 ** Returns bt_status_t 167 ** 168 *******************************************************************************/ 169 bt_status_t btif_get_remote_service_record( bt_bdaddr_t *remote_addr, 170 bt_uuid_t *uuid); 171 172 173 /******************************************************************************* 174 ** BTIF DM API 175 ********************************************************************************/ 176 177 /******************************************************************************* 178 ** 179 ** Function btif_dm_start_discovery 180 ** 181 ** Description Start device discovery/inquiry 182 ** 183 ** 184 ** Returns bt_status_t 185 ** 186 *******************************************************************************/ 187 bt_status_t btif_dm_start_discovery(void); 188 189 /******************************************************************************* 190 ** 191 ** Function btif_dm_cancel_discovery 192 ** 193 ** Description Cancels search 194 ** 195 ** Returns bt_status_t 196 ** 197 *******************************************************************************/ 198 bt_status_t btif_dm_cancel_discovery(void); 199 200 /******************************************************************************* 201 ** 202 ** Function btif_dm_create_bond 203 ** 204 ** Description Initiate bonding with the specified device 205 ** 206 ** Returns bt_status_t 207 ** 208 *******************************************************************************/ 209 bt_status_t btif_dm_create_bond(const bt_bdaddr_t *bd_addr, int transport); 210 211 /******************************************************************************* 212 ** 213 ** Function btif_dm_cancel_bond 214 ** 215 ** Description Initiate bonding with the specified device 216 ** 217 ** Returns bt_status_t 218 ** 219 *******************************************************************************/ 220 bt_status_t btif_dm_cancel_bond(const bt_bdaddr_t *bd_addr); 221 222 /******************************************************************************* 223 ** 224 ** Function btif_dm_remove_bond 225 ** 226 ** Description Removes bonding with the specified device 227 ** 228 ** Returns bt_status_t 229 ** 230 *******************************************************************************/ 231 bt_status_t btif_dm_remove_bond(const bt_bdaddr_t *bd_addr); 232 233 /******************************************************************************* 234 ** 235 ** Function btif_dm_get_connection_state 236 ** 237 ** Description Returns whether the remote device is currently connected 238 ** 239 ** Returns 0 if not connected 240 ** 241 *******************************************************************************/ 242 uint16_t btif_dm_get_connection_state(const bt_bdaddr_t *bd_addr); 243 244 /******************************************************************************* 245 ** 246 ** Function btif_dm_pin_reply 247 ** 248 ** Description BT legacy pairing - PIN code reply 249 ** 250 ** Returns bt_status_t 251 ** 252 *******************************************************************************/ 253 bt_status_t btif_dm_pin_reply( const bt_bdaddr_t *bd_addr, uint8_t accept, 254 uint8_t pin_len, bt_pin_code_t *pin_code); 255 256 /******************************************************************************* 257 ** 258 ** Function btif_dm_passkey_reply 259 ** 260 ** Description BT SSP passkey reply 261 ** 262 ** Returns bt_status_t 263 ** 264 *******************************************************************************/ 265 bt_status_t btif_dm_passkey_reply( const bt_bdaddr_t *bd_addr, 266 uint8_t accept, uint32_t passkey); 267 268 /******************************************************************************* 269 ** 270 ** Function btif_dm_ssp_reply 271 ** 272 ** Description BT SSP Reply - Just Works, Numeric Comparison & Passkey Entry 273 ** 274 ** Returns bt_status_t 275 ** 276 *******************************************************************************/ 277 bt_status_t btif_dm_ssp_reply( const bt_bdaddr_t *bd_addr, 278 bt_ssp_variant_t variant, uint8_t accept, 279 uint32_t passkey); 280 281 /******************************************************************************* 282 ** 283 ** Function btif_dm_get_adapter_property 284 ** 285 ** Description Queries the BTA for the adapter property 286 ** 287 ** Returns bt_status_t 288 ** 289 *******************************************************************************/ 290 bt_status_t btif_dm_get_adapter_property(bt_property_t *prop); 291 292 /******************************************************************************* 293 ** 294 ** Function btif_dm_get_remote_services 295 ** 296 ** Description Start SDP to get remote services 297 ** 298 ** Returns bt_status_t 299 ** 300 *******************************************************************************/ 301 bt_status_t btif_dm_get_remote_service_record(bt_bdaddr_t *remote_addr, 302 bt_uuid_t *uuid); 303 304 305 /******************************************************************************* 306 ** 307 ** Function btif_dm_get_remote_services 308 ** 309 ** Description Start SDP to get remote services 310 ** 311 ** Returns bt_status_t 312 ** 313 *******************************************************************************/ 314 bt_status_t btif_dm_get_remote_services(bt_bdaddr_t *remote_addr); 315 316 /******************************************************************************* 317 ** 318 ** Function btif_dut_mode_configure 319 ** 320 ** Description Configure Test Mode - 'enable' to 1 puts the device in test mode and 0 exits 321 ** test mode 322 ** 323 ** Returns BT_STATUS_SUCCESS on success 324 ** 325 *******************************************************************************/ 326 bt_status_t btif_dut_mode_configure(uint8_t enable); 327 328 /******************************************************************************* 329 ** 330 ** Function btif_dut_mode_send 331 ** 332 ** Description Sends a HCI Vendor specific command to the controller 333 ** 334 ** Returns BT_STATUS_SUCCESS on success 335 ** 336 *******************************************************************************/ 337 bt_status_t btif_dut_mode_send(uint16_t opcode, uint8_t *buf, uint8_t len); 338 339 /******************************************************************************* 340 ** 341 ** Function btif_le_test_mode 342 ** 343 ** Description Sends a HCI BLE Test command to the Controller 344 ** 345 ** Returns BT_STATUS_SUCCESS on success 346 ** 347 *******************************************************************************/ 348 bt_status_t btif_le_test_mode(uint16_t opcode, uint8_t *buf, uint8_t len); 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 #endif /* BTIF_API_H */ 372