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