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 * 225 * Function BTM_EnableTestMode 226 * 227 * Description Send HCI the enable device under test command. 228 * 229 * Note: Controller can only be taken out of this mode by 230 * resetting the controller. 231 * 232 * Returns 233 * BTM_SUCCESS Command sent. 234 * BTM_NO_RESOURCES If out of resources to send the command. 235 * 236 * 237 ******************************************************************************/ 238 tBTM_STATUS BTM_EnableTestMode(void); 239 240 /******************************************************************************* 241 * DEVICE DISCOVERY FUNCTIONS - Inquiry, Remote Name, Discovery, Class of Device 242 ******************************************************************************/ 243 244 /******************************************************************************* 245 * 246 * Function BTM_SetDiscoverability 247 * 248 * Description This function is called to set the device into or out of 249 * discoverable mode. Discoverable mode means inquiry 250 * scans are enabled. If a value of '0' is entered for window 251 * or interval, the default values are used. 252 * 253 * Returns BTM_SUCCESS if successful 254 * BTM_BUSY if a setting of the filter is already in progress 255 * BTM_NO_RESOURCES if couldn't get a memory pool buffer 256 * BTM_ILLEGAL_VALUE if a bad parameter was detected 257 * BTM_WRONG_MODE if the device is not up. 258 * 259 ******************************************************************************/ 260 tBTM_STATUS BTM_SetDiscoverability(uint16_t inq_mode); 261 262 /******************************************************************************* 263 * 264 * Function BTM_StartInquiry 265 * 266 * Description This function is called to start an inquiry. 267 * 268 * Parameters: p_inqparms - pointer to the inquiry information 269 * mode - GENERAL or LIMITED inquiry 270 * duration - length in 1.28 sec intervals (If '0', the 271 * inquiry is CANCELLED) 272 * filter_cond_type - BTM_CLR_INQUIRY_FILTER, 273 * BTM_FILTER_COND_DEVICE_CLASS, or 274 * BTM_FILTER_COND_BD_ADDR 275 * filter_cond - value for the filter (based on 276 * filter_cond_type) 277 * 278 * p_results_cb - Pointer to the callback routine which gets 279 * called upon receipt of an inquiry result. If 280 * this field is NULL, the application is not 281 * notified. 282 * 283 * p_cmpl_cb - Pointer to the callback routine which gets 284 * called upon completion. If this field is 285 * NULL, the application is not notified when 286 * completed. 287 * Returns tBTM_STATUS 288 * BTM_CMD_STARTED if successfully initiated 289 * BTM_BUSY if already in progress 290 * BTM_ILLEGAL_VALUE if parameter(s) are out of range 291 * BTM_NO_RESOURCES if could not allocate resources to start 292 * the command 293 * BTM_WRONG_MODE if the device is not up. 294 * 295 ******************************************************************************/ 296 tBTM_STATUS BTM_StartInquiry(tBTM_INQ_RESULTS_CB* p_results_cb, 297 tBTM_CMPL_CB* p_cmpl_cb); 298 299 /******************************************************************************* 300 * 301 * Function BTM_IsInquiryActive 302 * 303 * Description Return a bit mask of the current inquiry state 304 * 305 * Returns BTM_INQUIRY_INACTIVE if inactive (0) 306 * BTM_GENERAL_INQUIRY_ACTIVE if a general inquiry is active 307 * 308 ******************************************************************************/ 309 uint16_t BTM_IsInquiryActive(void); 310 311 /******************************************************************************* 312 * 313 * Function BTM_CancelInquiry 314 * 315 * Description This function cancels an inquiry if active 316 * 317 ******************************************************************************/ 318 void BTM_CancelInquiry(void); 319 320 /******************************************************************************* 321 * 322 * Function BTM_SetConnectability 323 * 324 * Description This function is called to set the device into or out of 325 * connectable mode. Discoverable mode means page scans are 326 * enabled. 327 * 328 * Returns BTM_SUCCESS if successful 329 * BTM_ILLEGAL_VALUE if a bad parameter is detected 330 * BTM_NO_RESOURCES if could not allocate a message buffer 331 * BTM_WRONG_MODE if the device is not up. 332 * 333 ******************************************************************************/ 334 tBTM_STATUS BTM_SetConnectability(uint16_t page_mode); 335 336 /******************************************************************************* 337 * 338 * Function BTM_SetInquiryMode 339 * 340 * Description This function is called to set standard, with RSSI 341 * mode or extended of the inquiry for local device. 342 * 343 * Input Params: BTM_INQ_RESULT_STANDARD, BTM_INQ_RESULT_WITH_RSSI or 344 * BTM_INQ_RESULT_EXTENDED 345 * 346 * Returns BTM_SUCCESS if successful 347 * BTM_NO_RESOURCES if couldn't get a memory pool buffer 348 * BTM_ILLEGAL_VALUE if a bad parameter was detected 349 * BTM_WRONG_MODE if the device is not up. 350 * 351 ******************************************************************************/ 352 tBTM_STATUS BTM_SetInquiryMode(uint8_t mode); 353 354 void BTM_EnableInterlacedInquiryScan(); 355 356 void BTM_EnableInterlacedPageScan(); 357 358 /******************************************************************************* 359 * 360 * Function BTM_ReadRemoteDeviceName 361 * 362 * Description This function initiates a remote device HCI command to the 363 * controller and calls the callback when the process has 364 * completed. 365 * 366 * Input Params: remote_bda - device address of name to retrieve 367 * p_cb - callback function called when 368 * BTM_CMD_STARTED is returned. 369 * A pointer to tBTM_REMOTE_DEV_NAME is 370 * passed to the callback. 371 * 372 * Returns 373 * BTM_CMD_STARTED is returned if the request was successfully 374 * sent to HCI. 375 * BTM_BUSY if already in progress 376 * BTM_UNKNOWN_ADDR if device address is bad 377 * BTM_NO_RESOURCES if resources could not be allocated to 378 * start the command 379 * BTM_WRONG_MODE if the device is not up. 380 * 381 ******************************************************************************/ 382 tBTM_STATUS BTM_ReadRemoteDeviceName(const RawAddress& remote_bda, 383 tBTM_CMPL_CB* p_cb, 384 tBT_TRANSPORT transport); 385 386 /******************************************************************************* 387 * 388 * Function BTM_CancelRemoteDeviceName 389 * 390 * Description This function initiates the cancel request for the specified 391 * remote device. 392 * 393 * Input Params: None 394 * 395 * Returns 396 * BTM_CMD_STARTED is returned if the request was successfully 397 * sent to HCI. 398 * BTM_NO_RESOURCES if resources could not be allocated to 399 * start the command 400 * BTM_WRONG_MODE if there is no active remote name request. 401 * 402 ******************************************************************************/ 403 tBTM_STATUS BTM_CancelRemoteDeviceName(void); 404 405 /******************************************************************************* 406 * 407 * Function BTM_IsRemoteNameKnown 408 * 409 * Description This function checks if the remote name is known. 410 * 411 * Input Params: bd_addr: Address of remote 412 * transport: Transport, auto if unknown 413 * 414 * Returns 415 * true if name is known, false otherwise 416 * 417 ******************************************************************************/ 418 bool BTM_IsRemoteNameKnown(const RawAddress& remote_bda, 419 tBT_TRANSPORT transport); 420 421 /******************************************************************************* 422 * 423 * Function BTM_ReadRemoteVersion 424 * 425 * Description This function is called to read a remote device's version 426 * 427 * Returns true if data valid, false otherwise 428 * 429 ******************************************************************************/ 430 bool BTM_ReadRemoteVersion(const RawAddress& addr, uint8_t* lmp_version, 431 uint16_t* manufacturer, uint16_t* lmp_sub_version); 432 433 /******************************************************************************* 434 * 435 * Function BTM_ReadRemoteFeatures 436 * 437 * Description This function is called to read a remote device's 438 * supported features mask (features mask located at page 0) 439 * 440 * Returns pointer to the remote supported features mask 441 * The size of device features mask page is 442 * HCI_FEATURE_BYTES_PER_PAGE bytes. 443 * 444 ******************************************************************************/ 445 uint8_t* BTM_ReadRemoteFeatures(const RawAddress& addr); 446 447 /******************************************************************************* 448 * 449 * Function BTM_InqDbRead 450 * 451 * Description This function looks through the inquiry database for a match 452 * based on Bluetooth Device Address. This is the application's 453 * interface to get the inquiry details of a specific BD 454 * address. 455 * 456 * Returns pointer to entry, or NULL if not found 457 * 458 ******************************************************************************/ 459 tBTM_INQ_INFO* BTM_InqDbRead(const RawAddress& p_bda); 460 461 /******************************************************************************* 462 * 463 * Function BTM_InqDbFirst 464 * 465 * Description This function looks through the inquiry database for the 466 * first used entry, and returns that. This is used in 467 * conjunction with BTM_InqDbNext by applications as a way to 468 * walk through the inquiry database. 469 * 470 * Returns pointer to first in-use entry, or NULL if DB is empty 471 * 472 ******************************************************************************/ 473 tBTM_INQ_INFO* BTM_InqDbFirst(void); 474 475 /******************************************************************************* 476 * 477 * Function BTM_InqDbNext 478 * 479 * Description This function looks through the inquiry database for the 480 * next used entry, and returns that. If the input parameter 481 * is NULL, the first entry is returned. 482 * 483 * Returns pointer to next in-use entry, or NULL if no more found. 484 * 485 ******************************************************************************/ 486 tBTM_INQ_INFO* BTM_InqDbNext(tBTM_INQ_INFO* p_cur); 487 488 /******************************************************************************* 489 * 490 * Function BTM_ClearInqDb 491 * 492 * Description This function is called to clear out a device or all devices 493 * from the inquiry database. 494 * 495 * Parameter p_bda - (input) BD_ADDR -> Address of device to clear 496 * (NULL clears all entries) 497 * 498 * Returns BTM_BUSY if an inquiry, get remote name, or event filter 499 * is active, otherwise BTM_SUCCESS 500 * 501 ******************************************************************************/ 502 tBTM_STATUS BTM_ClearInqDb(const RawAddress* p_bda); 503 504 /***************************************************************************** 505 * (e)SCO CHANNEL MANAGEMENT FUNCTIONS 506 ****************************************************************************/ 507 /******************************************************************************* 508 * 509 * Function BTM_CreateSco 510 * 511 * Description This function is called to create an SCO connection. If the 512 * "is_orig" flag is true, the connection will be originated, 513 * otherwise BTM will wait for the other side to connect. 514 * 515 * Returns BTM_UNKNOWN_ADDR if the ACL connection is not up 516 * BTM_BUSY if another SCO being set up to 517 * the same BD address 518 * BTM_NO_RESOURCES if the max SCO limit has been reached 519 * BTM_CMD_STARTED if the connection establishment is started. 520 * In this case, "*p_sco_inx" is filled in 521 * with the sco index used for the connection. 522 * 523 ******************************************************************************/ 524 tBTM_STATUS BTM_CreateSco(const RawAddress* remote_bda, bool is_orig, 525 uint16_t pkt_types, uint16_t* p_sco_inx, 526 tBTM_SCO_CB* p_conn_cb, tBTM_SCO_CB* p_disc_cb); 527 528 /******************************************************************************* 529 * 530 * Function BTM_RemoveSco 531 * 532 * Description This function is called to remove a specific SCO connection. 533 * 534 * Returns BTM_CMD_STARTED if successfully initiated, otherwise error 535 * 536 ******************************************************************************/ 537 tBTM_STATUS BTM_RemoveSco(uint16_t sco_inx); 538 void BTM_RemoveSco(const RawAddress& bda); 539 540 /******************************************************************************* 541 * 542 * Function BTM_ReadScoBdAddr 543 * 544 * Description This function is read the remote BD Address for a specific 545 * SCO connection, 546 * 547 * Returns pointer to BD address or NULL if not known 548 * 549 ******************************************************************************/ 550 const RawAddress* BTM_ReadScoBdAddr(uint16_t sco_inx); 551 552 /******************************************************************************* 553 * 554 * Function BTM_SetEScoMode 555 * 556 * Description This function sets up the negotiated parameters for SCO or 557 * eSCO, and sets as the default mode used for calls to 558 * BTM_CreateSco. It can be called only when there are no 559 * active (e)SCO links. 560 * 561 * Returns BTM_SUCCESS if the successful. 562 * BTM_BUSY if there are one or more active (e)SCO links. 563 * 564 ******************************************************************************/ 565 tBTM_STATUS BTM_SetEScoMode(enh_esco_params_t* p_parms); 566 567 /******************************************************************************* 568 * 569 * Function BTM_RegForEScoEvts 570 * 571 * Description This function registers a SCO event callback with the 572 * specified instance. It should be used to received 573 * connection indication events and change of link parameter 574 * events. 575 * 576 * Returns BTM_SUCCESS if the successful. 577 * BTM_ILLEGAL_VALUE if there is an illegal sco_inx 578 * 579 ******************************************************************************/ 580 tBTM_STATUS BTM_RegForEScoEvts(uint16_t sco_inx, tBTM_ESCO_CBACK* p_esco_cback); 581 582 /******************************************************************************* 583 * 584 * Function BTM_EScoConnRsp 585 * 586 * Description This function is called upon receipt of an (e)SCO connection 587 * request event (BTM_ESCO_CONN_REQ_EVT) to accept or reject 588 * the request. Parameters used to negotiate eSCO links. 589 * If p_parms is NULL, then values set through BTM_SetEScoMode 590 * are used. 591 * If the link type of the incoming request is SCO, then only 592 * the tx_bw, max_latency, content format, and packet_types are 593 * valid. The hci_status parameter should be 594 * ([0x0] to accept, [0x0d..0x0f] to reject) 595 * 596 * 597 * Returns void 598 * 599 ******************************************************************************/ 600 void BTM_EScoConnRsp(uint16_t sco_inx, uint8_t hci_status, 601 enh_esco_params_t* p_parms); 602 603 /******************************************************************************* 604 * 605 * Function BTM_GetNumScoLinks 606 * 607 * Description This function returns the number of active SCO links. 608 * 609 * Returns uint8_t 610 * 611 ******************************************************************************/ 612 uint8_t BTM_GetNumScoLinks(void); 613 614 /***************************************************************************** 615 * SECURITY MANAGEMENT FUNCTIONS 616 ****************************************************************************/ 617 618 /******************************************************************************* 619 * 620 * Function BTM_SecAddDevice 621 * 622 * Description Add/modify device. This function will be normally called 623 * during host startup to restore all required information 624 * stored in the NVRAM. 625 * dev_class, bd_name, link_key, and features are NULL if 626 * unknown 627 * 628 * Returns true if added OK, else false 629 * 630 ******************************************************************************/ 631 bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, 632 const BD_NAME& bd_name, uint8_t* features, 633 LinkKey* link_key, uint8_t key_type, uint8_t pin_length); 634 635 /** Free resources associated with the device associated with |bd_addr| address. 636 * 637 * *** WARNING *** 638 * tBTM_SEC_DEV_REC associated with bd_addr becomes invalid after this function 639 * is called, also any of it's fields. i.e. if you use p_dev_rec->bd_addr, it is 640 * no longer valid! 641 * *** WARNING *** 642 * 643 * Returns true if removed OK, false if not found or ACL link is active. 644 */ 645 bool BTM_SecDeleteDevice(const RawAddress& bd_addr); 646 647 /******************************************************************************* 648 * 649 * Function BTM_SecClearSecurityFlags 650 * 651 * Description Reset the security flags (mark as not-paired) for a given 652 * remove device. 653 * 654 ******************************************************************************/ 655 void BTM_SecClearSecurityFlags(const RawAddress& bd_addr); 656 657 /******************************************************************************* 658 * 659 * Function btm_sec_is_a_bonded_dev 660 * 661 * Description Is the specified device is a bonded device 662 * 663 * Returns true - dev is bonded 664 * 665 ******************************************************************************/ 666 extern bool btm_sec_is_a_bonded_dev(const RawAddress& bda); 667 668 /******************************************************************************* 669 * 670 * Function BTM_GetPeerDeviceTypeFromFeatures 671 * 672 * Description This function is called to retrieve the peer device type 673 * by referencing the remote features. 674 * 675 * Parameters: bd_addr - address of the peer 676 * 677 * Returns BT_DEVICE_TYPE_DUMO if both BR/EDR and BLE transports are 678 * supported by the peer, 679 * BT_DEVICE_TYPE_BREDR if only BR/EDR transport is supported, 680 * BT_DEVICE_TYPE_BLE if only BLE transport is supported. 681 * 682 ******************************************************************************/ 683 extern tBT_DEVICE_TYPE BTM_GetPeerDeviceTypeFromFeatures( 684 const RawAddress& bd_addr); 685 686 /***************************************************************************** 687 * POWER MANAGEMENT FUNCTIONS 688 ****************************************************************************/ 689 /******************************************************************************* 690 * 691 * Function BTM_PmRegister 692 * 693 * Description register or deregister with power manager 694 * 695 * Returns BTM_SUCCESS if successful, 696 * BTM_NO_RESOURCES if no room to hold registration 697 * BTM_ILLEGAL_VALUE 698 * 699 ******************************************************************************/ 700 tBTM_STATUS BTM_PmRegister(uint8_t mask, uint8_t* p_pm_id, 701 tBTM_PM_STATUS_CBACK* p_cb); 702 703 // Notified by ACL that a new link is connected 704 void BTM_PM_OnConnected(uint16_t handle, const RawAddress& remote_bda); 705 706 // Notified by ACL that a link is disconnected 707 void BTM_PM_OnDisconnected(uint16_t handle); 708 709 /******************************************************************************* 710 * 711 * Function BTM_SetPowerMode 712 * 713 * Description store the mode in control block or 714 * alter ACL connection behavior. 715 * 716 * Returns BTM_SUCCESS if successful, 717 * BTM_UNKNOWN_ADDR if bd addr is not active or bad 718 * 719 ******************************************************************************/ 720 tBTM_STATUS BTM_SetPowerMode(uint8_t pm_id, const RawAddress& remote_bda, 721 const tBTM_PM_PWR_MD* p_mode); 722 bool BTM_SetLinkPolicyActiveMode(const RawAddress& remote_bda); 723 724 /******************************************************************************* 725 * 726 * Function BTM_SetSsrParams 727 * 728 * Description This sends the given SSR parameters for the given ACL 729 * connection if it is in ACTIVE mode. 730 * 731 * Input Param remote_bda - device address of desired ACL connection 732 * max_lat - maximum latency (in 0.625ms)(0-0xFFFE) 733 * min_rmt_to - minimum remote timeout 734 * min_loc_to - minimum local timeout 735 * 736 * 737 * Returns BTM_SUCCESS if the HCI command is issued successful, 738 * BTM_UNKNOWN_ADDR if bd addr is not active or bad 739 * BTM_CMD_STORED if the command is stored 740 * 741 ******************************************************************************/ 742 tBTM_STATUS BTM_SetSsrParams(const RawAddress& remote_bda, uint16_t max_lat, 743 uint16_t min_rmt_to, uint16_t min_loc_to); 744 745 /******************************************************************************* 746 * 747 * Function BTM_GetHCIConnHandle 748 * 749 * Description This function is called to get the handle for an ACL 750 * connection to a specific remote BD Address. 751 * 752 * Returns the handle of the connection, or 0xFFFF if none. 753 * 754 ******************************************************************************/ 755 uint16_t BTM_GetHCIConnHandle(const RawAddress& remote_bda, 756 tBT_TRANSPORT transport); 757 758 /******************************************************************************* 759 * 760 * Function BTM_IsPhy2mSupported 761 * 762 * Description This function is called to check PHY 2M support 763 * from peer device 764 * Returns True when PHY 2M supported false otherwise 765 * 766 ******************************************************************************/ 767 bool BTM_IsPhy2mSupported(const RawAddress& remote_bda, tBT_TRANSPORT transport); 768 769 /******************************************************************************* 770 * 771 * Function BTM_RequestPeerSCA 772 * 773 * Description This function is called to request sleep clock accuracy 774 * from peer device 775 * 776 ******************************************************************************/ 777 extern void BTM_RequestPeerSCA(const RawAddress& remote_bda, 778 tBT_TRANSPORT transport); 779 780 /******************************************************************************* 781 * 782 * Function BTM_GetPeerSCA 783 * 784 * Description This function is called to get peer sleep clock accuracy 785 * 786 * Returns SCA or 0xFF if SCA was never previously requested, request 787 * is not supported by peer device or ACL does not exist 788 * 789 ******************************************************************************/ 790 extern uint8_t BTM_GetPeerSCA(const RawAddress& remote_bda, 791 tBT_TRANSPORT transport); 792 793 /******************************************************************************* 794 * 795 * Function BTM_DeleteStoredLinkKey 796 * 797 * Description This function is called to delete link key for the specified 798 * device addresses from the NVRAM storage attached to the 799 * Bluetooth controller. 800 * 801 * Parameters: bd_addr - Addresses of the devices 802 * p_cb - Call back function to be called to return 803 * the results 804 * 805 ******************************************************************************/ 806 tBTM_STATUS BTM_DeleteStoredLinkKey(const RawAddress* bd_addr, 807 tBTM_CMPL_CB* p_cb); 808 809 /******************************************************************************* 810 * 811 * Function BTM_WriteEIR 812 * 813 * Description This function is called to write EIR data to controller. 814 * 815 * Parameters p_buff - allocated HCI command buffer including extended 816 * inquriry response 817 * 818 * Returns BTM_SUCCESS - if successful 819 * BTM_MODE_UNSUPPORTED - if local device cannot support it 820 * 821 ******************************************************************************/ 822 tBTM_STATUS BTM_WriteEIR(BT_HDR* p_buff); 823 824 /******************************************************************************* 825 * 826 * Function BTM_HasEirService 827 * 828 * Description This function is called to know if UUID in bit map of UUID. 829 * 830 * Parameters p_eir_uuid - bit map of UUID list 831 * uuid16 - UUID 16-bit 832 * 833 * Returns true - if found 834 * false - if not found 835 * 836 ******************************************************************************/ 837 bool BTM_HasEirService(const uint32_t* p_eir_uuid, uint16_t uuid16); 838 839 /******************************************************************************* 840 * 841 * Function BTM_HasInquiryEirService 842 * 843 * Description Return if a UUID is in the bit map of a UUID list. 844 * 845 * Parameters p_results - inquiry results 846 * uuid16 - UUID 16-bit 847 * 848 * Returns BTM_EIR_FOUND - if found 849 * BTM_EIR_NOT_FOUND - if not found and it is a complete list 850 * BTM_EIR_UNKNOWN - if not found and it is not complete list 851 * 852 ******************************************************************************/ 853 tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService(tBTM_INQ_RESULTS* p_results, 854 uint16_t uuid16); 855 856 /******************************************************************************* 857 * 858 * Function BTM_AddEirService 859 * 860 * Description This function is called to add a service in the bit map UUID 861 * list. 862 * 863 * Parameters p_eir_uuid - bit mask of UUID list for EIR 864 * uuid16 - UUID 16-bit 865 * 866 * Returns None 867 * 868 ******************************************************************************/ 869 void BTM_AddEirService(uint32_t* p_eir_uuid, uint16_t uuid16); 870 871 /******************************************************************************* 872 * 873 * Function BTM_RemoveEirService 874 * 875 * Description This function is called to remove a service from the bit map 876 * UUID list. 877 * 878 * Parameters p_eir_uuid - bit mask of UUID list for EIR 879 * uuid16 - UUID 16-bit 880 * 881 * Returns None 882 * 883 ******************************************************************************/ 884 void BTM_RemoveEirService(uint32_t* p_eir_uuid, uint16_t uuid16); 885 886 /******************************************************************************* 887 * 888 * Function BTM_GetEirSupportedServices 889 * 890 * Description This function is called to get UUID list from bit map UUID 891 * list. 892 * 893 * Parameters p_eir_uuid - bit mask of UUID list for EIR 894 * p - reference of current pointer of EIR 895 * max_num_uuid16 - max number of UUID can be written in EIR 896 * num_uuid16 - number of UUID have been written in EIR 897 * 898 * Returns HCI_EIR_MORE_16BITS_UUID_TYPE, if it has more than max 899 * HCI_EIR_COMPLETE_16BITS_UUID_TYPE, otherwise 900 * 901 ******************************************************************************/ 902 uint8_t BTM_GetEirSupportedServices(uint32_t* p_eir_uuid, uint8_t** p, 903 uint8_t max_num_uuid16, 904 uint8_t* p_num_uuid16); 905 906 /******************************************************************************* 907 * 908 * Function BTM_GetEirUuidList 909 * 910 * Description This function parses EIR and returns UUID list. 911 * 912 * Parameters p_eir - EIR 913 * eirl_len - EIR len 914 * uuid_size - Uuid::kNumBytes16, Uuid::kNumBytes32, 915 * Uuid::kNumBytes128 916 * p_num_uuid - return number of UUID in found list 917 * p_uuid_list - return UUID 16-bit list 918 * max_num_uuid - maximum number of UUID to be returned 919 * 920 * Returns 0 - if not found 921 * HCI_EIR_COMPLETE_16BITS_UUID_TYPE 922 * HCI_EIR_MORE_16BITS_UUID_TYPE 923 * HCI_EIR_COMPLETE_32BITS_UUID_TYPE 924 * HCI_EIR_MORE_32BITS_UUID_TYPE 925 * HCI_EIR_COMPLETE_128BITS_UUID_TYPE 926 * HCI_EIR_MORE_128BITS_UUID_TYPE 927 * 928 ******************************************************************************/ 929 uint8_t BTM_GetEirUuidList(const uint8_t* p_eir, size_t eir_len, 930 uint8_t uuid_size, uint8_t* p_num_uuid, 931 uint8_t* p_uuid_list, uint8_t max_num_uuid); 932 933 /******************************************************************************* 934 * 935 * Function BTM_PM_ReadControllerState 936 * 937 * Description This function is called to obtain the controller state 938 * 939 * Returns Controller state (BTM_CONTRL_ACTIVE, BTM_CONTRL_SCAN, and 940 * BTM_CONTRL_IDLE) 941 * 942 ******************************************************************************/ 943 tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void); 944 945 /** 946 * Send remote name request, either to legacy HCI, or to GD shim Name module 947 */ 948 void SendRemoteNameRequest(const RawAddress& raw_address); 949 950 bool BTM_IsScoActiveByBdaddr(const RawAddress& remote_bda); 951 952 uint16_t BTM_GetClockOffset(const RawAddress& remote_bda); 953 954 /* Read maximum data packet that can be sent over current connection */ 955 uint16_t BTM_GetMaxPacketSize(const RawAddress& addr); 956 957 extern tBTM_STATUS BTM_BT_Quality_Report_VSE_Register( 958 bool is_register, tBTM_BT_QUALITY_REPORT_RECEIVER* p_bqr_report_receiver); 959 960 uint8_t btm_ble_read_sec_key_size(const RawAddress& bd_addr); 961 962 #endif /* BTM_API_H */ 963