1 /****************************************************************************** 2 * 3 * Copyright 1999-2012 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 /****************************************************************************** 20 * 21 * This file contains the Bluetooth Manager (BTM) API function external 22 * definitions. 23 * 24 ******************************************************************************/ 25 #ifndef BTM_API_H 26 #define BTM_API_H 27 28 #include "bt_target.h" 29 #include "device/include/esco_parameters.h" 30 #include "hcidefs.h" 31 #include "sdp_api.h" 32 33 #include "smp_api.h" 34 35 #include "btm_api_types.h" 36 37 /***************************************************************************** 38 * DEVICE CONTROL and COMMON 39 ****************************************************************************/ 40 41 /***************************************************************************** 42 * EXTERNAL FUNCTION DECLARATIONS 43 ****************************************************************************/ 44 45 /***************************************************************************** 46 * DEVICE CONTROL and COMMON FUNCTIONS 47 ****************************************************************************/ 48 49 /******************************************************************************* 50 * 51 * Function BTM_DeviceReset 52 * 53 * Description This function is called to reset the controller. The 54 * Callback function if provided is called when startup of the 55 * device has completed. 56 * 57 * Returns void 58 * 59 ******************************************************************************/ 60 extern void BTM_DeviceReset(tBTM_CMPL_CB* p_cb); 61 62 /******************************************************************************* 63 * 64 * Function BTM_IsDeviceUp 65 * 66 * Description This function is called to check if the device is up. 67 * 68 * Returns true if device is up, else false 69 * 70 ******************************************************************************/ 71 extern bool BTM_IsDeviceUp(void); 72 73 /******************************************************************************* 74 * 75 * Function BTM_SetLocalDeviceName 76 * 77 * Description This function is called to set the local device name. 78 * 79 * Returns BTM_CMD_STARTED if successful, otherwise an error 80 * 81 ******************************************************************************/ 82 extern tBTM_STATUS BTM_SetLocalDeviceName(char* p_name); 83 84 /******************************************************************************* 85 * 86 * Function BTM_SetDeviceClass 87 * 88 * Description This function is called to set the local device class 89 * 90 * Returns BTM_SUCCESS if successful, otherwise an error 91 * 92 ******************************************************************************/ 93 extern tBTM_STATUS BTM_SetDeviceClass(DEV_CLASS dev_class); 94 95 /******************************************************************************* 96 * 97 * Function BTM_ReadLocalDeviceName 98 * 99 * Description This function is called to read the local device name. 100 * 101 * Returns status of the operation 102 * If success, BTM_SUCCESS is returned and p_name points stored 103 * local device name 104 * If BTM doesn't store local device name, BTM_NO_RESOURCES is 105 * is returned and p_name is set to NULL 106 * 107 ******************************************************************************/ 108 extern tBTM_STATUS BTM_ReadLocalDeviceName(char** p_name); 109 110 /******************************************************************************* 111 * 112 * Function BTM_ReadLocalDeviceNameFromController 113 * 114 * Description Get local device name from controller. Do not use cached 115 * name (used to get chip-id prior to btm reset complete). 116 * 117 * Returns BTM_CMD_STARTED if successful, otherwise an error 118 * 119 ******************************************************************************/ 120 extern tBTM_STATUS BTM_ReadLocalDeviceNameFromController( 121 tBTM_CMPL_CB* p_rln_cmpl_cback); 122 123 /******************************************************************************* 124 * 125 * Function BTM_ReadDeviceClass 126 * 127 * Description This function is called to read the local device class 128 * 129 * Returns pointer to the device class 130 * 131 ******************************************************************************/ 132 extern uint8_t* BTM_ReadDeviceClass(void); 133 134 /******************************************************************************* 135 * 136 * Function BTM_ReadLocalFeatures 137 * 138 * Description This function is called to read the local features 139 * 140 * Returns pointer to the local features string 141 * 142 ******************************************************************************/ 143 extern uint8_t* BTM_ReadLocalFeatures(void); 144 145 /******************************************************************************* 146 * 147 * Function BTM_RegisterForDeviceStatusNotif 148 * 149 * Description This function is called to register for device status 150 * change notifications. 151 * 152 * Returns pointer to previous caller's callback function or NULL if 153 * first registration. 154 * 155 ******************************************************************************/ 156 extern tBTM_DEV_STATUS_CB* BTM_RegisterForDeviceStatusNotif( 157 tBTM_DEV_STATUS_CB* p_cb); 158 159 /******************************************************************************* 160 * 161 * Function BTM_RegisterForVSEvents 162 * 163 * Description This function is called to register/deregister for vendor 164 * specific HCI events. 165 * 166 * If is_register=true, then the function will be registered; 167 * otherwise the function will be deregistered. 168 * 169 * Returns BTM_SUCCESS if successful, 170 * BTM_BUSY if maximum number of callbacks have already been 171 * registered. 172 * 173 ******************************************************************************/ 174 extern tBTM_STATUS BTM_RegisterForVSEvents(tBTM_VS_EVT_CB* p_cb, 175 bool is_register); 176 177 /******************************************************************************* 178 * 179 * Function BTM_VendorSpecificCommand 180 * 181 * Description Send a vendor specific HCI command to the controller. 182 * 183 ******************************************************************************/ 184 extern void BTM_VendorSpecificCommand(uint16_t opcode, uint8_t param_len, 185 uint8_t* p_param_buf, 186 tBTM_VSC_CMPL_CB* p_cb); 187 188 /******************************************************************************* 189 * 190 * Function BTM_AllocateSCN 191 * 192 * Description Look through the Server Channel Numbers for a free one to be 193 * used with an RFCOMM connection. 194 * 195 * Returns Allocated SCN number or 0 if none. 196 * 197 ******************************************************************************/ 198 extern uint8_t BTM_AllocateSCN(void); 199 200 /******************************************************************************* 201 * 202 * Function BTM_TryAllocateSCN 203 * 204 * Description Try to allocate a fixed server channel 205 * 206 * Returns Returns true if server channel was available 207 * 208 ******************************************************************************/ 209 extern bool BTM_TryAllocateSCN(uint8_t scn); 210 211 /******************************************************************************* 212 * 213 * Function BTM_FreeSCN 214 * 215 * Description Free the specified SCN. 216 * 217 * Returns true if successful, false if SCN is not in use or invalid 218 * 219 ******************************************************************************/ 220 extern bool BTM_FreeSCN(uint8_t scn); 221 222 /******************************************************************************* 223 * 224 * Function BTM_SetTraceLevel 225 * 226 * Description This function sets the trace level for BTM. If called with 227 * a value of 0xFF, it simply returns the current trace level. 228 * 229 * Returns The new or current trace level 230 * 231 ******************************************************************************/ 232 extern uint8_t BTM_SetTraceLevel(uint8_t new_level); 233 234 /******************************************************************************* 235 * 236 * Function BTM_WritePageTimeout 237 * 238 * Description Send HCI Wite Page Timeout. 239 * 240 ******************************************************************************/ 241 extern void BTM_WritePageTimeout(uint16_t timeout); 242 243 /******************************************************************************* 244 * 245 * Function BTM_WriteVoiceSettings 246 * 247 * Description Send HCI Write Voice Settings command. 248 * See hcidefs.h for settings bitmask values. 249 * 250 ******************************************************************************/ 251 extern void BTM_WriteVoiceSettings(uint16_t settings); 252 253 /******************************************************************************* 254 * 255 * Function BTM_EnableTestMode 256 * 257 * Description Send HCI the enable device under test command. 258 * 259 * Note: Controller can only be taken out of this mode by 260 * resetting the controller. 261 * 262 * Returns 263 * BTM_SUCCESS Command sent. 264 * BTM_NO_RESOURCES If out of resources to send the command. 265 * 266 * 267 ******************************************************************************/ 268 extern tBTM_STATUS BTM_EnableTestMode(void); 269 270 /******************************************************************************* 271 * DEVICE DISCOVERY FUNCTIONS - Inquiry, Remote Name, Discovery, Class of Device 272 ******************************************************************************/ 273 274 /******************************************************************************* 275 * 276 * Function BTM_SetDiscoverability 277 * 278 * Description This function is called to set the device into or out of 279 * discoverable mode. Discoverable mode means inquiry 280 * scans are enabled. If a value of '0' is entered for window 281 * or interval, the default values are used. 282 * 283 * Returns BTM_SUCCESS if successful 284 * BTM_BUSY if a setting of the filter is already in progress 285 * BTM_NO_RESOURCES if couldn't get a memory pool buffer 286 * BTM_ILLEGAL_VALUE if a bad parameter was detected 287 * BTM_WRONG_MODE if the device is not up. 288 * 289 ******************************************************************************/ 290 extern tBTM_STATUS BTM_SetDiscoverability(uint16_t inq_mode, uint16_t window, 291 uint16_t interval); 292 293 /******************************************************************************* 294 * 295 * Function BTM_ReadDiscoverability 296 * 297 * Description This function is called to read the current discoverability 298 * mode of the device. 299 * 300 * Output Params: p_window - current inquiry scan duration 301 * p_interval - current inquiry scan interval 302 * 303 * Returns BTM_NON_DISCOVERABLE, BTM_LIMITED_DISCOVERABLE, or 304 * BTM_GENERAL_DISCOVERABLE 305 * 306 ******************************************************************************/ 307 extern uint16_t BTM_ReadDiscoverability(uint16_t* p_window, 308 uint16_t* p_interval); 309 310 /******************************************************************************* 311 * 312 * Function BTM_StartInquiry 313 * 314 * Description This function is called to start an inquiry. 315 * 316 * Parameters: p_inqparms - pointer to the inquiry information 317 * mode - GENERAL or LIMITED inquiry 318 * duration - length in 1.28 sec intervals (If '0', the 319 * inquiry is CANCELLED) 320 * max_resps - maximum amount of devices to search for 321 * before ending the inquiry 322 * filter_cond_type - BTM_CLR_INQUIRY_FILTER, 323 * BTM_FILTER_COND_DEVICE_CLASS, or 324 * BTM_FILTER_COND_BD_ADDR 325 * filter_cond - value for the filter (based on 326 * filter_cond_type) 327 * 328 * p_results_cb - Pointer to the callback routine which gets 329 * called upon receipt of an inquiry result. If 330 * this field is NULL, the application is not 331 * notified. 332 * 333 * p_cmpl_cb - Pointer to the callback routine which gets 334 * called upon completion. If this field is 335 * NULL, the application is not notified when 336 * completed. 337 * Returns tBTM_STATUS 338 * BTM_CMD_STARTED if successfully initiated 339 * BTM_BUSY if already in progress 340 * BTM_ILLEGAL_VALUE if parameter(s) are out of range 341 * BTM_NO_RESOURCES if could not allocate resources to start 342 * the command 343 * BTM_WRONG_MODE if the device is not up. 344 * 345 ******************************************************************************/ 346 extern tBTM_STATUS BTM_StartInquiry(tBTM_INQ_PARMS* p_inqparms, 347 tBTM_INQ_RESULTS_CB* p_results_cb, 348 tBTM_CMPL_CB* p_cmpl_cb); 349 350 /******************************************************************************* 351 * 352 * Function BTM_IsInquiryActive 353 * 354 * Description Return a bit mask of the current inquiry state 355 * 356 * Returns BTM_INQUIRY_INACTIVE if inactive (0) 357 * BTM_LIMITED_INQUIRY_ACTIVE if a limted inquiry is active 358 * BTM_GENERAL_INQUIRY_ACTIVE if a general inquiry is active 359 * BTM_PERIODIC_INQUIRY_ACTIVE if a periodic inquiry is active 360 * 361 ******************************************************************************/ 362 extern uint16_t BTM_IsInquiryActive(void); 363 364 /******************************************************************************* 365 * 366 * Function BTM_CancelInquiry 367 * 368 * Description This function cancels an inquiry if active 369 * 370 * Returns BTM_SUCCESS if successful 371 * BTM_NO_RESOURCES if could not allocate a message buffer 372 * BTM_WRONG_MODE if the device is not up. 373 * 374 ******************************************************************************/ 375 extern tBTM_STATUS BTM_CancelInquiry(void); 376 377 /******************************************************************************* 378 * 379 * Function BTM_CancelPeriodicInquiry 380 * 381 * Description This function cancels a periodic inquiry 382 * 383 * Returns 384 * BTM_NO_RESOURCES if could not allocate a message buffer 385 * BTM_SUCCESS - if cancelling the periodic inquiry 386 * BTM_WRONG_MODE if the device is not up. 387 * 388 ******************************************************************************/ 389 extern tBTM_STATUS BTM_CancelPeriodicInquiry(void); 390 391 /******************************************************************************* 392 * 393 * Function BTM_SetConnectability 394 * 395 * Description This function is called to set the device into or out of 396 * connectable mode. Discoverable mode means page scans are 397 * enabled. 398 * 399 * Returns BTM_SUCCESS if successful 400 * BTM_ILLEGAL_VALUE if a bad parameter is detected 401 * BTM_NO_RESOURCES if could not allocate a message buffer 402 * BTM_WRONG_MODE if the device is not up. 403 * 404 ******************************************************************************/ 405 extern tBTM_STATUS BTM_SetConnectability(uint16_t page_mode, uint16_t window, 406 uint16_t interval); 407 408 /******************************************************************************* 409 * 410 * Function BTM_ReadConnectability 411 * 412 * Description This function is called to read the current discoverability 413 * mode of the device. 414 * Output Params p_window - current page scan duration 415 * p_interval - current time between page scans 416 * 417 * Returns BTM_NON_CONNECTABLE or BTM_CONNECTABLE 418 * 419 ******************************************************************************/ 420 extern uint16_t BTM_ReadConnectability(uint16_t* p_window, 421 uint16_t* p_interval); 422 423 /******************************************************************************* 424 * 425 * Function BTM_SetInquiryMode 426 * 427 * Description This function is called to set standard, with RSSI 428 * mode or extended of the inquiry for local device. 429 * 430 * Input Params: BTM_INQ_RESULT_STANDARD, BTM_INQ_RESULT_WITH_RSSI or 431 * BTM_INQ_RESULT_EXTENDED 432 * 433 * Returns BTM_SUCCESS if successful 434 * BTM_NO_RESOURCES if couldn't get a memory pool buffer 435 * BTM_ILLEGAL_VALUE if a bad parameter was detected 436 * BTM_WRONG_MODE if the device is not up. 437 * 438 ******************************************************************************/ 439 extern tBTM_STATUS BTM_SetInquiryMode(uint8_t mode); 440 441 /******************************************************************************* 442 * 443 * Function BTM_SetInquiryScanType 444 * 445 * Description This function is called to set the iquiry scan-type to 446 * standard or interlaced. 447 * 448 * Input Params: BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED 449 * 450 * Returns BTM_SUCCESS if successful 451 * BTM_MODE_UNSUPPORTED if not a 1.2 device 452 * BTM_WRONG_MODE if the device is not up. 453 * 454 ******************************************************************************/ 455 extern tBTM_STATUS BTM_SetInquiryScanType(uint16_t scan_type); 456 457 /******************************************************************************* 458 * 459 * Function BTM_SetPageScanType 460 * 461 * Description This function is called to set the page scan-type to 462 * standard or interlaced. 463 * 464 * Input Params: BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED 465 * 466 * Returns BTM_SUCCESS if successful 467 * BTM_MODE_UNSUPPORTED if not a 1.2 device 468 * BTM_WRONG_MODE if the device is not up. 469 * 470 ******************************************************************************/ 471 472 extern tBTM_STATUS BTM_SetPageScanType(uint16_t scan_type); 473 474 /******************************************************************************* 475 * 476 * Function BTM_ReadRemoteDeviceName 477 * 478 * Description This function initiates a remote device HCI command to the 479 * controller and calls the callback when the process has 480 * completed. 481 * 482 * Input Params: remote_bda - device address of name to retrieve 483 * p_cb - callback function called when 484 * BTM_CMD_STARTED is returned. 485 * A pointer to tBTM_REMOTE_DEV_NAME is 486 * passed to the callback. 487 * 488 * Returns 489 * BTM_CMD_STARTED is returned if the request was successfully 490 * sent to HCI. 491 * BTM_BUSY if already in progress 492 * BTM_UNKNOWN_ADDR if device address is bad 493 * BTM_NO_RESOURCES if resources could not be allocated to 494 * start the command 495 * BTM_WRONG_MODE if the device is not up. 496 * 497 ******************************************************************************/ 498 extern tBTM_STATUS BTM_ReadRemoteDeviceName(const RawAddress& remote_bda, 499 tBTM_CMPL_CB* p_cb, 500 tBT_TRANSPORT transport); 501 502 /******************************************************************************* 503 * 504 * Function BTM_CancelRemoteDeviceName 505 * 506 * Description This function initiates the cancel request for the specified 507 * remote device. 508 * 509 * Input Params: None 510 * 511 * Returns 512 * BTM_CMD_STARTED is returned if the request was successfully 513 * sent to HCI. 514 * BTM_NO_RESOURCES if resources could not be allocated to 515 * start the command 516 * BTM_WRONG_MODE if there is no active remote name request. 517 * 518 ******************************************************************************/ 519 extern tBTM_STATUS BTM_CancelRemoteDeviceName(void); 520 521 /******************************************************************************* 522 * 523 * Function BTM_ReadRemoteVersion 524 * 525 * Description This function is called to read a remote device's version 526 * 527 * Returns BTM_SUCCESS if successful, otherwise an error 528 * 529 ******************************************************************************/ 530 extern tBTM_STATUS BTM_ReadRemoteVersion(const RawAddress& addr, 531 uint8_t* lmp_version, 532 uint16_t* manufacturer, 533 uint16_t* lmp_sub_version); 534 535 /******************************************************************************* 536 * 537 * Function BTM_ReadRemoteFeatures 538 * 539 * Description This function is called to read a remote device's 540 * supported features mask (features mask located at page 0) 541 * 542 * Note: The size of device features mask page is 543 * BTM_FEATURE_BYTES_PER_PAGE bytes. 544 * 545 * Returns pointer to the remote supported features mask 546 * 547 ******************************************************************************/ 548 extern uint8_t* BTM_ReadRemoteFeatures(const RawAddress& addr); 549 550 /******************************************************************************* 551 * 552 * Function BTM_InqDbRead 553 * 554 * Description This function looks through the inquiry database for a match 555 * based on Bluetooth Device Address. This is the application's 556 * interface to get the inquiry details of a specific BD 557 * address. 558 * 559 * Returns pointer to entry, or NULL if not found 560 * 561 ******************************************************************************/ 562 extern tBTM_INQ_INFO* BTM_InqDbRead(const RawAddress& p_bda); 563 564 /******************************************************************************* 565 * 566 * Function BTM_InqDbFirst 567 * 568 * Description This function looks through the inquiry database for the 569 * first used entry, and returns that. This is used in 570 * conjunction with BTM_InqDbNext by applications as a way to 571 * walk through the inquiry database. 572 * 573 * Returns pointer to first in-use entry, or NULL if DB is empty 574 * 575 ******************************************************************************/ 576 extern tBTM_INQ_INFO* BTM_InqDbFirst(void); 577 578 /******************************************************************************* 579 * 580 * Function BTM_InqDbNext 581 * 582 * Description This function looks through the inquiry database for the 583 * next used entry, and returns that. If the input parameter 584 * is NULL, the first entry is returned. 585 * 586 * Returns pointer to next in-use entry, or NULL if no more found. 587 * 588 ******************************************************************************/ 589 extern tBTM_INQ_INFO* BTM_InqDbNext(tBTM_INQ_INFO* p_cur); 590 591 /******************************************************************************* 592 * 593 * Function BTM_ClearInqDb 594 * 595 * Description This function is called to clear out a device or all devices 596 * from the inquiry database. 597 * 598 * Parameter p_bda - (input) BD_ADDR -> Address of device to clear 599 * (NULL clears all entries) 600 * 601 * Returns BTM_BUSY if an inquiry, get remote name, or event filter 602 * is active, otherwise BTM_SUCCESS 603 * 604 ******************************************************************************/ 605 extern tBTM_STATUS BTM_ClearInqDb(const RawAddress* p_bda); 606 607 /***************************************************************************** 608 * ACL CHANNEL MANAGEMENT FUNCTIONS 609 ****************************************************************************/ 610 /******************************************************************************* 611 * 612 * Function BTM_SetLinkPolicy 613 * 614 * Description Create and send HCI "Write Policy Set" command 615 * 616 * Returns BTM_CMD_STARTED if successfully initiated, otherwise error 617 * 618 ******************************************************************************/ 619 extern tBTM_STATUS BTM_SetLinkPolicy(const RawAddress& remote_bda, 620 uint16_t* settings); 621 622 /******************************************************************************* 623 * 624 * Function BTM_SetDefaultLinkPolicy 625 * 626 * Description Set the default value for HCI "Write Policy Set" command 627 * to use when an ACL link is created. 628 * 629 * Returns void 630 * 631 ******************************************************************************/ 632 extern void BTM_SetDefaultLinkPolicy(uint16_t settings); 633 634 /******************************************************************************* 635 * 636 * Function BTM_SetDefaultLinkSuperTout 637 * 638 * Description Set the default value for HCI "Write Link Supervision 639 * Timeout" command to use when an ACL link is created. 640 * 641 * Returns void 642 * 643 ******************************************************************************/ 644 extern void BTM_SetDefaultLinkSuperTout(uint16_t timeout); 645 646 /******************************************************************************* 647 * 648 * Function BTM_SetLinkSuperTout 649 * 650 * Description Create and send HCI "Write Link Supervision Timeout" command 651 * 652 * Returns BTM_CMD_STARTED if successfully initiated, otherwise error 653 * 654 ******************************************************************************/ 655 extern tBTM_STATUS BTM_SetLinkSuperTout(const RawAddress& remote_bda, 656 uint16_t timeout); 657 /******************************************************************************* 658 * 659 * Function BTM_GetLinkSuperTout 660 * 661 * Description Read the link supervision timeout value of the connection 662 * 663 * Returns status of the operation 664 * 665 ******************************************************************************/ 666 extern tBTM_STATUS BTM_GetLinkSuperTout(const RawAddress& remote_bda, 667 uint16_t* p_timeout); 668 669 /******************************************************************************* 670 * 671 * Function BTM_IsAclConnectionUp 672 * 673 * Description This function is called to check if an ACL connection exists 674 * to a specific remote BD Address. 675 * 676 * Returns true if connection is up, else false. 677 * 678 ******************************************************************************/ 679 extern bool BTM_IsAclConnectionUp(const RawAddress& remote_bda, 680 tBT_TRANSPORT transport); 681 682 /******************************************************************************* 683 * 684 * Function BTM_GetRole 685 * 686 * Description This function is called to get the role of the local device 687 * for the ACL connection with the specified remote device 688 * 689 * Returns BTM_SUCCESS if connection exists. 690 * BTM_UNKNOWN_ADDR if no active link with bd addr specified 691 * 692 ******************************************************************************/ 693 extern tBTM_STATUS BTM_GetRole(const RawAddress& remote_bd_addr, 694 uint8_t* p_role); 695 696 /******************************************************************************* 697 * 698 * Function BTM_SwitchRole 699 * 700 * Description This function is called to switch role between master and 701 * slave. If role is already set it will do nothing. If the 702 * command was initiated, the callback function is called upon 703 * completion. 704 * 705 * Returns BTM_SUCCESS if already in specified role. 706 * BTM_CMD_STARTED if command issued to controller. 707 * BTM_NO_RESOURCES if memory couldn't be allocated to issue 708 * the command 709 * BTM_UNKNOWN_ADDR if no active link with bd addr specified 710 * BTM_MODE_UNSUPPORTED if the local device does not support 711 * role switching 712 * 713 ******************************************************************************/ 714 extern tBTM_STATUS BTM_SwitchRole(const RawAddress& remote_bd_addr, 715 uint8_t new_role, tBTM_CMPL_CB* p_cb); 716 717 /******************************************************************************* 718 * 719 * Function BTM_ReadRSSI 720 * 721 * Description This function is called to read the link policy settings. 722 * The address of link policy results are returned in the 723 * callback. (tBTM_RSSI_RESULT) 724 * 725 * Returns BTM_CMD_STARTED if command issued to controller. 726 * BTM_NO_RESOURCES if memory couldn't be allocated to issue 727 * the command 728 * BTM_UNKNOWN_ADDR if no active link with bd addr specified 729 * BTM_BUSY if command is already in progress 730 * 731 ******************************************************************************/ 732 extern tBTM_STATUS BTM_ReadRSSI(const RawAddress& remote_bda, 733 tBTM_CMPL_CB* p_cb); 734 735 /******************************************************************************* 736 * 737 * Function BTM_ReadFailedContactCounter 738 * 739 * Description This function is called to read the failed contact counter. 740 * The result is returned in the callback. 741 * (tBTM_FAILED_CONTACT_COUNTER_RESULT) 742 * 743 * Returns BTM_CMD_STARTED if command issued to controller. 744 * BTM_NO_RESOURCES if memory couldn't be allocated to issue 745 * the command 746 * BTM_UNKNOWN_ADDR if no active link with bd addr specified 747 * BTM_BUSY if command is already in progress 748 * 749 ******************************************************************************/ 750 extern tBTM_STATUS BTM_ReadFailedContactCounter(const RawAddress& remote_bda, 751 tBTM_CMPL_CB* p_cb); 752 753 /******************************************************************************* 754 * 755 * Function BTM_ReadAutomaticFlushTimeout 756 * 757 * Description This function is called to read the automatic flush timeout. 758 * The result is returned in the callback. 759 * (tBTM_AUTOMATIC_FLUSH_TIMEOUT_RESULT) 760 * 761 * Returns BTM_CMD_STARTED if command issued to controller. 762 * BTM_NO_RESOURCES if memory couldn't be allocated to issue 763 * the command 764 * BTM_UNKNOWN_ADDR if no active link with bd addr specified 765 * BTM_BUSY if command is already in progress 766 * 767 ******************************************************************************/ 768 extern tBTM_STATUS BTM_ReadAutomaticFlushTimeout(const RawAddress& remote_bda, 769 tBTM_CMPL_CB* p_cb); 770 771 /******************************************************************************* 772 * 773 * Function BTM_ReadTxPower 774 * 775 * Description This function is called to read the current connection 776 * TX power of the connection. The TX power level results 777 * are returned in the callback. 778 * (tBTM_RSSI_RESULT) 779 * 780 * Returns BTM_CMD_STARTED if command issued to controller. 781 * BTM_NO_RESOURCES if memory couldn't be allocated to issue 782 * the command 783 * BTM_UNKNOWN_ADDR if no active link with bd addr specified 784 * BTM_BUSY if command is already in progress 785 * 786 ******************************************************************************/ 787 extern tBTM_STATUS BTM_ReadTxPower(const RawAddress& remote_bda, 788 tBT_TRANSPORT transport, tBTM_CMPL_CB* p_cb); 789 790 /******************************************************************************* 791 * 792 * Function BTM_RegBusyLevelNotif 793 * 794 * Description This function is called to register a callback to receive 795 * busy level change events. 796 * 797 * Returns BTM_SUCCESS if successfully registered, otherwise error 798 * 799 ******************************************************************************/ 800 extern tBTM_STATUS BTM_RegBusyLevelNotif(tBTM_BL_CHANGE_CB* p_cb, 801 uint8_t* p_level, 802 tBTM_BL_EVENT_MASK evt_mask); 803 804 /******************************************************************************* 805 * 806 * Function BTM_GetNumAclLinks 807 * 808 * Description This function is called to count the number of 809 * ACL links that are active. 810 * 811 * Returns uint16_t Number of active ACL links 812 * 813 ******************************************************************************/ 814 extern uint16_t BTM_GetNumAclLinks(void); 815 816 /***************************************************************************** 817 * (e)SCO CHANNEL MANAGEMENT FUNCTIONS 818 ****************************************************************************/ 819 /******************************************************************************* 820 * 821 * Function BTM_CreateSco 822 * 823 * Description This function is called to create an SCO connection. If the 824 * "is_orig" flag is true, the connection will be originated, 825 * otherwise BTM will wait for the other side to connect. 826 * 827 * Returns BTM_UNKNOWN_ADDR if the ACL connection is not up 828 * BTM_BUSY if another SCO being set up to 829 * the same BD address 830 * BTM_NO_RESOURCES if the max SCO limit has been reached 831 * BTM_CMD_STARTED if the connection establishment is started. 832 * In this case, "*p_sco_inx" is filled in 833 * with the sco index used for the connection. 834 * 835 ******************************************************************************/ 836 extern tBTM_STATUS BTM_CreateSco(const RawAddress* remote_bda, bool is_orig, 837 uint16_t pkt_types, uint16_t* p_sco_inx, 838 tBTM_SCO_CB* p_conn_cb, 839 tBTM_SCO_CB* p_disc_cb); 840 841 /******************************************************************************* 842 * 843 * Function BTM_RemoveSco 844 * 845 * Description This function is called to remove a specific SCO connection. 846 * 847 * Returns BTM_CMD_STARTED if successfully initiated, otherwise error 848 * 849 ******************************************************************************/ 850 extern tBTM_STATUS BTM_RemoveSco(uint16_t sco_inx); 851 852 /******************************************************************************* 853 * 854 * Function BTM_ReadScoBdAddr 855 * 856 * Description This function is read the remote BD Address for a specific 857 * SCO connection, 858 * 859 * Returns pointer to BD address or NULL if not known 860 * 861 ******************************************************************************/ 862 extern const RawAddress* BTM_ReadScoBdAddr(uint16_t sco_inx); 863 864 /******************************************************************************* 865 * 866 * Function BTM_SetEScoMode 867 * 868 * Description This function sets up the negotiated parameters for SCO or 869 * eSCO, and sets as the default mode used for calls to 870 * BTM_CreateSco. It can be called only when there are no 871 * active (e)SCO links. 872 * 873 * Returns BTM_SUCCESS if the successful. 874 * BTM_BUSY if there are one or more active (e)SCO links. 875 * 876 ******************************************************************************/ 877 extern tBTM_STATUS BTM_SetEScoMode(enh_esco_params_t* p_parms); 878 879 /******************************************************************************* 880 * 881 * Function BTM_RegForEScoEvts 882 * 883 * Description This function registers a SCO event callback with the 884 * specified instance. It should be used to received 885 * connection indication events and change of link parameter 886 * events. 887 * 888 * Returns BTM_SUCCESS if the successful. 889 * BTM_ILLEGAL_VALUE if there is an illegal sco_inx 890 * 891 ******************************************************************************/ 892 extern tBTM_STATUS BTM_RegForEScoEvts(uint16_t sco_inx, 893 tBTM_ESCO_CBACK* p_esco_cback); 894 895 /******************************************************************************* 896 * 897 * Function BTM_ChangeEScoLinkParms 898 * 899 * Description This function requests renegotiation of the parameters on 900 * the current eSCO Link. If any of the changes are accepted 901 * by the controllers, the BTM_ESCO_CHG_EVT event is sent in 902 * the tBTM_ESCO_CBACK function with the current settings of 903 * the link. The callback is registered through the call to 904 * BTM_SetEScoMode. 905 * 906 * 907 * Returns BTM_CMD_STARTED if command is successfully initiated. 908 * BTM_ILLEGAL_VALUE if no connection for specified sco_inx. 909 * BTM_NO_RESOURCES - not enough resources to initiate command. 910 * BTM_MODE_UNSUPPORTED if local controller does not support 911 * 1.2 specification. 912 * 913 ******************************************************************************/ 914 extern tBTM_STATUS BTM_ChangeEScoLinkParms(uint16_t sco_inx, 915 tBTM_CHG_ESCO_PARAMS* p_parms); 916 917 /******************************************************************************* 918 * 919 * Function BTM_EScoConnRsp 920 * 921 * Description This function is called upon receipt of an (e)SCO connection 922 * request event (BTM_ESCO_CONN_REQ_EVT) to accept or reject 923 * the request. Parameters used to negotiate eSCO links. 924 * If p_parms is NULL, then values set through BTM_SetEScoMode 925 * are used. 926 * If the link type of the incoming request is SCO, then only 927 * the tx_bw, max_latency, content format, and packet_types are 928 * valid. The hci_status parameter should be 929 * ([0x0] to accept, [0x0d..0x0f] to reject) 930 * 931 * 932 * Returns void 933 * 934 ******************************************************************************/ 935 extern void BTM_EScoConnRsp(uint16_t sco_inx, uint8_t hci_status, 936 enh_esco_params_t* p_parms); 937 938 /******************************************************************************* 939 * 940 * Function BTM_GetNumScoLinks 941 * 942 * Description This function returns the number of active SCO links. 943 * 944 * Returns uint8_t 945 * 946 ******************************************************************************/ 947 extern uint8_t BTM_GetNumScoLinks(void); 948 949 /***************************************************************************** 950 * SECURITY MANAGEMENT FUNCTIONS 951 ****************************************************************************/ 952 /******************************************************************************* 953 * 954 * Function BTM_SecRegister 955 * 956 * Description Application manager calls this function to register for 957 * security services. There can be one and only one 958 * application saving link keys. BTM allows only first 959 * registration. 960 * 961 * Returns true if registered OK, else false 962 * 963 ******************************************************************************/ 964 extern bool BTM_SecRegister(const tBTM_APPL_INFO* p_cb_info); 965 966 /******************************************************************************* 967 * 968 * Function BTM_SecAddRmtNameNotifyCallback 969 * 970 * Description Profiles can register to be notified when name of the 971 * remote device is resolved (up to 972 * BTM_SEC_MAX_RMT_NAME_CALLBACKS). 973 * 974 * Returns true if registered OK, else false 975 * 976 ******************************************************************************/ 977 extern bool BTM_SecAddRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK* p_callback); 978 979 /******************************************************************************* 980 * 981 * Function BTM_SecDeleteRmtNameNotifyCallback 982 * 983 * Description A profile can deregister notification when a new Link Key 984 * is generated per connection. 985 * 986 * Returns true if OK, else false 987 * 988 ******************************************************************************/ 989 extern bool BTM_SecDeleteRmtNameNotifyCallback( 990 tBTM_RMT_NAME_CALLBACK* p_callback); 991 992 /******************************************************************************* 993 * 994 * Function BTM_GetSecurityFlags 995 * 996 * Description Get security flags for the device 997 * 998 * Returns bool true or false is device found 999 * 1000 ******************************************************************************/ 1001 extern bool BTM_GetSecurityFlags(const RawAddress& bd_addr, 1002 uint8_t* p_sec_flags); 1003 1004 /******************************************************************************* 1005 * 1006 * Function BTM_GetSecurityFlagsByTransport 1007 * 1008 * Description Get security flags for the device on a particular transport 1009 * 1010 * Parameters bd_addr: BD address of remote device 1011 * p_sec_flags : Out parameter to be filled with security 1012 * flags for the connection 1013 * transport : Physical transport of the connection 1014 * (BR/EDR or LE) 1015 * 1016 * Returns bool true or false is device found 1017 * 1018 ******************************************************************************/ 1019 extern bool BTM_GetSecurityFlagsByTransport(const RawAddress& bd_addr, 1020 uint8_t* p_sec_flags, 1021 tBT_TRANSPORT transport); 1022 1023 /******************************************************************************* 1024 * 1025 * Function BTM_ReadTrustedMask 1026 * 1027 * Description Get trusted mask for the device 1028 * 1029 * Returns NULL, if the device record is not found. 1030 * otherwise, the trusted mask 1031 * 1032 ******************************************************************************/ 1033 extern uint32_t* BTM_ReadTrustedMask(const RawAddress& bd_addr); 1034 1035 /******************************************************************************* 1036 * 1037 * Function BTM_SetPinType 1038 * 1039 * Description Set PIN type for the device. 1040 * 1041 * Returns void 1042 * 1043 ******************************************************************************/ 1044 extern void BTM_SetPinType(uint8_t pin_type, PIN_CODE pin_code, 1045 uint8_t pin_code_len); 1046 1047 /******************************************************************************* 1048 * 1049 * Function BTM_SetPairableMode 1050 * 1051 * Description Enable or disable pairing 1052 * 1053 * Parameters allow_pairing - (true or false) whether or not the device 1054 * allows pairing. 1055 * connect_only_paired - (true or false) whether or not to 1056 * only allow paired devices to connect. 1057 * 1058 * Returns void 1059 * 1060 ******************************************************************************/ 1061 extern void BTM_SetPairableMode(bool allow_pairing, bool connect_only_paired); 1062 1063 /******************************************************************************* 1064 * 1065 * Function BTM_SetSecurityLevel 1066 * 1067 * Description Register service security level with Security Manager. Each 1068 * service must register its requirements regardless of the 1069 * security level that is used. This API is called once for 1070 * originators and again for acceptors of connections. 1071 * 1072 * Returns true if registered OK, else false 1073 * 1074 ******************************************************************************/ 1075 extern bool BTM_SetSecurityLevel(bool is_originator, const char* p_name, 1076 uint8_t service_id, uint16_t sec_level, 1077 uint16_t psm, uint32_t mx_proto_id, 1078 uint32_t mx_chan_id); 1079 1080 /******************************************************************************* 1081 * 1082 * Function BTM_SetOutService 1083 * 1084 * Description This function is called to set the service for 1085 * outgoing connection. 1086 * 1087 * Returns void 1088 * 1089 ******************************************************************************/ 1090 extern void BTM_SetOutService(const RawAddress& bd_addr, uint8_t service_id, 1091 uint32_t mx_chan_id); 1092 1093 /******************************************************************************* 1094 * 1095 * Function BTM_SecClrService 1096 * 1097 * Description Removes specified service record(s) from the security 1098 * database. All service records with the specified name are 1099 * removed. Typically used only by devices with limited RAM 1100 * so that it can reuse an old security service record. 1101 * 1102 * Returns Number of records that were freed. 1103 * 1104 ******************************************************************************/ 1105 extern uint8_t BTM_SecClrService(uint8_t service_id); 1106 1107 /******************************************************************************* 1108 * 1109 * Function BTM_SecAddDevice 1110 * 1111 * Description Add/modify device. This function will be normally called 1112 * during host startup to restore all required information 1113 * stored in the NVRAM. 1114 * dev_class, bd_name, link_key, and features are NULL if 1115 * unknown 1116 * 1117 * Returns true if added OK, else false 1118 * 1119 ******************************************************************************/ 1120 extern bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class, 1121 BD_NAME bd_name, uint8_t* features, 1122 uint32_t trusted_mask[], LinkKey* link_key, 1123 uint8_t key_type, tBTM_IO_CAP io_cap, 1124 uint8_t pin_length); 1125 1126 /** Free resources associated with the device associated with |bd_addr| address. 1127 * 1128 * *** WARNING *** 1129 * tBTM_SEC_DEV_REC associated with bd_addr becomes invalid after this function 1130 * is called, also any of it's fields. i.e. if you use p_dev_rec->bd_addr, it is 1131 * no longer valid! 1132 * *** WARNING *** 1133 * 1134 * Returns true if removed OK, false if not found or ACL link is active. 1135 */ 1136 extern bool BTM_SecDeleteDevice(const RawAddress& bd_addr); 1137 1138 /******************************************************************************* 1139 * 1140 * Function BTM_SecClearSecurityFlags 1141 * 1142 * Description Reset the security flags (mark as not-paired) for a given 1143 * remove device. 1144 * 1145 ******************************************************************************/ 1146 extern void BTM_SecClearSecurityFlags(const RawAddress& bd_addr); 1147 1148 /******************************************************************************* 1149 * 1150 * Function BTM_SecGetDeviceLinkKeyType 1151 * 1152 * Description This function is called to obtain link key type for the 1153 * device. 1154 * it returns BTM_SUCCESS if link key is available, or 1155 * BTM_UNKNOWN_ADDR if Security Manager does not know about 1156 * the device or device record does not contain link key info 1157 * 1158 * Returns BTM_LKEY_TYPE_IGNORE if link key is unknown, link type 1159 * otherwise. 1160 * 1161 ******************************************************************************/ 1162 extern tBTM_LINK_KEY_TYPE BTM_SecGetDeviceLinkKeyType( 1163 const RawAddress& bd_addr); 1164 1165 /******************************************************************************* 1166 * 1167 * Function BTM_PINCodeReply 1168 * 1169 * Description This function is called after Security Manager submitted 1170 * PIN code request to the UI. 1171 * 1172 * Parameters: bd_addr - Address of the device for which PIN was 1173 * requested 1174 * res - result of the operation BTM_SUCCESS if 1175 * success 1176 * pin_len - length in bytes of the PIN Code 1177 * p_pin - pointer to array with the PIN Code 1178 * trusted_mask - bitwise OR of trusted services 1179 * (array of uint32_t) 1180 * 1181 * Returns void 1182 * 1183 ******************************************************************************/ 1184 extern void BTM_PINCodeReply(const RawAddress& bd_addr, uint8_t res, 1185 uint8_t pin_len, uint8_t* p_pin, 1186 uint32_t trusted_mask[]); 1187 1188 /******************************************************************************* 1189 * 1190 * Function BTM_SecBond 1191 * 1192 * Description Perform bonding by designated transport 1193 * 1194 * Parameters: bd_addr - Address of the device to bond 1195 * addr_type - address type for LE transport 1196 * pin_len - length in bytes of the PIN Code 1197 * p_pin - pointer to array with the PIN Code 1198 * trusted_mask - bitwise OR of trusted services 1199 * (array of uint32_t) 1200 * transport : Physical transport to use for bonding 1201 * (BR/EDR or LE) 1202 * 1203 * Returns BTM_CMD_STARTED if successfully initiated, otherwise error 1204 * 1205 ******************************************************************************/ 1206 extern tBTM_STATUS BTM_SecBond(const RawAddress& bd_addr, 1207 tBLE_ADDR_TYPE addr_type, 1208 tBT_TRANSPORT transport, uint8_t pin_len, 1209 uint8_t* p_pin, uint32_t trusted_mask[]); 1210 1211 /******************************************************************************* 1212 * 1213 * Function BTM_SecBondCancel 1214 * 1215 * Description This function is called to cancel ongoing bonding process 1216 * with peer device. 1217 * 1218 * Returns BTM_CMD_STARTED if successfully initiated, otherwise error 1219 * 1220 ******************************************************************************/ 1221 extern tBTM_STATUS BTM_SecBondCancel(const RawAddress& bd_addr); 1222 1223 /******************************************************************************* 1224 * 1225 * Function BTM_SetEncryption 1226 * 1227 * Description This function is called to ensure that connection is 1228 * encrypted. Should be called only on an open connection. 1229 * Typically only needed for connections that first want to 1230 * bring up unencrypted links, then later encrypt them. 1231 * 1232 * Parameters: bd_addr - Address of the peer device 1233 * transport - Link transport 1234 * p_callback - Pointer to callback function called if 1235 * this function returns PENDING after required 1236 * procedures are completed. Can be set to 1237 * NULL if status is not desired. 1238 * p_ref_data - pointer to any data the caller wishes to 1239 * receive in the callback function upon 1240 * completion. 1241 * can be set to NULL if not used. 1242 * sec_act - LE security action, unused for BR/EDR 1243 * 1244 * Returns BTM_SUCCESS - already encrypted 1245 * BTM_PENDING - command will be returned in the callback 1246 * BTM_WRONG_MODE- connection not up. 1247 * BTM_BUSY - security procedures are currently active 1248 * BTM_MODE_UNSUPPORTED - if security manager not linked in. 1249 * 1250 ******************************************************************************/ 1251 extern tBTM_STATUS BTM_SetEncryption(const RawAddress& bd_addr, 1252 tBT_TRANSPORT transport, 1253 tBTM_SEC_CBACK* p_callback, 1254 void* p_ref_data, 1255 tBTM_BLE_SEC_ACT sec_act); 1256 1257 /******************************************************************************* 1258 * 1259 * Function BTM_ConfirmReqReply 1260 * 1261 * Description This function is called to confirm the numeric value for 1262 * Simple Pairing in response to BTM_SP_CFM_REQ_EVT 1263 * 1264 * Parameters: res - result of the operation BTM_SUCCESS if 1265 * success 1266 * bd_addr - Address of the peer device 1267 * 1268 ******************************************************************************/ 1269 extern void BTM_ConfirmReqReply(tBTM_STATUS res, const RawAddress& bd_addr); 1270 1271 /******************************************************************************* 1272 * 1273 * Function BTM_PasskeyReqReply 1274 * 1275 * Description This function is called to provide the passkey for 1276 * Simple Pairing in response to BTM_SP_KEY_REQ_EVT 1277 * 1278 * Parameters: res - result of the operation BTM_SUCCESS if 1279 * success 1280 * bd_addr - Address of the peer device 1281 * passkey - numeric value in the range of 1282 * 0 - 999999(0xF423F). 1283 * 1284 ******************************************************************************/ 1285 extern void BTM_PasskeyReqReply(tBTM_STATUS res, const RawAddress& bd_addr, 1286 uint32_t passkey); 1287 1288 /******************************************************************************* 1289 * 1290 * Function BTM_SendKeypressNotif 1291 * 1292 * Description This function is used during the passkey entry model 1293 * by a device with KeyboardOnly IO capabilities 1294 * (very likely to be a HID Device). 1295 * It is called by a HID Device to inform the remote device 1296 * when a key has been entered or erased. 1297 * 1298 * Parameters: bd_addr - Address of the peer device 1299 * type - notification type 1300 * 1301 ******************************************************************************/ 1302 extern void BTM_SendKeypressNotif(const RawAddress& bd_addr, 1303 tBTM_SP_KEY_TYPE type); 1304 1305 /******************************************************************************* 1306 * 1307 * Function BTM_IoCapRsp 1308 * 1309 * Description This function is called in response to BTM_SP_IO_REQ_EVT 1310 * When the event data io_req.oob_data is set to 1311 * BTM_OOB_UNKNOWN by the tBTM_SP_CALLBACK implementation, this 1312 * function is called to provide the actual response 1313 * 1314 * Parameters: bd_addr - Address of the peer device 1315 * io_cap - The IO capability of local device. 1316 * oob - BTM_OOB_NONE or BTM_OOB_PRESENT. 1317 * auth_req- MITM protection required or not. 1318 * 1319 ******************************************************************************/ 1320 extern void BTM_IoCapRsp(const RawAddress& bd_addr, tBTM_IO_CAP io_cap, 1321 tBTM_OOB_DATA oob, tBTM_AUTH_REQ auth_req); 1322 1323 /******************************************************************************* 1324 * 1325 * Function BTM_ReadLocalOobData 1326 * 1327 * Description This function is called to read the local OOB data from 1328 * LM 1329 * 1330 ******************************************************************************/ 1331 extern void BTM_ReadLocalOobData(void); 1332 1333 /******************************************************************************* 1334 * 1335 * Function BTM_RemoteOobDataReply 1336 * 1337 * Description This function is called to provide the remote OOB data for 1338 * Simple Pairing in response to BTM_SP_RMT_OOB_EVT 1339 * 1340 * Parameters: bd_addr - Address of the peer device 1341 * c - simple pairing Hash C. 1342 * r - simple pairing Randomizer C. 1343 * 1344 ******************************************************************************/ 1345 extern void BTM_RemoteOobDataReply(tBTM_STATUS res, const RawAddress& bd_addr, 1346 const Octet16& c, const Octet16& r); 1347 1348 /******************************************************************************* 1349 * 1350 * Function BTM_BothEndsSupportSecureConnections 1351 * 1352 * Description This function is called to check if both the local device 1353 * and the peer device specified by bd_addr support BR/EDR 1354 * Secure Connections. 1355 * 1356 * Parameters: bd_addr - address of the peer 1357 * 1358 * Returns true if BR/EDR Secure Connections are supported by both 1359 * local and the remote device. 1360 * else false. 1361 * 1362 ******************************************************************************/ 1363 extern bool BTM_BothEndsSupportSecureConnections(const RawAddress& bd_addr); 1364 1365 /******************************************************************************* 1366 * 1367 * Function BTM_PeerSupportsSecureConnections 1368 * 1369 * Description This function is called to check if the peer supports 1370 * BR/EDR Secure Connections. 1371 * 1372 * Parameters: bd_addr - address of the peer 1373 * 1374 * Returns true if BR/EDR Secure Connections are supported by the peer, 1375 * else false. 1376 * 1377 ******************************************************************************/ 1378 extern bool BTM_PeerSupportsSecureConnections(const RawAddress& bd_addr); 1379 1380 /******************************************************************************* 1381 * 1382 * Function BTM_SecReadDevName 1383 * 1384 * Description Looks for the device name in the security database for the 1385 * specified BD address. 1386 * 1387 * Returns Pointer to the name or NULL 1388 * 1389 ******************************************************************************/ 1390 extern char* BTM_SecReadDevName(const RawAddress& bd_addr); 1391 1392 /***************************************************************************** 1393 * POWER MANAGEMENT FUNCTIONS 1394 ****************************************************************************/ 1395 /******************************************************************************* 1396 * 1397 * Function BTM_PmRegister 1398 * 1399 * Description register or deregister with power manager 1400 * 1401 * Returns BTM_SUCCESS if successful, 1402 * BTM_NO_RESOURCES if no room to hold registration 1403 * BTM_ILLEGAL_VALUE 1404 * 1405 ******************************************************************************/ 1406 extern tBTM_STATUS BTM_PmRegister(uint8_t mask, uint8_t* p_pm_id, 1407 tBTM_PM_STATUS_CBACK* p_cb); 1408 1409 /******************************************************************************* 1410 * 1411 * Function BTM_SetPowerMode 1412 * 1413 * Description store the mode in control block or 1414 * alter ACL connection behavior. 1415 * 1416 * Returns BTM_SUCCESS if successful, 1417 * BTM_UNKNOWN_ADDR if bd addr is not active or bad 1418 * 1419 ******************************************************************************/ 1420 extern tBTM_STATUS BTM_SetPowerMode(uint8_t pm_id, const RawAddress& remote_bda, 1421 const tBTM_PM_PWR_MD* p_mode); 1422 1423 /******************************************************************************* 1424 * 1425 * Function BTM_ReadPowerMode 1426 * 1427 * Description This returns the current mode for a specific 1428 * ACL connection. 1429 * 1430 * Input Param remote_bda - device address of desired ACL connection 1431 * 1432 * Output Param p_mode - address where the current mode is copied into. 1433 * BTM_ACL_MODE_NORMAL 1434 * BTM_ACL_MODE_HOLD 1435 * BTM_ACL_MODE_SNIFF 1436 * BTM_ACL_MODE_PARK 1437 * (valid only if return code is BTM_SUCCESS) 1438 * 1439 * Returns BTM_SUCCESS if successful, 1440 * BTM_UNKNOWN_ADDR if bd addr is not active or bad 1441 * 1442 ******************************************************************************/ 1443 extern tBTM_STATUS BTM_ReadPowerMode(const RawAddress& remote_bda, 1444 tBTM_PM_MODE* p_mode); 1445 1446 /******************************************************************************* 1447 * 1448 * Function BTM_SetSsrParams 1449 * 1450 * Description This sends the given SSR parameters for the given ACL 1451 * connection if it is in ACTIVE mode. 1452 * 1453 * Input Param remote_bda - device address of desired ACL connection 1454 * max_lat - maximum latency (in 0.625ms)(0-0xFFFE) 1455 * min_rmt_to - minimum remote timeout 1456 * min_loc_to - minimum local timeout 1457 * 1458 * 1459 * Returns BTM_SUCCESS if the HCI command is issued successful, 1460 * BTM_UNKNOWN_ADDR if bd addr is not active or bad 1461 * BTM_CMD_STORED if the command is stored 1462 * 1463 ******************************************************************************/ 1464 extern tBTM_STATUS BTM_SetSsrParams(const RawAddress& remote_bda, 1465 uint16_t max_lat, uint16_t min_rmt_to, 1466 uint16_t min_loc_to); 1467 1468 /******************************************************************************* 1469 * 1470 * Function BTM_GetHCIConnHandle 1471 * 1472 * Description This function is called to get the handle for an ACL 1473 * connection to a specific remote BD Address. 1474 * 1475 * Returns the handle of the connection, or 0xFFFF if none. 1476 * 1477 ******************************************************************************/ 1478 extern uint16_t BTM_GetHCIConnHandle(const RawAddress& remote_bda, 1479 tBT_TRANSPORT transport); 1480 1481 /******************************************************************************* 1482 * 1483 * Function BTM_DeleteStoredLinkKey 1484 * 1485 * Description This function is called to delete link key for the specified 1486 * device addresses from the NVRAM storage attached to the 1487 * Bluetooth controller. 1488 * 1489 * Parameters: bd_addr - Addresses of the devices 1490 * p_cb - Call back function to be called to return 1491 * the results 1492 * 1493 ******************************************************************************/ 1494 extern tBTM_STATUS BTM_DeleteStoredLinkKey(const RawAddress* bd_addr, 1495 tBTM_CMPL_CB* p_cb); 1496 1497 /******************************************************************************* 1498 * 1499 * Function BTM_WriteEIR 1500 * 1501 * Description This function is called to write EIR data to controller. 1502 * 1503 * Parameters p_buff - allocated HCI command buffer including extended 1504 * inquriry response 1505 * 1506 * Returns BTM_SUCCESS - if successful 1507 * BTM_MODE_UNSUPPORTED - if local device cannot support it 1508 * 1509 ******************************************************************************/ 1510 extern tBTM_STATUS BTM_WriteEIR(BT_HDR* p_buff); 1511 1512 /******************************************************************************* 1513 * 1514 * Function BTM_HasEirService 1515 * 1516 * Description This function is called to know if UUID in bit map of UUID. 1517 * 1518 * Parameters p_eir_uuid - bit map of UUID list 1519 * uuid16 - UUID 16-bit 1520 * 1521 * Returns true - if found 1522 * false - if not found 1523 * 1524 ******************************************************************************/ 1525 extern bool BTM_HasEirService(const uint32_t* p_eir_uuid, uint16_t uuid16); 1526 1527 /******************************************************************************* 1528 * 1529 * Function BTM_HasInquiryEirService 1530 * 1531 * Description Return if a UUID is in the bit map of a UUID list. 1532 * 1533 * Parameters p_results - inquiry results 1534 * uuid16 - UUID 16-bit 1535 * 1536 * Returns BTM_EIR_FOUND - if found 1537 * BTM_EIR_NOT_FOUND - if not found and it is a complete list 1538 * BTM_EIR_UNKNOWN - if not found and it is not complete list 1539 * 1540 ******************************************************************************/ 1541 extern tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService( 1542 tBTM_INQ_RESULTS* p_results, uint16_t uuid16); 1543 1544 /******************************************************************************* 1545 * 1546 * Function BTM_AddEirService 1547 * 1548 * Description This function is called to add a service in the bit map UUID 1549 * list. 1550 * 1551 * Parameters p_eir_uuid - bit mask of UUID list for EIR 1552 * uuid16 - UUID 16-bit 1553 * 1554 * Returns None 1555 * 1556 ******************************************************************************/ 1557 extern void BTM_AddEirService(uint32_t* p_eir_uuid, uint16_t uuid16); 1558 1559 /******************************************************************************* 1560 * 1561 * Function BTM_RemoveEirService 1562 * 1563 * Description This function is called to remove a service from the bit map 1564 * UUID list. 1565 * 1566 * Parameters p_eir_uuid - bit mask of UUID list for EIR 1567 * uuid16 - UUID 16-bit 1568 * 1569 * Returns None 1570 * 1571 ******************************************************************************/ 1572 extern void BTM_RemoveEirService(uint32_t* p_eir_uuid, uint16_t uuid16); 1573 1574 /******************************************************************************* 1575 * 1576 * Function BTM_GetEirSupportedServices 1577 * 1578 * Description This function is called to get UUID list from bit map UUID 1579 * list. 1580 * 1581 * Parameters p_eir_uuid - bit mask of UUID list for EIR 1582 * p - reference of current pointer of EIR 1583 * max_num_uuid16 - max number of UUID can be written in EIR 1584 * num_uuid16 - number of UUID have been written in EIR 1585 * 1586 * Returns BTM_EIR_MORE_16BITS_UUID_TYPE, if it has more than max 1587 * BTM_EIR_COMPLETE_16BITS_UUID_TYPE, otherwise 1588 * 1589 ******************************************************************************/ 1590 extern uint8_t BTM_GetEirSupportedServices(uint32_t* p_eir_uuid, uint8_t** p, 1591 uint8_t max_num_uuid16, 1592 uint8_t* p_num_uuid16); 1593 1594 /******************************************************************************* 1595 * 1596 * Function BTM_GetEirUuidList 1597 * 1598 * Description This function parses EIR and returns UUID list. 1599 * 1600 * Parameters p_eir - EIR 1601 * eirl_len - EIR len 1602 * uuid_size - Uuid::kNumBytes16, Uuid::kNumBytes32, 1603 * Uuid::kNumBytes128 1604 * p_num_uuid - return number of UUID in found list 1605 * p_uuid_list - return UUID 16-bit list 1606 * max_num_uuid - maximum number of UUID to be returned 1607 * 1608 * Returns 0 - if not found 1609 * BTM_EIR_COMPLETE_16BITS_UUID_TYPE 1610 * BTM_EIR_MORE_16BITS_UUID_TYPE 1611 * BTM_EIR_COMPLETE_32BITS_UUID_TYPE 1612 * BTM_EIR_MORE_32BITS_UUID_TYPE 1613 * BTM_EIR_COMPLETE_128BITS_UUID_TYPE 1614 * BTM_EIR_MORE_128BITS_UUID_TYPE 1615 * 1616 ******************************************************************************/ 1617 extern uint8_t BTM_GetEirUuidList(uint8_t* p_eir, size_t eir_len, 1618 uint8_t uuid_size, uint8_t* p_num_uuid, 1619 uint8_t* p_uuid_list, uint8_t max_num_uuid); 1620 1621 /******************************************************************************* 1622 * 1623 * Function BTM_PM_ReadControllerState 1624 * 1625 * Description This function is called to obtain the controller state 1626 * 1627 * Returns Controller state (BTM_CONTRL_ACTIVE, BTM_CONTRL_SCAN, and 1628 * BTM_CONTRL_IDLE) 1629 * 1630 ******************************************************************************/ 1631 extern tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void); 1632 1633 #endif /* BTM_API_H */ 1634