OSDN Git Service

DO NOT MERGE Drop Bluetooth connection with weak encryption key
[android-x86/system-bt.git] / stack / include / btm_ble_api.h
1 /******************************************************************************
2  *
3  *  Copyright (C) 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_IsBleConnection
370  *
371  * Description      This function is called to check if the connection handle
372  *                  for an LE link
373  *
374  * Returns          true if connection is LE link, otherwise false.
375  *
376  ******************************************************************************/
377 extern bool BTM_IsBleConnection(uint16_t conn_handle);
378
379 /*******************************************************************************
380  *
381  * Function         BTM_ReadRemoteConnectionAddr
382  *
383  * Description      Read the remote device address currently used.
384  *
385  * Returns          void
386  *
387  ******************************************************************************/
388 extern bool BTM_ReadRemoteConnectionAddr(const RawAddress& pseudo_addr,
389                                          RawAddress& conn_addr,
390                                          tBLE_ADDR_TYPE* p_addr_type);
391
392 /*******************************************************************************
393  *
394  * Function         BTM_BleLoadLocalKeys
395  *
396  * Description      Local local identity key, encryption root or sign counter.
397  *
398  * Parameters:      key_type: type of key, can be BTM_BLE_KEY_TYPE_ID,
399  *                            BTM_BLE_KEY_TYPE_ER
400  *                            or BTM_BLE_KEY_TYPE_COUNTER.
401  *                  p_key: pointer to the key.
402 *
403  * Returns          non2.
404  *
405  ******************************************************************************/
406 extern void BTM_BleLoadLocalKeys(uint8_t key_type, tBTM_BLE_LOCAL_KEYS* p_key);
407
408 /**
409  * Set BLE connectable mode to auto connect
410  */
411 extern void BTM_BleStartAutoConn();
412
413 /*******************************************************************************
414  *
415  * Function         BTM_BleUpdateBgConnDev
416  *
417  * Description      This function is called to add or remove a device into/from
418  *                  background connection procedure. The background connection
419 *                   procedure is decided by the background connection type, it
420 *can be
421 *                   auto connection, or selective connection.
422  *
423  * Parameters       add_remove: true to add; false to remove.
424  *                  remote_bda: device address to add/remove.
425  *
426  * Returns          void
427  *
428  ******************************************************************************/
429 extern bool BTM_BleUpdateBgConnDev(bool add_remove,
430                                    const RawAddress& remote_bda);
431
432 /*******************************************************************************
433  *
434  * Function         BTM_BleClearBgConnDev
435  *
436  * Description      This function is called to clear the whitelist,
437  *                  end any pending whitelist connections,
438  *                  and reset the local bg device list.
439  *
440  * Parameters       void
441  *
442  * Returns          void
443  *
444  ******************************************************************************/
445 extern void BTM_BleClearBgConnDev(void);
446
447 /********************************************************
448  *
449  * Function         BTM_BleSetPrefConnParams
450  *
451  * Description      Set a peripheral's preferred connection parameters. When
452  *                  any of the value does not want to be updated while others
453  *                  do, use BTM_BLE_CONN_PARAM_UNDEF for the ones want to
454  *                  leave untouched.
455  *
456  * Parameters:      bd_addr          - BD address of the peripheral
457  *                  min_conn_int     - minimum preferred connection interval
458  *                  max_conn_int     - maximum preferred connection interval
459  *                  slave_latency    - preferred slave latency
460  *                  supervision_tout - preferred supervision timeout
461  *
462  * Returns          void
463  *
464  ******************************************************************************/
465 extern void BTM_BleSetPrefConnParams(const RawAddress& bd_addr,
466                                      uint16_t min_conn_int,
467                                      uint16_t max_conn_int,
468                                      uint16_t slave_latency,
469                                      uint16_t supervision_tout);
470
471 /******************************************************************************
472  *
473  * Function         BTM_BleSetConnScanParams
474  *
475  * Description      Set scan parameters used in BLE connection request
476  *
477  * Parameters:      scan_interval    - scan interval
478  *                  scan_window      - scan window
479  *
480  * Returns          void
481  *
482  ******************************************************************************/
483 extern void BTM_BleSetConnScanParams(uint32_t scan_interval,
484                                      uint32_t scan_window);
485
486 /******************************************************************************
487  *
488  * Function         BTM_BleReadControllerFeatures
489  *
490  * Description      Reads BLE specific controller features
491  *
492  * Parameters:      tBTM_BLE_CTRL_FEATURES_CBACK : Callback to notify when
493  *                  features are read
494  *
495  * Returns          void
496  *
497  ******************************************************************************/
498 extern void BTM_BleReadControllerFeatures(
499     tBTM_BLE_CTRL_FEATURES_CBACK* p_vsc_cback);
500
501 /*******************************************************************************
502  *
503  * Function         BTM__BLEReadDiscoverability
504  *
505  * Description      This function is called to read the current LE
506  *                  discoverability mode of the device.
507  *
508  * Returns          BTM_BLE_NON_DISCOVERABLE ,BTM_BLE_LIMITED_DISCOVERABLE or
509  *                     BTM_BLE_GENRAL_DISCOVERABLE
510  *
511  ******************************************************************************/
512 uint16_t BTM_BleReadDiscoverability();
513
514 /*******************************************************************************
515  *
516  * Function         BTM__BLEReadConnectability
517  *
518  * Description      This function is called to read the current LE
519  *                  connectibility mode of the device.
520  *
521  * Returns          BTM_BLE_NON_CONNECTABLE or BTM_BLE_CONNECTABLE
522  *
523  ******************************************************************************/
524 extern uint16_t BTM_BleReadConnectability();
525
526 /*******************************************************************************
527  *
528  * Function         BTM_ReadDevInfo
529  *
530  * Description      This function is called to read the device/address type
531  *                  of BD address.
532  *
533  * Parameter        remote_bda: remote device address
534  *                  p_dev_type: output parameter to read the device type.
535  *                  p_addr_type: output parameter to read the address type.
536  *
537  ******************************************************************************/
538 extern void BTM_ReadDevInfo(const RawAddress& remote_bda,
539                             tBT_DEVICE_TYPE* p_dev_type,
540                             tBLE_ADDR_TYPE* p_addr_type);
541
542 /*******************************************************************************
543  *
544  * Function         BTM_ReadConnectedTransportAddress
545  *
546  * Description      This function is called to read the paired device/address
547  *                  type of other device paired corresponding to the BD_address
548  *
549  * Parameter        remote_bda: remote device address, carry out the transport
550  *                              address
551  *                  transport: active transport
552  *
553  * Return           true if an active link is identified; false otherwise
554  *
555  ******************************************************************************/
556 extern bool BTM_ReadConnectedTransportAddress(RawAddress* remote_bda,
557                                               tBT_TRANSPORT transport);
558
559 /*******************************************************************************
560  *
561  * Function         BTM_BleConfigPrivacy
562  *
563  * Description      This function is called to enable or disable the privacy in
564  *                  the local device.
565  *
566  * Parameters       enable: true to enable it; false to disable it.
567  *
568  * Returns          bool    privacy mode set success; otherwise failed.
569  *
570  ******************************************************************************/
571 extern bool BTM_BleConfigPrivacy(bool enable);
572
573 /*******************************************************************************
574  *
575  * Function         BTM_BleLocalPrivacyEnabled
576  *
577  * Description        Checks if local device supports private address
578  *
579  * Returns          Return true if local privacy is enabled else false
580  *
581  ******************************************************************************/
582 extern bool BTM_BleLocalPrivacyEnabled(void);
583
584 /*******************************************************************************
585  *
586  * Function         BTM_BleEnableMixedPrivacyMode
587  *
588  * Description      This function is called to enabled Mixed mode if privacy 1.2
589  *                  is applicable in controller.
590  *
591  * Parameters       mixed_on:  mixed mode to be used or not.
592  *
593  * Returns          void
594  *
595  ******************************************************************************/
596 extern void BTM_BleEnableMixedPrivacyMode(bool mixed_on);
597
598 /*******************************************************************************
599  *
600  * Function          BTM_BleMaxMultiAdvInstanceCount
601  *
602  * Description      Returns the maximum number of multi adv instances supported
603  *                  by the controller.
604  *
605  * Returns          Max multi adv instance count
606  *
607  ******************************************************************************/
608 extern uint8_t BTM_BleMaxMultiAdvInstanceCount();
609
610 /*******************************************************************************
611  *
612  * Function         BTM_BleSetConnectableMode
613  *
614  * Description      This function is called to set BLE connectable mode for a
615  *                  peripheral device.
616  *
617  * Parameters       connectable_mode:  directed connectable mode, or
618  *                                     non-directed. It can be
619  *                                     BTM_BLE_CONNECT_EVT,
620  *                                     BTM_BLE_CONNECT_DIR_EVT or
621  *                                     BTM_BLE_CONNECT_LO_DUTY_DIR_EVT
622  *
623  * Returns          BTM_ILLEGAL_VALUE if controller does not support BLE.
624  *                  BTM_SUCCESS is status set successfully; otherwise failure.
625  *
626  ******************************************************************************/
627 extern tBTM_STATUS BTM_BleSetConnectableMode(
628     tBTM_BLE_CONN_MODE connectable_mode);
629
630 /*******************************************************************************
631  *
632  * Function         BTM_BleTurnOnPrivacyOnRemote
633  *
634  * Description      This function is called to enable or disable the privacy on
635  *                  the remote device.
636  *
637  * Parameters       bd_addr: remote device address.
638  *                  privacy_on: true to enable it; false to disable it.
639  *
640  * Returns          void
641  *
642  ******************************************************************************/
643 extern void BTM_BleTurnOnPrivacyOnRemote(const RawAddress& bd_addr,
644                                          bool privacy_on);
645
646 /*******************************************************************************
647  *
648  * Function         BTM_BleUpdateAdvFilterPolicy
649  *
650  * Description      This function update the filter policy of advertiser.
651  *
652  * Parameter        adv_policy: advertising filter policy
653  *
654  * Return           void
655  ******************************************************************************/
656 extern void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy);
657
658 /*******************************************************************************
659  *
660  * Function         BTM_BleReceiverTest
661  *
662  * Description      This function is called to start the LE Receiver test
663  *
664  * Parameter       rx_freq - Frequency Range
665  *               p_cmd_cmpl_cback - Command Complete callback
666  *
667  ******************************************************************************/
668 void BTM_BleReceiverTest(uint8_t rx_freq, tBTM_CMPL_CB* p_cmd_cmpl_cback);
669
670 /*******************************************************************************
671  *
672  * Function         BTM_BleTransmitterTest
673  *
674  * Description      This function is called to start the LE Transmitter test
675  *
676  * Parameter       tx_freq - Frequency Range
677  *                       test_data_len - Length in bytes of payload data in each
678  *                                       packet
679  *                       packet_payload - Pattern to use in the payload
680  *                       p_cmd_cmpl_cback - Command Complete callback
681  *
682  ******************************************************************************/
683 void BTM_BleTransmitterTest(uint8_t tx_freq, uint8_t test_data_len,
684                             uint8_t packet_payload,
685                             tBTM_CMPL_CB* p_cmd_cmpl_cback);
686
687 /*******************************************************************************
688  *
689  * Function         BTM_BleTestEnd
690  *
691  * Description     This function is called to stop the in-progress TX or RX test
692  *
693  * Parameter       p_cmd_cmpl_cback - Command complete callback
694  *
695  ******************************************************************************/
696 void BTM_BleTestEnd(tBTM_CMPL_CB* p_cmd_cmpl_cback);
697
698 /*******************************************************************************
699  *
700  * Function         BTM_UseLeLink
701  *
702  * Description      Select the underlying physical link to use.
703  *
704  * Returns          true to use LE, false use BR/EDR.
705  *
706  ******************************************************************************/
707 extern bool BTM_UseLeLink(const RawAddress& bd_addr);
708
709 /*******************************************************************************
710  *
711  * Function         BTM_BleStackEnable
712  *
713  * Description      Enable/Disable BLE functionality on stack regardless of
714  *                  controller capability.
715  *
716  * Parameters:      enable: true to enable, false to disable.
717  *
718  * Returns          true if added OK, else false
719  *
720  ******************************************************************************/
721 extern tBTM_STATUS BTM_BleStackEnable(bool enable);
722
723 /*******************************************************************************
724  *
725  * Function         BTM_GetLeSecurityState
726  *
727  * Description      This function is called to get security mode 1 flags and
728  *                  encryption key size for LE peer.
729  *
730  * Returns          bool    true if LE device is found, false otherwise.
731  *
732  ******************************************************************************/
733 extern bool BTM_GetLeSecurityState(const RawAddress& bd_addr,
734                                    uint8_t* p_le_dev_sec_flags,
735                                    uint8_t* p_le_key_size);
736
737 /*******************************************************************************
738  *
739  * Function         BTM_BleSecurityProcedureIsRunning
740  *
741  * Description      This function indicates if LE security procedure is
742  *                  currently running with the peer.
743  *
744  * Returns          bool true if security procedure is running, false otherwise.
745  *
746  ******************************************************************************/
747 extern bool BTM_BleSecurityProcedureIsRunning(const RawAddress& bd_addr);
748
749 /*******************************************************************************
750  *
751  * Function         BTM_BleGetSupportedKeySize
752  *
753  * Description      This function gets the maximum encryption key size in bytes
754  *                  the local device can suport.
755  *                  record.
756  *
757  * Returns          the key size or 0 if the size can't be retrieved.
758  *
759  ******************************************************************************/
760 extern uint8_t BTM_BleGetSupportedKeySize(const RawAddress& bd_addr);
761
762 /*******************************************************************************
763  *
764  * Function         BTM_BleAdvFilterParamSetup
765  *
766  * Description      This function is called to setup the adv data payload filter
767  *                  condition.
768  *
769  ******************************************************************************/
770 extern void BTM_BleAdvFilterParamSetup(
771     int action, tBTM_BLE_PF_FILT_INDEX filt_index,
772     std::unique_ptr<btgatt_filt_param_setup_t> p_filt_params,
773     tBTM_BLE_PF_PARAM_CB cb);
774
775 /**
776  * This functions are called to configure the adv data payload filter condition
777  */
778 extern void BTM_LE_PF_srvc_data(tBTM_BLE_SCAN_COND_OP action,
779                                 tBTM_BLE_PF_FILT_INDEX filt_index);
780 extern void BTM_LE_PF_addr_filter(tBTM_BLE_SCAN_COND_OP action,
781                                   tBTM_BLE_PF_FILT_INDEX filt_index,
782                                   tBLE_BD_ADDR addr, tBTM_BLE_PF_CFG_CBACK cb);
783 extern void BTM_LE_PF_local_name(tBTM_BLE_SCAN_COND_OP action,
784                                  tBTM_BLE_PF_FILT_INDEX filt_index,
785                                  std::vector<uint8_t> name,
786                                  tBTM_BLE_PF_CFG_CBACK cb);
787 extern void BTM_LE_PF_uuid_filter(tBTM_BLE_SCAN_COND_OP action,
788                                   tBTM_BLE_PF_FILT_INDEX filt_index,
789                                   tBTM_BLE_PF_COND_TYPE filter_type,
790                                   tBT_UUID uuid,
791                                   tBTM_BLE_PF_LOGIC_TYPE cond_logic,
792                                   tBTM_BLE_PF_COND_MASK* p_uuid_mask,
793                                   tBTM_BLE_PF_CFG_CBACK cb);
794 extern void BTM_LE_PF_manu_data(tBTM_BLE_SCAN_COND_OP action,
795                                 tBTM_BLE_PF_FILT_INDEX filt_index,
796                                 uint16_t company_id, uint16_t company_id_mask,
797                                 std::vector<uint8_t> data,
798                                 std::vector<uint8_t> data_mask,
799                                 tBTM_BLE_PF_CFG_CBACK cb);
800 extern void BTM_LE_PF_srvc_data_pattern(tBTM_BLE_SCAN_COND_OP action,
801                                         tBTM_BLE_PF_FILT_INDEX filt_index,
802                                         std::vector<uint8_t> data,
803                                         std::vector<uint8_t> data_mask,
804                                         tBTM_BLE_PF_CFG_CBACK cb);
805 extern void BTM_LE_PF_clear(tBTM_BLE_PF_FILT_INDEX filt_index,
806                             tBTM_BLE_PF_CFG_CBACK cb);
807
808 /*******************************************************************************
809  *
810  * Function         BTM_BleEnableDisableFilterFeature
811  *
812  * Description      Enable or disable the APCF feature
813  *
814  * Parameters       enable - true - enables APCF, false - disables APCF
815  *
816  ******************************************************************************/
817 extern void BTM_BleEnableDisableFilterFeature(
818     uint8_t enable, tBTM_BLE_PF_STATUS_CBACK p_stat_cback);
819
820 /*******************************************************************************
821  *
822  * Function         BTM_BleGetEnergyInfo
823  *
824  * Description      This function obtains the energy info
825  *
826  * Parameters       p_ener_cback - Callback pointer
827  *
828  * Returns          status
829  *
830  ******************************************************************************/
831 extern tBTM_STATUS BTM_BleGetEnergyInfo(
832     tBTM_BLE_ENERGY_INFO_CBACK* p_ener_cback);
833
834 /*******************************************************************************
835  *
836  * Function         BTM_SetBleDataLength
837  *
838  * Description      Set the maximum BLE transmission packet size
839  *
840  * Returns          BTM_SUCCESS if success; otherwise failed.
841  *
842  ******************************************************************************/
843 extern tBTM_STATUS BTM_SetBleDataLength(const RawAddress& bd_addr,
844                                         uint16_t tx_pdu_length);
845
846 /*******************************************************************************
847  *
848  * Function         BTM_BleReadPhy
849  *
850  * Description      To read the current PHYs for specified LE connection
851  *
852  *
853  * Returns          BTM_SUCCESS if success; otherwise failed.
854  *
855  ******************************************************************************/
856 extern void BTM_BleReadPhy(
857     const RawAddress& bd_addr,
858     base::Callback<void(uint8_t tx_phy, uint8_t rx_phy, uint8_t status)> cb);
859
860 /*******************************************************************************
861  *
862  * Function         BTM_BleSetDefaultPhy
863  *
864  * Description      To set preferred PHY for ensuing LE connections
865  *
866  *
867  * Returns          BTM_SUCCESS if success; otherwise failed.
868  *
869  ******************************************************************************/
870 extern tBTM_STATUS BTM_BleSetDefaultPhy(uint8_t all_phys, uint8_t tx_phys,
871                                         uint8_t rx_phys);
872
873 /*******************************************************************************
874  *
875  * Function         BTM_BleSetPhy
876  *
877  * Description      To set PHY preferences for specified LE connection
878  *
879  *
880  * Returns          BTM_SUCCESS if success; otherwise failed.
881  *
882  ******************************************************************************/
883 extern void BTM_BleSetPhy(const RawAddress& bd_addr, uint8_t tx_phys,
884                           uint8_t rx_phys, uint16_t phy_options);
885
886 extern void btm_ble_multi_adv_cleanup(void);
887
888 #endif