The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright (C) 2003-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 | * This is the API implementation file for the BTA device manager. |
| 22 | * |
| 23 | ******************************************************************************/ |
| 24 | |
| 25 | #include "gki.h" |
| 26 | #include "bd.h" |
| 27 | #include "bta_sys.h" |
| 28 | #include "bta_api.h" |
| 29 | #include "bta_dm_int.h" |
| 30 | #include "bta_sys_int.h" |
| 31 | #include "btm_api.h" |
| 32 | #include "btm_int.h" |
| 33 | #include <string.h> |
Mike J. Chen | 5cd8bff | 2014-01-31 18:16:59 -0800 | [diff] [blame] | 34 | #include "utl.h" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 35 | |
| 36 | /***************************************************************************** |
| 37 | ** Constants |
| 38 | *****************************************************************************/ |
| 39 | |
| 40 | static const tBTA_SYS_REG bta_dm_reg = |
| 41 | { |
| 42 | bta_dm_sm_execute, |
| 43 | bta_dm_sm_disable |
| 44 | }; |
| 45 | |
| 46 | static const tBTA_SYS_REG bta_dm_search_reg = |
| 47 | { |
| 48 | bta_dm_search_sm_execute, |
| 49 | bta_dm_search_sm_disable |
| 50 | }; |
| 51 | |
| 52 | /******************************************************************************* |
| 53 | ** |
| 54 | ** Function BTA_EnableBluetooth |
| 55 | ** |
| 56 | ** Description Enables bluetooth service. This function must be |
| 57 | ** called before any other functions in the BTA API are called. |
| 58 | ** |
| 59 | ** |
| 60 | ** Returns tBTA_STATUS |
| 61 | ** |
| 62 | *******************************************************************************/ |
| 63 | tBTA_STATUS BTA_EnableBluetooth(tBTA_DM_SEC_CBACK *p_cback) |
| 64 | { |
| 65 | |
| 66 | tBTA_DM_API_ENABLE *p_msg; |
| 67 | |
| 68 | /* Bluetooth disabling is in progress */ |
| 69 | if (bta_dm_cb.disabling) |
| 70 | return BTA_FAILURE; |
| 71 | |
| 72 | memset(&bta_dm_cb, 0, sizeof(bta_dm_cb)); |
| 73 | |
| 74 | GKI_sched_lock(); |
| 75 | bta_sys_register (BTA_ID_DM, &bta_dm_reg ); |
| 76 | bta_sys_register (BTA_ID_DM_SEARCH, &bta_dm_search_reg ); |
| 77 | |
| 78 | /* if UUID list is not provided as static data */ |
| 79 | bta_sys_eir_register(bta_dm_eir_update_uuid); |
| 80 | |
| 81 | GKI_sched_unlock(); |
| 82 | |
| 83 | if ((p_msg = (tBTA_DM_API_ENABLE *) GKI_getbuf(sizeof(tBTA_DM_API_ENABLE))) != NULL) |
| 84 | { |
| 85 | p_msg->hdr.event = BTA_DM_API_ENABLE_EVT; |
| 86 | p_msg->p_sec_cback = p_cback; |
| 87 | bta_sys_sendmsg(p_msg); |
| 88 | return BTA_SUCCESS; |
| 89 | } |
| 90 | return BTA_FAILURE; |
| 91 | |
| 92 | } |
| 93 | |
| 94 | /******************************************************************************* |
| 95 | ** |
| 96 | ** Function BTA_DisableBluetooth |
| 97 | ** |
| 98 | ** Description Disables bluetooth service. This function is called when |
| 99 | ** the application no longer needs bluetooth service |
| 100 | ** |
| 101 | ** Returns void |
| 102 | ** |
| 103 | *******************************************************************************/ |
| 104 | tBTA_STATUS BTA_DisableBluetooth(void) |
| 105 | { |
| 106 | |
| 107 | BT_HDR *p_msg; |
| 108 | |
| 109 | if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) |
| 110 | { |
| 111 | p_msg->event = BTA_DM_API_DISABLE_EVT; |
| 112 | bta_sys_sendmsg(p_msg); |
| 113 | } |
| 114 | else |
| 115 | { |
| 116 | return BTA_FAILURE; |
| 117 | } |
| 118 | |
| 119 | return BTA_SUCCESS; |
| 120 | } |
| 121 | |
| 122 | /******************************************************************************* |
| 123 | ** |
| 124 | ** Function BTA_EnableTestMode |
| 125 | ** |
| 126 | ** Description Enables bluetooth device under test mode |
| 127 | ** |
| 128 | ** |
| 129 | ** Returns tBTA_STATUS |
| 130 | ** |
| 131 | *******************************************************************************/ |
| 132 | tBTA_STATUS BTA_EnableTestMode(void) |
| 133 | { |
| 134 | BT_HDR *p_msg; |
| 135 | |
| 136 | APPL_TRACE_API0("BTA_EnableTestMode"); |
| 137 | |
| 138 | if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) |
| 139 | { |
| 140 | p_msg->event = BTA_DM_API_ENABLE_TEST_MODE_EVT; |
| 141 | bta_sys_sendmsg(p_msg); |
| 142 | return BTA_SUCCESS; |
| 143 | } |
| 144 | return BTA_FAILURE; |
| 145 | } |
| 146 | |
| 147 | /******************************************************************************* |
| 148 | ** |
| 149 | ** Function BTA_DisableTestMode |
| 150 | ** |
| 151 | ** Description Disable bluetooth device under test mode |
| 152 | ** |
| 153 | ** |
| 154 | ** Returns None |
| 155 | ** |
| 156 | *******************************************************************************/ |
| 157 | void BTA_DisableTestMode(void) |
| 158 | { |
| 159 | BT_HDR *p_msg; |
| 160 | |
| 161 | APPL_TRACE_API0("BTA_DisableTestMode"); |
| 162 | |
| 163 | if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) |
| 164 | { |
| 165 | p_msg->event = BTA_DM_API_DISABLE_TEST_MODE_EVT; |
| 166 | bta_sys_sendmsg(p_msg); |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | /******************************************************************************* |
| 171 | ** |
| 172 | ** Function BTA_DmIsDeviceUp |
| 173 | ** |
| 174 | ** Description Called during startup to check whether the bluetooth module |
| 175 | ** is up and ready |
| 176 | ** |
| 177 | ** Returns BOOLEAN |
| 178 | ** |
| 179 | *******************************************************************************/ |
| 180 | BOOLEAN BTA_DmIsDeviceUp(void) |
| 181 | { |
| 182 | |
| 183 | BOOLEAN status; |
| 184 | |
| 185 | GKI_sched_lock(); |
| 186 | status = BTM_IsDeviceUp(); |
| 187 | GKI_sched_unlock(); |
| 188 | return status; |
| 189 | |
| 190 | } |
| 191 | |
| 192 | /******************************************************************************* |
| 193 | ** |
| 194 | ** Function BTA_DmSetDeviceName |
| 195 | ** |
| 196 | ** Description This function sets the Bluetooth name of local device |
| 197 | ** |
| 198 | ** |
| 199 | ** Returns void |
| 200 | ** |
| 201 | *******************************************************************************/ |
| 202 | void BTA_DmSetDeviceName(char *p_name) |
| 203 | { |
| 204 | |
| 205 | tBTA_DM_API_SET_NAME *p_msg; |
| 206 | |
| 207 | if ((p_msg = (tBTA_DM_API_SET_NAME *) GKI_getbuf(sizeof(tBTA_DM_API_SET_NAME))) != NULL) |
| 208 | { |
| 209 | p_msg->hdr.event = BTA_DM_API_SET_NAME_EVT; |
| 210 | /* truncate the name if needed */ |
Mike J. Chen | 5cd8bff | 2014-01-31 18:16:59 -0800 | [diff] [blame] | 211 | BCM_STRNCPY_S((char *)p_msg->name, sizeof(p_msg->name), p_name, BD_NAME_LEN-1); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 212 | p_msg->name[BD_NAME_LEN-1]=0; |
| 213 | |
| 214 | bta_sys_sendmsg(p_msg); |
| 215 | } |
| 216 | |
| 217 | |
| 218 | } |
| 219 | |
| 220 | /******************************************************************************* |
| 221 | ** |
| 222 | ** Function BTA_DmSetVisibility |
| 223 | ** |
| 224 | ** Description This function sets the Bluetooth connectable, |
| 225 | ** discoverable, pairable and conn paired only modes of local device |
| 226 | ** |
| 227 | ** |
| 228 | ** Returns void |
| 229 | ** |
| 230 | *******************************************************************************/ |
| 231 | void BTA_DmSetVisibility(tBTA_DM_DISC disc_mode, tBTA_DM_CONN conn_mode, UINT8 pairable_mode, UINT8 conn_filter ) |
| 232 | { |
| 233 | |
| 234 | tBTA_DM_API_SET_VISIBILITY *p_msg; |
| 235 | |
| 236 | if ((p_msg = (tBTA_DM_API_SET_VISIBILITY *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL) |
| 237 | { |
| 238 | p_msg->hdr.event = BTA_DM_API_SET_VISIBILITY_EVT; |
| 239 | p_msg->disc_mode = disc_mode; |
| 240 | p_msg->conn_mode = conn_mode; |
| 241 | p_msg->pair_mode = pairable_mode; |
| 242 | p_msg->conn_paired_only = conn_filter; |
| 243 | |
| 244 | |
| 245 | bta_sys_sendmsg(p_msg); |
| 246 | } |
| 247 | |
| 248 | |
| 249 | } |
| 250 | |
| 251 | /******************************************************************************* |
| 252 | ** |
| 253 | ** Function BTA_DmSetScanParam |
| 254 | ** |
| 255 | ** Description This function sets the parameters for page scan and |
| 256 | ** inquiry scan. |
| 257 | ** |
| 258 | ** |
| 259 | ** Returns void |
| 260 | ** |
| 261 | *******************************************************************************/ |
| 262 | void BTA_DmSetScanParam (UINT16 page_scan_interval, UINT16 page_scan_window, |
| 263 | UINT16 inquiry_scan_interval, UINT16 inquiry_scan_window) |
| 264 | { |
| 265 | APPL_TRACE_API4 ("BTA_DmSetScanParam: %d, %d, %d, %d", |
| 266 | page_scan_interval, page_scan_window, |
| 267 | inquiry_scan_interval, inquiry_scan_window); |
| 268 | |
| 269 | bta_dm_cb.page_scan_interval = page_scan_interval; |
| 270 | bta_dm_cb.page_scan_window = page_scan_window; |
| 271 | bta_dm_cb.inquiry_scan_interval = inquiry_scan_interval; |
| 272 | bta_dm_cb.inquiry_scan_window = inquiry_scan_window; |
| 273 | } |
| 274 | |
| 275 | /******************************************************************************* |
| 276 | ** |
| 277 | ** Function BTA_DmSetAfhChannels |
| 278 | ** |
| 279 | ** Description This function sets the AFH first and |
| 280 | ** last disable channel, so channels within |
| 281 | ** that range are disabled. |
| 282 | ** |
| 283 | ** Returns void |
| 284 | ** |
| 285 | *******************************************************************************/ |
| 286 | void BTA_DmSetAfhChannels(UINT8 first, UINT8 last) |
| 287 | { |
| 288 | |
| 289 | tBTA_DM_API_SET_AFH_CHANNELS_EVT *p_msg; |
| 290 | |
| 291 | if ((p_msg = (tBTA_DM_API_SET_AFH_CHANNELS_EVT *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL) |
| 292 | { |
| 293 | p_msg->hdr.event = BTA_DM_API_SET_AFH_CHANNELS_EVT; |
| 294 | p_msg->first = first; |
| 295 | p_msg->last = last; |
| 296 | bta_sys_sendmsg(p_msg); |
| 297 | } |
| 298 | |
| 299 | |
| 300 | } |
| 301 | |
| 302 | /******************************************************************************* |
| 303 | ** |
| 304 | ** Function BTA_SetAfhChannelAssessment |
| 305 | ** |
| 306 | ** Description This function is called to set the channel assessment mode on or off |
| 307 | ** |
| 308 | ** Returns status |
| 309 | ** |
| 310 | *******************************************************************************/ |
| 311 | void BTA_DmSetAfhChannelAssessment (BOOLEAN enable_or_disable) |
| 312 | { |
| 313 | tBTA_DM_API_SET_AFH_CHANNEL_ASSESSMENT *p_msg; |
| 314 | |
| 315 | if ((p_msg = (tBTA_DM_API_SET_AFH_CHANNEL_ASSESSMENT *) GKI_getbuf(sizeof(tBTA_DM_API_SET_AFH_CHANNEL_ASSESSMENT))) != NULL) |
| 316 | { |
| 317 | p_msg->hdr.event = BTA_DM_API_SET_AFH_CHANNEL_ASSESMENT_EVT; |
| 318 | p_msg->enable_or_disable = enable_or_disable; |
| 319 | bta_sys_sendmsg(p_msg); |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | /******************************************************************************* |
| 324 | ** |
| 325 | ** Function BTA_DmVendorSpecificCommand |
| 326 | ** |
| 327 | ** Description This function sends the vendor specific command |
| 328 | ** to the controller |
| 329 | ** |
| 330 | ** |
| 331 | ** Returns tBTA_STATUS |
| 332 | ** |
| 333 | *******************************************************************************/ |
| 334 | tBTA_STATUS BTA_DmVendorSpecificCommand (UINT16 opcode, UINT8 param_len, |
| 335 | UINT8 *p_param_buf, |
| 336 | tBTA_VENDOR_CMPL_CBACK *p_cback) |
| 337 | { |
| 338 | |
| 339 | tBTA_DM_API_VENDOR_SPECIFIC_COMMAND *p_msg; |
| 340 | UINT16 size; |
| 341 | |
| 342 | /* If p_cback is NULL, Notify application */ |
| 343 | if (p_cback == NULL) |
| 344 | { |
| 345 | return (BTA_FAILURE); |
| 346 | } |
| 347 | else |
| 348 | { |
| 349 | size = sizeof (tBTA_DM_API_VENDOR_SPECIFIC_COMMAND) + param_len; |
| 350 | if ((p_msg = (tBTA_DM_API_VENDOR_SPECIFIC_COMMAND *) GKI_getbuf(size)) != NULL) |
| 351 | { |
| 352 | p_msg->hdr.event = BTA_DM_API_VENDOR_SPECIFIC_COMMAND_EVT; |
| 353 | p_msg->opcode = opcode; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 354 | p_msg->p_param_buf = (UINT8 *)(p_msg + 1); |
| 355 | p_msg->p_cback = p_cback; |
| 356 | |
Andre Eisenbach | 3aa6054 | 2013-03-22 18:00:51 -0700 | [diff] [blame] | 357 | if (p_param_buf && param_len) |
| 358 | { |
| 359 | memcpy (p_msg->p_param_buf, p_param_buf, param_len); |
| 360 | p_msg->param_len = param_len; |
| 361 | } |
| 362 | else |
| 363 | { |
| 364 | p_msg->param_len = 0; |
| 365 | p_msg->p_param_buf = NULL; |
| 366 | |
| 367 | } |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 368 | |
| 369 | bta_sys_sendmsg(p_msg); |
| 370 | } |
| 371 | return (BTA_SUCCESS); |
| 372 | } |
| 373 | } |
| 374 | /******************************************************************************* |
| 375 | ** |
| 376 | ** Function BTA_DmSearch |
| 377 | ** |
| 378 | ** Description This function searches for peer Bluetooth devices. It performs |
| 379 | ** an inquiry and gets the remote name for devices. Service |
| 380 | ** discovery is done if services is non zero |
| 381 | ** |
| 382 | ** |
| 383 | ** Returns void |
| 384 | ** |
| 385 | *******************************************************************************/ |
| 386 | void BTA_DmSearch(tBTA_DM_INQ *p_dm_inq, tBTA_SERVICE_MASK services, tBTA_DM_SEARCH_CBACK *p_cback) |
| 387 | { |
| 388 | |
| 389 | tBTA_DM_API_SEARCH *p_msg; |
| 390 | |
| 391 | if ((p_msg = (tBTA_DM_API_SEARCH *) GKI_getbuf(sizeof(tBTA_DM_API_SEARCH))) != NULL) |
| 392 | { |
| 393 | memset(p_msg, 0, sizeof(tBTA_DM_API_SEARCH)); |
| 394 | |
| 395 | p_msg->hdr.event = BTA_DM_API_SEARCH_EVT; |
| 396 | memcpy(&p_msg->inq_params, p_dm_inq, sizeof(tBTA_DM_INQ)); |
| 397 | p_msg->services = services; |
| 398 | p_msg->p_cback = p_cback; |
| 399 | p_msg->rs_res = BTA_DM_RS_NONE; |
| 400 | bta_sys_sendmsg(p_msg); |
| 401 | } |
| 402 | |
| 403 | } |
| 404 | |
| 405 | |
| 406 | /******************************************************************************* |
| 407 | ** |
| 408 | ** Function BTA_DmSearchCancel |
| 409 | ** |
| 410 | ** Description This function cancels a search initiated by BTA_DmSearch |
| 411 | ** |
| 412 | ** |
| 413 | ** Returns void |
| 414 | ** |
| 415 | *******************************************************************************/ |
| 416 | void BTA_DmSearchCancel(void) |
| 417 | { |
| 418 | BT_HDR *p_msg; |
| 419 | |
| 420 | if ((p_msg = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) |
| 421 | { |
| 422 | p_msg->event = BTA_DM_API_SEARCH_CANCEL_EVT; |
| 423 | bta_sys_sendmsg(p_msg); |
| 424 | } |
| 425 | |
| 426 | } |
| 427 | |
| 428 | /******************************************************************************* |
| 429 | ** |
| 430 | ** Function BTA_DmDiscover |
| 431 | ** |
| 432 | ** Description This function does service discovery for services of a |
| 433 | ** peer device |
| 434 | ** |
| 435 | ** |
| 436 | ** Returns void |
| 437 | ** |
| 438 | *******************************************************************************/ |
| 439 | void BTA_DmDiscover(BD_ADDR bd_addr, tBTA_SERVICE_MASK services, |
| 440 | tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search) |
| 441 | { |
| 442 | tBTA_DM_API_DISCOVER *p_msg; |
| 443 | |
| 444 | if ((p_msg = (tBTA_DM_API_DISCOVER *) GKI_getbuf(sizeof(tBTA_DM_API_DISCOVER))) != NULL) |
| 445 | { |
| 446 | memset(p_msg, 0, sizeof(tBTA_DM_API_DISCOVER)); |
| 447 | |
| 448 | p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT; |
| 449 | bdcpy(p_msg->bd_addr, bd_addr); |
| 450 | p_msg->services = services; |
| 451 | p_msg->p_cback = p_cback; |
| 452 | p_msg->sdp_search = sdp_search; |
| 453 | bta_sys_sendmsg(p_msg); |
| 454 | } |
| 455 | |
| 456 | } |
| 457 | |
| 458 | /******************************************************************************* |
| 459 | ** |
| 460 | ** Function BTA_DmDiscoverUUID |
| 461 | ** |
| 462 | ** Description This function does service discovery for services of a |
| 463 | ** peer device |
| 464 | ** |
| 465 | ** |
| 466 | ** Returns void |
| 467 | ** |
| 468 | *******************************************************************************/ |
| 469 | void BTA_DmDiscoverUUID(BD_ADDR bd_addr, tSDP_UUID *uuid, |
| 470 | tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search) |
| 471 | { |
| 472 | tBTA_DM_API_DISCOVER *p_msg; |
| 473 | |
| 474 | if ((p_msg = (tBTA_DM_API_DISCOVER *) GKI_getbuf(sizeof(tBTA_DM_API_DISCOVER))) != NULL) |
| 475 | { |
| 476 | p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT; |
| 477 | bdcpy(p_msg->bd_addr, bd_addr); |
| 478 | p_msg->services = BTA_USER_SERVICE_MASK; //Not exposed at API level |
| 479 | p_msg->p_cback = p_cback; |
| 480 | p_msg->sdp_search = sdp_search; |
| 481 | |
| 482 | #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE |
| 483 | p_msg->num_uuid = 0; |
| 484 | p_msg->p_uuid = NULL; |
| 485 | #endif |
| 486 | memcpy( &p_msg->uuid, uuid, sizeof(tSDP_UUID) ); |
| 487 | bta_sys_sendmsg(p_msg); |
| 488 | } |
| 489 | |
| 490 | } |
| 491 | /******************************************************************************* |
| 492 | ** |
| 493 | ** Function BTA_DmIsMaster |
| 494 | ** |
| 495 | ** Description This function checks if the local device is the master of |
| 496 | ** the link to the given device |
| 497 | ** |
| 498 | ** Returns TRUE if master. |
| 499 | ** FALSE if not. |
| 500 | ** |
| 501 | *******************************************************************************/ |
| 502 | BOOLEAN BTA_DmIsMaster(BD_ADDR bd_addr) |
| 503 | { |
| 504 | BOOLEAN is_master = FALSE; |
| 505 | UINT8 link_role; |
| 506 | |
| 507 | BTM_GetRole(bd_addr, &link_role); |
| 508 | APPL_TRACE_API1("BTA_DmIsMaster role:x%x", link_role); |
| 509 | if(link_role == BTM_ROLE_MASTER) |
| 510 | { |
| 511 | is_master = TRUE; |
| 512 | } |
| 513 | return is_master; |
| 514 | } |
| 515 | |
| 516 | /******************************************************************************* |
| 517 | ** |
| 518 | ** Function BTA_DmBond |
| 519 | ** |
| 520 | ** Description This function initiates a bonding procedure with a peer |
| 521 | ** device |
| 522 | ** |
| 523 | ** |
| 524 | ** Returns void |
| 525 | ** |
| 526 | *******************************************************************************/ |
| 527 | void BTA_DmBond(BD_ADDR bd_addr) |
| 528 | { |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame^] | 529 | BTA_DmBondByTransport (bd_addr, BTA_TRANSPORT_UNKNOWN); |
| 530 | } |
| 531 | |
| 532 | /******************************************************************************* |
| 533 | ** |
| 534 | ** Function BTA_DmBondByTransports |
| 535 | ** |
| 536 | ** Description This function initiates a bonding procedure with a peer |
| 537 | ** device |
| 538 | ** |
| 539 | ** |
| 540 | ** Returns void |
| 541 | ** |
| 542 | *******************************************************************************/ |
| 543 | void BTA_DmBondByTransport(BD_ADDR bd_addr, tBTA_TRANSPORT transport) |
| 544 | { |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 545 | tBTA_DM_API_BOND *p_msg; |
| 546 | |
| 547 | if ((p_msg = (tBTA_DM_API_BOND *) GKI_getbuf(sizeof(tBTA_DM_API_BOND))) != NULL) |
| 548 | { |
| 549 | p_msg->hdr.event = BTA_DM_API_BOND_EVT; |
| 550 | bdcpy(p_msg->bd_addr, bd_addr); |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame^] | 551 | p_msg->transport = transport; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 552 | bta_sys_sendmsg(p_msg); |
| 553 | } |
| 554 | |
| 555 | |
| 556 | } |
| 557 | |
| 558 | /******************************************************************************* |
| 559 | ** |
| 560 | ** Function BTA_DmBondCancel |
| 561 | ** |
| 562 | ** Description This function cancels the bonding procedure with a peer |
| 563 | ** device |
| 564 | ** |
| 565 | ** |
| 566 | ** Returns void |
| 567 | ** |
| 568 | *******************************************************************************/ |
| 569 | void BTA_DmBondCancel(BD_ADDR bd_addr) |
| 570 | { |
| 571 | tBTA_DM_API_BOND_CANCEL *p_msg; |
| 572 | |
| 573 | if ((p_msg = (tBTA_DM_API_BOND_CANCEL *) GKI_getbuf(sizeof(tBTA_DM_API_BOND_CANCEL))) != NULL) |
| 574 | { |
| 575 | p_msg->hdr.event = BTA_DM_API_BOND_CANCEL_EVT; |
| 576 | bdcpy(p_msg->bd_addr, bd_addr); |
| 577 | bta_sys_sendmsg(p_msg); |
| 578 | } |
| 579 | |
| 580 | |
| 581 | } |
| 582 | |
| 583 | /******************************************************************************* |
| 584 | ** |
| 585 | ** Function BTA_DmPinReply |
| 586 | ** |
| 587 | ** Description This function provides a pincode for a remote device when |
| 588 | ** one is requested by DM through BTA_DM_PIN_REQ_EVT |
| 589 | ** |
| 590 | ** |
| 591 | ** Returns void |
| 592 | ** |
| 593 | *******************************************************************************/ |
| 594 | void BTA_DmPinReply(BD_ADDR bd_addr, BOOLEAN accept, UINT8 pin_len, UINT8 *p_pin) |
| 595 | |
| 596 | { |
| 597 | tBTA_DM_API_PIN_REPLY *p_msg; |
| 598 | |
| 599 | if ((p_msg = (tBTA_DM_API_PIN_REPLY *) GKI_getbuf(sizeof(tBTA_DM_API_PIN_REPLY))) != NULL) |
| 600 | { |
| 601 | p_msg->hdr.event = BTA_DM_API_PIN_REPLY_EVT; |
| 602 | bdcpy(p_msg->bd_addr, bd_addr); |
| 603 | p_msg->accept = accept; |
| 604 | if(accept) |
| 605 | { |
| 606 | p_msg->pin_len = pin_len; |
| 607 | memcpy(p_msg->p_pin, p_pin, pin_len); |
| 608 | } |
| 609 | bta_sys_sendmsg(p_msg); |
| 610 | } |
| 611 | |
| 612 | } |
| 613 | |
| 614 | /******************************************************************************* |
| 615 | ** |
| 616 | ** Function BTA_DmLinkPolicy |
| 617 | ** |
| 618 | ** Description This function sets/clears the link policy mask to the given |
| 619 | ** bd_addr. |
| 620 | ** If clearing the sniff or park mode mask, the link is put |
| 621 | ** in active mode. |
| 622 | ** |
| 623 | ** Returns void |
| 624 | ** |
| 625 | *******************************************************************************/ |
| 626 | void BTA_DmLinkPolicy(BD_ADDR bd_addr, tBTA_DM_LP_MASK policy_mask, |
| 627 | BOOLEAN set) |
| 628 | { |
| 629 | tBTA_DM_API_LINK_POLICY *p_msg; |
| 630 | |
| 631 | if ((p_msg = (tBTA_DM_API_LINK_POLICY *) GKI_getbuf(sizeof(tBTA_DM_API_LINK_POLICY))) != NULL) |
| 632 | { |
| 633 | p_msg->hdr.event = BTA_DM_API_LINK_POLICY_EVT; |
| 634 | bdcpy(p_msg->bd_addr, bd_addr); |
| 635 | p_msg->policy_mask = policy_mask; |
| 636 | p_msg->set = set; |
| 637 | bta_sys_sendmsg(p_msg); |
| 638 | } |
| 639 | } |
| 640 | |
| 641 | |
| 642 | #if (BTM_OOB_INCLUDED == TRUE) |
| 643 | /******************************************************************************* |
| 644 | ** |
| 645 | ** Function BTA_DmLocalOob |
| 646 | ** |
| 647 | ** Description This function retrieves the OOB data from local controller. |
| 648 | ** The result is reported by bta_dm_co_loc_oob(). |
| 649 | ** |
| 650 | ** Returns void |
| 651 | ** |
| 652 | *******************************************************************************/ |
| 653 | void BTA_DmLocalOob(void) |
| 654 | { |
| 655 | tBTA_DM_API_LOC_OOB *p_msg; |
| 656 | |
| 657 | if ((p_msg = (tBTA_DM_API_LOC_OOB *) GKI_getbuf(sizeof(tBTA_DM_API_LOC_OOB))) != NULL) |
| 658 | { |
| 659 | p_msg->hdr.event = BTA_DM_API_LOC_OOB_EVT; |
| 660 | bta_sys_sendmsg(p_msg); |
| 661 | } |
| 662 | } |
| 663 | #endif /* BTM_OOB_INCLUDED */ |
| 664 | /******************************************************************************* |
| 665 | ** |
| 666 | ** Function BTA_DmConfirm |
| 667 | ** |
| 668 | ** Description This function accepts or rejects the numerical value of the |
| 669 | ** Simple Pairing process on BTA_DM_SP_CFM_REQ_EVT |
| 670 | ** |
| 671 | ** Returns void |
| 672 | ** |
| 673 | *******************************************************************************/ |
| 674 | void BTA_DmConfirm(BD_ADDR bd_addr, BOOLEAN accept) |
| 675 | { |
| 676 | tBTA_DM_API_CONFIRM *p_msg; |
| 677 | |
| 678 | if ((p_msg = (tBTA_DM_API_CONFIRM *) GKI_getbuf(sizeof(tBTA_DM_API_CONFIRM))) != NULL) |
| 679 | { |
| 680 | p_msg->hdr.event = BTA_DM_API_CONFIRM_EVT; |
| 681 | bdcpy(p_msg->bd_addr, bd_addr); |
| 682 | p_msg->accept = accept; |
| 683 | bta_sys_sendmsg(p_msg); |
| 684 | } |
| 685 | } |
| 686 | |
| 687 | /******************************************************************************* |
| 688 | ** |
| 689 | ** Function BTA_DmPasskeyCancel |
| 690 | ** |
| 691 | ** Description This function is called to cancel the simple pairing process |
| 692 | ** reported by BTA_DM_SP_KEY_NOTIF_EVT |
| 693 | ** |
| 694 | ** Returns void |
| 695 | ** |
| 696 | *******************************************************************************/ |
| 697 | #if (BTM_LOCAL_IO_CAPS != BTM_IO_CAP_NONE) |
| 698 | void BTA_DmPasskeyCancel(BD_ADDR bd_addr) |
| 699 | { |
| 700 | tBTA_DM_API_PASKY_CANCEL *p_msg; |
| 701 | |
| 702 | if ((p_msg = (tBTA_DM_API_PASKY_CANCEL *) \ |
| 703 | GKI_getbuf(sizeof(tBTA_DM_API_PASKY_CANCEL))) != NULL) |
| 704 | { |
| 705 | p_msg->hdr.event = BTA_DM_API_PASKY_CANCEL_EVT; |
| 706 | bdcpy(p_msg->bd_addr, bd_addr); |
| 707 | bta_sys_sendmsg(p_msg); |
| 708 | } |
| 709 | } |
| 710 | #endif |
| 711 | |
| 712 | |
| 713 | /******************************************************************************* |
| 714 | ** |
| 715 | ** Function BTA_DmAddDevice |
| 716 | ** |
| 717 | ** Description This function adds a device to the security database list of |
| 718 | ** peer device |
| 719 | ** |
| 720 | ** |
| 721 | ** Returns void |
| 722 | ** |
| 723 | *******************************************************************************/ |
| 724 | void BTA_DmAddDevice(BD_ADDR bd_addr, DEV_CLASS dev_class, LINK_KEY link_key, |
| 725 | tBTA_SERVICE_MASK trusted_mask, BOOLEAN is_trusted, |
| 726 | UINT8 key_type, tBTA_IO_CAP io_cap) |
| 727 | { |
| 728 | |
| 729 | tBTA_DM_API_ADD_DEVICE *p_msg; |
| 730 | |
| 731 | if ((p_msg = (tBTA_DM_API_ADD_DEVICE *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_DEVICE))) != NULL) |
| 732 | { |
| 733 | memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_DEVICE)); |
| 734 | |
| 735 | p_msg->hdr.event = BTA_DM_API_ADD_DEVICE_EVT; |
| 736 | bdcpy(p_msg->bd_addr, bd_addr); |
| 737 | p_msg->tm = trusted_mask; |
| 738 | p_msg->is_trusted = is_trusted; |
| 739 | p_msg->io_cap = io_cap; |
| 740 | |
| 741 | if (link_key) |
| 742 | { |
| 743 | p_msg->link_key_known = TRUE; |
| 744 | p_msg->key_type = key_type; |
| 745 | memcpy(p_msg->link_key, link_key, LINK_KEY_LEN); |
| 746 | } |
| 747 | |
| 748 | /* Load device class if specified */ |
| 749 | if (dev_class) |
| 750 | { |
| 751 | p_msg->dc_known = TRUE; |
| 752 | memcpy (p_msg->dc, dev_class, DEV_CLASS_LEN); |
| 753 | } |
| 754 | |
| 755 | memset (p_msg->bd_name, 0, BD_NAME_LEN); |
Andre Eisenbach | 3aa6054 | 2013-03-22 18:00:51 -0700 | [diff] [blame] | 756 | memset (p_msg->features, 0, sizeof (p_msg->features)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 757 | |
| 758 | bta_sys_sendmsg(p_msg); |
| 759 | } |
| 760 | } |
| 761 | |
| 762 | |
| 763 | /******************************************************************************* |
| 764 | ** |
| 765 | ** Function BTA_DmRemoveDevice |
| 766 | ** |
| 767 | ** Description This function removes a device fromthe security database list of |
| 768 | ** peer device |
| 769 | ** |
| 770 | ** |
| 771 | ** Returns void |
| 772 | ** |
| 773 | *******************************************************************************/ |
| 774 | tBTA_STATUS BTA_DmRemoveDevice(BD_ADDR bd_addr) |
| 775 | { |
| 776 | tBTA_DM_API_REMOVE_DEVICE *p_msg; |
| 777 | |
| 778 | if ((p_msg = (tBTA_DM_API_REMOVE_DEVICE *) GKI_getbuf(sizeof(tBTA_DM_API_REMOVE_DEVICE))) != NULL) |
| 779 | { |
| 780 | memset (p_msg, 0, sizeof(tBTA_DM_API_REMOVE_DEVICE)); |
| 781 | |
| 782 | p_msg->hdr.event = BTA_DM_API_REMOVE_DEVICE_EVT; |
| 783 | bdcpy(p_msg->bd_addr, bd_addr); |
| 784 | bta_sys_sendmsg(p_msg); |
| 785 | } |
| 786 | else |
| 787 | { |
| 788 | return BTA_FAILURE; |
| 789 | } |
| 790 | |
| 791 | return BTA_SUCCESS; |
| 792 | } |
| 793 | |
| 794 | /******************************************************************************* |
| 795 | ** |
| 796 | ** Function BTA_DmAddDevWithName |
| 797 | ** |
| 798 | ** Description This function is newer version of BTA_DmAddDevice() |
| 799 | ** which added bd_name and features as input parameters. |
| 800 | ** |
| 801 | ** |
| 802 | ** Returns void |
| 803 | ** |
| 804 | *******************************************************************************/ |
| 805 | void BTA_DmAddDevWithName (BD_ADDR bd_addr, DEV_CLASS dev_class, |
Andre Eisenbach | 3aa6054 | 2013-03-22 18:00:51 -0700 | [diff] [blame] | 806 | BD_NAME bd_name, UINT8 *features, |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 807 | LINK_KEY link_key, tBTA_SERVICE_MASK trusted_mask, |
| 808 | BOOLEAN is_trusted, UINT8 key_type, tBTA_IO_CAP io_cap) |
| 809 | { |
| 810 | tBTA_DM_API_ADD_DEVICE *p_msg; |
| 811 | |
| 812 | if ((p_msg = (tBTA_DM_API_ADD_DEVICE *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_DEVICE))) != NULL) |
| 813 | { |
| 814 | memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_DEVICE)); |
| 815 | |
| 816 | p_msg->hdr.event = BTA_DM_API_ADD_DEVICE_EVT; |
| 817 | bdcpy(p_msg->bd_addr, bd_addr); |
| 818 | p_msg->tm = trusted_mask; |
| 819 | p_msg->is_trusted = is_trusted; |
| 820 | p_msg->io_cap = io_cap; |
| 821 | |
| 822 | if (link_key) |
| 823 | { |
| 824 | p_msg->link_key_known = TRUE; |
| 825 | p_msg->key_type = key_type; |
| 826 | memcpy(p_msg->link_key, link_key, LINK_KEY_LEN); |
| 827 | } |
| 828 | |
| 829 | /* Load device class if specified */ |
| 830 | if (dev_class) |
| 831 | { |
| 832 | p_msg->dc_known = TRUE; |
| 833 | memcpy (p_msg->dc, dev_class, DEV_CLASS_LEN); |
| 834 | } |
| 835 | |
| 836 | if (bd_name) |
| 837 | memcpy(p_msg->bd_name, bd_name, BD_NAME_LEN); |
| 838 | |
| 839 | if (features) |
Andre Eisenbach | 3aa6054 | 2013-03-22 18:00:51 -0700 | [diff] [blame] | 840 | memcpy(p_msg->features, features, sizeof(p_msg->features)); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 841 | |
| 842 | bta_sys_sendmsg(p_msg); |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | /******************************************************************************* |
| 847 | ** |
| 848 | ** Function BTA_DmAuthorizeReply |
| 849 | ** |
| 850 | ** Description This function provides an authorization reply when authorization |
| 851 | ** is requested by BTA through BTA_DM_AUTHORIZE_EVT |
| 852 | ** |
| 853 | ** |
| 854 | ** Returns tBTA_STATUS |
| 855 | ** |
| 856 | *******************************************************************************/ |
| 857 | void BTA_DmAuthorizeReply(BD_ADDR bd_addr, tBTA_SERVICE_ID service, tBTA_AUTH_RESP response) |
| 858 | { |
| 859 | |
| 860 | tBTA_DM_API_AUTH_REPLY *p_msg; |
| 861 | |
| 862 | if ((p_msg = (tBTA_DM_API_AUTH_REPLY *) GKI_getbuf(sizeof(tBTA_DM_API_AUTH_REPLY))) != NULL) |
| 863 | { |
| 864 | p_msg->hdr.event = BTA_DM_API_AUTH_REPLY_EVT; |
| 865 | bdcpy(p_msg->bd_addr, bd_addr); |
| 866 | p_msg->service = service; |
| 867 | p_msg->response = response; |
| 868 | |
| 869 | bta_sys_sendmsg(p_msg); |
| 870 | } |
| 871 | |
| 872 | } |
| 873 | |
| 874 | /******************************************************************************* |
| 875 | ** |
| 876 | ** Function BTA_DmSignalStrength |
| 877 | ** |
| 878 | ** Description This function initiates RSSI and channnel quality |
| 879 | ** measurments. BTA_DM_SIG_STRENGTH_EVT is sent to |
| 880 | ** application with the values of RSSI and channel |
| 881 | ** quality |
| 882 | ** |
| 883 | ** |
| 884 | ** Returns void |
| 885 | ** |
| 886 | *******************************************************************************/ |
| 887 | void BTA_DmSignalStrength(tBTA_SIG_STRENGTH_MASK mask, UINT16 period, BOOLEAN start) |
| 888 | { |
| 889 | |
| 890 | tBTA_API_DM_SIG_STRENGTH *p_msg; |
| 891 | |
| 892 | if ((p_msg = (tBTA_API_DM_SIG_STRENGTH *) GKI_getbuf(sizeof(tBTA_API_DM_SIG_STRENGTH))) != NULL) |
| 893 | { |
| 894 | p_msg->hdr.event = BTA_API_DM_SIG_STRENGTH_EVT; |
| 895 | p_msg->mask = mask; |
| 896 | p_msg->period = period; |
| 897 | p_msg->start = start; |
| 898 | |
| 899 | bta_sys_sendmsg(p_msg); |
| 900 | } |
| 901 | |
| 902 | |
| 903 | } |
| 904 | |
| 905 | /******************************************************************************* |
| 906 | ** |
| 907 | ** Function BTA_DmWriteInqTxPower |
| 908 | ** |
| 909 | ** Description This command is used to write the inquiry transmit power level |
| 910 | ** used to transmit the inquiry (ID) data packets. |
| 911 | ** |
| 912 | ** Parameters tx_power - tx inquiry power to use, valid value is -70 ~ 20 |
| 913 | |
| 914 | ** Returns void |
| 915 | ** |
| 916 | *******************************************************************************/ |
| 917 | void BTA_DmWriteInqTxPower(INT8 tx_power) |
| 918 | { |
| 919 | |
| 920 | tBTA_API_DM_TX_INQPWR *p_msg; |
| 921 | |
| 922 | if ((p_msg = (tBTA_API_DM_TX_INQPWR *) GKI_getbuf(sizeof(tBTA_API_DM_TX_INQPWR))) != NULL) |
| 923 | { |
| 924 | p_msg->hdr.event = BTA_DM_API_TX_INQPWR_EVT; |
| 925 | p_msg->tx_power = tx_power; |
| 926 | |
| 927 | bta_sys_sendmsg(p_msg); |
| 928 | } |
| 929 | } |
| 930 | |
| 931 | |
| 932 | /******************************************************************************* |
| 933 | ** |
| 934 | ** Function BTA_DmEirAddUUID |
| 935 | ** |
| 936 | ** Description This function is called to add UUID into EIR. |
| 937 | ** |
| 938 | ** Parameters tBT_UUID - UUID |
| 939 | ** |
| 940 | ** Returns None |
| 941 | ** |
| 942 | *******************************************************************************/ |
| 943 | void BTA_DmEirAddUUID (tBT_UUID *p_uuid) |
| 944 | { |
| 945 | #if ( BTM_EIR_SERVER_INCLUDED == TRUE )&&( BTA_EIR_CANNED_UUID_LIST != TRUE )&&(BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0) |
| 946 | tBTA_DM_API_UPDATE_EIR_UUID *p_msg; |
| 947 | |
| 948 | if ((p_msg = (tBTA_DM_API_UPDATE_EIR_UUID *) GKI_getbuf(sizeof(tBTA_DM_API_UPDATE_EIR_UUID))) != NULL) |
| 949 | { |
| 950 | p_msg->hdr.event = BTA_DM_API_UPDATE_EIR_UUID_EVT; |
| 951 | p_msg->is_add = TRUE; |
| 952 | memcpy (&(p_msg->uuid), p_uuid, sizeof(tBT_UUID)); |
| 953 | |
| 954 | bta_sys_sendmsg(p_msg); |
| 955 | } |
| 956 | #endif |
| 957 | } |
| 958 | |
| 959 | /******************************************************************************* |
| 960 | ** |
| 961 | ** Function BTA_DmEirRemoveUUID |
| 962 | ** |
| 963 | ** Description This function is called to remove UUID from EIR. |
| 964 | ** |
| 965 | ** Parameters tBT_UUID - UUID |
| 966 | ** |
| 967 | ** Returns None |
| 968 | ** |
| 969 | *******************************************************************************/ |
| 970 | void BTA_DmEirRemoveUUID (tBT_UUID *p_uuid) |
| 971 | { |
| 972 | #if ( BTM_EIR_SERVER_INCLUDED == TRUE )&&( BTA_EIR_CANNED_UUID_LIST != TRUE )&&(BTA_EIR_SERVER_NUM_CUSTOM_UUID > 0) |
| 973 | tBTA_DM_API_UPDATE_EIR_UUID *p_msg; |
| 974 | |
| 975 | if ((p_msg = (tBTA_DM_API_UPDATE_EIR_UUID *) GKI_getbuf(sizeof(tBTA_DM_API_UPDATE_EIR_UUID))) != NULL) |
| 976 | { |
| 977 | p_msg->hdr.event = BTA_DM_API_UPDATE_EIR_UUID_EVT; |
| 978 | p_msg->is_add = FALSE; |
| 979 | memcpy (&(p_msg->uuid), p_uuid, sizeof(tBT_UUID)); |
| 980 | |
| 981 | bta_sys_sendmsg(p_msg); |
| 982 | } |
| 983 | #endif |
| 984 | } |
| 985 | |
| 986 | /******************************************************************************* |
| 987 | ** |
| 988 | ** Function BTA_DmSetEIRConfig |
| 989 | ** |
| 990 | ** Description This function is called to override the BTA default EIR parameters. |
| 991 | ** This funciton is only valid in a system where BTU & App task |
| 992 | ** are in the same memory space. |
| 993 | ** |
| 994 | ** Parameters Pointer to User defined EIR config |
| 995 | ** |
| 996 | ** Returns None |
| 997 | ** |
| 998 | *******************************************************************************/ |
| 999 | void BTA_DmSetEIRConfig (tBTA_DM_EIR_CONF *p_eir_cfg) |
| 1000 | { |
| 1001 | #if (BTM_EIR_SERVER_INCLUDED == TRUE) |
| 1002 | tBTA_DM_API_SET_EIR_CONFIG *p_msg; |
| 1003 | |
| 1004 | if ((p_msg = (tBTA_DM_API_SET_EIR_CONFIG *) GKI_getbuf(sizeof(tBTA_DM_API_SET_EIR_CONFIG))) != NULL) |
| 1005 | { |
| 1006 | p_msg->hdr.event = BTA_DM_API_SET_EIR_CONFIG_EVT; |
| 1007 | p_msg->p_eir_cfg = p_eir_cfg; |
| 1008 | |
| 1009 | bta_sys_sendmsg(p_msg); |
| 1010 | } |
| 1011 | #endif |
| 1012 | } |
| 1013 | |
| 1014 | /******************************************************************************* |
| 1015 | ** |
| 1016 | ** Function BTA_CheckEirData |
| 1017 | ** |
| 1018 | ** Description This function is called to get EIR data from significant part. |
| 1019 | ** |
| 1020 | ** Parameters p_eir - pointer of EIR significant part |
| 1021 | ** type - finding EIR data type |
| 1022 | ** p_length - return the length of EIR data |
| 1023 | ** |
| 1024 | ** Returns pointer of EIR data |
| 1025 | ** |
| 1026 | *******************************************************************************/ |
| 1027 | UINT8 *BTA_CheckEirData( UINT8 *p_eir, UINT8 type, UINT8 *p_length ) |
| 1028 | { |
| 1029 | #if ( BTM_EIR_CLIENT_INCLUDED == TRUE ) |
| 1030 | return BTM_CheckEirData( p_eir, type, p_length ); |
| 1031 | #else |
| 1032 | return NULL; |
| 1033 | #endif |
| 1034 | } |
| 1035 | |
| 1036 | /******************************************************************************* |
| 1037 | ** |
| 1038 | ** Function BTA_GetEirService |
| 1039 | ** |
| 1040 | ** Description This function is called to get BTA service mask from EIR. |
| 1041 | ** |
| 1042 | ** Parameters p_eir - pointer of EIR significant part |
| 1043 | ** p_services - return the BTA service mask |
| 1044 | ** |
| 1045 | ** Returns None |
| 1046 | ** |
| 1047 | *******************************************************************************/ |
| 1048 | extern const UINT16 bta_service_id_to_uuid_lkup_tbl []; |
| 1049 | void BTA_GetEirService( UINT8 *p_eir, tBTA_SERVICE_MASK *p_services ) |
| 1050 | { |
| 1051 | #if ( BTM_EIR_CLIENT_INCLUDED == TRUE ) |
| 1052 | UINT8 xx, yy; |
| 1053 | UINT8 num_uuid, max_num_uuid = 32; |
| 1054 | UINT8 uuid_list[32*LEN_UUID_16]; |
| 1055 | UINT16 *p_uuid16 = (UINT16 *)uuid_list; |
| 1056 | tBTA_SERVICE_MASK mask; |
| 1057 | |
| 1058 | BTM_GetEirUuidList( p_eir, LEN_UUID_16, &num_uuid, uuid_list, max_num_uuid); |
| 1059 | for( xx = 0; xx < num_uuid; xx++ ) |
| 1060 | { |
| 1061 | mask = 1; |
| 1062 | for( yy = 0; yy < BTA_MAX_SERVICE_ID; yy++ ) |
| 1063 | { |
| 1064 | if( *(p_uuid16 + xx) == bta_service_id_to_uuid_lkup_tbl[yy] ) |
| 1065 | { |
| 1066 | *p_services |= mask; |
| 1067 | break; |
| 1068 | } |
| 1069 | mask <<= 1; |
| 1070 | } |
| 1071 | |
| 1072 | /* for HSP v1.2 only device */ |
| 1073 | if (*(p_uuid16 + xx) == UUID_SERVCLASS_HEADSET_HS) |
| 1074 | *p_services |= BTA_HSP_SERVICE_MASK; |
| 1075 | |
| 1076 | if (*(p_uuid16 + xx) == UUID_SERVCLASS_HDP_SOURCE) |
| 1077 | *p_services |= BTA_HL_SERVICE_MASK; |
| 1078 | |
| 1079 | if (*(p_uuid16 + xx) == UUID_SERVCLASS_HDP_SINK) |
| 1080 | *p_services |= BTA_HL_SERVICE_MASK; |
| 1081 | } |
| 1082 | #endif |
| 1083 | } |
| 1084 | |
| 1085 | /******************************************************************************* |
| 1086 | ** |
| 1087 | ** Function BTA_DmUseSsr |
| 1088 | ** |
| 1089 | ** Description This function is called to check if the connected peer device |
| 1090 | ** supports SSR or not. |
| 1091 | ** |
| 1092 | ** Returns TRUE, if SSR is supported |
| 1093 | ** |
| 1094 | *******************************************************************************/ |
| 1095 | BOOLEAN BTA_DmUseSsr( BD_ADDR bd_addr ) |
| 1096 | { |
| 1097 | BOOLEAN use_ssr = FALSE; |
| 1098 | tBTA_DM_PEER_DEVICE * p_dev = bta_dm_find_peer_device(bd_addr); |
| 1099 | if(p_dev && (p_dev->info & BTA_DM_DI_USE_SSR) ) |
| 1100 | use_ssr = TRUE; |
| 1101 | return use_ssr; |
| 1102 | } |
| 1103 | |
| 1104 | /******************************************************************************* |
| 1105 | ** Device Identification (DI) Server Functions |
| 1106 | *******************************************************************************/ |
| 1107 | /******************************************************************************* |
| 1108 | ** |
| 1109 | ** Function BTA_DmSetLocalDiRecord |
| 1110 | ** |
| 1111 | ** Description This function adds a DI record to the local SDP database. |
| 1112 | ** |
| 1113 | ** Returns BTA_SUCCESS if record set sucessfully, otherwise error code. |
| 1114 | ** |
| 1115 | *******************************************************************************/ |
| 1116 | tBTA_STATUS BTA_DmSetLocalDiRecord( tBTA_DI_RECORD *p_device_info, |
| 1117 | UINT32 *p_handle ) |
| 1118 | { |
| 1119 | tBTA_STATUS status = BTA_FAILURE; |
| 1120 | |
| 1121 | if(bta_dm_di_cb.di_num < BTA_DI_NUM_MAX) |
| 1122 | { |
| 1123 | if(SDP_SetLocalDiRecord((tSDP_DI_RECORD *)p_device_info, p_handle) == SDP_SUCCESS) |
| 1124 | { |
| 1125 | if(!p_device_info->primary_record) |
| 1126 | { |
| 1127 | bta_dm_di_cb.di_handle[bta_dm_di_cb.di_num] = *p_handle; |
| 1128 | bta_dm_di_cb.di_num ++; |
| 1129 | } |
| 1130 | |
| 1131 | bta_sys_add_uuid(UUID_SERVCLASS_PNP_INFORMATION); |
| 1132 | status = BTA_SUCCESS; |
| 1133 | } |
| 1134 | } |
| 1135 | |
| 1136 | return status; |
| 1137 | } |
| 1138 | |
| 1139 | /******************************************************************************* |
| 1140 | ** |
| 1141 | ** Function BTA_DmGetLocalDiRecord |
| 1142 | ** |
| 1143 | ** Description Get a specified DI record to the local SDP database. If no |
| 1144 | ** record handle is provided, the primary DI record will be |
| 1145 | ** returned. |
| 1146 | ** |
| 1147 | ** Fills in the device information of the record |
| 1148 | ** p_handle - if p_handle == 0, the primary record is returned |
| 1149 | ** |
| 1150 | ** Returns BTA_SUCCESS if record set sucessfully, otherwise error code. |
| 1151 | ** |
| 1152 | *******************************************************************************/ |
| 1153 | tBTA_STATUS BTA_DmGetLocalDiRecord( tBTA_DI_GET_RECORD *p_device_info, |
| 1154 | UINT32 *p_handle ) |
| 1155 | { |
| 1156 | UINT16 status; |
| 1157 | |
| 1158 | status = SDP_GetLocalDiRecord(p_device_info, p_handle); |
| 1159 | |
| 1160 | if (status == SDP_SUCCESS) |
| 1161 | return BTA_SUCCESS; |
| 1162 | else |
| 1163 | return BTA_FAILURE; |
| 1164 | |
| 1165 | } |
| 1166 | |
| 1167 | /******************************************************************************* |
| 1168 | ** Device Identification (DI) Client Functions |
| 1169 | *******************************************************************************/ |
| 1170 | /******************************************************************************* |
| 1171 | ** |
| 1172 | ** Function BTA_DmDiDiscover |
| 1173 | ** |
| 1174 | ** Description This function queries a remote device for DI information. |
| 1175 | ** |
| 1176 | ** |
| 1177 | ** Returns None. |
| 1178 | ** |
| 1179 | *******************************************************************************/ |
| 1180 | void BTA_DmDiDiscover( BD_ADDR remote_device, tBTA_DISCOVERY_DB *p_db, |
| 1181 | UINT32 len, tBTA_DM_SEARCH_CBACK *p_cback ) |
| 1182 | { |
| 1183 | tBTA_DM_API_DI_DISC *p_msg; |
| 1184 | |
| 1185 | if ((p_msg = (tBTA_DM_API_DI_DISC *) GKI_getbuf(sizeof(tBTA_DM_API_DI_DISC))) != NULL) |
| 1186 | { |
| 1187 | bdcpy(p_msg->bd_addr, remote_device); |
| 1188 | p_msg->hdr.event = BTA_DM_API_DI_DISCOVER_EVT; |
| 1189 | p_msg->p_sdp_db = p_db; |
| 1190 | p_msg->len = len; |
| 1191 | p_msg->p_cback = p_cback; |
| 1192 | |
| 1193 | bta_sys_sendmsg(p_msg); |
| 1194 | } |
| 1195 | } |
| 1196 | |
| 1197 | /******************************************************************************* |
| 1198 | ** |
| 1199 | ** Function BTA_DmGetDiRecord |
| 1200 | ** |
| 1201 | ** Description This function retrieves a remote device's DI record from |
| 1202 | ** the specified database. |
| 1203 | ** |
| 1204 | ** Returns BTA_SUCCESS if Get DI record is succeed. |
| 1205 | ** BTA_FAILURE if Get DI record failed. |
| 1206 | ** |
| 1207 | *******************************************************************************/ |
| 1208 | tBTA_STATUS BTA_DmGetDiRecord( UINT8 get_record_index, tBTA_DI_GET_RECORD *p_device_info, |
| 1209 | tBTA_DISCOVERY_DB *p_db ) |
| 1210 | { |
| 1211 | if (SDP_GetDiRecord(get_record_index, p_device_info, p_db) != SDP_SUCCESS) |
| 1212 | return BTA_FAILURE; |
| 1213 | else |
| 1214 | return BTA_SUCCESS; |
| 1215 | } |
| 1216 | |
| 1217 | /******************************************************************************* |
| 1218 | ** |
| 1219 | ** Function BTA_SysFeatures |
| 1220 | ** |
| 1221 | ** Description This function is called to set system features. |
| 1222 | ** |
| 1223 | ** Returns void |
| 1224 | ** |
| 1225 | *******************************************************************************/ |
| 1226 | void BTA_SysFeatures (UINT16 sys_features) |
| 1227 | { |
| 1228 | bta_sys_cb.sys_features = sys_features; |
| 1229 | |
| 1230 | APPL_TRACE_API1("BTA_SysFeatures: sys_features = %d", sys_features); |
| 1231 | } |
| 1232 | |
| 1233 | /******************************************************************************* |
| 1234 | ** |
| 1235 | ** Function bta_dmexecutecallback |
| 1236 | ** |
| 1237 | ** Description This function will request BTA to execute a call back in the context of BTU task |
| 1238 | ** This API was named in lower case because it is only intended |
| 1239 | ** for the internal customers(like BTIF). |
| 1240 | ** |
| 1241 | ** Returns void |
| 1242 | ** |
| 1243 | *******************************************************************************/ |
| 1244 | void bta_dmexecutecallback (tBTA_DM_EXEC_CBACK* p_callback, void * p_param) |
| 1245 | { |
| 1246 | tBTA_DM_API_EXECUTE_CBACK *p_msg; |
| 1247 | |
| 1248 | if ((p_msg = (tBTA_DM_API_EXECUTE_CBACK *) GKI_getbuf(sizeof(tBTA_DM_MSG))) != NULL) |
| 1249 | { |
| 1250 | p_msg->hdr.event = BTA_DM_API_EXECUTE_CBACK_EVT; |
| 1251 | p_msg->p_param= p_param; |
| 1252 | p_msg->p_exec_cback= p_callback; |
| 1253 | bta_sys_sendmsg(p_msg); |
| 1254 | } |
| 1255 | } |
| 1256 | |
Mike J. Chen | bf9a8aa | 2014-02-11 13:51:29 -0800 | [diff] [blame] | 1257 | #if BLE_INCLUDED == TRUE |
| 1258 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1259 | /******************************************************************************* |
| 1260 | ** |
| 1261 | ** Function BTA_DmAddBleKey |
| 1262 | ** |
| 1263 | ** Description Add/modify LE device information. This function will be |
| 1264 | ** normally called during host startup to restore all required |
| 1265 | ** information stored in the NVRAM. |
| 1266 | ** |
| 1267 | ** Parameters: bd_addr - BD address of the peer |
| 1268 | ** p_le_key - LE key values. |
| 1269 | ** key_type - LE SMP key type. |
| 1270 | ** |
| 1271 | ** Returns void |
| 1272 | ** |
| 1273 | *******************************************************************************/ |
| 1274 | void BTA_DmAddBleKey (BD_ADDR bd_addr, tBTA_LE_KEY_VALUE *p_le_key, tBTA_LE_KEY_TYPE key_type) |
| 1275 | { |
| 1276 | #if BLE_INCLUDED == TRUE |
| 1277 | |
| 1278 | tBTA_DM_API_ADD_BLEKEY *p_msg; |
| 1279 | |
| 1280 | if ((p_msg = (tBTA_DM_API_ADD_BLEKEY *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_BLEKEY))) != NULL) |
| 1281 | { |
| 1282 | memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_BLEKEY)); |
| 1283 | |
| 1284 | p_msg->hdr.event = BTA_DM_API_ADD_BLEKEY_EVT; |
| 1285 | p_msg->key_type = key_type; |
| 1286 | bdcpy(p_msg->bd_addr, bd_addr); |
| 1287 | memcpy(&p_msg->blekey, p_le_key, sizeof(tBTA_LE_KEY_VALUE)); |
| 1288 | |
| 1289 | bta_sys_sendmsg(p_msg); |
| 1290 | } |
| 1291 | |
| 1292 | #endif |
| 1293 | } |
| 1294 | |
| 1295 | /******************************************************************************* |
| 1296 | ** |
| 1297 | ** Function BTA_DmAddBleDevice |
| 1298 | ** |
| 1299 | ** Description Add a BLE device. This function will be normally called |
| 1300 | ** during host startup to restore all required information |
| 1301 | ** for a LE device stored in the NVRAM. |
| 1302 | ** |
| 1303 | ** Parameters: bd_addr - BD address of the peer |
| 1304 | ** dev_type - Remote device's device type. |
| 1305 | ** addr_type - LE device address type. |
| 1306 | ** |
| 1307 | ** Returns void |
| 1308 | ** |
| 1309 | *******************************************************************************/ |
| 1310 | void BTA_DmAddBleDevice(BD_ADDR bd_addr, tBLE_ADDR_TYPE addr_type, tBT_DEVICE_TYPE dev_type) |
| 1311 | { |
| 1312 | #if BLE_INCLUDED == TRUE |
| 1313 | tBTA_DM_API_ADD_BLE_DEVICE *p_msg; |
| 1314 | |
| 1315 | if ((p_msg = (tBTA_DM_API_ADD_BLE_DEVICE *) GKI_getbuf(sizeof(tBTA_DM_API_ADD_BLE_DEVICE))) != NULL) |
| 1316 | { |
| 1317 | memset (p_msg, 0, sizeof(tBTA_DM_API_ADD_BLE_DEVICE)); |
| 1318 | |
| 1319 | p_msg->hdr.event = BTA_DM_API_ADD_BLEDEVICE_EVT; |
| 1320 | bdcpy(p_msg->bd_addr, bd_addr); |
| 1321 | p_msg->addr_type = addr_type; |
| 1322 | p_msg->dev_type = dev_type; |
| 1323 | |
| 1324 | bta_sys_sendmsg(p_msg); |
| 1325 | } |
| 1326 | #endif |
| 1327 | } |
| 1328 | /******************************************************************************* |
| 1329 | ** |
| 1330 | ** Function BTA_DmBlePasskeyReply |
| 1331 | ** |
| 1332 | ** Description Send BLE SMP passkey reply. |
| 1333 | ** |
| 1334 | ** Parameters: bd_addr - BD address of the peer |
| 1335 | ** accept - passkey entry sucessful or declined. |
| 1336 | ** passkey - passkey value, must be a 6 digit number, |
| 1337 | ** can be lead by 0. |
| 1338 | ** |
| 1339 | ** Returns void |
| 1340 | ** |
| 1341 | *******************************************************************************/ |
| 1342 | void BTA_DmBlePasskeyReply(BD_ADDR bd_addr, BOOLEAN accept, UINT32 passkey) |
| 1343 | { |
| 1344 | #if BLE_INCLUDED == TRUE |
| 1345 | tBTA_DM_API_PASSKEY_REPLY *p_msg; |
| 1346 | |
| 1347 | if ((p_msg = (tBTA_DM_API_PASSKEY_REPLY *) GKI_getbuf(sizeof(tBTA_DM_API_PASSKEY_REPLY))) != NULL) |
| 1348 | { |
| 1349 | memset(p_msg, 0, sizeof(tBTA_DM_API_PASSKEY_REPLY)); |
| 1350 | |
| 1351 | p_msg->hdr.event = BTA_DM_API_BLE_PASSKEY_REPLY_EVT; |
| 1352 | bdcpy(p_msg->bd_addr, bd_addr); |
| 1353 | p_msg->accept = accept; |
| 1354 | |
| 1355 | if(accept) |
| 1356 | { |
| 1357 | p_msg->passkey = passkey; |
| 1358 | } |
| 1359 | bta_sys_sendmsg(p_msg); |
| 1360 | } |
| 1361 | #endif |
| 1362 | } |
| 1363 | /******************************************************************************* |
| 1364 | ** |
| 1365 | ** Function BTA_DmBleSecurityGrant |
| 1366 | ** |
| 1367 | ** Description Grant security request access. |
| 1368 | ** |
| 1369 | ** Parameters: bd_addr - BD address of the peer |
| 1370 | ** res - security grant status. |
| 1371 | ** |
| 1372 | ** Returns void |
| 1373 | ** |
| 1374 | *******************************************************************************/ |
| 1375 | void BTA_DmBleSecurityGrant(BD_ADDR bd_addr, tBTA_DM_BLE_SEC_GRANT res) |
| 1376 | { |
| 1377 | #if BLE_INCLUDED == TRUE |
| 1378 | tBTA_DM_API_BLE_SEC_GRANT *p_msg; |
| 1379 | |
| 1380 | if ((p_msg = (tBTA_DM_API_BLE_SEC_GRANT *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_SEC_GRANT))) != NULL) |
| 1381 | { |
| 1382 | memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SEC_GRANT)); |
| 1383 | |
| 1384 | p_msg->hdr.event = BTA_DM_API_BLE_SEC_GRANT_EVT; |
| 1385 | bdcpy(p_msg->bd_addr, bd_addr); |
| 1386 | p_msg->res = res; |
| 1387 | |
| 1388 | bta_sys_sendmsg(p_msg); |
| 1389 | } |
| 1390 | #endif |
| 1391 | } |
| 1392 | /******************************************************************************* |
| 1393 | ** |
| 1394 | ** Function BTA_DmSetBlePrefConnParams |
| 1395 | ** |
| 1396 | ** Description This function is called to set the preferred connection |
| 1397 | ** parameters when default connection parameter is not desired. |
| 1398 | ** |
| 1399 | ** Parameters: bd_addr - BD address of the peripheral |
| 1400 | ** scan_interval - scan interval |
| 1401 | ** scan_window - scan window |
| 1402 | ** min_conn_int - minimum preferred connection interval |
| 1403 | ** max_conn_int - maximum preferred connection interval |
| 1404 | ** slave_latency - preferred slave latency |
| 1405 | ** supervision_tout - preferred supervision timeout |
| 1406 | ** |
| 1407 | ** |
| 1408 | ** Returns void |
| 1409 | ** |
| 1410 | *******************************************************************************/ |
| 1411 | void BTA_DmSetBlePrefConnParams(BD_ADDR bd_addr, |
| 1412 | UINT16 min_conn_int, UINT16 max_conn_int, |
| 1413 | UINT16 slave_latency, UINT16 supervision_tout ) |
| 1414 | { |
| 1415 | #if BLE_INCLUDED == TRUE |
| 1416 | tBTA_DM_API_BLE_CONN_PARAMS *p_msg; |
| 1417 | |
| 1418 | if ((p_msg = (tBTA_DM_API_BLE_CONN_PARAMS *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_CONN_PARAMS))) != NULL) |
| 1419 | { |
| 1420 | memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_CONN_PARAMS)); |
| 1421 | |
| 1422 | p_msg->hdr.event = BTA_DM_API_BLE_CONN_PARAM_EVT; |
| 1423 | |
| 1424 | memcpy(p_msg->peer_bda, bd_addr, BD_ADDR_LEN); |
| 1425 | |
| 1426 | p_msg->conn_int_max = max_conn_int; |
| 1427 | p_msg->conn_int_min = min_conn_int; |
| 1428 | p_msg->slave_latency = slave_latency; |
| 1429 | p_msg->supervision_tout = supervision_tout; |
| 1430 | |
| 1431 | bta_sys_sendmsg(p_msg); |
| 1432 | } |
| 1433 | #endif |
| 1434 | } |
| 1435 | |
| 1436 | /******************************************************************************* |
| 1437 | ** |
| 1438 | ** Function BTA_DmSetBleConnScanParams |
| 1439 | ** |
| 1440 | ** Description This function is called to set scan parameters used in |
| 1441 | ** BLE connection request |
| 1442 | ** |
| 1443 | ** Parameters: scan_interval - scan interval |
| 1444 | ** scan_window - scan window |
| 1445 | ** |
| 1446 | ** Returns void |
| 1447 | ** |
| 1448 | *******************************************************************************/ |
| 1449 | void BTA_DmSetBleConnScanParams(UINT16 scan_interval, UINT16 scan_window ) |
| 1450 | { |
| 1451 | #if BLE_INCLUDED == TRUE |
| 1452 | tBTA_DM_API_BLE_SCAN_PARAMS *p_msg; |
| 1453 | |
| 1454 | if ((p_msg = (tBTA_DM_API_BLE_SCAN_PARAMS *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_SCAN_PARAMS))) != NULL) |
| 1455 | { |
| 1456 | memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SCAN_PARAMS)); |
| 1457 | |
| 1458 | p_msg->hdr.event = BTA_DM_API_BLE_SCAN_PARAM_EVT; |
| 1459 | |
| 1460 | p_msg->scan_int = scan_interval; |
| 1461 | p_msg->scan_window = scan_window; |
| 1462 | |
| 1463 | bta_sys_sendmsg(p_msg); |
| 1464 | } |
| 1465 | #endif |
| 1466 | } |
| 1467 | |
| 1468 | /******************************************************************************* |
| 1469 | ** |
Andre Eisenbach | 5c44e45 | 2013-08-06 18:19:37 -0700 | [diff] [blame] | 1470 | ** Function BTA_DmSetBleAdvParams |
| 1471 | ** |
| 1472 | ** Description This function sets the advertising parameters BLE functionality. |
| 1473 | ** It is to be called when device act in peripheral or broadcaster |
| 1474 | ** role. |
| 1475 | ** |
| 1476 | ** |
| 1477 | ** Returns void |
| 1478 | ** |
| 1479 | *******************************************************************************/ |
| 1480 | void BTA_DmSetBleAdvParams (UINT16 adv_int_min, UINT16 adv_int_max, |
| 1481 | tBLE_BD_ADDR *p_dir_bda) |
| 1482 | { |
| 1483 | #if BLE_INCLUDED == TRUE |
| 1484 | tBTA_DM_API_BLE_ADV_PARAMS *p_msg; |
| 1485 | |
| 1486 | APPL_TRACE_API2 ("BTA_DmSetBleAdvParam: %d, %d", adv_int_min, adv_int_max); |
| 1487 | |
| 1488 | if ((p_msg = (tBTA_DM_API_BLE_ADV_PARAMS *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_ADV_PARAMS))) != NULL) |
| 1489 | { |
| 1490 | memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_ADV_PARAMS)); |
| 1491 | |
| 1492 | p_msg->hdr.event = BTA_DM_API_BLE_ADV_PARAM_EVT; |
| 1493 | |
| 1494 | p_msg->adv_int_min = adv_int_min; |
| 1495 | p_msg->adv_int_max = adv_int_max; |
| 1496 | |
| 1497 | if (p_dir_bda != NULL) |
| 1498 | { |
| 1499 | p_msg->p_dir_bda = (tBLE_BD_ADDR *)(p_msg + 1); |
| 1500 | memcpy(p_msg->p_dir_bda, p_dir_bda, sizeof(tBLE_BD_ADDR)); |
| 1501 | } |
| 1502 | |
| 1503 | bta_sys_sendmsg(p_msg); |
| 1504 | } |
| 1505 | #endif |
| 1506 | } |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame^] | 1507 | /******************************************************************************* |
| 1508 | ** BLE ADV data management API |
| 1509 | ********************************************************************************/ |
Andre Eisenbach | 5c44e45 | 2013-08-06 18:19:37 -0700 | [diff] [blame] | 1510 | |
| 1511 | #if BLE_INCLUDED == TRUE |
| 1512 | /******************************************************************************* |
| 1513 | ** |
| 1514 | ** Function BTA_DmBleSetAdvConfig |
| 1515 | ** |
| 1516 | ** Description This function is called to override the BTA default ADV parameters. |
| 1517 | ** |
| 1518 | ** Parameters Pointer to User defined ADV data structure |
| 1519 | ** |
| 1520 | ** Returns None |
| 1521 | ** |
| 1522 | *******************************************************************************/ |
| 1523 | void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg) |
| 1524 | { |
| 1525 | tBTA_DM_API_SET_ADV_CONFIG *p_msg; |
| 1526 | |
| 1527 | if ((p_msg = (tBTA_DM_API_SET_ADV_CONFIG *) GKI_getbuf(sizeof(tBTA_DM_API_SET_ADV_CONFIG))) != NULL) |
| 1528 | { |
| 1529 | p_msg->hdr.event = BTA_DM_API_BLE_SET_ADV_CONFIG_EVT; |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame^] | 1530 | p_msg->data_mask = data_mask; |
Andre Eisenbach | 5c44e45 | 2013-08-06 18:19:37 -0700 | [diff] [blame] | 1531 | p_msg->p_adv_cfg = p_adv_cfg; |
| 1532 | |
| 1533 | bta_sys_sendmsg(p_msg); |
| 1534 | } |
| 1535 | } |
Andre Eisenbach | eeeac99 | 2013-11-08 10:23:52 -0800 | [diff] [blame] | 1536 | |
| 1537 | /******************************************************************************* |
| 1538 | ** |
| 1539 | ** Function BTA_DmBleSetScanRsp |
| 1540 | ** |
| 1541 | ** Description This function is called to override the BTA scan response. |
| 1542 | ** |
| 1543 | ** Parameters Pointer to User defined ADV data structure |
| 1544 | ** |
| 1545 | ** Returns None |
| 1546 | ** |
| 1547 | *******************************************************************************/ |
| 1548 | BTA_API extern void BTA_DmBleSetScanRsp (tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_adv_cfg) |
| 1549 | { |
| 1550 | tBTA_DM_API_SET_ADV_CONFIG *p_msg; |
| 1551 | |
| 1552 | if ((p_msg = (tBTA_DM_API_SET_ADV_CONFIG *) GKI_getbuf(sizeof(tBTA_DM_API_SET_ADV_CONFIG))) != NULL) |
| 1553 | { |
| 1554 | p_msg->hdr.event = BTA_DM_API_BLE_SET_SCAN_RSP_EVT; |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame^] | 1555 | p_msg->data_mask = data_mask; |
Andre Eisenbach | eeeac99 | 2013-11-08 10:23:52 -0800 | [diff] [blame] | 1556 | p_msg->p_adv_cfg = p_adv_cfg; |
| 1557 | |
| 1558 | bta_sys_sendmsg(p_msg); |
| 1559 | } |
| 1560 | } |
| 1561 | |
| 1562 | /******************************************************************************* |
| 1563 | ** |
| 1564 | ** Function BTA_DmBleBroadcast |
| 1565 | ** |
| 1566 | ** Description This function starts or stops LE broadcasting. |
| 1567 | ** |
| 1568 | ** Parameters start: start or stop broadcast. |
| 1569 | ** |
| 1570 | ** Returns None |
| 1571 | ** |
| 1572 | *******************************************************************************/ |
| 1573 | BTA_API extern void BTA_DmBleBroadcast (BOOLEAN start) |
| 1574 | { |
| 1575 | tBTA_DM_API_BLE_OBSERVE *p_msg; |
| 1576 | |
| 1577 | APPL_TRACE_API1("BTA_DmBleBroadcast: start = %d ", start); |
| 1578 | |
| 1579 | if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL) |
| 1580 | { |
| 1581 | memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_OBSERVE)); |
| 1582 | |
| 1583 | p_msg->hdr.event = BTA_DM_API_BLE_BROADCAST_EVT; |
| 1584 | p_msg->start = start; |
| 1585 | |
| 1586 | bta_sys_sendmsg(p_msg); |
| 1587 | } |
| 1588 | } |
| 1589 | |
Andre Eisenbach | 5c44e45 | 2013-08-06 18:19:37 -0700 | [diff] [blame] | 1590 | #endif |
| 1591 | /******************************************************************************* |
| 1592 | ** |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1593 | ** Function BTA_DmBleSetBgConnType |
| 1594 | ** |
| 1595 | ** Description This function is called to set BLE connectable mode for a |
| 1596 | ** peripheral device. |
| 1597 | ** |
| 1598 | ** Parameters bg_conn_type: it can be auto connection, or selective connection. |
| 1599 | ** p_select_cback: callback function when selective connection procedure |
| 1600 | ** is being used. |
| 1601 | ** |
| 1602 | ** Returns void |
| 1603 | ** |
| 1604 | *******************************************************************************/ |
| 1605 | void BTA_DmBleSetBgConnType(tBTA_DM_BLE_CONN_TYPE bg_conn_type, tBTA_DM_BLE_SEL_CBACK *p_select_cback) |
| 1606 | { |
| 1607 | #if BLE_INCLUDED == TRUE |
| 1608 | tBTA_DM_API_BLE_SET_BG_CONN_TYPE *p_msg; |
| 1609 | |
| 1610 | if ((p_msg = (tBTA_DM_API_BLE_SET_BG_CONN_TYPE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_SET_BG_CONN_TYPE))) != NULL) |
| 1611 | { |
| 1612 | memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_SET_BG_CONN_TYPE)); |
| 1613 | |
| 1614 | p_msg->hdr.event = BTA_DM_API_BLE_SET_BG_CONN_TYPE; |
| 1615 | p_msg->bg_conn_type = bg_conn_type; |
| 1616 | p_msg->p_select_cback = p_select_cback; |
| 1617 | |
| 1618 | bta_sys_sendmsg(p_msg); |
| 1619 | } |
| 1620 | #endif |
| 1621 | } |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame^] | 1622 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1623 | /******************************************************************************* |
| 1624 | ** |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame^] | 1625 | ** Function bta_dm_discover_send_msg |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1626 | ** |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame^] | 1627 | ** Description This function send discover message to BTA task. |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1628 | ** |
| 1629 | ** Returns void |
| 1630 | ** |
| 1631 | *******************************************************************************/ |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame^] | 1632 | static void bta_dm_discover_send_msg(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services, |
| 1633 | tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search, |
| 1634 | tBTA_TRANSPORT transport) |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1635 | { |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1636 | tBTA_DM_API_DISCOVER *p_msg; |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame^] | 1637 | UINT16 len = p_services ? (sizeof(tBTA_DM_API_DISCOVER) + |
| 1638 | sizeof(tBT_UUID) * p_services->num_uuid) : |
| 1639 | sizeof(tBTA_DM_API_DISCOVER); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1640 | |
| 1641 | if ((p_msg = (tBTA_DM_API_DISCOVER *) GKI_getbuf(len)) != NULL) |
| 1642 | { |
| 1643 | memset(p_msg, 0, len); |
| 1644 | |
| 1645 | p_msg->hdr.event = BTA_DM_API_DISCOVER_EVT; |
| 1646 | bdcpy(p_msg->bd_addr, bd_addr); |
| 1647 | p_msg->p_cback = p_cback; |
| 1648 | p_msg->sdp_search = sdp_search; |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame^] | 1649 | p_msg->transport = transport; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1650 | |
| 1651 | if (p_services != NULL) |
| 1652 | { |
| 1653 | p_msg->services = p_services->srvc_mask; |
| 1654 | p_msg->num_uuid = p_services->num_uuid; |
| 1655 | |
| 1656 | if (p_services->num_uuid != 0) |
| 1657 | { |
| 1658 | p_msg->p_uuid = (tBT_UUID *)(p_msg + 1); |
| 1659 | memcpy(p_msg->p_uuid, p_services->p_uuid, sizeof(tBT_UUID) * p_services->num_uuid); |
| 1660 | } |
| 1661 | } |
| 1662 | |
| 1663 | bta_sys_sendmsg(p_msg); |
| 1664 | } |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame^] | 1665 | } |
| 1666 | |
| 1667 | /******************************************************************************* |
| 1668 | ** |
| 1669 | ** Function BTA_DmDiscoverByTransport |
| 1670 | ** |
| 1671 | ** Description This function does service discovery on particular transport |
| 1672 | ** for services of a |
| 1673 | ** peer device. When services.num_uuid is 0, it indicates all |
| 1674 | ** GATT based services are to be searched; otherwise a list of |
| 1675 | ** UUID of interested services should be provided through |
| 1676 | ** p_services->p_uuid. |
| 1677 | ** |
| 1678 | ** Parameters bd_addr: Bluetooth address of remote device |
| 1679 | ** p_services :bit mask of the list of services to be discovered |
| 1680 | ** p_cback : Callback on which result will be received |
| 1681 | ** sdp_search: if TRUE SDP search will be initiated, else services present in |
| 1682 | ** EIR structure of remote device will be returned. |
| 1683 | ** transport : Physical transport BR/EDR or LE |
| 1684 | ** Returns void |
| 1685 | ** |
| 1686 | *******************************************************************************/ |
| 1687 | |
| 1688 | void BTA_DmDiscoverByTransport(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services, |
| 1689 | tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search, |
| 1690 | tBTA_TRANSPORT transport) |
| 1691 | { |
| 1692 | bta_dm_discover_send_msg(bd_addr, p_services, p_cback, sdp_search, transport); |
| 1693 | } |
| 1694 | |
| 1695 | |
| 1696 | /******************************************************************************* |
| 1697 | ** |
| 1698 | ** Function BTA_DmDiscoverExt |
| 1699 | ** |
| 1700 | ** Description This function does service discovery for services of a |
| 1701 | ** peer device. When services.num_uuid is 0, it indicates all |
| 1702 | ** GATT based services are to be searched; other wise a list of |
| 1703 | ** UUID of interested services should be provided through |
| 1704 | ** p_services->p_uuid. |
| 1705 | ** |
| 1706 | ** Parameters bd_addr: Bluetooth address of remote device |
| 1707 | ** p_services :bit mask of the list of services to be discovered |
| 1708 | ** p_cback : Callback on which result will be received |
| 1709 | ** sdp_search: if TRUE SDP search will be initiated, else services present in |
| 1710 | ** EIR structure of remote device will be returned. |
| 1711 | ** |
| 1712 | ** Returns void |
| 1713 | ** |
| 1714 | *******************************************************************************/ |
| 1715 | void BTA_DmDiscoverExt(BD_ADDR bd_addr, tBTA_SERVICE_MASK_EXT *p_services, |
| 1716 | tBTA_DM_SEARCH_CBACK *p_cback, BOOLEAN sdp_search) |
| 1717 | { |
| 1718 | bta_dm_discover_send_msg(bd_addr, p_services, p_cback, sdp_search, BTA_TRANSPORT_UNKNOWN); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1719 | |
| 1720 | } |
| 1721 | |
| 1722 | /******************************************************************************* |
| 1723 | ** |
| 1724 | ** Function BTA_DmSearchExt |
| 1725 | ** |
| 1726 | ** Description This function searches for peer Bluetooth devices. It performs |
| 1727 | ** an inquiry and gets the remote name for devices. Service |
| 1728 | ** discovery is done if services is non zero |
| 1729 | ** |
| 1730 | ** Parameters p_dm_inq: inquiry conditions |
| 1731 | ** p_services: if service is not empty, service discovery will be done. |
| 1732 | ** for all GATT based service condition, put num_uuid, and |
| 1733 | ** p_uuid is the pointer to the list of UUID values. |
| 1734 | ** p_cback: callback functino when search is completed. |
| 1735 | ** |
| 1736 | ** |
| 1737 | ** |
| 1738 | ** Returns void |
| 1739 | ** |
| 1740 | *******************************************************************************/ |
| 1741 | void BTA_DmSearchExt(tBTA_DM_INQ *p_dm_inq, tBTA_SERVICE_MASK_EXT *p_services, tBTA_DM_SEARCH_CBACK *p_cback) |
| 1742 | { |
| 1743 | #if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE |
| 1744 | tBTA_DM_API_SEARCH *p_msg; |
| 1745 | UINT16 len = p_services ? (sizeof(tBTA_DM_API_SEARCH) + sizeof(tBT_UUID) * p_services->num_uuid) : |
| 1746 | sizeof(tBTA_DM_API_SEARCH); |
| 1747 | |
| 1748 | if ((p_msg = (tBTA_DM_API_SEARCH *) GKI_getbuf(len)) != NULL) |
| 1749 | { |
| 1750 | memset(p_msg, 0, len); |
| 1751 | |
| 1752 | p_msg->hdr.event = BTA_DM_API_SEARCH_EVT; |
| 1753 | memcpy(&p_msg->inq_params, p_dm_inq, sizeof(tBTA_DM_INQ)); |
| 1754 | p_msg->p_cback = p_cback; |
| 1755 | p_msg->rs_res = BTA_DM_RS_NONE; |
| 1756 | |
| 1757 | |
| 1758 | if (p_services != NULL) |
| 1759 | { |
| 1760 | p_msg->services = p_services->srvc_mask; |
| 1761 | p_msg->num_uuid = p_services->num_uuid; |
| 1762 | |
| 1763 | if (p_services->num_uuid != 0) |
| 1764 | { |
| 1765 | p_msg->p_uuid = (tBT_UUID *)(p_msg + 1); |
| 1766 | memcpy(p_msg->p_uuid, p_services->p_uuid, sizeof(tBT_UUID) * p_services->num_uuid); |
| 1767 | } |
| 1768 | else |
| 1769 | p_msg->p_uuid = NULL; |
| 1770 | } |
| 1771 | |
| 1772 | bta_sys_sendmsg(p_msg); |
| 1773 | } |
Mike J. Chen | a89616a | 2014-02-11 16:23:31 -0800 | [diff] [blame] | 1774 | #else |
| 1775 | UNUSED(p_dm_inq); |
| 1776 | UNUSED(p_services); |
| 1777 | UNUSED(p_cback); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1778 | #endif |
| 1779 | } |
| 1780 | |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 1781 | /******************************************************************************* |
| 1782 | ** |
| 1783 | ** Function BTA_DmBleEnableRemotePrivacy |
| 1784 | ** |
| 1785 | ** Description Enable/disable privacy on a remote device |
| 1786 | ** |
| 1787 | ** Parameters: bd_addr - BD address of the peer |
| 1788 | ** privacy_enable - enable/disabe privacy on remote device. |
| 1789 | ** |
| 1790 | ** Returns void |
| 1791 | ** |
| 1792 | *******************************************************************************/ |
| 1793 | void BTA_DmBleEnableRemotePrivacy(BD_ADDR bd_addr, BOOLEAN privacy_enable) |
| 1794 | { |
Mike J. Chen | 5cd8bff | 2014-01-31 18:16:59 -0800 | [diff] [blame] | 1795 | UNUSED(bd_addr); |
| 1796 | UNUSED(privacy_enable); |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 1797 | } |
| 1798 | |
| 1799 | |
| 1800 | /******************************************************************************* |
| 1801 | ** |
| 1802 | ** Function BTA_DmBleConfigLocalPrivacy |
| 1803 | ** |
| 1804 | ** Description Enable/disable privacy on the local device |
| 1805 | ** |
| 1806 | ** Parameters: privacy_enable - enable/disabe privacy on remote device. |
| 1807 | ** |
| 1808 | ** Returns void |
| 1809 | ** |
| 1810 | *******************************************************************************/ |
| 1811 | void BTA_DmBleConfigLocalPrivacy(BOOLEAN privacy_enable) |
| 1812 | { |
Mike J. Chen | 5cd8bff | 2014-01-31 18:16:59 -0800 | [diff] [blame] | 1813 | UNUSED(privacy_enable); |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 1814 | } |
Mike J. Chen | bf9a8aa | 2014-02-11 13:51:29 -0800 | [diff] [blame] | 1815 | #endif |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1816 | |
| 1817 | /******************************************************************************* |
| 1818 | ** |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame^] | 1819 | ** Function BTA_DmBleUpdateConnectionParams |
| 1820 | ** |
| 1821 | ** Description Update connection parameters, can only be used when connection is up. |
| 1822 | ** |
| 1823 | ** Parameters: bd_addr - BD address of the peer |
| 1824 | ** min_int - minimum connection interval, [0x0004~ 0x4000] |
| 1825 | ** max_int - maximum connection interval, [0x0004~ 0x4000] |
| 1826 | ** latency - slave latency [0 ~ 500] |
| 1827 | ** timeout - supervision timeout [0x000a ~ 0xc80] |
| 1828 | ** |
| 1829 | ** Returns void |
| 1830 | ** |
| 1831 | *******************************************************************************/ |
| 1832 | void BTA_DmBleUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int, UINT16 max_int, |
| 1833 | UINT16 latency, UINT16 timeout) |
| 1834 | { |
| 1835 | #if BLE_INCLUDED == TRUE |
| 1836 | tBTA_DM_API_UPDATE_CONN_PARAM *p_msg; |
| 1837 | |
| 1838 | if ((p_msg = (tBTA_DM_API_UPDATE_CONN_PARAM *) GKI_getbuf(sizeof(tBTA_DM_API_UPDATE_CONN_PARAM))) != NULL) |
| 1839 | { |
| 1840 | memset (p_msg, 0, sizeof(tBTA_DM_API_UPDATE_CONN_PARAM)); |
| 1841 | |
| 1842 | p_msg->hdr.event = BTA_DM_API_UPDATE_CONN_PARAM_EVT; |
| 1843 | bdcpy(p_msg->bd_addr, bd_addr); |
| 1844 | p_msg->min_int = min_int; |
| 1845 | p_msg->max_int = max_int; |
| 1846 | p_msg->latency = latency; |
| 1847 | p_msg->timeout = timeout; |
| 1848 | |
| 1849 | bta_sys_sendmsg(p_msg); |
| 1850 | } |
| 1851 | #endif |
| 1852 | } |
| 1853 | |
| 1854 | /******************************************************************************* |
| 1855 | ** |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1856 | ** Function BTA_DmSetEncryption |
| 1857 | ** |
| 1858 | ** Description This function is called to ensure that connection is |
| 1859 | ** encrypted. Should be called only on an open connection. |
| 1860 | ** Typically only needed for connections that first want to |
| 1861 | ** bring up unencrypted links, then later encrypt them. |
| 1862 | ** |
| 1863 | ** Parameters: bd_addr - Address of the peer device |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame^] | 1864 | ** transport - transport of the link to be encruypted |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1865 | ** p_callback - Pointer to callback function to indicat the |
| 1866 | ** link encryption status |
| 1867 | ** sec_act - This is the security action to indicate |
| 1868 | ** what knid of BLE security level is required for |
| 1869 | ** the BLE link if the BLE is supported |
| 1870 | ** Note: This parameter is ignored for the BR/EDR link |
| 1871 | ** or the BLE is not supported |
| 1872 | ** |
| 1873 | ** Returns void |
| 1874 | ** |
| 1875 | *******************************************************************************/ |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame^] | 1876 | void BTA_DmSetEncryption(BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_DM_ENCRYPT_CBACK *p_callback, |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1877 | tBTA_DM_BLE_SEC_ACT sec_act) |
| 1878 | { |
| 1879 | tBTA_DM_API_SET_ENCRYPTION *p_msg; |
| 1880 | |
| 1881 | APPL_TRACE_API0("BTA_DmSetEncryption"); //todo |
| 1882 | if ((p_msg = (tBTA_DM_API_SET_ENCRYPTION *) GKI_getbuf(sizeof(tBTA_DM_API_SET_ENCRYPTION))) != NULL) |
| 1883 | { |
| 1884 | memset(p_msg, 0, sizeof(tBTA_DM_API_SET_ENCRYPTION)); |
| 1885 | |
| 1886 | p_msg->hdr.event = BTA_DM_API_SET_ENCRYPTION_EVT; |
| 1887 | |
| 1888 | memcpy(p_msg->bd_addr, bd_addr, BD_ADDR_LEN); |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame^] | 1889 | p_msg->transport = transport; |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1890 | p_msg->p_callback = p_callback; |
| 1891 | p_msg->sec_act = sec_act; |
| 1892 | |
| 1893 | bta_sys_sendmsg(p_msg); |
| 1894 | } |
| 1895 | } |
| 1896 | |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 1897 | /******************************************************************************* |
| 1898 | ** |
| 1899 | ** Function BTA_DmCloseACL |
| 1900 | ** |
| 1901 | ** Description This function force to close an ACL connection and remove the |
| 1902 | ** device from the security database list of known devices. |
| 1903 | ** |
| 1904 | ** Parameters: bd_addr - Address of the peer device |
| 1905 | ** remove_dev - remove device or not after link down |
| 1906 | ** |
| 1907 | ** Returns void |
| 1908 | ** |
| 1909 | *******************************************************************************/ |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame^] | 1910 | void BTA_DmCloseACL(BD_ADDR bd_addr, BOOLEAN remove_dev, tBTA_TRANSPORT transport) |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 1911 | { |
| 1912 | tBTA_DM_API_REMOVE_ACL *p_msg; |
| 1913 | |
| 1914 | APPL_TRACE_API0("BTA_DmCloseACL"); |
| 1915 | |
| 1916 | if ((p_msg = (tBTA_DM_API_REMOVE_ACL *) GKI_getbuf(sizeof(tBTA_DM_API_REMOVE_ACL))) != NULL) |
| 1917 | { |
| 1918 | memset(p_msg, 0, sizeof(tBTA_DM_API_REMOVE_ACL)); |
| 1919 | |
| 1920 | p_msg->hdr.event = BTA_DM_API_REMOVE_ACL_EVT; |
| 1921 | |
| 1922 | memcpy(p_msg->bd_addr, bd_addr, BD_ADDR_LEN); |
| 1923 | p_msg->remove_dev = remove_dev; |
Ganesh Ganapathi Batta | 7fa4fba | 2014-04-16 16:50:09 -0700 | [diff] [blame^] | 1924 | p_msg->transport = transport; |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 1925 | |
| 1926 | bta_sys_sendmsg(p_msg); |
| 1927 | } |
| 1928 | } |
| 1929 | |
Mike J. Chen | bf9a8aa | 2014-02-11 13:51:29 -0800 | [diff] [blame] | 1930 | #if BLE_INCLUDED == TRUE |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 1931 | /******************************************************************************* |
| 1932 | ** |
| 1933 | ** Function BTA_DmBleObserve |
| 1934 | ** |
| 1935 | ** Description This procedure keep the device listening for advertising |
| 1936 | ** events from a broadcast device. |
| 1937 | ** |
| 1938 | ** Parameters start: start or stop observe. |
| 1939 | ** |
| 1940 | ** Returns void |
| 1941 | |
| 1942 | ** |
| 1943 | ** Returns void. |
| 1944 | ** |
| 1945 | *******************************************************************************/ |
| 1946 | BTA_API extern void BTA_DmBleObserve(BOOLEAN start, UINT8 duration, |
| 1947 | tBTA_DM_SEARCH_CBACK *p_results_cb) |
| 1948 | { |
| 1949 | #if BLE_INCLUDED == TRUE |
| 1950 | |
| 1951 | tBTA_DM_API_BLE_OBSERVE *p_msg; |
| 1952 | |
| 1953 | APPL_TRACE_API1("BTA_DmBleObserve:start = %d ", start); |
| 1954 | |
| 1955 | if ((p_msg = (tBTA_DM_API_BLE_OBSERVE *) GKI_getbuf(sizeof(tBTA_DM_API_BLE_OBSERVE))) != NULL) |
| 1956 | { |
| 1957 | memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_OBSERVE)); |
| 1958 | |
| 1959 | p_msg->hdr.event = BTA_DM_API_BLE_OBSERVE_EVT; |
| 1960 | p_msg->start = start; |
| 1961 | p_msg->duration = duration; |
| 1962 | p_msg->p_cback = p_results_cb; |
| 1963 | |
| 1964 | bta_sys_sendmsg(p_msg); |
| 1965 | } |
| 1966 | #endif |
| 1967 | } |
Mike J. Chen | bf9a8aa | 2014-02-11 13:51:29 -0800 | [diff] [blame] | 1968 | #endif |