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_BLE_API_H
     26 #define BTM_BLE_API_H
     27 
     28 #include <base/callback_forward.h>
     29 #include <hardware/bt_common_types.h>
     30 #include <memory>
     31 #include "bt_common.h"
     32 #include "btm_api.h"
     33 #include "btm_ble_api_types.h"
     34 #include "osi/include/alarm.h"
     35 
     36 /*****************************************************************************
     37  *  EXTERNAL FUNCTION DECLARATIONS
     38  ****************************************************************************/
     39 /*******************************************************************************
     40  *
     41  * Function         BTM_SecAddBleDevice
     42  *
     43  * Description      Add/modify device.  This function will be normally called
     44  *                  during host startup to restore all required information
     45  *                  for a LE device stored in the NVRAM.
     46  *
     47  * Parameters:      bd_addr          - BD address of the peer
     48  *                  bd_name          - Name of the peer device. NULL if unknown.
     49  *                  dev_type         - Remote device's device type.
     50  *                  addr_type        - LE device address type.
     51  *
     52  * Returns          true if added OK, else false
     53  *
     54  ******************************************************************************/
     55 extern bool BTM_SecAddBleDevice(const RawAddress& bd_addr, BD_NAME bd_name,
     56                                 tBT_DEVICE_TYPE dev_type,
     57                                 tBLE_ADDR_TYPE addr_type);
     58 
     59 /*******************************************************************************
     60  *
     61  * Function         BTM_SecAddBleKey
     62  *
     63  * Description      Add/modify LE device information.  This function will be
     64  *                  normally called during host startup to restore all required
     65  *                  information stored in the NVRAM.
     66  *
     67  * Parameters:      bd_addr          - BD address of the peer
     68  *                  p_le_key         - LE key values.
     69  *                  key_type         - LE SMP key type.
     70 *
     71  * Returns          true if added OK, else false
     72  *
     73  ******************************************************************************/
     74 extern bool BTM_SecAddBleKey(const RawAddress& bd_addr,
     75                              tBTM_LE_KEY_VALUE* p_le_key,
     76                              tBTM_LE_KEY_TYPE key_type);
     77 
     78 /*******************************************************************************
     79  *
     80  * Function         BTM_BleSetAdvParams
     81  *
     82  * Description      This function is called to set advertising parameters.
     83  *
     84  * Parameters:       None.
     85  *
     86  * Returns          void
     87  *
     88  ******************************************************************************/
     89 extern tBTM_STATUS BTM_BleSetAdvParams(uint16_t adv_int_min,
     90                                        uint16_t adv_int_max,
     91                                        tBLE_BD_ADDR* p_dir_bda,
     92                                        tBTM_BLE_ADV_CHNL_MAP chnl_map);
     93 
     94 /*******************************************************************************
     95  *
     96  * Function         BTM_BleObtainVendorCapabilities
     97  *
     98  * Description      This function is called to obatin vendor capabilties
     99  *
    100  * Parameters       p_cmn_vsc_cb - Returns the vednor capabilities
    101  *
    102  * Returns          void
    103  *
    104  ******************************************************************************/
    105 extern void BTM_BleObtainVendorCapabilities(tBTM_BLE_VSC_CB* p_cmn_vsc_cb);
    106 
    107 /**
    108  * This function is called to set scan parameters. |cb| is called with operation
    109  * status
    110  **/
    111 extern void BTM_BleSetScanParams(uint32_t scan_interval, uint32_t scan_window,
    112                                  tBLE_SCAN_MODE scan_type,
    113                                  base::Callback<void(uint8_t)> cb);
    114 
    115 /*******************************************************************************
    116  *
    117  * Function         BTM_BleGetVendorCapabilities
    118  *
    119  * Description      This function reads local LE features
    120  *
    121  * Parameters       p_cmn_vsc_cb : Locala LE capability structure
    122  *
    123  * Returns          void
    124  *
    125  ******************************************************************************/
    126 extern void BTM_BleGetVendorCapabilities(tBTM_BLE_VSC_CB* p_cmn_vsc_cb);
    127 /*******************************************************************************
    128  *
    129  * Function         BTM_BleSetStorageConfig
    130  *
    131  * Description      This function is called to setup storage configuration and
    132  *                  setup callbacks.
    133  *
    134  * Parameters       uint8_t batch_scan_full_max -Batch scan full maximum
    135                     uint8_t batch_scan_trunc_max - Batch scan truncated value
    136  maximum
    137                     uint8_t batch_scan_notify_threshold - Threshold value
    138                     cb - Setup callback
    139                     tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback -Threshold
    140  callback
    141                     void *p_ref - Reference value
    142  *
    143  *
    144  ******************************************************************************/
    145 extern void BTM_BleSetStorageConfig(
    146     uint8_t batch_scan_full_max, uint8_t batch_scan_trunc_max,
    147     uint8_t batch_scan_notify_threshold,
    148     base::Callback<void(uint8_t /* status */)> cb,
    149     tBTM_BLE_SCAN_THRESHOLD_CBACK* p_thres_cback, tBTM_BLE_REF_VALUE ref_value);
    150 
    151 /* This function is called to enable batch scan */
    152 extern void BTM_BleEnableBatchScan(
    153     tBTM_BLE_BATCH_SCAN_MODE scan_mode, uint32_t scan_interval,
    154     uint32_t scan_window, tBTM_BLE_DISCARD_RULE discard_rule,
    155     tBLE_ADDR_TYPE addr_type, base::Callback<void(uint8_t /* status */)> cb);
    156 
    157 /* This function is called to disable batch scanning */
    158 extern void BTM_BleDisableBatchScan(
    159     base::Callback<void(uint8_t /* status */)> cb);
    160 
    161 /* This function is called to read batch scan reports */
    162 extern void BTM_BleReadScanReports(tBLE_SCAN_MODE scan_mode,
    163                                    tBTM_BLE_SCAN_REP_CBACK cb);
    164 
    165 /* This function is called to setup the callback for tracking */
    166 extern void BTM_BleTrackAdvertiser(tBTM_BLE_TRACK_ADV_CBACK* p_track_cback,
    167                                    tBTM_BLE_REF_VALUE ref_value);
    168 
    169 /*******************************************************************************
    170  *
    171  * Function         BTM_BleWriteScanRsp
    172  *
    173  * Description      This function is called to write LE scan response.
    174  *
    175  * Parameters:      p_scan_rsp: scan response.
    176  *
    177  * Returns          status
    178  *
    179  ******************************************************************************/
    180 extern void BTM_BleWriteScanRsp(uint8_t* data, uint8_t length,
    181                                 tBTM_BLE_ADV_DATA_CMPL_CBACK* p_adv_data_cback);
    182 
    183 /*******************************************************************************
    184  *
    185  * Function         BTM_BleObserve
    186  *
    187  * Description      This procedure keep the device listening for advertising
    188  *                  events from a broadcast device.
    189  *
    190  * Parameters       start: start or stop observe.
    191  *
    192  * Returns          void
    193  *
    194  ******************************************************************************/
    195 extern tBTM_STATUS BTM_BleObserve(bool start, uint8_t duration,
    196                                   tBTM_INQ_RESULTS_CB* p_results_cb,
    197                                   tBTM_CMPL_CB* p_cmpl_cb);
    198 
    199 /*******************************************************************************
    200  *
    201  * Function         BTM_GetDeviceIDRoot
    202  *
    203  * Description      This function is called to read the local device identity
    204  *                  root.
    205  *
    206  * Returns          void
    207  *                  the local device ER is copied into er
    208  *
    209  ******************************************************************************/
    210 extern void BTM_GetDeviceIDRoot(BT_OCTET16 ir);
    211 
    212 /*******************************************************************************
    213  *
    214  * Function         BTM_GetDeviceEncRoot
    215  *
    216  * Description      This function is called to read the local device encryption
    217  *                  root.
    218  *
    219  * Returns          void
    220  *                  the local device ER is copied into er
    221  *
    222  ******************************************************************************/
    223 extern void BTM_GetDeviceEncRoot(BT_OCTET16 er);
    224 
    225 /*******************************************************************************
    226  *
    227  * Function         BTM_GetDeviceDHK
    228  *
    229  * Description      This function is called to read the local device DHK.
    230  *
    231  * Returns          void
    232  *                  the local device DHK is copied into dhk
    233  *
    234  ******************************************************************************/
    235 extern void BTM_GetDeviceDHK(BT_OCTET16 dhk);
    236 
    237 /*******************************************************************************
    238  *
    239  * Function         BTM_SecurityGrant
    240  *
    241  * Description      This function is called to grant security process.
    242  *
    243  * Parameters       bd_addr - peer device bd address.
    244  *                  res     - result of the operation BTM_SUCCESS if success.
    245  *                            Otherwise, BTM_REPEATED_ATTEMPTS is too many
    246  *                            attempts.
    247  *
    248  * Returns          None
    249  *
    250  ******************************************************************************/
    251 extern void BTM_SecurityGrant(const RawAddress& bd_addr, uint8_t res);
    252 
    253 /*******************************************************************************
    254  *
    255  * Function         BTM_BlePasskeyReply
    256  *
    257  * Description      This function is called after Security Manager submitted
    258  *                  passkey request to the application.
    259  *
    260  * Parameters:      bd_addr - Address of the device for which passkey was
    261  *                            requested
    262  *                  res     - result of the operation SMP_SUCCESS if success
    263  *                  passkey - numeric value in the range of
    264  *                               BTM_MIN_PASSKEY_VAL(0) -
    265  *                               BTM_MAX_PASSKEY_VAL(999999(0xF423F)).
    266  *
    267  ******************************************************************************/
    268 extern void BTM_BlePasskeyReply(const RawAddress& bd_addr, uint8_t res,
    269                                 uint32_t passkey);
    270 
    271 /*******************************************************************************
    272  *
    273  * Function         BTM_BleConfirmReply
    274  *
    275  * Description      This function is called after Security Manager submitted
    276  *                  numeric comparison request to the application.
    277  *
    278  * Parameters:      bd_addr      - Address of the device with which numeric
    279  *                                 comparison was requested
    280  *                  res          - comparison result BTM_SUCCESS if success
    281  *
    282  ******************************************************************************/
    283 extern void BTM_BleConfirmReply(const RawAddress& bd_addr, uint8_t res);
    284 
    285 /*******************************************************************************
    286  *
    287  * Function         BTM_LeOobDataReply
    288  *
    289  * Description      This function is called to provide the OOB data for
    290  *                  SMP in response to BTM_LE_OOB_REQ_EVT
    291  *
    292  * Parameters:      bd_addr     - Address of the peer device
    293  *                  res         - result of the operation SMP_SUCCESS if success
    294  *                  p_data      - simple pairing Randomizer  C.
    295  *
    296  ******************************************************************************/
    297 extern void BTM_BleOobDataReply(const RawAddress& bd_addr, uint8_t res,
    298                                 uint8_t len, uint8_t* p_data);
    299 
    300 /*******************************************************************************
    301  *
    302  * Function         BTM_BleSecureConnectionOobDataReply
    303  *
    304  * Description      This function is called to provide the OOB data for
    305  *                  SMP in response to BTM_LE_OOB_REQ_EVT when secure connection
    306  *                  data is available
    307  *
    308  * Parameters:      bd_addr     - Address of the peer device
    309  *                  p_c         - pointer to Confirmation
    310  *                  p_r         - pointer to Randomizer.
    311  *
    312  ******************************************************************************/
    313 extern void BTM_BleSecureConnectionOobDataReply(const RawAddress& bd_addr,
    314                                                 uint8_t* p_c, uint8_t* p_r);
    315 
    316 /*******************************************************************************
    317  *
    318  * Function         BTM_BleDataSignature
    319  *
    320  * Description      This function is called to sign the data using AES128 CMAC
    321  *                  algorith.
    322  *
    323  * Parameter        bd_addr: target device the data to be signed for.
    324  *                  p_text: singing data
    325  *                  len: length of the signing data
    326  *                  signature: output parameter where data signature is going to
    327  *                             be stored.
    328  *
    329  * Returns          true if signing sucessul, otherwise false.
    330  *
    331  ******************************************************************************/
    332 extern bool BTM_BleDataSignature(const RawAddress& bd_addr, uint8_t* p_text,
    333                                  uint16_t len, BLE_SIGNATURE signature);
    334 
    335 /*******************************************************************************
    336  *
    337  * Function         BTM_BleVerifySignature
    338  *
    339  * Description      This function is called to verify the data signature
    340  *
    341  * Parameter        bd_addr: target device the data to be signed for.
    342  *                  p_orig:  original data before signature.
    343  *                  len: length of the signing data
    344  *                  counter: counter used when doing data signing
    345  *                  p_comp: signature to be compared against.
    346 
    347  * Returns          true if signature verified correctly; otherwise false.
    348  *
    349  ******************************************************************************/
    350 extern bool BTM_BleVerifySignature(const RawAddress& bd_addr, uint8_t* p_orig,
    351                                    uint16_t len, uint32_t counter,
    352                                    uint8_t* p_comp);
    353 
    354 /*******************************************************************************
    355  *
    356  * Function         BTM_ReadConnectionAddr
    357  *
    358  * Description      Read the local device random address.
    359  *
    360  * Returns          void
    361  *
    362  ******************************************************************************/
    363 extern void BTM_ReadConnectionAddr(const RawAddress& remote_bda,
    364                                    RawAddress& local_conn_addr,
    365                                    tBLE_ADDR_TYPE* p_addr_type);
    366 
    367 /*******************************************************************************
    368  *
    369  * Function         BTM_ReadRemoteConnectionAddr
    370  *
    371  * Description      Read the remote device address currently used.
    372  *
    373  * Returns          void
    374  *
    375  ******************************************************************************/
    376 extern bool BTM_ReadRemoteConnectionAddr(const RawAddress& pseudo_addr,
    377                                          RawAddress& conn_addr,
    378                                          tBLE_ADDR_TYPE* p_addr_type);
    379 
    380 /*******************************************************************************
    381  *
    382  * Function         BTM_BleLoadLocalKeys
    383  *
    384  * Description      Local local identity key, encryption root or sign counter.
    385  *
    386  * Parameters:      key_type: type of key, can be BTM_BLE_KEY_TYPE_ID,
    387  *                            BTM_BLE_KEY_TYPE_ER
    388  *                            or BTM_BLE_KEY_TYPE_COUNTER.
    389  *                  p_key: pointer to the key.
    390 *
    391  * Returns          non2.
    392  *
    393  ******************************************************************************/
    394 extern void BTM_BleLoadLocalKeys(uint8_t key_type, tBTM_BLE_LOCAL_KEYS* p_key);
    395 
    396 /**
    397  * Set BLE connectable mode to auto connect
    398  */
    399 extern void BTM_BleStartAutoConn();
    400 
    401 /*******************************************************************************
    402  *
    403  * Function         BTM_BleUpdateBgConnDev
    404  *
    405  * Description      This function is called to add or remove a device into/from
    406  *                  background connection procedure. The background connection
    407 *                   procedure is decided by the background connection type, it
    408 *can be
    409 *                   auto connection, or selective connection.
    410  *
    411  * Parameters       add_remove: true to add; false to remove.
    412  *                  remote_bda: device address to add/remove.
    413  *
    414  * Returns          void
    415  *
    416  ******************************************************************************/
    417 extern bool BTM_BleUpdateBgConnDev(bool add_remove,
    418                                    const RawAddress& remote_bda);
    419 
    420 /*******************************************************************************
    421  *
    422  * Function         BTM_BleClearBgConnDev
    423  *
    424  * Description      This function is called to clear the whitelist,
    425  *                  end any pending whitelist connections,
    426  *                  and reset the local bg device list.
    427  *
    428  * Parameters       void
    429  *
    430  * Returns          void
    431  *
    432  ******************************************************************************/
    433 extern void BTM_BleClearBgConnDev(void);
    434 
    435 /********************************************************
    436  *
    437  * Function         BTM_BleSetPrefConnParams
    438  *
    439  * Description      Set a peripheral's preferred connection parameters. When
    440  *                  any of the value does not want to be updated while others
    441  *                  do, use BTM_BLE_CONN_PARAM_UNDEF for the ones want to
    442  *                  leave untouched.
    443  *
    444  * Parameters:      bd_addr          - BD address of the peripheral
    445  *                  min_conn_int     - minimum preferred connection interval
    446  *                  max_conn_int     - maximum preferred connection interval
    447  *                  slave_latency    - preferred slave latency
    448  *                  supervision_tout - preferred supervision timeout
    449  *
    450  * Returns          void
    451  *
    452  ******************************************************************************/
    453 extern void BTM_BleSetPrefConnParams(const RawAddress& bd_addr,
    454                                      uint16_t min_conn_int,
    455                                      uint16_t max_conn_int,
    456                                      uint16_t slave_latency,
    457                                      uint16_t supervision_tout);
    458 
    459 /******************************************************************************
    460  *
    461  * Function         BTM_BleSetConnScanParams
    462  *
    463  * Description      Set scan parameters used in BLE connection request
    464  *
    465  * Parameters:      scan_interval    - scan interval
    466  *                  scan_window      - scan window
    467  *
    468  * Returns          void
    469  *
    470  ******************************************************************************/
    471 extern void BTM_BleSetConnScanParams(uint32_t scan_interval,
    472                                      uint32_t scan_window);
    473 
    474 /******************************************************************************
    475  *
    476  * Function         BTM_BleReadControllerFeatures
    477  *
    478  * Description      Reads BLE specific controller features
    479  *
    480  * Parameters:      tBTM_BLE_CTRL_FEATURES_CBACK : Callback to notify when
    481  *                  features are read
    482  *
    483  * Returns          void
    484  *
    485  ******************************************************************************/
    486 extern void BTM_BleReadControllerFeatures(
    487     tBTM_BLE_CTRL_FEATURES_CBACK* p_vsc_cback);
    488 
    489 /*******************************************************************************
    490  *
    491  * Function         BTM__BLEReadDiscoverability
    492  *
    493  * Description      This function is called to read the current LE
    494  *                  discoverability mode of the device.
    495  *
    496  * Returns          BTM_BLE_NON_DISCOVERABLE ,BTM_BLE_LIMITED_DISCOVERABLE or
    497  *                     BTM_BLE_GENRAL_DISCOVERABLE
    498  *
    499  ******************************************************************************/
    500 uint16_t BTM_BleReadDiscoverability();
    501 
    502 /*******************************************************************************
    503  *
    504  * Function         BTM__BLEReadConnectability
    505  *
    506  * Description      This function is called to read the current LE
    507  *                  connectibility mode of the device.
    508  *
    509  * Returns          BTM_BLE_NON_CONNECTABLE or BTM_BLE_CONNECTABLE
    510  *
    511  ******************************************************************************/
    512 extern uint16_t BTM_BleReadConnectability();
    513 
    514 /*******************************************************************************
    515  *
    516  * Function         BTM_ReadDevInfo
    517  *
    518  * Description      This function is called to read the device/address type
    519  *                  of BD address.
    520  *
    521  * Parameter        remote_bda: remote device address
    522  *                  p_dev_type: output parameter to read the device type.
    523  *                  p_addr_type: output parameter to read the address type.
    524  *
    525  ******************************************************************************/
    526 extern void BTM_ReadDevInfo(const RawAddress& remote_bda,
    527                             tBT_DEVICE_TYPE* p_dev_type,
    528                             tBLE_ADDR_TYPE* p_addr_type);
    529 
    530 /*******************************************************************************
    531  *
    532  * Function         BTM_ReadConnectedTransportAddress
    533  *
    534  * Description      This function is called to read the paired device/address
    535  *                  type of other device paired corresponding to the BD_address
    536  *
    537  * Parameter        remote_bda: remote device address, carry out the transport
    538  *                              address
    539  *                  transport: active transport
    540  *
    541  * Return           true if an active link is identified; false otherwise
    542  *
    543  ******************************************************************************/
    544 extern bool BTM_ReadConnectedTransportAddress(RawAddress* remote_bda,
    545                                               tBT_TRANSPORT transport);
    546 
    547 /*******************************************************************************
    548  *
    549  * Function         BTM_BleConfigPrivacy
    550  *
    551  * Description      This function is called to enable or disable the privacy in
    552  *                  the local device.
    553  *
    554  * Parameters       enable: true to enable it; false to disable it.
    555  *
    556  * Returns          bool    privacy mode set success; otherwise failed.
    557  *
    558  ******************************************************************************/
    559 extern bool BTM_BleConfigPrivacy(bool enable);
    560 
    561 /*******************************************************************************
    562  *
    563  * Function         BTM_BleLocalPrivacyEnabled
    564  *
    565  * Description        Checks if local device supports private address
    566  *
    567  * Returns          Return true if local privacy is enabled else false
    568  *
    569  ******************************************************************************/
    570 extern bool BTM_BleLocalPrivacyEnabled(void);
    571 
    572 /*******************************************************************************
    573  *
    574  * Function         BTM_BleEnableMixedPrivacyMode
    575  *
    576  * Description      This function is called to enabled Mixed mode if privacy 1.2
    577  *                  is applicable in controller.
    578  *
    579  * Parameters       mixed_on:  mixed mode to be used or not.
    580  *
    581  * Returns          void
    582  *
    583  ******************************************************************************/
    584 extern void BTM_BleEnableMixedPrivacyMode(bool mixed_on);
    585 
    586 /*******************************************************************************
    587  *
    588  * Function          BTM_BleMaxMultiAdvInstanceCount
    589  *
    590  * Description      Returns the maximum number of multi adv instances supported
    591  *                  by the controller.
    592  *
    593  * Returns          Max multi adv instance count
    594  *
    595  ******************************************************************************/
    596 extern uint8_t BTM_BleMaxMultiAdvInstanceCount();
    597 
    598 /*******************************************************************************
    599  *
    600  * Function         BTM_BleSetConnectableMode
    601  *
    602  * Description      This function is called to set BLE connectable mode for a
    603  *                  peripheral device.
    604  *
    605  * Parameters       connectable_mode:  directed connectable mode, or
    606  *                                     non-directed. It can be
    607  *                                     BTM_BLE_CONNECT_EVT,
    608  *                                     BTM_BLE_CONNECT_DIR_EVT or
    609  *                                     BTM_BLE_CONNECT_LO_DUTY_DIR_EVT
    610  *
    611  * Returns          BTM_ILLEGAL_VALUE if controller does not support BLE.
    612  *                  BTM_SUCCESS is status set successfully; otherwise failure.
    613  *
    614  ******************************************************************************/
    615 extern tBTM_STATUS BTM_BleSetConnectableMode(
    616     tBTM_BLE_CONN_MODE connectable_mode);
    617 
    618 /*******************************************************************************
    619  *
    620  * Function         BTM_BleTurnOnPrivacyOnRemote
    621  *
    622  * Description      This function is called to enable or disable the privacy on
    623  *                  the remote device.
    624  *
    625  * Parameters       bd_addr: remote device address.
    626  *                  privacy_on: true to enable it; false to disable it.
    627  *
    628  * Returns          void
    629  *
    630  ******************************************************************************/
    631 extern void BTM_BleTurnOnPrivacyOnRemote(const RawAddress& bd_addr,
    632                                          bool privacy_on);
    633 
    634 /*******************************************************************************
    635  *
    636  * Function         BTM_BleUpdateAdvFilterPolicy
    637  *
    638  * Description      This function update the filter policy of advertiser.
    639  *
    640  * Parameter        adv_policy: advertising filter policy
    641  *
    642  * Return           void
    643  ******************************************************************************/
    644 extern void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy);
    645 
    646 /*******************************************************************************
    647  *
    648  * Function         BTM_BleReceiverTest
    649  *
    650  * Description      This function is called to start the LE Receiver test
    651  *
    652  * Parameter       rx_freq - Frequency Range
    653  *               p_cmd_cmpl_cback - Command Complete callback
    654  *
    655  ******************************************************************************/
    656 void BTM_BleReceiverTest(uint8_t rx_freq, tBTM_CMPL_CB* p_cmd_cmpl_cback);
    657 
    658 /*******************************************************************************
    659  *
    660  * Function         BTM_BleTransmitterTest
    661  *
    662  * Description      This function is called to start the LE Transmitter test
    663  *
    664  * Parameter       tx_freq - Frequency Range
    665  *                       test_data_len - Length in bytes of payload data in each
    666  *                                       packet
    667  *                       packet_payload - Pattern to use in the payload
    668  *                       p_cmd_cmpl_cback - Command Complete callback
    669  *
    670  ******************************************************************************/
    671 void BTM_BleTransmitterTest(uint8_t tx_freq, uint8_t test_data_len,
    672                             uint8_t packet_payload,
    673                             tBTM_CMPL_CB* p_cmd_cmpl_cback);
    674 
    675 /*******************************************************************************
    676  *
    677  * Function         BTM_BleTestEnd
    678  *
    679  * Description     This function is called to stop the in-progress TX or RX test
    680  *
    681  * Parameter       p_cmd_cmpl_cback - Command complete callback
    682  *
    683  ******************************************************************************/
    684 void BTM_BleTestEnd(tBTM_CMPL_CB* p_cmd_cmpl_cback);
    685 
    686 /*******************************************************************************
    687  *
    688  * Function         BTM_UseLeLink
    689  *
    690  * Description      Select the underlying physical link to use.
    691  *
    692  * Returns          true to use LE, false use BR/EDR.
    693  *
    694  ******************************************************************************/
    695 extern bool BTM_UseLeLink(const RawAddress& bd_addr);
    696 
    697 /*******************************************************************************
    698  *
    699  * Function         BTM_BleStackEnable
    700  *
    701  * Description      Enable/Disable BLE functionality on stack regardless of
    702  *                  controller capability.
    703  *
    704  * Parameters:      enable: true to enable, false to disable.
    705  *
    706  * Returns          true if added OK, else false
    707  *
    708  ******************************************************************************/
    709 extern tBTM_STATUS BTM_BleStackEnable(bool enable);
    710 
    711 /*******************************************************************************
    712  *
    713  * Function         BTM_GetLeSecurityState
    714  *
    715  * Description      This function is called to get security mode 1 flags and
    716  *                  encryption key size for LE peer.
    717  *
    718  * Returns          bool    true if LE device is found, false otherwise.
    719  *
    720  ******************************************************************************/
    721 extern bool BTM_GetLeSecurityState(const RawAddress& bd_addr,
    722                                    uint8_t* p_le_dev_sec_flags,
    723                                    uint8_t* p_le_key_size);
    724 
    725 /*******************************************************************************
    726  *
    727  * Function         BTM_BleSecurityProcedureIsRunning
    728  *
    729  * Description      This function indicates if LE security procedure is
    730  *                  currently running with the peer.
    731  *
    732  * Returns          bool true if security procedure is running, false otherwise.
    733  *
    734  ******************************************************************************/
    735 extern bool BTM_BleSecurityProcedureIsRunning(const RawAddress& bd_addr);
    736 
    737 /*******************************************************************************
    738  *
    739  * Function         BTM_BleGetSupportedKeySize
    740  *
    741  * Description      This function gets the maximum encryption key size in bytes
    742  *                  the local device can suport.
    743  *                  record.
    744  *
    745  * Returns          the key size or 0 if the size can't be retrieved.
    746  *
    747  ******************************************************************************/
    748 extern uint8_t BTM_BleGetSupportedKeySize(const RawAddress& bd_addr);
    749 
    750 /*******************************************************************************
    751  *
    752  * Function         BTM_BleAdvFilterParamSetup
    753  *
    754  * Description      This function is called to setup the adv data payload filter
    755  *                  condition.
    756  *
    757  ******************************************************************************/
    758 extern void BTM_BleAdvFilterParamSetup(
    759     int action, tBTM_BLE_PF_FILT_INDEX filt_index,
    760     std::unique_ptr<btgatt_filt_param_setup_t> p_filt_params,
    761     tBTM_BLE_PF_PARAM_CB cb);
    762 
    763 /**
    764  * This functions are called to configure the adv data payload filter condition
    765  */
    766 extern void BTM_LE_PF_set(tBTM_BLE_PF_FILT_INDEX filt_index,
    767                           std::vector<ApcfCommand> commands,
    768                           tBTM_BLE_PF_CFG_CBACK cb);
    769 extern void BTM_LE_PF_clear(tBTM_BLE_PF_FILT_INDEX filt_index,
    770                             tBTM_BLE_PF_CFG_CBACK cb);
    771 
    772 /*******************************************************************************
    773  *
    774  * Function         BTM_BleEnableDisableFilterFeature
    775  *
    776  * Description      Enable or disable the APCF feature
    777  *
    778  * Parameters       enable - true - enables APCF, false - disables APCF
    779  *
    780  ******************************************************************************/
    781 extern void BTM_BleEnableDisableFilterFeature(
    782     uint8_t enable, tBTM_BLE_PF_STATUS_CBACK p_stat_cback);
    783 
    784 /*******************************************************************************
    785  *
    786  * Function         BTM_BleGetEnergyInfo
    787  *
    788  * Description      This function obtains the energy info
    789  *
    790  * Parameters       p_ener_cback - Callback pointer
    791  *
    792  * Returns          status
    793  *
    794  ******************************************************************************/
    795 extern tBTM_STATUS BTM_BleGetEnergyInfo(
    796     tBTM_BLE_ENERGY_INFO_CBACK* p_ener_cback);
    797 
    798 /*******************************************************************************
    799  *
    800  * Function         BTM_SetBleDataLength
    801  *
    802  * Description      Set the maximum BLE transmission packet size
    803  *
    804  * Returns          BTM_SUCCESS if success; otherwise failed.
    805  *
    806  ******************************************************************************/
    807 extern tBTM_STATUS BTM_SetBleDataLength(const RawAddress& bd_addr,
    808                                         uint16_t tx_pdu_length);
    809 
    810 /*******************************************************************************
    811  *
    812  * Function         BTM_BleReadPhy
    813  *
    814  * Description      To read the current PHYs for specified LE connection
    815  *
    816  *
    817  * Returns          BTM_SUCCESS if success; otherwise failed.
    818  *
    819  ******************************************************************************/
    820 extern void BTM_BleReadPhy(
    821     const RawAddress& bd_addr,
    822     base::Callback<void(uint8_t tx_phy, uint8_t rx_phy, uint8_t status)> cb);
    823 
    824 /*******************************************************************************
    825  *
    826  * Function         BTM_BleSetDefaultPhy
    827  *
    828  * Description      To set preferred PHY for ensuing LE connections
    829  *
    830  *
    831  * Returns          BTM_SUCCESS if success; otherwise failed.
    832  *
    833  ******************************************************************************/
    834 extern tBTM_STATUS BTM_BleSetDefaultPhy(uint8_t all_phys, uint8_t tx_phys,
    835                                         uint8_t rx_phys);
    836 
    837 /*******************************************************************************
    838  *
    839  * Function         BTM_BleSetPhy
    840  *
    841  * Description      To set PHY preferences for specified LE connection
    842  *
    843  *
    844  * Returns          BTM_SUCCESS if success; otherwise failed.
    845  *
    846  ******************************************************************************/
    847 extern void BTM_BleSetPhy(const RawAddress& bd_addr, uint8_t tx_phys,
    848                           uint8_t rx_phys, uint16_t phy_options);
    849 
    850 extern void btm_ble_multi_adv_cleanup(void);
    851 
    852 #endif
    853