1 /* 2 * Copyright 1999-2012 Broadcom Corporation 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at: 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 * 16 ******************************************************************************/ 17 18 /****************************************************************************** 19 * 20 * This file contains the Bluetooth Manager (BTM) API function external 21 * definitions. 22 * 23 ******************************************************************************/ 24 #ifndef BTM_API_H 25 #define BTM_API_H 26 27 #include <cstdint> 28 29 #include "device/include/esco_parameters.h" 30 #include "stack/btm/neighbor_inquiry.h" 31 #include "stack/include/bt_hdr.h" 32 #include "stack/include/bt_octets.h" 33 #include "stack/include/btm_api_types.h" 34 #include "stack/include/btm_log_history.h" 35 #include "stack/include/btm_status.h" 36 #include "stack/include/sco_client_callbacks.h" 37 #include "stack/include/sdp_api.h" 38 #include "types/bluetooth/uuid.h" 39 #include "types/bt_transport.h" 40 #include "types/raw_address.h" 41 42 void btm_init(); 43 void btm_free(); 44 45 /***************************************************************************** 46 * DEVICE CONTROL and COMMON 47 ****************************************************************************/ 48 49 /***************************************************************************** 50 * EXTERNAL FUNCTION DECLARATIONS 51 ****************************************************************************/ 52 53 /***************************************************************************** 54 * DEVICE CONTROL and COMMON FUNCTIONS 55 ****************************************************************************/ 56 57 void BTM_reset_complete(); 58 59 /******************************************************************************* 60 * 61 * Function BTM_IsDeviceUp 62 * 63 * Description This function is called to check if the device is up. 64 * 65 * Returns true if device is up, else false 66 * 67 ******************************************************************************/ 68 bool BTM_IsDeviceUp(void); 69 70 /******************************************************************************* 71 * 72 * Function BTM_SetLocalDeviceName 73 * 74 * Description This function is called to set the local device name. 75 * 76 * Returns BTM_CMD_STARTED if successful, otherwise an error 77 * 78 ******************************************************************************/ 79 tBTM_STATUS BTM_SetLocalDeviceName(const char* p_name); 80 81 /******************************************************************************* 82 * 83 * Function BTM_SetDeviceClass 84 * 85 * Description This function is called to set the local device class 86 * 87 * Returns BTM_SUCCESS if successful, otherwise an error 88 * 89 ******************************************************************************/ 90 tBTM_STATUS BTM_SetDeviceClass(DEV_CLASS dev_class); 91 92 /******************************************************************************* 93 * 94 * Function BTM_ReadLocalDeviceName 95 * 96 * Description This function is called to read the local device name. 97 * 98 * Returns status of the operation 99 * If success, BTM_SUCCESS is returned and p_name points stored 100 * local device name 101 * If BTM doesn't store local device name, BTM_NO_RESOURCES is 102 * is returned and p_name is set to NULL 103 * 104 ******************************************************************************/ 105 tBTM_STATUS BTM_ReadLocalDeviceName(const char** p_name); 106 107 /******************************************************************************* 108 * 109 * Function BTM_ReadLocalDeviceNameFromController 110 * 111 * Description Get local device name from controller. Do not use cached 112 * name (used to get chip-id prior to btm reset complete). 113 * 114 * Returns BTM_CMD_STARTED if successful, otherwise an error 115 * 116 ******************************************************************************/ 117 tBTM_STATUS BTM_ReadLocalDeviceNameFromController( 118 tBTM_CMPL_CB* p_rln_cmpl_cback); 119 120 /******************************************************************************* 121 * 122 * Function BTM_ReadDeviceClass 123 * 124 * Description This function is called to read the local device class 125 * 126 * Returns pointer to the device class 127 * 128 ******************************************************************************/ 129 uint8_t* BTM_ReadDeviceClass(void); 130 131 /******************************************************************************* 132 * 133 * Function BTM_RegisterForVSEvents 134 * 135 * Description This function is called to register/deregister for vendor 136 * specific HCI events. 137 * 138 * If is_register=true, then the function will be registered; 139 * otherwise the function will be deregistered. 140 * 141 * Returns BTM_SUCCESS if successful, 142 * BTM_BUSY if maximum number of callbacks have already been 143 * registered. 144 * 145 ******************************************************************************/ 146 tBTM_STATUS BTM_RegisterForVSEvents(tBTM_VS_EVT_CB* p_cb, bool is_register); 147 148 /******************************************************************************* 149 * 150 * Function BTM_VendorSpecificCommand 151 * 152 * Description Send a vendor specific HCI command to the controller. 153 * 154 ******************************************************************************/ 155 void BTM_VendorSpecificCommand(uint16_t opcode, uint8_t param_len, 156 uint8_t* p_param_buf, tBTM_VSC_CMPL_CB* p_cb); 157 158 /******************************************************************************* 159 * 160 * Function BTM_AllocateSCN 161 * 162 * Description Look through the Server Channel Numbers for a free one to be 163 * used with an RFCOMM connection. 164 * 165 * Returns Allocated SCN number or 0 if none. 166 * 167 ******************************************************************************/ 168 uint8_t BTM_AllocateSCN(void); 169 170 /******************************************************************************* 171 * 172 * Function BTM_TryAllocateSCN 173 * 174 * Description Try to allocate a fixed server channel 175 * 176 * Returns Returns true if server channel was available 177 * 178 ******************************************************************************/ 179 bool BTM_TryAllocateSCN(uint8_t scn); 180 181 /******************************************************************************* 182 * 183 * Function BTM_FreeSCN 184 * 185 * Description Free the specified SCN. 186 * 187 * Returns true if successful, false if SCN is not in use or invalid 188 * 189 ******************************************************************************/ 190 bool BTM_FreeSCN(uint8_t scn); 191 192 /******************************************************************************* 193 * 194 * Function BTM_SetTraceLevel 195 * 196 * Description This function sets the trace level for BTM. If called with 197 * a value of 0xFF, it simply returns the current trace level. 198 * 199 * Returns The new or current trace level 200 * 201 ******************************************************************************/ 202 uint8_t BTM_SetTraceLevel(uint8_t new_level); 203 204 /******************************************************************************* 205 * 206 * Function BTM_WritePageTimeout 207 * 208 * Description Send HCI Wite Page Timeout. 209 * 210 ******************************************************************************/ 211 void BTM_WritePageTimeout(uint16_t timeout); 212 213 /******************************************************************************* 214 * 215 * Function BTM_WriteVoiceSettings 216 * 217 * Description Send HCI Write Voice Settings command. 218 * See hcidefs.h for settings bitmask values. 219 * 220 ******************************************************************************/ 221 void BTM_WriteVoiceSettings(uint16_t settings); 222 223 /******************************************************************************* 224 * DEVICE DISCOVERY FUNCTIONS - Inquiry, Remote Name, Discovery, Class of Device 225 ******************************************************************************/ 226 227 /******************************************************************************* 228 * 229 * Function BTM_SetDiscoverability 230 * 231 * Description This function is called to set the device into or out of 232 * discoverable mode. Discoverable mode means inquiry 233 * scans are enabled. If a value of '0' is entered for window 234 * or interval, the default values are used. 235 * 236 * Returns BTM_SUCCESS if successful 237 * BTM_BUSY if a setting of the filter is already in progress 238 * BTM_NO_RESOURCES if couldn't get a memory pool buffer 239 * BTM_ILLEGAL_VALUE if a bad parameter was detected 240 * BTM_WRONG_MODE if the device is not up. 241 * 242 ******************************************************************************/ 243 tBTM_STATUS BTM_SetDiscoverability(uint16_t inq_mode); 244 245 /******************************************************************************* 246 * 247 * Function BTM_StartInquiry 248 * 249 * Description This function is called to start an inquiry. 250 * 251 * Parameters: p_inqparms - pointer to the inquiry information 252 * mode - GENERAL or LIMITED inquiry 253 * duration - length in 1.28 sec intervals (If '0', the 254 * inquiry is CANCELLED) 255 * filter_cond_type - BTM_CLR_INQUIRY_FILTER, 256 * BTM_FILTER_COND_DEVICE_CLASS, or 257 * BTM_FILTER_COND_BD_ADDR 258 * filter_cond - value for the filter (based on 259 * filter_cond_type) 260 * 261 * p_results_cb - Pointer to the callback routine which gets 262 * called upon receipt of an inquiry result. If 263 * this field is NULL, the application is not 264 * notified. 265 * 266 * p_cmpl_cb - Pointer to the callback routine which gets 267 * called upon completion. If this field is 268 * NULL, the application is not notified when 269 * completed. 270 * Returns tBTM_STATUS 271 * BTM_CMD_STARTED if successfully initiated 272 * BTM_BUSY if already in progress 273 * BTM_ILLEGAL_VALUE if parameter(s) are out of range 274 * BTM_NO_RESOURCES if could not allocate resources to start 275 * the command 276 * BTM_WRONG_MODE if the device is not up. 277 * 278 ******************************************************************************/ 279 tBTM_STATUS BTM_StartInquiry(tBTM_INQ_RESULTS_CB* p_results_cb, 280 tBTM_CMPL_CB* p_cmpl_cb); 281 282 /******************************************************************************* 283 * 284 * Function BTM_IsInquiryActive 285 * 286 * Description Return a bit mask of the current inquiry state 287 * 288 * Returns BTM_INQUIRY_INACTIVE if inactive (0) 289 * BTM_GENERAL_INQUIRY_ACTIVE if a general inquiry is active 290 * 291 ******************************************************************************/ 292 uint16_t BTM_IsInquiryActive(void); 293 294 /******************************************************************************* 295 * 296 * Function BTM_CancelInquiry 297 * 298 * Description This function cancels an inquiry if active 299 * 300 ******************************************************************************/ 301 void BTM_CancelInquiry(void); 302 303 /******************************************************************************* 304 * 305 * Function BTM_SetConnectability 306 * 307 * Description This function is called to set the device into or out of 308 * connectable mode. Discoverable mode means page scans are 309 * enabled. 310 * 311 * Returns BTM_SUCCESS if successful 312 * BTM_ILLEGAL_VALUE if a bad parameter is detected 313 * BTM_NO_RESOURCES if could not allocate a message buffer 314 * BTM_WRONG_MODE if the device is not up. 315 * 316 ******************************************************************************/ 317 tBTM_STATUS BTM_SetConnectability(uint16_t page_mode); 318 319 /******************************************************************************* 320 * 321 * Function BTM_SetInquiryMode 322 * 323 * Description This function is called to set standard, with RSSI 324 * mode or extended of the inquiry for local device. 325 * 326 * Input Params: BTM_INQ_RESULT_STANDARD, BTM_INQ_RESULT_WITH_RSSI or 327 * BTM_INQ_RESULT_EXTENDED 328 * 329 * Returns BTM_SUCCESS if successful 330 * BTM_NO_RESOURCES if couldn't get a memory pool buffer 331 * BTM_ILLEGAL_VALUE if a bad parameter was detected 332 * BTM_WRONG_MODE if the device is not up. 333 * 334 ******************************************************************************/ 335 tBTM_STATUS BTM_SetInquiryMode(uint8_t mode); 336 337 void BTM_EnableInterlacedInquiryScan(); 338 339 void BTM_EnableInterlacedPageScan(); 340 341 /******************************************************************************* 342 * 343 * Function BTM_ReadRemoteDeviceName 344 * 345 * Description This function initiates a remote device HCI command to the 346 * controller and calls the callback when the process has 347 * completed. 348 * 349 * Input Params: remote_bda - device address of name to retrieve 350 * p_cb - callback function called when 351 * BTM_CMD_STARTED is returned. 352 * A pointer to tBTM_REMOTE_DEV_NAME is 353 * passed to the callback. 354 * 355 * Returns 356 * BTM_CMD_STARTED is returned if the request was successfully 357 * sent to HCI. 358 * BTM_BUSY if already in progress 359 * BTM_UNKNOWN_ADDR if device address is bad 360 * BTM_NO_RESOURCES if resources could not be allocated to 361 * start the command 362 * BTM_WRONG_MODE if the device is not up. 363 * 364 ******************************************************************************/ 365 tBTM_STATUS BTM_ReadRemoteDeviceName(const RawAddress& remote_bda, 366 tBTM_NAME_CMPL_CB* p_cb, 367 tBT_TRANSPORT transport); 368 369 /******************************************************************************* 370 * 371 * Function BTM_CancelRemoteDeviceName 372 * 373 * Description This function initiates the cancel request for the specified 374 * remote device. 375 * 376 * Input Params: None 377 * 378 * Returns 379 * BTM_CMD_STARTED is returned if the request was successfully 380 * sent to HCI. 381 * BTM_NO_RESOURCES if resources could not be allocated to 382 * start the command 383 * BTM_WRONG_MODE if there is no active remote name request. 384 * 385 ******************************************************************************/ 386 tBTM_STATUS BTM_CancelRemoteDeviceName(void); 387 388 /******************************************************************************* 389 * 390 * Function BTM_IsRemoteNameKnown 391 * 392 * Description This function checks if the remote name is known. 393 * 394 * Input Params: bd_addr: Address of remote 395 * transport: Transport, auto if unknown 396 * 397 * Returns 398 * true if name is known, false otherwise 399 * 400 ******************************************************************************/ 401 bool BTM_IsRemoteNameKnown(const RawAddress& remote_bda, 402 tBT_TRANSPORT transport); 403 404 /******************************************************************************* 405 * 406 * Function BTM_ReadRemoteVersion 407 * 408 * Description This function is called to read a remote device's version 409 * 410 * Returns true if data valid, false otherwise 411 * 412 ******************************************************************************/ 413 bool BTM_ReadRemoteVersion(const RawAddress& addr, uint8_t* lmp_version, 414 uint16_t* manufacturer, uint16_t* lmp_sub_version); 415 416 /******************************************************************************* 417 * 418 * Function BTM_ReadRemoteFeatures 419 * 420 * Description This function is called to read a remote device's 421 * supported features mask (features mask located at page 0) 422 * 423 * Returns pointer to the remote supported features mask 424 * The size of device features mask page is 425 * HCI_FEATURE_BYTES_PER_PAGE bytes. 426 * 427 ******************************************************************************/ 428 uint8_t* BTM_ReadRemoteFeatures(const RawAddress& addr); 429 430 /******************************************************************************* 431 * 432 * Function BTM_InqDbRead 433 * 434 * Description This function looks through the inquiry database for a match 435 * based on Bluetooth Device Address. This is the application's 436 * interface to get the inquiry details of a specific BD 437 * address. 438 * 439 * Returns pointer to entry, or NULL if not found 440 * 441 ******************************************************************************/ 442 tBTM_INQ_INFO* BTM_InqDbRead(const RawAddress& p_bda); 443 444 /******************************************************************************* 445 * 446 * Function BTM_InqDbFirst 447 * 448 * Description This function looks through the inquiry database for the 449 * first used entry, and returns that. This is used in 450 * conjunction with BTM_InqDbNext by applications as a way to 451 * walk through the inquiry database. 452 * 453 * Returns pointer to first in-use entry, or NULL if DB is empty 454 * 455 ******************************************************************************/ 456 tBTM_INQ_INFO* BTM_InqDbFirst(void); 457 458 /******************************************************************************* 459 * 460 * Function BTM_InqDbNext 461 * 462 * Description This function looks through the inquiry database for the 463 * next used entry, and returns that. If the input parameter 464 * is NULL, the first entry is returned. 465 * 466 * Returns pointer to next in-use entry, or NULL if no more found. 467 * 468 ******************************************************************************/ 469 tBTM_INQ_INFO* BTM_InqDbNext(tBTM_INQ_INFO* p_cur); 470 471 /******************************************************************************* 472 * 473 * Function BTM_ClearInqDb 474 * 475 * Description This function is called to clear out a device or all devices 476 * from the inquiry database. 477 * 478 * Parameter p_bda - (input) BD_ADDR -> Address of device to clear 479 * (NULL clears all entries) 480 * 481 * Returns BTM_BUSY if an inquiry, get remote name, or event filter 482 * is active, otherwise BTM_SUCCESS 483 * 484 ******************************************************************************/ 485 tBTM_STATUS BTM_ClearInqDb(const RawAddress* p_bda); 486 487 /***************************************************************************** 488 * (e)SCO CHANNEL MANAGEMENT FUNCTIONS 489 ****************************************************************************/ 490 /******************************************************************************* 491 * 492 * Function BTM_CreateSco 493 * 494 * Description This function is called to create an SCO connection. If the 495 * "is_orig" flag is true, the connection will be originated, 496 * otherwise BTM will wait for the other side to connect. 497 * 498 * Returns BTM_UNKNOWN_ADDR if the ACL connection is not up 499 * BTM_BUSY if another SCO being set up to 500 * the same BD address 501 * BTM_NO_RESOURCES if the max SCO limit has been reached 502 * BTM_CMD_STARTED if the connection establishment is started. 503 * In this case, "*p_sco_inx" is filled in 504 * with the sco index used for the connection. 505 * 506 ******************************************************************************/ 507 tBTM_STATUS BTM_CreateSco(const RawAddress* remote_bda, bool is_orig, 508 uint16_t pkt_types, uint16_t* p_sco_inx, 509 tBTM_SCO_CB* p_conn_cb, tBTM_SCO_CB* p_disc_cb); 510 511 /******************************************************************************* 512 * 513 * Function BTM_RemoveSco 514 * 515 * Description This function is called to remove a specific SCO connection. 516 * 517 * Returns BTM_CMD_STARTED if successfully initiated, otherwise error 518 * 519 ******************************************************************************/ 520 tBTM_STATUS BTM_RemoveSco(uint16_t sco_inx); 521 void BTM_RemoveSco(const RawAddress& bda); 522 523 /******************************************************************************* 524 * 525 * Function BTM_ReadScoBdAddr 526 * 527 * Description This function is read the remote BD Address for a specific 528 * SCO connection, 529 * 530 * Returns pointer to BD address or NULL if not known 531 * 532 ******************************************************************************/ 533 const RawAddress* BTM_ReadScoBdAddr(uint16_t sco_inx); 534 535 /******************************************************************************* 536 * 537 * Function BTM_SetEScoMode 538 * 539 * Description This function sets up the negotiated parameters for SCO or 540 * eSCO, and sets as the default mode used for calls to 541 * BTM_CreateSco. It can be called only when there are no 542 * active (e)SCO links. 543 * 544 * Returns BTM_SUCCESS if the successful. 545 * BTM_BUSY if there are one or more active (e)SCO links. 546 * 547 ******************************************************************************/ 548 tBTM_STATUS BTM_SetEScoMode(enh_esco_params_t* p_parms); 549 550 /******************************************************************************* 551 * 552 * Function BTM_RegForEScoEvts 553 * 554 * Description This function registers a SCO event callback with the 555 * specified instance. It should be used to received 556 * connection indication events and change of link parameter 557 * events. 558 * 559 * Returns BTM_SUCCESS if the successful. 560 * BTM_ILLEGAL_VALUE if there is an illegal sco_inx 561 * 562 ******************************************************************************/ 563 tBTM_STATUS BTM_RegForEScoEvts(uint16_t sco_inx, tBTM_ESCO_CBACK* p_esco_cback); 564 565 /******************************************************************************* 566 * 567 * Function BTM_EScoConnRsp 568 * 569 * Description This function is called upon receipt of an (e)SCO connection 570 * request event (BTM_ESCO_CONN_REQ_EVT) to accept or reject 571 * the request. Parameters used to negotiate eSCO links. 572 * If p_parms is NULL, then values set through BTM_SetEScoMode 573 * are used. 574 * If the link type of the incoming request is SCO, then only 575 * the tx_bw, max_latency, content format, and packet_types are 576 * valid. The hci_status parameter should be 577 * ([0x0] to accept, [0x0d..0x0f] to reject) 578 * 579 * 580 * Returns void 581 * 582 ******************************************************************************/ 583 void BTM_EScoConnRsp(uint16_t sco_inx, uint8_t hci_status, 584 enh_esco_params_t* p_parms); 585 586 /******************************************************************************* 587 * 588 * Function BTM_GetNumScoLinks 589 * 590 * Description This function returns the number of active SCO links. 591 * 592 * Returns uint8_t 593 * 594 ******************************************************************************/ 595 uint8_t BTM_GetNumScoLinks(void); 596 597 /***************************************************************************** 598 * SECURITY MANAGEMENT FUNCTIONS 599 ****************************************************************************/ 600 601 /******************************************************************************* 602 * 603 * Function BTM_SecAddDevice 604 * 605 * Description Add/modify device. This function will be normally called 606 * during host startup to restore all required information 607 * stored in the NVRAM. 608 * dev_class, bd_name, link_key, and features are NULL if 609 * unknown 610 * 611 * Returns true if added OK, else false 612 * 613 ******************************************************************************/ 614 bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, 615 const BD_NAME& bd_name, uint8_t* features, 616 LinkKey* link_key, uint8_t key_type, uint8_t pin_length); 617 618 /** Free resources associated with the device associated with |bd_addr| address. 619 * 620 * *** WARNING *** 621 * tBTM_SEC_DEV_REC associated with bd_addr becomes invalid after this function 622 * is called, also any of it's fields. i.e. if you use p_dev_rec->bd_addr, it is 623 * no longer valid! 624 * *** WARNING *** 625 * 626 * Returns true if removed OK, false if not found or ACL link is active. 627 */ 628 bool BTM_SecDeleteDevice(const RawAddress& bd_addr); 629 630 /******************************************************************************* 631 * 632 * Function BTM_SecClearSecurityFlags 633 * 634 * Description Reset the security flags (mark as not-paired) for a given 635 * remove device. 636 * 637 ******************************************************************************/ 638 void BTM_SecClearSecurityFlags(const RawAddress& bd_addr); 639 640 /******************************************************************************* 641 * 642 * Function btm_sec_is_a_bonded_dev 643 * 644 * Description Is the specified device is a bonded device 645 * 646 * Returns true - dev is bonded 647 * 648 ******************************************************************************/ 649 bool btm_sec_is_a_bonded_dev(const RawAddress& bda); 650 651 /******************************************************************************* 652 * 653 * Function BTM_GetPeerDeviceTypeFromFeatures 654 * 655 * Description This function is called to retrieve the peer device type 656 * by referencing the remote features. 657 * 658 * Parameters: bd_addr - address of the peer 659 * 660 * Returns BT_DEVICE_TYPE_DUMO if both BR/EDR and BLE transports are 661 * supported by the peer, 662 * BT_DEVICE_TYPE_BREDR if only BR/EDR transport is supported, 663 * BT_DEVICE_TYPE_BLE if only BLE transport is supported. 664 * 665 ******************************************************************************/ 666 tBT_DEVICE_TYPE BTM_GetPeerDeviceTypeFromFeatures(const RawAddress& bd_addr); 667 668 /***************************************************************************** 669 * POWER MANAGEMENT FUNCTIONS 670 ****************************************************************************/ 671 /******************************************************************************* 672 * 673 * Function BTM_PmRegister 674 * 675 * Description register or deregister with power manager 676 * 677 * Returns BTM_SUCCESS if successful, 678 * BTM_NO_RESOURCES if no room to hold registration 679 * BTM_ILLEGAL_VALUE 680 * 681 ******************************************************************************/ 682 tBTM_STATUS BTM_PmRegister(uint8_t mask, uint8_t* p_pm_id, 683 tBTM_PM_STATUS_CBACK* p_cb); 684 685 // Notified by ACL that a new link is connected 686 void BTM_PM_OnConnected(uint16_t handle, const RawAddress& remote_bda); 687 688 // Notified by ACL that a link is disconnected 689 void BTM_PM_OnDisconnected(uint16_t handle); 690 691 /******************************************************************************* 692 * 693 * Function BTM_SetPowerMode 694 * 695 * Description store the mode in control block or 696 * alter ACL connection behavior. 697 * 698 * Returns BTM_SUCCESS if successful, 699 * BTM_UNKNOWN_ADDR if bd addr is not active or bad 700 * 701 ******************************************************************************/ 702 tBTM_STATUS BTM_SetPowerMode(uint8_t pm_id, const RawAddress& remote_bda, 703 const tBTM_PM_PWR_MD* p_mode); 704 bool BTM_SetLinkPolicyActiveMode(const RawAddress& remote_bda); 705 706 /******************************************************************************* 707 * 708 * Function BTM_SetSsrParams 709 * 710 * Description This sends the given SSR parameters for the given ACL 711 * connection if it is in ACTIVE mode. 712 * 713 * Input Param remote_bda - device address of desired ACL connection 714 * max_lat - maximum latency (in 0.625ms)(0-0xFFFE) 715 * min_rmt_to - minimum remote timeout 716 * min_loc_to - minimum local timeout 717 * 718 * 719 * Returns BTM_SUCCESS if the HCI command is issued successful, 720 * BTM_UNKNOWN_ADDR if bd addr is not active or bad 721 * BTM_CMD_STORED if the command is stored 722 * 723 ******************************************************************************/ 724 tBTM_STATUS BTM_SetSsrParams(const RawAddress& remote_bda, uint16_t max_lat, 725 uint16_t min_rmt_to, uint16_t min_loc_to); 726 727 /******************************************************************************* 728 * 729 * Function BTM_GetHCIConnHandle 730 * 731 * Description This function is called to get the handle for an ACL 732 * connection to a specific remote BD Address. 733 * 734 * Returns the handle of the connection, or 0xFFFF if none. 735 * 736 ******************************************************************************/ 737 uint16_t BTM_GetHCIConnHandle(const RawAddress& remote_bda, 738 tBT_TRANSPORT transport); 739 740 /******************************************************************************* 741 * 742 * Function BTM_IsPhy2mSupported 743 * 744 * Description This function is called to check PHY 2M support 745 * from peer device 746 * Returns True when PHY 2M supported false otherwise 747 * 748 ******************************************************************************/ 749 bool BTM_IsPhy2mSupported(const RawAddress& remote_bda, tBT_TRANSPORT transport); 750 751 /******************************************************************************* 752 * 753 * Function BTM_RequestPeerSCA 754 * 755 * Description This function is called to request sleep clock accuracy 756 * from peer device 757 * 758 ******************************************************************************/ 759 void BTM_RequestPeerSCA(const RawAddress& remote_bda, tBT_TRANSPORT transport); 760 761 /******************************************************************************* 762 * 763 * Function BTM_GetPeerSCA 764 * 765 * Description This function is called to get peer sleep clock accuracy 766 * 767 * Returns SCA or 0xFF if SCA was never previously requested, request 768 * is not supported by peer device or ACL does not exist 769 * 770 ******************************************************************************/ 771 uint8_t BTM_GetPeerSCA(const RawAddress& remote_bda, tBT_TRANSPORT transport); 772 773 /******************************************************************************* 774 * 775 * Function BTM_DeleteStoredLinkKey 776 * 777 * Description This function is called to delete link key for the specified 778 * device addresses from the NVRAM storage attached to the 779 * Bluetooth controller. 780 * 781 * Parameters: bd_addr - Addresses of the devices 782 * p_cb - Call back function to be called to return 783 * the results 784 * 785 ******************************************************************************/ 786 tBTM_STATUS BTM_DeleteStoredLinkKey(const RawAddress* bd_addr, 787 tBTM_CMPL_CB* p_cb); 788 789 /******************************************************************************* 790 * 791 * Function BTM_WriteEIR 792 * 793 * Description This function is called to write EIR data to controller. 794 * 795 * Parameters p_buff - allocated HCI command buffer including extended 796 * inquriry response 797 * 798 * Returns BTM_SUCCESS - if successful 799 * BTM_MODE_UNSUPPORTED - if local device cannot support it 800 * 801 ******************************************************************************/ 802 tBTM_STATUS BTM_WriteEIR(BT_HDR* p_buff); 803 804 /******************************************************************************* 805 * 806 * Function BTM_HasEirService 807 * 808 * Description This function is called to know if UUID in bit map of UUID. 809 * 810 * Parameters p_eir_uuid - bit map of UUID list 811 * uuid16 - UUID 16-bit 812 * 813 * Returns true - if found 814 * false - if not found 815 * 816 ******************************************************************************/ 817 bool BTM_HasEirService(const uint32_t* p_eir_uuid, uint16_t uuid16); 818 819 /******************************************************************************* 820 * 821 * Function BTM_HasInquiryEirService 822 * 823 * Description Return if a UUID is in the bit map of a UUID list. 824 * 825 * Parameters p_results - inquiry results 826 * uuid16 - UUID 16-bit 827 * 828 * Returns BTM_EIR_FOUND - if found 829 * BTM_EIR_NOT_FOUND - if not found and it is a complete list 830 * BTM_EIR_UNKNOWN - if not found and it is not complete list 831 * 832 ******************************************************************************/ 833 tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService(tBTM_INQ_RESULTS* p_results, 834 uint16_t uuid16); 835 836 /******************************************************************************* 837 * 838 * Function BTM_AddEirService 839 * 840 * Description This function is called to add a service in the bit map UUID 841 * list. 842 * 843 * Parameters p_eir_uuid - bit mask of UUID list for EIR 844 * uuid16 - UUID 16-bit 845 * 846 * Returns None 847 * 848 ******************************************************************************/ 849 void BTM_AddEirService(uint32_t* p_eir_uuid, uint16_t uuid16); 850 851 /******************************************************************************* 852 * 853 * Function BTM_RemoveEirService 854 * 855 * Description This function is called to remove a service from the bit map 856 * UUID list. 857 * 858 * Parameters p_eir_uuid - bit mask of UUID list for EIR 859 * uuid16 - UUID 16-bit 860 * 861 * Returns None 862 * 863 ******************************************************************************/ 864 void BTM_RemoveEirService(uint32_t* p_eir_uuid, uint16_t uuid16); 865 866 /******************************************************************************* 867 * 868 * Function BTM_GetEirSupportedServices 869 * 870 * Description This function is called to get UUID list from bit map UUID 871 * list. 872 * 873 * Parameters p_eir_uuid - bit mask of UUID list for EIR 874 * p - reference of current pointer of EIR 875 * max_num_uuid16 - max number of UUID can be written in EIR 876 * num_uuid16 - number of UUID have been written in EIR 877 * 878 * Returns HCI_EIR_MORE_16BITS_UUID_TYPE, if it has more than max 879 * HCI_EIR_COMPLETE_16BITS_UUID_TYPE, otherwise 880 * 881 ******************************************************************************/ 882 uint8_t BTM_GetEirSupportedServices(uint32_t* p_eir_uuid, uint8_t** p, 883 uint8_t max_num_uuid16, 884 uint8_t* p_num_uuid16); 885 886 /******************************************************************************* 887 * 888 * Function BTM_GetEirUuidList 889 * 890 * Description This function parses EIR and returns UUID list. 891 * 892 * Parameters p_eir - EIR 893 * eirl_len - EIR len 894 * uuid_size - Uuid::kNumBytes16, Uuid::kNumBytes32, 895 * Uuid::kNumBytes128 896 * p_num_uuid - return number of UUID in found list 897 * p_uuid_list - return UUID 16-bit list 898 * max_num_uuid - maximum number of UUID to be returned 899 * 900 * Returns 0 - if not found 901 * HCI_EIR_COMPLETE_16BITS_UUID_TYPE 902 * HCI_EIR_MORE_16BITS_UUID_TYPE 903 * HCI_EIR_COMPLETE_32BITS_UUID_TYPE 904 * HCI_EIR_MORE_32BITS_UUID_TYPE 905 * HCI_EIR_COMPLETE_128BITS_UUID_TYPE 906 * HCI_EIR_MORE_128BITS_UUID_TYPE 907 * 908 ******************************************************************************/ 909 uint8_t BTM_GetEirUuidList(const uint8_t* p_eir, size_t eir_len, 910 uint8_t uuid_size, uint8_t* p_num_uuid, 911 uint8_t* p_uuid_list, uint8_t max_num_uuid); 912 913 /******************************************************************************* 914 * 915 * Function BTM_PM_ReadControllerState 916 * 917 * Description This function is called to obtain the controller state 918 * 919 * Returns Controller state (BTM_CONTRL_ACTIVE, BTM_CONTRL_SCAN, and 920 * BTM_CONTRL_IDLE) 921 * 922 ******************************************************************************/ 923 tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void); 924 925 /** 926 * Send remote name request, either to legacy HCI, or to GD shim Name module 927 */ 928 void SendRemoteNameRequest(const RawAddress& raw_address); 929 930 bool BTM_IsScoActiveByBdaddr(const RawAddress& remote_bda); 931 932 uint16_t BTM_GetClockOffset(const RawAddress& remote_bda); 933 934 /* Read maximum data packet that can be sent over current connection */ 935 uint16_t BTM_GetMaxPacketSize(const RawAddress& addr); 936 937 tBTM_STATUS BTM_BT_Quality_Report_VSE_Register( 938 bool is_register, tBTM_BT_QUALITY_REPORT_RECEIVER* p_bqr_report_receiver); 939 940 uint8_t btm_ble_read_sec_key_size(const RawAddress& bd_addr); 941 942 typedef void(BTM_CONSOLIDATION_CB)(const RawAddress& identity_addr, 943 const RawAddress& rpa); 944 void BTM_SetConsolidationCallback(BTM_CONSOLIDATION_CB* cb); 945 946 #endif /* BTM_API_H */ 947