Home | History | Annotate | Download | only in include
      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_SetPeriodicInquiryMode
    313  *
    314  * Description      This function is called to set the device periodic inquiry
    315  *                  mode. If the duration is zero, the periodic inquiry mode is
    316  *                  cancelled.
    317  *
    318  * Parameters:      p_inqparms - pointer to the inquiry information
    319  *                      mode - GENERAL or LIMITED inquiry
    320  *                      duration - length in 1.28 sec intervals (If '0', the
    321  *                                 inquiry is CANCELLED)
    322  *                      max_resps - maximum amount of devices to search for
    323  *                                  before ending the inquiry
    324  *                      filter_cond_type - BTM_CLR_INQUIRY_FILTER,
    325  *                                         BTM_FILTER_COND_DEVICE_CLASS, or
    326  *                                         BTM_FILTER_COND_BD_ADDR
    327  *                      filter_cond - value for the filter (based on
    328  *                                                          filter_cond_type)
    329  *
    330  *                  max_delay - maximum amount of time between successive
    331  *                              inquiries
    332  *                  min_delay - minimum amount of time between successive
    333  *                              inquiries
    334  *                  p_results_cb - callback returning pointer to results
    335  *                              (tBTM_INQ_RESULTS)
    336  *
    337  * Returns          BTM_CMD_STARTED if successfully started
    338  *                  BTM_ILLEGAL_VALUE if a bad parameter is detected
    339  *                  BTM_NO_RESOURCES if could not allocate a message buffer
    340  *                  BTM_SUCCESS - if cancelling the periodic inquiry
    341  *                  BTM_BUSY - if an inquiry is already active
    342  *                  BTM_WRONG_MODE if the device is not up.
    343  *
    344  ******************************************************************************/
    345 extern tBTM_STATUS BTM_SetPeriodicInquiryMode(
    346     tBTM_INQ_PARMS* p_inqparms, uint16_t max_delay, uint16_t min_delay,
    347     tBTM_INQ_RESULTS_CB* p_results_cb);
    348 
    349 /*******************************************************************************
    350  *
    351  * Function         BTM_StartInquiry
    352  *
    353  * Description      This function is called to start an inquiry.
    354  *
    355  * Parameters:      p_inqparms - pointer to the inquiry information
    356  *                      mode - GENERAL or LIMITED inquiry
    357  *                      duration - length in 1.28 sec intervals (If '0', the
    358  *                                 inquiry is CANCELLED)
    359  *                      max_resps - maximum amount of devices to search for
    360  *                                  before ending the inquiry
    361  *                      filter_cond_type - BTM_CLR_INQUIRY_FILTER,
    362  *                                         BTM_FILTER_COND_DEVICE_CLASS, or
    363  *                                         BTM_FILTER_COND_BD_ADDR
    364  *                      filter_cond - value for the filter (based on
    365  *                                                          filter_cond_type)
    366  *
    367  *                  p_results_cb  - Pointer to the callback routine which gets
    368  *                                called upon receipt of an inquiry result. If
    369  *                                this field is NULL, the application is not
    370  *                                notified.
    371  *
    372  *                  p_cmpl_cb   - Pointer to the callback routine which gets
    373  *                                called upon completion.  If this field is
    374  *                                NULL, the application is not notified when
    375  *                                completed.
    376  * Returns          tBTM_STATUS
    377  *                  BTM_CMD_STARTED if successfully initiated
    378  *                  BTM_BUSY if already in progress
    379  *                  BTM_ILLEGAL_VALUE if parameter(s) are out of range
    380  *                  BTM_NO_RESOURCES if could not allocate resources to start
    381  *                                   the command
    382  *                  BTM_WRONG_MODE if the device is not up.
    383  *
    384  ******************************************************************************/
    385 extern tBTM_STATUS BTM_StartInquiry(tBTM_INQ_PARMS* p_inqparms,
    386                                     tBTM_INQ_RESULTS_CB* p_results_cb,
    387                                     tBTM_CMPL_CB* p_cmpl_cb);
    388 
    389 /*******************************************************************************
    390  *
    391  * Function         BTM_IsInquiryActive
    392  *
    393  * Description      Return a bit mask of the current inquiry state
    394  *
    395  * Returns          BTM_INQUIRY_INACTIVE if inactive (0)
    396  *                  BTM_LIMITED_INQUIRY_ACTIVE if a limted inquiry is active
    397  *                  BTM_GENERAL_INQUIRY_ACTIVE if a general inquiry is active
    398  *                  BTM_PERIODIC_INQUIRY_ACTIVE if a periodic inquiry is active
    399  *
    400  ******************************************************************************/
    401 extern uint16_t BTM_IsInquiryActive(void);
    402 
    403 /*******************************************************************************
    404  *
    405  * Function         BTM_CancelInquiry
    406  *
    407  * Description      This function cancels an inquiry if active
    408  *
    409  * Returns          BTM_SUCCESS if successful
    410  *                  BTM_NO_RESOURCES if could not allocate a message buffer
    411  *                  BTM_WRONG_MODE if the device is not up.
    412  *
    413  ******************************************************************************/
    414 extern tBTM_STATUS BTM_CancelInquiry(void);
    415 
    416 /*******************************************************************************
    417  *
    418  * Function         BTM_CancelPeriodicInquiry
    419  *
    420  * Description      This function cancels a periodic inquiry
    421  *
    422  * Returns
    423  *                  BTM_NO_RESOURCES if could not allocate a message buffer
    424  *                  BTM_SUCCESS - if cancelling the periodic inquiry
    425  *                  BTM_WRONG_MODE if the device is not up.
    426  *
    427  ******************************************************************************/
    428 extern tBTM_STATUS BTM_CancelPeriodicInquiry(void);
    429 
    430 /*******************************************************************************
    431  *
    432  * Function         BTM_SetConnectability
    433  *
    434  * Description      This function is called to set the device into or out of
    435  *                  connectable mode. Discoverable mode means page scans are
    436  *                  enabled.
    437  *
    438  * Returns          BTM_SUCCESS if successful
    439  *                  BTM_ILLEGAL_VALUE if a bad parameter is detected
    440  *                  BTM_NO_RESOURCES if could not allocate a message buffer
    441  *                  BTM_WRONG_MODE if the device is not up.
    442  *
    443  ******************************************************************************/
    444 extern tBTM_STATUS BTM_SetConnectability(uint16_t page_mode, uint16_t window,
    445                                          uint16_t interval);
    446 
    447 /*******************************************************************************
    448  *
    449  * Function         BTM_ReadConnectability
    450  *
    451  * Description      This function is called to read the current discoverability
    452  *                  mode of the device.
    453  * Output Params    p_window - current page scan duration
    454  *                  p_interval - current time between page scans
    455  *
    456  * Returns          BTM_NON_CONNECTABLE or BTM_CONNECTABLE
    457  *
    458  ******************************************************************************/
    459 extern uint16_t BTM_ReadConnectability(uint16_t* p_window,
    460                                        uint16_t* p_interval);
    461 
    462 /*******************************************************************************
    463  *
    464  * Function         BTM_SetInquiryMode
    465  *
    466  * Description      This function is called to set standard, with RSSI
    467  *                  mode or extended of the inquiry for local device.
    468  *
    469  * Input Params:    BTM_INQ_RESULT_STANDARD, BTM_INQ_RESULT_WITH_RSSI or
    470  *                  BTM_INQ_RESULT_EXTENDED
    471  *
    472  * Returns          BTM_SUCCESS if successful
    473  *                  BTM_NO_RESOURCES if couldn't get a memory pool buffer
    474  *                  BTM_ILLEGAL_VALUE if a bad parameter was detected
    475  *                  BTM_WRONG_MODE if the device is not up.
    476  *
    477  ******************************************************************************/
    478 extern tBTM_STATUS BTM_SetInquiryMode(uint8_t mode);
    479 
    480 /*******************************************************************************
    481  *
    482  * Function         BTM_SetInquiryScanType
    483  *
    484  * Description      This function is called to set the iquiry scan-type to
    485  *                  standard or interlaced.
    486  *
    487  * Input Params:    BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
    488  *
    489  * Returns          BTM_SUCCESS if successful
    490  *                  BTM_MODE_UNSUPPORTED if not a 1.2 device
    491  *                  BTM_WRONG_MODE if the device is not up.
    492  *
    493  ******************************************************************************/
    494 extern tBTM_STATUS BTM_SetInquiryScanType(uint16_t scan_type);
    495 
    496 /*******************************************************************************
    497  *
    498  * Function         BTM_SetPageScanType
    499  *
    500  * Description      This function is called to set the page scan-type to
    501  *                  standard or interlaced.
    502  *
    503  * Input Params:    BTM_SCAN_TYPE_STANDARD or BTM_SCAN_TYPE_INTERLACED
    504  *
    505  * Returns          BTM_SUCCESS if successful
    506  *                  BTM_MODE_UNSUPPORTED if not a 1.2 device
    507  *                  BTM_WRONG_MODE if the device is not up.
    508  *
    509  ******************************************************************************/
    510 
    511 extern tBTM_STATUS BTM_SetPageScanType(uint16_t scan_type);
    512 
    513 /*******************************************************************************
    514  *
    515  * Function         BTM_ReadRemoteDeviceName
    516  *
    517  * Description      This function initiates a remote device HCI command to the
    518  *                  controller and calls the callback when the process has
    519  *                  completed.
    520  *
    521  * Input Params:    remote_bda      - device address of name to retrieve
    522  *                  p_cb            - callback function called when
    523  *                                    BTM_CMD_STARTED is returned.
    524  *                                    A pointer to tBTM_REMOTE_DEV_NAME is
    525  *                                    passed to the callback.
    526  *
    527  * Returns
    528  *                  BTM_CMD_STARTED is returned if the request was successfully
    529  *                                  sent to HCI.
    530  *                  BTM_BUSY if already in progress
    531  *                  BTM_UNKNOWN_ADDR if device address is bad
    532  *                  BTM_NO_RESOURCES if resources could not be allocated to
    533  *                                   start the command
    534  *                  BTM_WRONG_MODE if the device is not up.
    535  *
    536  ******************************************************************************/
    537 extern tBTM_STATUS BTM_ReadRemoteDeviceName(const RawAddress& remote_bda,
    538                                             tBTM_CMPL_CB* p_cb,
    539                                             tBT_TRANSPORT transport);
    540 
    541 /*******************************************************************************
    542  *
    543  * Function         BTM_CancelRemoteDeviceName
    544  *
    545  * Description      This function initiates the cancel request for the specified
    546  *                  remote device.
    547  *
    548  * Input Params:    None
    549  *
    550  * Returns
    551  *                  BTM_CMD_STARTED is returned if the request was successfully
    552  *                                  sent to HCI.
    553  *                  BTM_NO_RESOURCES if resources could not be allocated to
    554  *                                   start the command
    555  *                  BTM_WRONG_MODE if there is no active remote name request.
    556  *
    557  ******************************************************************************/
    558 extern tBTM_STATUS BTM_CancelRemoteDeviceName(void);
    559 
    560 /*******************************************************************************
    561  *
    562  * Function         BTM_ReadRemoteVersion
    563  *
    564  * Description      This function is called to read a remote device's version
    565  *
    566  * Returns          BTM_SUCCESS if successful, otherwise an error
    567  *
    568  ******************************************************************************/
    569 extern tBTM_STATUS BTM_ReadRemoteVersion(const RawAddress& addr,
    570                                          uint8_t* lmp_version,
    571                                          uint16_t* manufacturer,
    572                                          uint16_t* lmp_sub_version);
    573 
    574 /*******************************************************************************
    575  *
    576  * Function         BTM_ReadRemoteFeatures
    577  *
    578  * Description      This function is called to read a remote device's
    579  *                  supported features mask (features mask located at page 0)
    580  *
    581  *                  Note: The size of device features mask page is
    582  *                  BTM_FEATURE_BYTES_PER_PAGE bytes.
    583  *
    584  * Returns          pointer to the remote supported features mask
    585  *
    586  ******************************************************************************/
    587 extern uint8_t* BTM_ReadRemoteFeatures(const RawAddress& addr);
    588 
    589 /*******************************************************************************
    590  *
    591  * Function         BTM_ReadRemoteExtendedFeatures
    592  *
    593  * Description      This function is called to read a specific extended features
    594  *                  page of the remote device
    595  *
    596  *                  Note1: The size of device features mask page is
    597  *                  BTM_FEATURE_BYTES_PER_PAGE bytes.
    598  *                  Note2: The valid device features mask page number depends on
    599  *                  the remote device capabilities. It is expected to be in the
    600  *                  range [0 - BTM_EXT_FEATURES_PAGE_MAX].
    601 
    602  * Returns          pointer to the remote extended features mask
    603  *                  or NULL if page_number is not valid
    604  *
    605  ******************************************************************************/
    606 extern uint8_t* BTM_ReadRemoteExtendedFeatures(const RawAddress& addr,
    607                                                uint8_t page_number);
    608 
    609 /*******************************************************************************
    610  *
    611  * Function         BTM_ReadNumberRemoteFeaturesPages
    612  *
    613  * Description      This function is called to retrieve the number of feature
    614  *                  pages read from the remote device
    615  *
    616  * Returns          number of features pages read from the remote device
    617  *
    618  ******************************************************************************/
    619 extern uint8_t BTM_ReadNumberRemoteFeaturesPages(const RawAddress& addr);
    620 
    621 /*******************************************************************************
    622  *
    623  * Function         BTM_ReadAllRemoteFeatures
    624  *
    625  * Description      Read all the features of the remote device
    626  *
    627  * Returns          pointer to the byte[0] of the page[0] of the remote device
    628  *                  feature mask.
    629  *
    630  * Note:            the function returns the pointer to the array of the size
    631  *                  BTM_FEATURE_BYTES_PER_PAGE * (BTM_EXT_FEATURES_PAGE_MAX + 1)
    632  *
    633  ******************************************************************************/
    634 extern uint8_t* BTM_ReadAllRemoteFeatures(const RawAddress& addr);
    635 
    636 /*******************************************************************************
    637  *
    638  * Function         BTM_InqDbRead
    639  *
    640  * Description      This function looks through the inquiry database for a match
    641  *                  based on Bluetooth Device Address. This is the application's
    642  *                  interface to get the inquiry details of a specific BD
    643  *                  address.
    644  *
    645  * Returns          pointer to entry, or NULL if not found
    646  *
    647  ******************************************************************************/
    648 extern tBTM_INQ_INFO* BTM_InqDbRead(const RawAddress& p_bda);
    649 
    650 /*******************************************************************************
    651  *
    652  * Function         BTM_InqDbFirst
    653  *
    654  * Description      This function looks through the inquiry database for the
    655  *                  first used entry, and returns that. This is used in
    656  *                  conjunction with BTM_InqDbNext by applications as a way to
    657  *                  walk through the inquiry database.
    658  *
    659  * Returns          pointer to first in-use entry, or NULL if DB is empty
    660  *
    661  ******************************************************************************/
    662 extern tBTM_INQ_INFO* BTM_InqDbFirst(void);
    663 
    664 /*******************************************************************************
    665  *
    666  * Function         BTM_InqDbNext
    667  *
    668  * Description      This function looks through the inquiry database for the
    669  *                  next used entry, and returns that.  If the input parameter
    670  *                  is NULL, the first entry is returned.
    671  *
    672  * Returns          pointer to next in-use entry, or NULL if no more found.
    673  *
    674  ******************************************************************************/
    675 extern tBTM_INQ_INFO* BTM_InqDbNext(tBTM_INQ_INFO* p_cur);
    676 
    677 /*******************************************************************************
    678  *
    679  * Function         BTM_ClearInqDb
    680  *
    681  * Description      This function is called to clear out a device or all devices
    682  *                  from the inquiry database.
    683  *
    684  * Parameter        p_bda - (input) BD_ADDR ->  Address of device to clear
    685  *                                              (NULL clears all entries)
    686  *
    687  * Returns          BTM_BUSY if an inquiry, get remote name, or event filter
    688  *                          is active, otherwise BTM_SUCCESS
    689  *
    690  ******************************************************************************/
    691 extern tBTM_STATUS BTM_ClearInqDb(const RawAddress* p_bda);
    692 
    693 /*******************************************************************************
    694  *
    695  * Function         BTM_ReadInquiryRspTxPower
    696  *
    697  * Description      This command will read the inquiry Transmit Power level used
    698  *                  to transmit the FHS and EIR data packets.
    699  *                  This can be used directly in the Tx Power Level EIR data
    700  *                  type.
    701  *
    702  * Returns          BTM_SUCCESS if successful
    703  *
    704  ******************************************************************************/
    705 extern tBTM_STATUS BTM_ReadInquiryRspTxPower(tBTM_CMPL_CB* p_cb);
    706 
    707 /*****************************************************************************
    708  *  ACL CHANNEL MANAGEMENT FUNCTIONS
    709  ****************************************************************************/
    710 /*******************************************************************************
    711  *
    712  * Function         BTM_SetLinkPolicy
    713  *
    714  * Description      Create and send HCI "Write Policy Set" command
    715  *
    716  * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
    717  *
    718  ******************************************************************************/
    719 extern tBTM_STATUS BTM_SetLinkPolicy(const RawAddress& remote_bda,
    720                                      uint16_t* settings);
    721 
    722 /*******************************************************************************
    723  *
    724  * Function         BTM_SetDefaultLinkPolicy
    725  *
    726  * Description      Set the default value for HCI "Write Policy Set" command
    727  *                  to use when an ACL link is created.
    728  *
    729  * Returns          void
    730  *
    731  ******************************************************************************/
    732 extern void BTM_SetDefaultLinkPolicy(uint16_t settings);
    733 
    734 /*******************************************************************************
    735  *
    736  * Function         BTM_SetDefaultLinkSuperTout
    737  *
    738  * Description      Set the default value for HCI "Write Link Supervision
    739  *                  Timeout" command to use when an ACL link is created.
    740  *
    741  * Returns          void
    742  *
    743  ******************************************************************************/
    744 extern void BTM_SetDefaultLinkSuperTout(uint16_t timeout);
    745 
    746 /*******************************************************************************
    747  *
    748  * Function         BTM_SetLinkSuperTout
    749  *
    750  * Description      Create and send HCI "Write Link Supervision Timeout" command
    751  *
    752  * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
    753  *
    754  ******************************************************************************/
    755 extern tBTM_STATUS BTM_SetLinkSuperTout(const RawAddress& remote_bda,
    756                                         uint16_t timeout);
    757 /*******************************************************************************
    758  *
    759  * Function         BTM_GetLinkSuperTout
    760  *
    761  * Description      Read the link supervision timeout value of the connection
    762  *
    763  * Returns          status of the operation
    764  *
    765  ******************************************************************************/
    766 extern tBTM_STATUS BTM_GetLinkSuperTout(const RawAddress& remote_bda,
    767                                         uint16_t* p_timeout);
    768 
    769 /*******************************************************************************
    770  *
    771  * Function         BTM_IsAclConnectionUp
    772  *
    773  * Description      This function is called to check if an ACL connection exists
    774  *                  to a specific remote BD Address.
    775  *
    776  * Returns          true if connection is up, else false.
    777  *
    778  ******************************************************************************/
    779 extern bool BTM_IsAclConnectionUp(const RawAddress& remote_bda,
    780                                   tBT_TRANSPORT transport);
    781 
    782 /*******************************************************************************
    783  *
    784  * Function         BTM_GetRole
    785  *
    786  * Description      This function is called to get the role of the local device
    787  *                  for the ACL connection with the specified remote device
    788  *
    789  * Returns          BTM_SUCCESS if connection exists.
    790  *                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
    791  *
    792  ******************************************************************************/
    793 extern tBTM_STATUS BTM_GetRole(const RawAddress& remote_bd_addr,
    794                                uint8_t* p_role);
    795 
    796 /*******************************************************************************
    797  *
    798  * Function         BTM_SwitchRole
    799  *
    800  * Description      This function is called to switch role between master and
    801  *                  slave.  If role is already set it will do nothing.  If the
    802  *                  command was initiated, the callback function is called upon
    803  *                  completion.
    804  *
    805  * Returns          BTM_SUCCESS if already in specified role.
    806  *                  BTM_CMD_STARTED if command issued to controller.
    807  *                  BTM_NO_RESOURCES if memory couldn't be allocated to issue
    808  *                                   the command
    809  *                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
    810  *                  BTM_MODE_UNSUPPORTED if the local device does not support
    811  *                                       role switching
    812  *
    813  ******************************************************************************/
    814 extern tBTM_STATUS BTM_SwitchRole(const RawAddress& remote_bd_addr,
    815                                   uint8_t new_role, tBTM_CMPL_CB* p_cb);
    816 
    817 /*******************************************************************************
    818  *
    819  * Function         BTM_ReadRSSI
    820  *
    821  * Description      This function is called to read the link policy settings.
    822  *                  The address of link policy results are returned in the
    823  *                  callback. (tBTM_RSSI_RESULT)
    824  *
    825  * Returns          BTM_CMD_STARTED if command issued to controller.
    826  *                  BTM_NO_RESOURCES if memory couldn't be allocated to issue
    827  *                                   the command
    828  *                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
    829  *                  BTM_BUSY if command is already in progress
    830  *
    831  ******************************************************************************/
    832 extern tBTM_STATUS BTM_ReadRSSI(const RawAddress& remote_bda,
    833                                 tBTM_CMPL_CB* p_cb);
    834 
    835 /*******************************************************************************
    836  *
    837  * Function         BTM_ReadFailedContactCounter
    838  *
    839  * Description      This function is called to read the failed contact counter.
    840  *                  The result is returned in the callback.
    841  *                  (tBTM_FAILED_CONTACT_COUNTER_RESULT)
    842  *
    843  * Returns          BTM_CMD_STARTED if command issued to controller.
    844  *                  BTM_NO_RESOURCES if memory couldn't be allocated to issue
    845  *                                   the command
    846  *                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
    847  *                  BTM_BUSY if command is already in progress
    848  *
    849  ******************************************************************************/
    850 extern tBTM_STATUS BTM_ReadFailedContactCounter(const RawAddress& remote_bda,
    851                                                 tBTM_CMPL_CB* p_cb);
    852 
    853 /*******************************************************************************
    854  *
    855  * Function         BTM_ReadAutomaticFlushTimeout
    856  *
    857  * Description      This function is called to read the automatic flush timeout.
    858  *                  The result is returned in the callback.
    859  *                  (tBTM_AUTOMATIC_FLUSH_TIMEOUT_RESULT)
    860  *
    861  * Returns          BTM_CMD_STARTED if command issued to controller.
    862  *                  BTM_NO_RESOURCES if memory couldn't be allocated to issue
    863  *                                   the command
    864  *                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
    865  *                  BTM_BUSY if command is already in progress
    866  *
    867  ******************************************************************************/
    868 extern tBTM_STATUS BTM_ReadAutomaticFlushTimeout(const RawAddress& remote_bda,
    869                                                  tBTM_CMPL_CB* p_cb);
    870 
    871 /*******************************************************************************
    872  *
    873  * Function         BTM_ReadTxPower
    874  *
    875  * Description      This function is called to read the current connection
    876  *                  TX power of the connection. The TX power level results
    877  *                  are returned in the callback.
    878  *                  (tBTM_RSSI_RESULT)
    879  *
    880  * Returns          BTM_CMD_STARTED if command issued to controller.
    881  *                  BTM_NO_RESOURCES if memory couldn't be allocated to issue
    882  *                                   the command
    883  *                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
    884  *                  BTM_BUSY if command is already in progress
    885  *
    886  ******************************************************************************/
    887 extern tBTM_STATUS BTM_ReadTxPower(const RawAddress& remote_bda,
    888                                    tBT_TRANSPORT transport, tBTM_CMPL_CB* p_cb);
    889 
    890 /*******************************************************************************
    891  *
    892  * Function         BTM_ReadLinkQuality
    893  *
    894  * Description      This function is called to read the link quality.
    895  *                  The value of the link quality is returned in the callback.
    896  *                  (tBTM_LINK_QUALITY_RESULT)
    897  *
    898  * Returns          BTM_CMD_STARTED if command issued to controller.
    899  *                  BTM_NO_RESOURCES if memory couldn't be allocated to issue
    900  *                                   the command
    901  *                  BTM_UNKNOWN_ADDR if no active link with bd addr specified
    902  *                  BTM_BUSY if command is already in progress
    903  *
    904  ******************************************************************************/
    905 extern tBTM_STATUS BTM_ReadLinkQuality(const RawAddress& remote_bda,
    906                                        tBTM_CMPL_CB* p_cb);
    907 
    908 /*******************************************************************************
    909  *
    910  * Function         BTM_RegBusyLevelNotif
    911  *
    912  * Description      This function is called to register a callback to receive
    913  *                  busy level change events.
    914  *
    915  * Returns          BTM_SUCCESS if successfully registered, otherwise error
    916  *
    917  ******************************************************************************/
    918 extern tBTM_STATUS BTM_RegBusyLevelNotif(tBTM_BL_CHANGE_CB* p_cb,
    919                                          uint8_t* p_level,
    920                                          tBTM_BL_EVENT_MASK evt_mask);
    921 
    922 /*******************************************************************************
    923  *
    924  * Function         BTM_AclRegisterForChanges
    925  *
    926  * Description      This function is called to register a callback to receive
    927  *                  ACL database change events, i.e. new connection or removed.
    928  *
    929  * Returns          BTM_SUCCESS if successfully initiated, otherwise error
    930  *
    931  ******************************************************************************/
    932 extern tBTM_STATUS BTM_AclRegisterForChanges(tBTM_ACL_DB_CHANGE_CB* p_cb);
    933 
    934 /*******************************************************************************
    935  *
    936  * Function         BTM_GetNumAclLinks
    937  *
    938  * Description      This function is called to count the number of
    939  *                  ACL links that are active.
    940  *
    941  * Returns          uint16_t Number of active ACL links
    942  *
    943  ******************************************************************************/
    944 extern uint16_t BTM_GetNumAclLinks(void);
    945 
    946 /*******************************************************************************
    947  *
    948  * Function         BTM_SetQoS
    949  *
    950  * Description      This function is called to setup QoS
    951  *
    952  * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
    953  *
    954  ******************************************************************************/
    955 extern tBTM_STATUS BTM_SetQoS(const RawAddress& bd, FLOW_SPEC* p_flow,
    956                               tBTM_CMPL_CB* p_cb);
    957 
    958 /*****************************************************************************
    959  *  (e)SCO CHANNEL MANAGEMENT FUNCTIONS
    960  ****************************************************************************/
    961 /*******************************************************************************
    962  *
    963  * Function         BTM_CreateSco
    964  *
    965  * Description      This function is called to create an SCO connection. If the
    966  *                  "is_orig" flag is true, the connection will be originated,
    967  *                  otherwise BTM will wait for the other side to connect.
    968  *
    969  * Returns          BTM_UNKNOWN_ADDR if the ACL connection is not up
    970  *                  BTM_BUSY         if another SCO being set up to
    971  *                                   the same BD address
    972  *                  BTM_NO_RESOURCES if the max SCO limit has been reached
    973  *                  BTM_CMD_STARTED  if the connection establishment is started.
    974  *                                   In this case, "*p_sco_inx" is filled in
    975  *                                   with the sco index used for the connection.
    976  *
    977  ******************************************************************************/
    978 extern tBTM_STATUS BTM_CreateSco(const RawAddress* remote_bda, bool is_orig,
    979                                  uint16_t pkt_types, uint16_t* p_sco_inx,
    980                                  tBTM_SCO_CB* p_conn_cb,
    981                                  tBTM_SCO_CB* p_disc_cb);
    982 
    983 /*******************************************************************************
    984  *
    985  * Function         BTM_RemoveSco
    986  *
    987  * Description      This function is called to remove a specific SCO connection.
    988  *
    989  * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
    990  *
    991  ******************************************************************************/
    992 extern tBTM_STATUS BTM_RemoveSco(uint16_t sco_inx);
    993 
    994 /*******************************************************************************
    995  *
    996  * Function         BTM_SetScoPacketTypes
    997  *
    998  * Description      This function is called to set the packet types used for
    999  *                  a specific SCO connection,
   1000  *
   1001  * Parameters       pkt_types - One or more of the following
   1002  *                  BTM_SCO_PKT_TYPES_MASK_HV1
   1003  *                  BTM_SCO_PKT_TYPES_MASK_HV2
   1004  *                  BTM_SCO_PKT_TYPES_MASK_HV3
   1005  *                  BTM_SCO_PKT_TYPES_MASK_EV3
   1006  *                  BTM_SCO_PKT_TYPES_MASK_EV4
   1007  *                  BTM_SCO_PKT_TYPES_MASK_EV5
   1008  *
   1009  *                  BTM_SCO_LINK_ALL_MASK   - enables all supported types
   1010  *
   1011  * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
   1012  *
   1013  ******************************************************************************/
   1014 extern tBTM_STATUS BTM_SetScoPacketTypes(uint16_t sco_inx, uint16_t pkt_types);
   1015 
   1016 /*******************************************************************************
   1017  *
   1018  * Function         BTM_ReadScoPacketTypes
   1019  *
   1020  * Description      This function is read the packet types used for a specific
   1021  *                  SCO connection.
   1022  *
   1023  * Returns       One or more of the following (bitmask)
   1024  *                  BTM_SCO_PKT_TYPES_MASK_HV1
   1025  *                  BTM_SCO_PKT_TYPES_MASK_HV2
   1026  *                  BTM_SCO_PKT_TYPES_MASK_HV3
   1027  *                  BTM_SCO_PKT_TYPES_MASK_EV3
   1028  *                  BTM_SCO_PKT_TYPES_MASK_EV4
   1029  *                  BTM_SCO_PKT_TYPES_MASK_EV5
   1030  *
   1031  * Returns          packet types supported for the connection
   1032  *
   1033  ******************************************************************************/
   1034 extern uint16_t BTM_ReadScoPacketTypes(uint16_t sco_inx);
   1035 
   1036 /*******************************************************************************
   1037  *
   1038  * Function         BTM_ReadDeviceScoPacketTypes
   1039  *
   1040  * Description      This function is read the SCO packet types that
   1041  *                  the device supports.
   1042  *
   1043  * Returns          packet types supported by the device.
   1044  *
   1045  ******************************************************************************/
   1046 extern uint16_t BTM_ReadDeviceScoPacketTypes(void);
   1047 
   1048 /*******************************************************************************
   1049  *
   1050  * Function         BTM_ReadScoHandle
   1051  *
   1052  * Description      Reead the HCI handle used for a specific SCO connection,
   1053  *
   1054  * Returns          handle for the connection, or 0xFFFF if invalid SCO index.
   1055  *
   1056  ******************************************************************************/
   1057 extern uint16_t BTM_ReadScoHandle(uint16_t sco_inx);
   1058 
   1059 /*******************************************************************************
   1060  *
   1061  * Function         BTM_ReadScoBdAddr
   1062  *
   1063  * Description      This function is read the remote BD Address for a specific
   1064  *                  SCO connection,
   1065  *
   1066  * Returns          pointer to BD address or NULL if not known
   1067  *
   1068  ******************************************************************************/
   1069 extern const RawAddress* BTM_ReadScoBdAddr(uint16_t sco_inx);
   1070 
   1071 /*******************************************************************************
   1072  *
   1073  * Function         BTM_ReadScoDiscReason
   1074  *
   1075  * Description      This function is returns the reason why an (e)SCO connection
   1076  *                  has been removed. It contains the value until read, or until
   1077  *                  another (e)SCO connection has disconnected.
   1078  *
   1079  * Returns          HCI reason or BTM_INVALID_SCO_DISC_REASON if not set.
   1080  *
   1081  ******************************************************************************/
   1082 extern uint16_t BTM_ReadScoDiscReason(void);
   1083 
   1084 /*******************************************************************************
   1085  *
   1086  * Function         BTM_SetEScoMode
   1087  *
   1088  * Description      This function sets up the negotiated parameters for SCO or
   1089  *                  eSCO, and sets as the default mode used for calls to
   1090  *                  BTM_CreateSco.  It can be called only when there are no
   1091  *                  active (e)SCO links.
   1092  *
   1093  * Returns          BTM_SUCCESS if the successful.
   1094  *                  BTM_BUSY if there are one or more active (e)SCO links.
   1095  *
   1096  ******************************************************************************/
   1097 extern tBTM_STATUS BTM_SetEScoMode(enh_esco_params_t* p_parms);
   1098 
   1099 /*******************************************************************************
   1100  *
   1101  * Function         BTM_SetWBSCodec
   1102  *
   1103  * Description      This function sends command to the controller to setup
   1104  *                  WBS codec for the upcoming eSCO connection.
   1105  *
   1106  * Returns          BTM_SUCCESS.
   1107  *
   1108  *
   1109  ******************************************************************************/
   1110 extern tBTM_STATUS BTM_SetWBSCodec(tBTM_SCO_CODEC_TYPE codec_type);
   1111 
   1112 /*******************************************************************************
   1113  *
   1114  * Function         BTM_RegForEScoEvts
   1115  *
   1116  * Description      This function registers a SCO event callback with the
   1117  *                  specified instance.  It should be used to received
   1118  *                  connection indication events and change of link parameter
   1119  *                  events.
   1120  *
   1121  * Returns          BTM_SUCCESS if the successful.
   1122  *                  BTM_ILLEGAL_VALUE if there is an illegal sco_inx
   1123  *
   1124  ******************************************************************************/
   1125 extern tBTM_STATUS BTM_RegForEScoEvts(uint16_t sco_inx,
   1126                                       tBTM_ESCO_CBACK* p_esco_cback);
   1127 
   1128 /*******************************************************************************
   1129  *
   1130  * Function         BTM_ReadEScoLinkParms
   1131  *
   1132  * Description      This function returns the current eSCO link parameters for
   1133  *                  the specified handle.  This can be called anytime a
   1134  *                  connection is active, but is typically called after
   1135  *                  receiving the SCO opened callback.
   1136  *
   1137  *                  Note: If called over a 1.1 controller, only the packet types
   1138  *                        field has meaning.
   1139  *                  Note: If the upper layer doesn't know the current sco index,
   1140  *                  BTM_FIRST_ACTIVE_SCO_INDEX can be used as the first
   1141  *                  parameter to find the first active SCO index
   1142  *
   1143  * Returns          BTM_SUCCESS if returned data is valid connection.
   1144  *                  BTM_ILLEGAL_VALUE if no connection for specified sco_inx.
   1145  *                  BTM_MODE_UNSUPPORTED if local controller does not support
   1146  *                      1.2 specification.
   1147  *
   1148  ******************************************************************************/
   1149 extern tBTM_STATUS BTM_ReadEScoLinkParms(uint16_t sco_inx,
   1150                                          tBTM_ESCO_DATA* p_parms);
   1151 
   1152 /*******************************************************************************
   1153  *
   1154  * Function         BTM_ChangeEScoLinkParms
   1155  *
   1156  * Description      This function requests renegotiation of the parameters on
   1157  *                  the current eSCO Link.  If any of the changes are accepted
   1158  *                  by the controllers, the BTM_ESCO_CHG_EVT event is sent in
   1159  *                  the tBTM_ESCO_CBACK function with the current settings of
   1160  *                  the link. The callback is registered through the call to
   1161  *                  BTM_SetEScoMode.
   1162  *
   1163  *
   1164  * Returns          BTM_CMD_STARTED if command is successfully initiated.
   1165  *                  BTM_ILLEGAL_VALUE if no connection for specified sco_inx.
   1166  *                  BTM_NO_RESOURCES - not enough resources to initiate command.
   1167  *                  BTM_MODE_UNSUPPORTED if local controller does not support
   1168  *                      1.2 specification.
   1169  *
   1170  ******************************************************************************/
   1171 extern tBTM_STATUS BTM_ChangeEScoLinkParms(uint16_t sco_inx,
   1172                                            tBTM_CHG_ESCO_PARAMS* p_parms);
   1173 
   1174 /*******************************************************************************
   1175  *
   1176  * Function         BTM_EScoConnRsp
   1177  *
   1178  * Description      This function is called upon receipt of an (e)SCO connection
   1179  *                  request event (BTM_ESCO_CONN_REQ_EVT) to accept or reject
   1180  *                  the request. Parameters used to negotiate eSCO links.
   1181  *                  If p_parms is NULL, then values set through BTM_SetEScoMode
   1182  *                  are used.
   1183  *                  If the link type of the incoming request is SCO, then only
   1184  *                  the tx_bw, max_latency, content format, and packet_types are
   1185  *                  valid.  The hci_status parameter should be
   1186  *                  ([0x0] to accept, [0x0d..0x0f] to reject)
   1187  *
   1188  *
   1189  * Returns          void
   1190  *
   1191  ******************************************************************************/
   1192 extern void BTM_EScoConnRsp(uint16_t sco_inx, uint8_t hci_status,
   1193                             enh_esco_params_t* p_parms);
   1194 
   1195 /*******************************************************************************
   1196  *
   1197  * Function         BTM_GetNumScoLinks
   1198  *
   1199  * Description      This function returns the number of active SCO links.
   1200  *
   1201  * Returns          uint8_t
   1202  *
   1203  ******************************************************************************/
   1204 extern uint8_t BTM_GetNumScoLinks(void);
   1205 
   1206 /*****************************************************************************
   1207  *  SECURITY MANAGEMENT FUNCTIONS
   1208  ****************************************************************************/
   1209 /*******************************************************************************
   1210  *
   1211  * Function         BTM_SecRegister
   1212  *
   1213  * Description      Application manager calls this function to register for
   1214  *                  security services.  There can be one and only one
   1215  *                  application saving link keys.  BTM allows only first
   1216  *                  registration.
   1217  *
   1218  * Returns          true if registered OK, else false
   1219  *
   1220  ******************************************************************************/
   1221 extern bool BTM_SecRegister(const tBTM_APPL_INFO* p_cb_info);
   1222 
   1223 /*******************************************************************************
   1224  *
   1225  * Function         BTM_SecRegisterLinkKeyNotificationCallback
   1226  *
   1227  * Description      Profiles can register to be notified when a new Link Key
   1228  *                  is generated per connection.
   1229  *
   1230  * Returns          true if registered OK, else false
   1231  *
   1232  ******************************************************************************/
   1233 extern bool BTM_SecRegisterLinkKeyNotificationCallback(
   1234     tBTM_LINK_KEY_CALLBACK* p_callback);
   1235 
   1236 /*******************************************************************************
   1237  *
   1238  * Function         BTM_SecAddRmtNameNotifyCallback
   1239  *
   1240  * Description      Profiles can register to be notified when name of the
   1241  *                  remote device is resolved (up to
   1242  *                  BTM_SEC_MAX_RMT_NAME_CALLBACKS).
   1243  *
   1244  * Returns          true if registered OK, else false
   1245  *
   1246  ******************************************************************************/
   1247 extern bool BTM_SecAddRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK* p_callback);
   1248 
   1249 /*******************************************************************************
   1250  *
   1251  * Function         BTM_SecDeleteRmtNameNotifyCallback
   1252  *
   1253  * Description      A profile can deregister notification when a new Link Key
   1254  *                  is generated per connection.
   1255  *
   1256  * Returns          true if OK, else false
   1257  *
   1258  ******************************************************************************/
   1259 extern bool BTM_SecDeleteRmtNameNotifyCallback(
   1260     tBTM_RMT_NAME_CALLBACK* p_callback);
   1261 
   1262 /*******************************************************************************
   1263  *
   1264  * Function         BTM_GetSecurityFlags
   1265  *
   1266  * Description      Get security flags for the device
   1267  *
   1268  * Returns          bool    true or false is device found
   1269  *
   1270  ******************************************************************************/
   1271 extern bool BTM_GetSecurityFlags(const RawAddress& bd_addr,
   1272                                  uint8_t* p_sec_flags);
   1273 
   1274 /*******************************************************************************
   1275  *
   1276  * Function         BTM_GetSecurityFlagsByTransport
   1277  *
   1278  * Description      Get security flags for the device on a particular transport
   1279  *
   1280  * Parameters      bd_addr: BD address of remote device
   1281  *                  p_sec_flags : Out parameter to be filled with security
   1282  *                                flags for the connection
   1283  *                  transport :  Physical transport of the connection
   1284  *                               (BR/EDR or LE)
   1285  *
   1286  * Returns          bool    true or false is device found
   1287  *
   1288  ******************************************************************************/
   1289 extern bool BTM_GetSecurityFlagsByTransport(const RawAddress& bd_addr,
   1290                                             uint8_t* p_sec_flags,
   1291                                             tBT_TRANSPORT transport);
   1292 
   1293 /*******************************************************************************
   1294  *
   1295  * Function         BTM_ReadTrustedMask
   1296  *
   1297  * Description      Get trusted mask for the device
   1298  *
   1299  * Returns          NULL, if the device record is not found.
   1300  *                  otherwise, the trusted mask
   1301  *
   1302  ******************************************************************************/
   1303 extern uint32_t* BTM_ReadTrustedMask(const RawAddress& bd_addr);
   1304 
   1305 /*******************************************************************************
   1306  *
   1307  * Function         BTM_SetPinType
   1308  *
   1309  * Description      Set PIN type for the device.
   1310  *
   1311  * Returns          void
   1312  *
   1313  ******************************************************************************/
   1314 extern void BTM_SetPinType(uint8_t pin_type, PIN_CODE pin_code,
   1315                            uint8_t pin_code_len);
   1316 
   1317 /*******************************************************************************
   1318  *
   1319  * Function         BTM_SetPairableMode
   1320  *
   1321  * Description      Enable or disable pairing
   1322  *
   1323  * Parameters       allow_pairing - (true or false) whether or not the device
   1324  *                      allows pairing.
   1325  *                  connect_only_paired - (true or false) whether or not to
   1326  *                      only allow paired devices to connect.
   1327  *
   1328  * Returns          void
   1329  *
   1330  ******************************************************************************/
   1331 extern void BTM_SetPairableMode(bool allow_pairing, bool connect_only_paired);
   1332 
   1333 /*******************************************************************************
   1334  *
   1335  * Function         BTM_SetSecureConnectionsOnly
   1336  *
   1337  * Description      Enable or disable default treatment for Mode 4 Level 0
   1338  *                  services
   1339  *
   1340  * Parameter        secure_connections_only_mode - (true or false)
   1341  *                  true means that the device should treat Mode 4 Level 0
   1342  *                  services as services of other levels.
   1343  *                  false means that the device should provide default
   1344  *                  treatment for Mode 4 Level 0 services.
   1345  *
   1346  * Returns          void
   1347  *
   1348  ******************************************************************************/
   1349 extern void BTM_SetSecureConnectionsOnly(bool secure_connections_only_mode);
   1350 
   1351 /*******************************************************************************
   1352  *
   1353  * Function         BTM_SetSecurityLevel
   1354  *
   1355  * Description      Register service security level with Security Manager.  Each
   1356  *                  service must register its requirements regardless of the
   1357  *                  security level that is used.  This API is called once for
   1358  *                  originators and again for acceptors of connections.
   1359  *
   1360  * Returns          true if registered OK, else false
   1361  *
   1362  ******************************************************************************/
   1363 extern bool BTM_SetSecurityLevel(bool is_originator, const char* p_name,
   1364                                  uint8_t service_id, uint16_t sec_level,
   1365                                  uint16_t psm, uint32_t mx_proto_id,
   1366                                  uint32_t mx_chan_id);
   1367 
   1368 /*******************************************************************************
   1369  *
   1370  * Function         BTM_SetOutService
   1371  *
   1372  * Description      This function is called to set the service for
   1373  *                  outgoing connection.
   1374  *
   1375  * Returns          void
   1376  *
   1377  ******************************************************************************/
   1378 extern void BTM_SetOutService(const RawAddress& bd_addr, uint8_t service_id,
   1379                               uint32_t mx_chan_id);
   1380 
   1381 /*******************************************************************************
   1382  *
   1383  * Function         BTM_SecClrService
   1384  *
   1385  * Description      Removes specified service record(s) from the security
   1386  *                  database. All service records with the specified name are
   1387  *                  removed. Typically used only by devices with limited RAM
   1388  *                  so that it can reuse an old security service record.
   1389  *
   1390  * Returns          Number of records that were freed.
   1391  *
   1392  ******************************************************************************/
   1393 extern uint8_t BTM_SecClrService(uint8_t service_id);
   1394 
   1395 /*******************************************************************************
   1396  *
   1397  * Function         BTM_SecAddDevice
   1398  *
   1399  * Description      Add/modify device.  This function will be normally called
   1400  *                  during host startup to restore all required information
   1401  *                  stored in the NVRAM.
   1402  *                  dev_class, bd_name, link_key, and features are NULL if
   1403  *                  unknown
   1404  *
   1405  * Returns          true if added OK, else false
   1406  *
   1407  ******************************************************************************/
   1408 extern bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class,
   1409                              BD_NAME bd_name, uint8_t* features,
   1410                              uint32_t trusted_mask[], LINK_KEY link_key,
   1411                              uint8_t key_type, tBTM_IO_CAP io_cap,
   1412                              uint8_t pin_length);
   1413 
   1414 /*******************************************************************************
   1415  *
   1416  * Function         BTM_SecDeleteDevice
   1417  *
   1418  * Description      Free resources associated with the device.
   1419  *
   1420  * Returns          true if rmoved OK, false if not found
   1421  *
   1422  ******************************************************************************/
   1423 extern bool BTM_SecDeleteDevice(const RawAddress& bd_addr);
   1424 
   1425 /*******************************************************************************
   1426  *
   1427  * Function         BTM_SecClearSecurityFlags
   1428  *
   1429  * Description      Reset the security flags (mark as not-paired) for a given
   1430  *                  remove device.
   1431  *
   1432  ******************************************************************************/
   1433 extern void BTM_SecClearSecurityFlags(const RawAddress& bd_addr);
   1434 
   1435 /*******************************************************************************
   1436  *
   1437  * Function         BTM_SecGetDeviceLinkKey
   1438  *
   1439  * Description      This function is called to obtain link key for the device
   1440  *                  it returns BTM_SUCCESS if link key is available, or
   1441  *                  BTM_UNKNOWN_ADDR if Security Manager does not know about
   1442  *                  the device or device record does not contain link key info
   1443  *
   1444  * Returns          BTM_SUCCESS if successful, otherwise error code
   1445  *
   1446  ******************************************************************************/
   1447 extern tBTM_STATUS BTM_SecGetDeviceLinkKey(const RawAddress& bd_addr,
   1448                                            LINK_KEY link_key);
   1449 
   1450 /*******************************************************************************
   1451  *
   1452  * Function         BTM_SecGetDeviceLinkKeyType
   1453  *
   1454  * Description      This function is called to obtain link key type for the
   1455  *                  device.
   1456  *                  it returns BTM_SUCCESS if link key is available, or
   1457  *                  BTM_UNKNOWN_ADDR if Security Manager does not know about
   1458  *                  the device or device record does not contain link key info
   1459  *
   1460  * Returns          BTM_LKEY_TYPE_IGNORE if link key is unknown, link type
   1461  *                  otherwise.
   1462  *
   1463  ******************************************************************************/
   1464 extern tBTM_LINK_KEY_TYPE BTM_SecGetDeviceLinkKeyType(
   1465     const RawAddress& bd_addr);
   1466 
   1467 /*******************************************************************************
   1468  *
   1469  * Function         BTM_PINCodeReply
   1470  *
   1471  * Description      This function is called after Security Manager submitted
   1472  *                  PIN code request to the UI.
   1473  *
   1474  * Parameters:      bd_addr      - Address of the device for which PIN was
   1475  *                                 requested
   1476  *                  res          - result of the operation BTM_SUCCESS if
   1477  *                                 success
   1478  *                  pin_len      - length in bytes of the PIN Code
   1479  *                  p_pin        - pointer to array with the PIN Code
   1480  *                  trusted_mask - bitwise OR of trusted services
   1481  *                                 (array of uint32_t)
   1482  *
   1483  * Returns          void
   1484  *
   1485  ******************************************************************************/
   1486 extern void BTM_PINCodeReply(const RawAddress& bd_addr, uint8_t res,
   1487                              uint8_t pin_len, uint8_t* p_pin,
   1488                              uint32_t trusted_mask[]);
   1489 
   1490 /*******************************************************************************
   1491  *
   1492  * Function         BTM_SecBond
   1493  *
   1494  * Description      This function is called to perform bonding with peer device.
   1495  *
   1496  * Parameters:      bd_addr      - Address of the device to bond
   1497  *                  pin_len      - length in bytes of the PIN Code
   1498  *                  p_pin        - pointer to array with the PIN Code
   1499  *                  trusted_mask - bitwise OR of trusted services
   1500  *                                 (array of uint32_t)
   1501  * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
   1502  *
   1503  ******************************************************************************/
   1504 extern tBTM_STATUS BTM_SecBond(const RawAddress& bd_addr, uint8_t pin_len,
   1505                                uint8_t* p_pin, uint32_t trusted_mask[]);
   1506 
   1507 /*******************************************************************************
   1508  *
   1509  * Function         BTM_SecBondByTransport
   1510  *
   1511  * Description      Perform bonding by designated transport
   1512  *
   1513  * Parameters:      bd_addr      - Address of the device to bond
   1514  *                  pin_len      - length in bytes of the PIN Code
   1515  *                  p_pin        - pointer to array with the PIN Code
   1516  *                  trusted_mask - bitwise OR of trusted services
   1517  *                                 (array of uint32_t)
   1518  *                  transport :  Physical transport to use for bonding
   1519  *                               (BR/EDR or LE)
   1520  *
   1521  * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
   1522  *
   1523  ******************************************************************************/
   1524 extern tBTM_STATUS BTM_SecBondByTransport(const RawAddress& bd_addr,
   1525                                           tBT_TRANSPORT transport,
   1526                                           uint8_t pin_len, uint8_t* p_pin,
   1527                                           uint32_t trusted_mask[]);
   1528 
   1529 /*******************************************************************************
   1530  *
   1531  * Function         BTM_SecBondCancel
   1532  *
   1533  * Description      This function is called to cancel ongoing bonding process
   1534  *                  with peer device.
   1535  *
   1536  * Returns          BTM_CMD_STARTED if successfully initiated, otherwise error
   1537  *
   1538  ******************************************************************************/
   1539 extern tBTM_STATUS BTM_SecBondCancel(const RawAddress& bd_addr);
   1540 
   1541 /*******************************************************************************
   1542  *
   1543  * Function         BTM_SetEncryption
   1544  *
   1545  * Description      This function is called to ensure that connection is
   1546  *                  encrypted.  Should be called only on an open connection.
   1547  *                  Typically only needed for connections that first want to
   1548  *                  bring up unencrypted links, then later encrypt them.
   1549  *
   1550  * Parameters:      bd_addr       - Address of the peer device
   1551  *                  transport     - Link transport
   1552  *                  p_callback    - Pointer to callback function called if
   1553  *                                  this function returns PENDING after required
   1554  *                                  procedures are completed.  Can be set to
   1555  *                                  NULL if status is not desired.
   1556  *                  p_ref_data    - pointer to any data the caller wishes to
   1557  *                                  receive in the callback function upon
   1558  *                                  completion.
   1559  *                                  can be set to NULL if not used.
   1560  *                  sec_act       - LE security action, unused for BR/EDR
   1561  *
   1562  * Returns          BTM_SUCCESS   - already encrypted
   1563  *                  BTM_PENDING   - command will be returned in the callback
   1564  *                  BTM_WRONG_MODE- connection not up.
   1565  *                  BTM_BUSY      - security procedures are currently active
   1566  *                  BTM_MODE_UNSUPPORTED - if security manager not linked in.
   1567  *
   1568  ******************************************************************************/
   1569 extern tBTM_STATUS BTM_SetEncryption(const RawAddress& bd_addr,
   1570                                      tBT_TRANSPORT transport,
   1571                                      tBTM_SEC_CBACK* p_callback,
   1572                                      void* p_ref_data,
   1573                                      tBTM_BLE_SEC_ACT sec_act);
   1574 
   1575 /*******************************************************************************
   1576  *
   1577  * Function         BTM_ConfirmReqReply
   1578  *
   1579  * Description      This function is called to confirm the numeric value for
   1580  *                  Simple Pairing in response to BTM_SP_CFM_REQ_EVT
   1581  *
   1582  * Parameters:      res           - result of the operation BTM_SUCCESS if
   1583  *                                  success
   1584  *                  bd_addr       - Address of the peer device
   1585  *
   1586  ******************************************************************************/
   1587 extern void BTM_ConfirmReqReply(tBTM_STATUS res, const RawAddress& bd_addr);
   1588 
   1589 /*******************************************************************************
   1590  *
   1591  * Function         BTM_PasskeyReqReply
   1592  *
   1593  * Description      This function is called to provide the passkey for
   1594  *                  Simple Pairing in response to BTM_SP_KEY_REQ_EVT
   1595  *
   1596  * Parameters:      res           - result of the operation BTM_SUCCESS if
   1597  *                                  success
   1598  *                  bd_addr       - Address of the peer device
   1599  *                  passkey       - numeric value in the range of
   1600  *                                  0 - 999999(0xF423F).
   1601  *
   1602  ******************************************************************************/
   1603 extern void BTM_PasskeyReqReply(tBTM_STATUS res, const RawAddress& bd_addr,
   1604                                 uint32_t passkey);
   1605 
   1606 /*******************************************************************************
   1607  *
   1608  * Function         BTM_SendKeypressNotif
   1609  *
   1610  * Description      This function is used during the passkey entry model
   1611  *                  by a device with KeyboardOnly IO capabilities
   1612  *                  (very likely to be a HID Device).
   1613  *                  It is called by a HID Device to inform the remote device
   1614  *                  when a key has been entered or erased.
   1615  *
   1616  * Parameters:      bd_addr - Address of the peer device
   1617  *                  type - notification type
   1618  *
   1619  ******************************************************************************/
   1620 extern void BTM_SendKeypressNotif(const RawAddress& bd_addr,
   1621                                   tBTM_SP_KEY_TYPE type);
   1622 
   1623 /*******************************************************************************
   1624  *
   1625  * Function         BTM_IoCapRsp
   1626  *
   1627  * Description      This function is called in response to BTM_SP_IO_REQ_EVT
   1628  *                  When the event data io_req.oob_data is set to
   1629  *                  BTM_OOB_UNKNOWN by the tBTM_SP_CALLBACK implementation, this
   1630  *                  function is called to provide the actual response
   1631  *
   1632  * Parameters:      bd_addr - Address of the peer device
   1633  *                  io_cap  - The IO capability of local device.
   1634  *                  oob     - BTM_OOB_NONE or BTM_OOB_PRESENT.
   1635  *                  auth_req- MITM protection required or not.
   1636  *
   1637  ******************************************************************************/
   1638 extern void BTM_IoCapRsp(const RawAddress& bd_addr, tBTM_IO_CAP io_cap,
   1639                          tBTM_OOB_DATA oob, tBTM_AUTH_REQ auth_req);
   1640 
   1641 /*******************************************************************************
   1642  *
   1643  * Function         BTM_ReadLocalOobData
   1644  *
   1645  * Description      This function is called to read the local OOB data from
   1646  *                  LM
   1647  *
   1648  ******************************************************************************/
   1649 extern void BTM_ReadLocalOobData(void);
   1650 
   1651 /*******************************************************************************
   1652  *
   1653  * Function         BTM_RemoteOobDataReply
   1654  *
   1655  * Description      This function is called to provide the remote OOB data for
   1656  *                  Simple Pairing in response to BTM_SP_RMT_OOB_EVT
   1657  *
   1658  * Parameters:      bd_addr     - Address of the peer device
   1659  *                  c           - simple pairing Hash C.
   1660  *                  r           - simple pairing Randomizer  C.
   1661  *
   1662  ******************************************************************************/
   1663 extern void BTM_RemoteOobDataReply(tBTM_STATUS res, const RawAddress& bd_addr,
   1664                                    BT_OCTET16 c, BT_OCTET16 r);
   1665 
   1666 /*******************************************************************************
   1667  *
   1668  * Function         BTM_BuildOobData
   1669  *
   1670  * Description      This function is called to build the OOB data payload to
   1671  *                  be sent over OOB (non-Bluetooth) link
   1672  *
   1673  * Parameters:      p_data  - the location for OOB data
   1674  *                  max_len - p_data size.
   1675  *                  c       - simple pairing Hash C.
   1676  *                  r       - simple pairing Randomizer  C.
   1677  *                  name_len- 0, local device name would not be included.
   1678  *                            otherwise, the local device name is included for
   1679  *                            up to this specified length
   1680  *
   1681  * Returns          Number of bytes in p_data.
   1682  *
   1683  ******************************************************************************/
   1684 extern uint16_t BTM_BuildOobData(uint8_t* p_data, uint16_t max_len,
   1685                                  BT_OCTET16 c, BT_OCTET16 r, uint8_t name_len);
   1686 
   1687 /*******************************************************************************
   1688  *
   1689  * Function         BTM_BothEndsSupportSecureConnections
   1690  *
   1691  * Description      This function is called to check if both the local device
   1692  *                  and the peer device specified by bd_addr support BR/EDR
   1693  *                  Secure Connections.
   1694  *
   1695  * Parameters:      bd_addr - address of the peer
   1696  *
   1697  * Returns          true if BR/EDR Secure Connections are supported by both
   1698  *                  local and the remote device.
   1699  *                  else false.
   1700  *
   1701  ******************************************************************************/
   1702 extern bool BTM_BothEndsSupportSecureConnections(const RawAddress& bd_addr);
   1703 
   1704 /*******************************************************************************
   1705  *
   1706  * Function         BTM_PeerSupportsSecureConnections
   1707  *
   1708  * Description      This function is called to check if the peer supports
   1709  *                  BR/EDR Secure Connections.
   1710  *
   1711  * Parameters:      bd_addr - address of the peer
   1712  *
   1713  * Returns          true if BR/EDR Secure Connections are supported by the peer,
   1714  *                  else false.
   1715  *
   1716  ******************************************************************************/
   1717 extern bool BTM_PeerSupportsSecureConnections(const RawAddress& bd_addr);
   1718 
   1719 /*******************************************************************************
   1720  *
   1721  * Function         BTM_ReadOobData
   1722  *
   1723  * Description      This function is called to parse the OOB data payload
   1724  *                  received over OOB (non-Bluetooth) link
   1725  *
   1726  * Parameters:      p_data  - the location for OOB data
   1727  *                  eir_tag - The associated EIR tag to read the data.
   1728  *                  *p_len(output) - the length of the data with the given tag.
   1729  *
   1730  * Returns          the beginning of the data with the given tag.
   1731  *                  NULL, if the tag is not found.
   1732  *
   1733  ******************************************************************************/
   1734 extern uint8_t* BTM_ReadOobData(uint8_t* p_data, uint8_t eir_tag,
   1735                                 uint8_t* p_len);
   1736 
   1737 /*******************************************************************************
   1738  *
   1739  * Function         BTM_SecReadDevName
   1740  *
   1741  * Description      Looks for the device name in the security database for the
   1742  *                  specified BD address.
   1743  *
   1744  * Returns          Pointer to the name or NULL
   1745  *
   1746  ******************************************************************************/
   1747 extern char* BTM_SecReadDevName(const RawAddress& bd_addr);
   1748 
   1749 /*****************************************************************************
   1750  *  POWER MANAGEMENT FUNCTIONS
   1751  ****************************************************************************/
   1752 /*******************************************************************************
   1753  *
   1754  * Function         BTM_PmRegister
   1755  *
   1756  * Description      register or deregister with power manager
   1757  *
   1758  * Returns          BTM_SUCCESS if successful,
   1759  *                  BTM_NO_RESOURCES if no room to hold registration
   1760  *                  BTM_ILLEGAL_VALUE
   1761  *
   1762  ******************************************************************************/
   1763 extern tBTM_STATUS BTM_PmRegister(uint8_t mask, uint8_t* p_pm_id,
   1764                                   tBTM_PM_STATUS_CBACK* p_cb);
   1765 
   1766 /*******************************************************************************
   1767  *
   1768  * Function         BTM_SetPowerMode
   1769  *
   1770  * Description      store the mode in control block or
   1771  *                  alter ACL connection behavior.
   1772  *
   1773  * Returns          BTM_SUCCESS if successful,
   1774  *                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
   1775  *
   1776  ******************************************************************************/
   1777 extern tBTM_STATUS BTM_SetPowerMode(uint8_t pm_id, const RawAddress& remote_bda,
   1778                                     const tBTM_PM_PWR_MD* p_mode);
   1779 
   1780 /*******************************************************************************
   1781  *
   1782  * Function         BTM_ReadPowerMode
   1783  *
   1784  * Description      This returns the current mode for a specific
   1785  *                  ACL connection.
   1786  *
   1787  * Input Param      remote_bda - device address of desired ACL connection
   1788  *
   1789  * Output Param     p_mode - address where the current mode is copied into.
   1790  *                          BTM_ACL_MODE_NORMAL
   1791  *                          BTM_ACL_MODE_HOLD
   1792  *                          BTM_ACL_MODE_SNIFF
   1793  *                          BTM_ACL_MODE_PARK
   1794  *                          (valid only if return code is BTM_SUCCESS)
   1795  *
   1796  * Returns          BTM_SUCCESS if successful,
   1797  *                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
   1798  *
   1799  ******************************************************************************/
   1800 extern tBTM_STATUS BTM_ReadPowerMode(const RawAddress& remote_bda,
   1801                                      tBTM_PM_MODE* p_mode);
   1802 
   1803 /*******************************************************************************
   1804  *
   1805  * Function         BTM_SetSsrParams
   1806  *
   1807  * Description      This sends the given SSR parameters for the given ACL
   1808  *                  connection if it is in ACTIVE mode.
   1809  *
   1810  * Input Param      remote_bda - device address of desired ACL connection
   1811  *                  max_lat    - maximum latency (in 0.625ms)(0-0xFFFE)
   1812  *                  min_rmt_to - minimum remote timeout
   1813  *                  min_loc_to - minimum local timeout
   1814  *
   1815  *
   1816  * Returns          BTM_SUCCESS if the HCI command is issued successful,
   1817  *                  BTM_UNKNOWN_ADDR if bd addr is not active or bad
   1818  *                  BTM_CMD_STORED if the command is stored
   1819  *
   1820  ******************************************************************************/
   1821 extern tBTM_STATUS BTM_SetSsrParams(const RawAddress& remote_bda,
   1822                                     uint16_t max_lat, uint16_t min_rmt_to,
   1823                                     uint16_t min_loc_to);
   1824 
   1825 /*******************************************************************************
   1826  *
   1827  * Function         BTM_GetHCIConnHandle
   1828  *
   1829  * Description      This function is called to get the handle for an ACL
   1830  *                  connection to a specific remote BD Address.
   1831  *
   1832  * Returns          the handle of the connection, or 0xFFFF if none.
   1833  *
   1834  ******************************************************************************/
   1835 extern uint16_t BTM_GetHCIConnHandle(const RawAddress& remote_bda,
   1836                                      tBT_TRANSPORT transport);
   1837 
   1838 /*******************************************************************************
   1839  *
   1840  * Function         BTM_DeleteStoredLinkKey
   1841  *
   1842  * Description      This function is called to delete link key for the specified
   1843  *                  device addresses from the NVRAM storage attached to the
   1844  *                  Bluetooth controller.
   1845  *
   1846  * Parameters:      bd_addr      - Addresses of the devices
   1847  *                  p_cb         - Call back function to be called to return
   1848  *                                 the results
   1849  *
   1850  ******************************************************************************/
   1851 extern tBTM_STATUS BTM_DeleteStoredLinkKey(const RawAddress* bd_addr,
   1852                                            tBTM_CMPL_CB* p_cb);
   1853 
   1854 /*******************************************************************************
   1855  *
   1856  * Function         BTM_WriteEIR
   1857  *
   1858  * Description      This function is called to write EIR data to controller.
   1859  *
   1860  * Parameters       p_buff - allocated HCI command buffer including extended
   1861  *                           inquriry response
   1862  *
   1863  * Returns          BTM_SUCCESS  - if successful
   1864  *                  BTM_MODE_UNSUPPORTED - if local device cannot support it
   1865  *
   1866  ******************************************************************************/
   1867 extern tBTM_STATUS BTM_WriteEIR(BT_HDR* p_buff);
   1868 
   1869 /*******************************************************************************
   1870  *
   1871  * Function         BTM_HasEirService
   1872  *
   1873  * Description      This function is called to know if UUID in bit map of UUID.
   1874  *
   1875  * Parameters       p_eir_uuid - bit map of UUID list
   1876  *                  uuid16 - UUID 16-bit
   1877  *
   1878  * Returns          true - if found
   1879  *                  false - if not found
   1880  *
   1881  ******************************************************************************/
   1882 extern bool BTM_HasEirService(const uint32_t* p_eir_uuid, uint16_t uuid16);
   1883 
   1884 /*******************************************************************************
   1885  *
   1886  * Function         BTM_HasInquiryEirService
   1887  *
   1888  * Description      Return if a UUID is in the bit map of a UUID list.
   1889  *
   1890  * Parameters       p_results - inquiry results
   1891  *                  uuid16 - UUID 16-bit
   1892  *
   1893  * Returns          BTM_EIR_FOUND - if found
   1894  *                  BTM_EIR_NOT_FOUND - if not found and it is a complete list
   1895  *                  BTM_EIR_UNKNOWN - if not found and it is not complete list
   1896  *
   1897  ******************************************************************************/
   1898 extern tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService(
   1899     tBTM_INQ_RESULTS* p_results, uint16_t uuid16);
   1900 
   1901 /*******************************************************************************
   1902  *
   1903  * Function         BTM_AddEirService
   1904  *
   1905  * Description      This function is called to add a service in the bit map UUID
   1906  *                  list.
   1907  *
   1908  * Parameters       p_eir_uuid - bit mask of UUID list for EIR
   1909  *                  uuid16 - UUID 16-bit
   1910  *
   1911  * Returns          None
   1912  *
   1913  ******************************************************************************/
   1914 extern void BTM_AddEirService(uint32_t* p_eir_uuid, uint16_t uuid16);
   1915 
   1916 /*******************************************************************************
   1917  *
   1918  * Function         BTM_RemoveEirService
   1919  *
   1920  * Description      This function is called to remove a service from the bit map
   1921  *                  UUID list.
   1922  *
   1923  * Parameters       p_eir_uuid - bit mask of UUID list for EIR
   1924  *                  uuid16 - UUID 16-bit
   1925  *
   1926  * Returns          None
   1927  *
   1928  ******************************************************************************/
   1929 extern void BTM_RemoveEirService(uint32_t* p_eir_uuid, uint16_t uuid16);
   1930 
   1931 /*******************************************************************************
   1932  *
   1933  * Function         BTM_GetEirSupportedServices
   1934  *
   1935  * Description      This function is called to get UUID list from bit map UUID
   1936  *                  list.
   1937  *
   1938  * Parameters       p_eir_uuid - bit mask of UUID list for EIR
   1939  *                  p - reference of current pointer of EIR
   1940  *                  max_num_uuid16 - max number of UUID can be written in EIR
   1941  *                  num_uuid16 - number of UUID have been written in EIR
   1942  *
   1943  * Returns          BTM_EIR_MORE_16BITS_UUID_TYPE, if it has more than max
   1944  *                  BTM_EIR_COMPLETE_16BITS_UUID_TYPE, otherwise
   1945  *
   1946  ******************************************************************************/
   1947 extern uint8_t BTM_GetEirSupportedServices(uint32_t* p_eir_uuid, uint8_t** p,
   1948                                            uint8_t max_num_uuid16,
   1949                                            uint8_t* p_num_uuid16);
   1950 
   1951 /*******************************************************************************
   1952  *
   1953  * Function         BTM_GetEirUuidList
   1954  *
   1955  * Description      This function parses EIR and returns UUID list.
   1956  *
   1957  * Parameters       p_eir - EIR
   1958  *                  eirl_len - EIR len
   1959  *                  uuid_size - Uuid::kNumBytes16, Uuid::kNumBytes32,
   1960  *                              Uuid::kNumBytes128
   1961  *                  p_num_uuid - return number of UUID in found list
   1962  *                  p_uuid_list - return UUID 16-bit list
   1963  *                  max_num_uuid - maximum number of UUID to be returned
   1964  *
   1965  * Returns          0 - if not found
   1966  *                  BTM_EIR_COMPLETE_16BITS_UUID_TYPE
   1967  *                  BTM_EIR_MORE_16BITS_UUID_TYPE
   1968  *                  BTM_EIR_COMPLETE_32BITS_UUID_TYPE
   1969  *                  BTM_EIR_MORE_32BITS_UUID_TYPE
   1970  *                  BTM_EIR_COMPLETE_128BITS_UUID_TYPE
   1971  *                  BTM_EIR_MORE_128BITS_UUID_TYPE
   1972  *
   1973  ******************************************************************************/
   1974 extern uint8_t BTM_GetEirUuidList(uint8_t* p_eir, size_t eir_len,
   1975                                   uint8_t uuid_size, uint8_t* p_num_uuid,
   1976                                   uint8_t* p_uuid_list, uint8_t max_num_uuid);
   1977 
   1978 /*****************************************************************************
   1979  *  SCO OVER HCI
   1980  ****************************************************************************/
   1981 /*******************************************************************************
   1982  *
   1983  * Function         BTM_ConfigScoPath
   1984  *
   1985  * Description      This function enable/disable SCO over HCI and registers SCO
   1986  *                  data callback if SCO over HCI is enabled.
   1987  *
   1988  * Parameter        path: SCO or HCI
   1989  *                  p_sco_data_cb: callback function or SCO data if path is set
   1990  *                                 to transport.
   1991  *                  p_pcm_param: pointer to the PCM interface parameter. If a
   1992  *                               NULL pointer is used, the PCM parameter
   1993  *                               maintained in the control block will be used;
   1994  *                               otherwise update the control block value.
   1995  *                  err_data_rpt: Lisbon feature to enable the erronous data
   1996  *                                report or not.
   1997  *
   1998  * Returns          BTM_SUCCESS if the successful.
   1999  *                  BTM_NO_RESOURCES: no rsource to start the command.
   2000  *                  BTM_ILLEGAL_VALUE: invalid callback function pointer.
   2001  *                  BTM_CMD_STARTED : Command sent. Waiting for command
   2002  *                                    complete event.
   2003  *
   2004  *
   2005  ******************************************************************************/
   2006 extern tBTM_STATUS BTM_ConfigScoPath(esco_data_path_t path,
   2007                                      tBTM_SCO_DATA_CB* p_sco_data_cb,
   2008                                      tBTM_SCO_PCM_PARAM* p_pcm_param,
   2009                                      bool err_data_rpt);
   2010 
   2011 /*******************************************************************************
   2012  *
   2013  * Function         BTM_WriteScoData
   2014  *
   2015  * Description      This function write SCO data to a specified instance. The
   2016  *                  data to be written p_buf needs to carry an offset of
   2017  *                  HCI_SCO_PREAMBLE_SIZE bytes, and the data length can not
   2018  *                  exceed BTM_SCO_DATA_SIZE_MAX bytes, whose default value is
   2019  *                  set to 60 and is configurable. Data longer than the maximum
   2020  *                  bytes will be truncated.
   2021  *
   2022  * Returns          BTM_SUCCESS: data write is successful
   2023  *                  BTM_ILLEGAL_VALUE: SCO data contains illegal offset value.
   2024  *                  BTM_SCO_BAD_LENGTH: SCO data length exceeds the max SCO
   2025  *                                      packet size.
   2026  *                  BTM_NO_RESOURCES: no resources.
   2027  *                  BTM_UNKNOWN_ADDR: unknown SCO connection handle, or SCO is
   2028  *                                    not routed via HCI.
   2029  *
   2030  *
   2031  ******************************************************************************/
   2032 extern tBTM_STATUS BTM_WriteScoData(uint16_t sco_inx, BT_HDR* p_buf);
   2033 
   2034 /*******************************************************************************
   2035  *
   2036  * Function         BTM_SetARCMode
   2037  *
   2038  * Description      Send Audio Routing Control command.
   2039  *
   2040  * Returns          void
   2041  *
   2042  ******************************************************************************/
   2043 extern void BTM_SetARCMode(uint8_t iface, uint8_t arc_mode,
   2044                            tBTM_VSC_CMPL_CB* p_arc_cb);
   2045 
   2046 /*******************************************************************************
   2047  *
   2048  * Function         BTM_PCM2Setup_Write
   2049  *
   2050  * Description      Send PCM2_Setup write command.
   2051  *
   2052  * Returns          void
   2053  *
   2054  ******************************************************************************/
   2055 extern void BTM_PCM2Setup_Write(bool clk_master, tBTM_VSC_CMPL_CB* p_arc_cb);
   2056 
   2057 /*******************************************************************************
   2058  *
   2059  * Function         BTM_PM_ReadControllerState
   2060  *
   2061  * Description      This function is called to obtain the controller state
   2062  *
   2063  * Returns          Controller state (BTM_CONTRL_ACTIVE, BTM_CONTRL_SCAN, and
   2064  *                                    BTM_CONTRL_IDLE)
   2065  *
   2066  ******************************************************************************/
   2067 extern tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void);
   2068 
   2069 #endif /* BTM_API_H */
   2070