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