1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
|
/*
* Copyright 2019 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include "device/include/esco_parameters.h"
#include "stack/btm/btm_sec.h"
#include "stack/btm/neighbor_inquiry.h"
#include "stack/include/acl_api_types.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/bt_octets.h"
#include "stack/include/btm_api_types.h"
#include "stack/include/btm_ble_api_types.h"
#include "types/bluetooth/uuid.h"
#include "types/hci_role.h"
#include "types/raw_address.h"
namespace bluetooth {
namespace shim {
/*******************************************************************************
*
* Function BTM_StartInquiry
*
* Description This function is called to start an inquiry.
*
* Parameters: p_inqparms - pointer to the inquiry information
* mode - GENERAL or LIMITED inquiry
* duration - length in 1.28 sec intervals (If '0', the
* inquiry is CANCELLED)
* filter_cond_type - BTM_CLR_INQUIRY_FILTER,
* BTM_FILTER_COND_DEVICE_CLASS, or
* BTM_FILTER_COND_BD_ADDR
* filter_cond - value for the filter (based on
* filter_cond_type)
*
* p_results_cb - Pointer to the callback routine which gets
* called upon receipt of an inquiry result. If
* this field is NULL, the application is not
* notified.
*
* p_cmpl_cb - Pointer to the callback routine which gets
* called upon completion. If this field is
* NULL, the application is not notified when
* completed.
* Returns tBTM_STATUS
* BTM_CMD_STARTED if successfully initiated
* BTM_BUSY if already in progress
* BTM_ILLEGAL_VALUE if parameter(s) are out of range
* BTM_NO_RESOURCES if could not allocate resources to start
* the command
* BTM_WRONG_MODE if the device is not up.
*
******************************************************************************/
tBTM_STATUS BTM_StartInquiry(tBTM_INQ_RESULTS_CB* p_results_cb,
tBTM_CMPL_CB* p_cmpl_cb);
/*******************************************************************************
*
* Function BTM_SetDiscoverability
*
* Description This function is called to set the device into or out of
* discoverable mode. Discoverable mode means inquiry
* scans are enabled. If a value of '0' is entered for window
* or interval, the default values are used.
*
* Returns BTM_SUCCESS if successful
* BTM_BUSY if a setting of the filter is already in progress
* BTM_NO_RESOURCES if couldn't get a memory pool buffer
* BTM_ILLEGAL_VALUE if a bad parameter was detected
* BTM_WRONG_MODE if the device is not up.
*
******************************************************************************/
tBTM_STATUS BTM_SetDiscoverability(uint16_t inq_mode, uint16_t window,
uint16_t interval);
/*******************************************************************************
*
* Function BTM_BleObserve
*
* Description This procedure keep the device listening for advertising
* events from a broadcast device.
*
* Parameters start: start or stop observe.
*
* Returns void
*
******************************************************************************/
tBTM_STATUS BTM_BleObserve(bool start, uint8_t duration,
tBTM_INQ_RESULTS_CB* p_results_cb,
tBTM_CMPL_CB* p_cmpl_cb);
/*******************************************************************************
*
* Function BTM_BleOpportunisticObserve
*
* Description Register/unregister opportunistic scan callback. This method
* does not trigger scan start/stop, but if scan is ever started,
* this callback would get called with scan results. Additionally,
* this callback is not reset on each scan start/stop. It's
* intended to be used by LE Audio related profiles, that would
* find yet unpaired members of CSIS set, or broadcasts.
*
* Parameters enable: enable/disable observing.
* p_results_cb: callback for results.
*
* Returns void
*
******************************************************************************/
void BTM_BleOpportunisticObserve(bool enable,
tBTM_INQ_RESULTS_CB* p_results_cb);
void BTM_EnableInterlacedInquiryScan();
void BTM_EnableInterlacedPageScan();
/*******************************************************************************
*
* Function BTM_SetInquiryMode
*
* Description This function is called to set standard, with RSSI
* mode or extended of the inquiry for local device.
*
* Input Params: BTM_INQ_RESULT_STANDARD, BTM_INQ_RESULT_WITH_RSSI or
* BTM_INQ_RESULT_EXTENDED
*
* Returns BTM_SUCCESS if successful
* BTM_NO_RESOURCES if couldn't get a memory pool buffer
* BTM_ILLEGAL_VALUE if a bad parameter was detected
* BTM_WRONG_MODE if the device is not up.
*
******************************************************************************/
tBTM_STATUS BTM_SetInquiryMode(uint8_t mode);
/*******************************************************************************
*
* Function BTM_SetConnectability
*
* Description This function is called to set the device into or out of
* connectable mode. Discoverable mode means page scans are
* enabled.
*
* Returns BTM_SUCCESS if successful
* BTM_ILLEGAL_VALUE if a bad parameter is detected
* BTM_NO_RESOURCES if could not allocate a message buffer
* BTM_WRONG_MODE if the device is not up.
*
******************************************************************************/
tBTM_STATUS BTM_SetConnectability(uint16_t page_mode, uint16_t window,
uint16_t interval);
/*******************************************************************************
*
* Function BTM_IsInquiryActive
*
* Description Return a bit mask of the current inquiry state
*
* Returns BTM_INQUIRY_INACTIVE if inactive (0)
* BTM_GENERAL_INQUIRY_ACTIVE if a general inquiry is active
*
******************************************************************************/
uint16_t BTM_IsInquiryActive(void);
/*******************************************************************************
*
* Function BTM_CancelInquiry
*
* Description This function cancels an inquiry if active
*
******************************************************************************/
void BTM_CancelInquiry(void);
/*******************************************************************************
*
* Function BTM_ReadRemoteDeviceName
*
* Description This function initiates a remote device HCI command to the
* controller and calls the callback when the process has
* completed.
*
* Input Params: remote_bda - device address of name to retrieve
* p_cb - callback function called when
* BTM_CMD_STARTED is returned.
* A pointer to tBTM_REMOTE_DEV_NAME is
* passed to the callback.
*
* Returns
* BTM_CMD_STARTED is returned if the request was successfully
* sent to HCI.
* BTM_BUSY if already in progress
* BTM_UNKNOWN_ADDR if device address is bad
* BTM_NO_RESOURCES if resources could not be allocated to
* start the command
* BTM_WRONG_MODE if the device is not up.
*
******************************************************************************/
tBTM_STATUS BTM_ReadRemoteDeviceName(const RawAddress& remote_bda,
tBTM_CMPL_CB* p_cb,
tBT_TRANSPORT transport);
/*******************************************************************************
*
* Function BTM_CancelRemoteDeviceName
*
* Description This function initiates the cancel request for the specified
* remote device.
*
* Input Params: None
*
* Returns
* BTM_CMD_STARTED is returned if the request was successfully
* sent to HCI.
* BTM_NO_RESOURCES if resources could not be allocated to
* start the command
* BTM_WRONG_MODE if there is no active remote name request.
*
******************************************************************************/
tBTM_STATUS BTM_CancelRemoteDeviceName(void);
/*******************************************************************************
*
* Function BTM_InqDbRead
*
* Description This function looks through the inquiry database for a match
* based on Bluetooth Device Address. This is the application's
* interface to get the inquiry details of a specific BD
* address.
*
* Returns pointer to entry, or NULL if not found
*
******************************************************************************/
tBTM_INQ_INFO* BTM_InqDbRead(const RawAddress& p_bda);
/*******************************************************************************
*
* Function BTM_InqDbFirst
*
* Description This function looks through the inquiry database for the
* first used entry, and returns that. This is used in
* conjunction with BTM_InqDbNext by applications as a way to
* walk through the inquiry database.
*
* Returns pointer to first in-use entry, or NULL if DB is empty
*
******************************************************************************/
tBTM_INQ_INFO* BTM_InqDbFirst(void);
/*******************************************************************************
*
* Function BTM_InqDbNext
*
* Description This function looks through the inquiry database for the
* next used entry, and returns that. If the input parameter
* is NULL, the first entry is returned.
*
* Returns pointer to next in-use entry, or NULL if no more found.
*
******************************************************************************/
tBTM_INQ_INFO* BTM_InqDbNext(tBTM_INQ_INFO* p_cur);
/*******************************************************************************
*
* Function BTM_ClearInqDb
*
* Description This function is called to clear out a device or all devices
* from the inquiry database.
*
* Parameter p_bda - (input) BD_ADDR -> Address of device to clear
* (NULL clears all entries)
*
* Returns BTM_BUSY if an inquiry, get remote name, or event filter
* is active, otherwise BTM_SUCCESS
*
******************************************************************************/
tBTM_STATUS BTM_ClearInqDb(const RawAddress* p_bda);
/*******************************************************************************
*
* Function BTM_HasEirService
*
* Description This function is called to know if UUID in bit map of UUID.
*
* Parameters p_eir_uuid - bit map of UUID list
* uuid16 - UUID 16-bit
*
* Returns true - if found
* false - if not found
*
******************************************************************************/
bool BTM_HasEirService(const uint32_t* p_eir_uuid, uint16_t uuid16);
/*******************************************************************************
*
* Function BTM_HasInquiryEirService
*
* Description Return if a UUID is in the bit map of a UUID list.
*
* Parameters p_results - inquiry results
* uuid16 - UUID 16-bit
*
* Returns BTM_EIR_FOUND - if found
* BTM_EIR_NOT_FOUND - if not found and it is a complete list
* BTM_EIR_UNKNOWN - if not found and it is not complete list
*
******************************************************************************/
tBTM_EIR_SEARCH_RESULT BTM_HasInquiryEirService(tBTM_INQ_RESULTS* p_results,
uint16_t uuid16);
/*******************************************************************************
*
* Function BTM_AddEirService
*
* Description This function is called to add a service in the bit map UUID
* list.
*
* Parameters p_eir_uuid - bit mask of UUID list for EIR
* uuid16 - UUID 16-bit
*
* Returns None
*
******************************************************************************/
void BTM_AddEirService(uint32_t* p_eir_uuid, uint16_t uuid16);
/*******************************************************************************
*
* Function BTM_SecAddBleDevice
*
* Description Add/modify device. This function will be normally called
* during host startup to restore all required information
* for a LE device stored in the NVRAM.
*
* Parameters: bd_addr - BD address of the peer
* dev_type - Remote device's device type.
* addr_type - LE device address type.
*
******************************************************************************/
void BTM_SecAddBleDevice(const RawAddress& bd_addr, tBT_DEVICE_TYPE dev_type,
tBLE_ADDR_TYPE addr_type);
/*******************************************************************************
*
* Function BTM_SecAddBleKey
*
* Description Add/modify LE device information. This function will be
* normally called during host startup to restore all required
* information stored in the NVRAM.
*
* Parameters: bd_addr - BD address of the peer
* p_le_key - LE key values.
* key_type - LE SMP key type.
*
******************************************************************************/
void BTM_SecAddBleKey(const RawAddress& bd_addr, tBTM_LE_KEY_VALUE* p_le_key,
tBTM_LE_KEY_TYPE key_type);
/*******************************************************************************
*
* Function BTM_BleLoadLocalKeys
*
* Description Local local identity key, encryption root or sign counter.
*
* Parameters: key_type: type of key, can be BTM_BLE_KEY_TYPE_ID,
* BTM_BLE_KEY_TYPE_ER
* or BTM_BLE_KEY_TYPE_COUNTER.
* p_key: pointer to the key.
*
* Returns non2.
*
******************************************************************************/
void BTM_BleLoadLocalKeys(uint8_t key_type, tBTM_BLE_LOCAL_KEYS* p_key);
/** Returns local device encryption root (ER) */
const Octet16& BTM_GetDeviceEncRoot();
/** Returns local device identity root (IR) */
const Octet16& BTM_GetDeviceIDRoot();
/** Return local device DHK. */
const Octet16& BTM_GetDeviceDHK();
/*******************************************************************************
*
* Function BTM_ReadConnectionAddr
*
* Description Read the local device random address.
*
* Returns void
*
******************************************************************************/
void BTM_ReadConnectionAddr(const RawAddress& remote_bda,
RawAddress& local_conn_addr,
tBLE_ADDR_TYPE* p_addr_type);
/*******************************************************************************
*
* Function BTM_ReadRemoteConnectionAddr
*
* Description Read the remote device address currently used.
*
* Returns void
*
******************************************************************************/
bool BTM_ReadRemoteConnectionAddr(const RawAddress& pseudo_addr,
RawAddress& conn_addr,
tBLE_ADDR_TYPE* p_addr_type);
/*******************************************************************************
*
* Function BTM_SecurityGrant
*
* Description This function is called to grant security process.
*
* Parameters bd_addr - peer device bd address.
* res - result of the operation BTM_SUCCESS if success.
* Otherwise, BTM_REPEATED_ATTEMPTS is too many
* attempts.
*
* Returns None
*
******************************************************************************/
void BTM_SecurityGrant(const RawAddress& bd_addr, uint8_t res);
/*******************************************************************************
*
* Function BTM_LeOobDataReply
*
* Description This function is called to provide the OOB data for
* SMP in response to BTM_LE_OOB_REQ_EVT
*
* Parameters: bd_addr - Address of the peer device
* res - result of the operation SMP_SUCCESS if success
* p_data - simple pairing Randomizer C.
*
******************************************************************************/
void BTM_BleOobDataReply(const RawAddress& bd_addr, uint8_t res, uint8_t len,
uint8_t* p_data);
/*******************************************************************************
*
* Function BTM_BleSecureConnectionOobDataReply
*
* Description This function is called to provide the OOB data for
* SMP in response to BTM_LE_OOB_REQ_EVT when secure connection
* data is available
*
* Parameters: bd_addr - Address of the peer device
* p_c - pointer to Confirmation
* p_r - pointer to Randomizer.
*
******************************************************************************/
void BTM_BleSecureConnectionOobDataReply(const RawAddress& bd_addr,
uint8_t* p_c, uint8_t* p_r);
/******************************************************************************
*
* Function BTM_BleSetConnScanParams
*
* Description Set scan parameters used in BLE connection request
*
* Parameters: scan_interval - scan interval
* scan_window - scan window
*
* Returns void
*
******************************************************************************/
void BTM_BleSetConnScanParams(uint32_t scan_interval, uint32_t scan_window);
/********************************************************
*
* Function BTM_BleSetPrefConnParams
*
* Description Set a peripheral's preferred connection parameters. When
* any of the value does not want to be updated while others
* do, use BTM_BLE_CONN_PARAM_UNDEF for the ones want to
* leave untouched.
*
* Parameters: bd_addr - BD address of the peripheral
* min_conn_int - minimum preferred connection interval
* max_conn_int - maximum preferred connection interval
* peripheral_latency - preferred peripheral latency
* supervision_tout - preferred supervision timeout
*
* Returns void
*
******************************************************************************/
void BTM_BleSetPrefConnParams(const RawAddress& bd_addr, uint16_t min_conn_int,
uint16_t max_conn_int,
uint16_t peripheral_latency,
uint16_t supervision_tout);
/*******************************************************************************
*
* Function BTM_ReadDevInfo
*
* Description This function is called to read the device/address type
* of BD address.
*
* Parameter remote_bda: remote device address
* p_dev_type: output parameter to read the device type.
* p_addr_type: output parameter to read the address type.
*
******************************************************************************/
void BTM_ReadDevInfo(const RawAddress& remote_bda, tBT_DEVICE_TYPE* p_dev_type,
tBLE_ADDR_TYPE* p_addr_type);
/*******************************************************************************
*
* Function BTM_ReadConnectedTransportAddress
*
* Description This function is called to read the paired device/address
* type of other device paired corresponding to the BD_address
*
* Parameter remote_bda: remote device address, carry out the transport
* address
* transport: active transport
*
* Return true if an active link is identified; false otherwise
*
******************************************************************************/
bool BTM_ReadConnectedTransportAddress(RawAddress* remote_bda,
tBT_TRANSPORT transport);
/*******************************************************************************
*
* Function BTM_BleReceiverTest
*
* Description This function is called to start the LE Receiver test
*
* Parameter rx_freq - Frequency Range
* p_cmd_cmpl_cback - Command Complete callback
*
******************************************************************************/
void BTM_BleReceiverTest(uint8_t rx_freq, tBTM_CMPL_CB* p_cmd_cmpl_cback);
/*******************************************************************************
*
* Function BTM_BleTransmitterTest
*
* Description This function is called to start the LE Transmitter test
*
* Parameter tx_freq - Frequency Range
* test_data_len - Length in bytes of payload data in each
* packet
* packet_payload - Pattern to use in the payload
* p_cmd_cmpl_cback - Command Complete callback
*
******************************************************************************/
void BTM_BleTransmitterTest(uint8_t tx_freq, uint8_t test_data_len,
uint8_t packet_payload,
tBTM_CMPL_CB* p_cmd_cmpl_cback);
/*******************************************************************************
*
* Function BTM_BleTestEnd
*
* Description This function is called to stop the in-progress TX or RX test
*
* Parameter p_cmd_cmpl_cback - Command complete callback
*
******************************************************************************/
void BTM_BleTestEnd(tBTM_CMPL_CB* p_cmd_cmpl_cback);
/*******************************************************************************
*
* Function BTM_UseLeLink
*
* Description Select the underlying physical link to use.
*
* Returns true to use LE, false use BR/EDR.
*
******************************************************************************/
bool BTM_UseLeLink(const RawAddress& bd_addr);
/*******************************************************************************
*
* Function BTM_BleReadPhy
*
* Description To read the current PHYs for specified LE connection
*
*
* Returns BTM_SUCCESS if success; otherwise failed.
*
******************************************************************************/
void BTM_BleReadPhy(
const RawAddress& bd_addr,
base::Callback<void(uint8_t tx_phy, uint8_t rx_phy, uint8_t status)> cb);
/*******************************************************************************
*
* Function BTM_BleSetPhy
*
* Description To set PHY preferences for specified LE connection
*
*
* Returns BTM_SUCCESS if success; otherwise failed.
* BTM_MODE_UNSUPPORTED if local controller doesn't support LE
* 2M or LE Coded PHY,
* BTM_ILLEGAL_VALUE if specified remote doesn't support LE 2M
* or LE Coded PHY,
* BTM_WRONG_MODE if Device in wrong mode for request.
*
******************************************************************************/
void BTM_BleSetPhy(const RawAddress& bd_addr, uint8_t tx_phys, uint8_t rx_phys,
uint16_t phy_options);
/*******************************************************************************
*
* Function BTM_BleDataSignature
*
* Description This function is called to sign the data using AES128 CMAC
* algorith.
*
* Parameter bd_addr: target device the data to be signed for.
* p_text: singing data
* len: length of the signing data
* signature: output parameter where data signature is going to
* be stored.
*
* Returns true if signing sucessul, otherwise false.
*
******************************************************************************/
bool BTM_BleDataSignature(const RawAddress& bd_addr, uint8_t* p_text,
uint16_t len, BLE_SIGNATURE signature);
/*******************************************************************************
*
* Function BTM_BleVerifySignature
*
* Description This function is called to verify the data signature
*
* Parameter bd_addr: target device the data to be signed for.
* p_orig: original data before signature.
* len: length of the signing data
* counter: counter used when doing data signing
* p_comp: signature to be compared against.
* Returns true if signature verified correctly; otherwise false.
*
******************************************************************************/
bool BTM_BleVerifySignature(const RawAddress& bd_addr, uint8_t* p_orig,
uint16_t len, uint32_t counter, uint8_t* p_comp);
/*******************************************************************************
*
* Function BTM_GetLeSecurityState
*
* Description This function is called to get security mode 1 flags and
* encryption key size for LE peer.
*
* Returns bool true if LE device is found, false otherwise.
*
******************************************************************************/
bool BTM_GetLeSecurityState(const RawAddress& bd_addr,
uint8_t* p_le_dev_sec_flags,
uint8_t* p_le_key_size);
/*******************************************************************************
*
* Function BTM_BleSecurityProcedureIsRunning
*
* Description This function indicates if LE security procedure is
* currently running with the peer.
*
* Returns bool true if security procedure is running, false otherwise.
*
******************************************************************************/
bool BTM_BleSecurityProcedureIsRunning(const RawAddress& bd_addr);
/*******************************************************************************
*
* Function BTM_BleGetSupportedKeySize
*
* Description This function gets the maximum encryption key size in bytes
* the local device can suport.
* record.
*
* Returns the key size or 0 if the size can't be retrieved.
*
******************************************************************************/
uint8_t BTM_BleGetSupportedKeySize(const RawAddress& bd_addr);
void BTM_LE_PF_local_name(tBTM_BLE_SCAN_COND_OP action,
tBTM_BLE_PF_FILT_INDEX filt_index,
std::vector<uint8_t> name, tBTM_BLE_PF_CFG_CBACK cb);
void BTM_LE_PF_srvc_data(tBTM_BLE_SCAN_COND_OP action,
tBTM_BLE_PF_FILT_INDEX filt_index);
void BTM_LE_PF_manu_data(tBTM_BLE_SCAN_COND_OP action,
tBTM_BLE_PF_FILT_INDEX filt_index, uint16_t company_id,
uint16_t company_id_mask, std::vector<uint8_t> data,
std::vector<uint8_t> data_mask,
tBTM_BLE_PF_CFG_CBACK cb);
void BTM_LE_PF_srvc_data_pattern(tBTM_BLE_SCAN_COND_OP action,
tBTM_BLE_PF_FILT_INDEX filt_index,
std::vector<uint8_t> data,
std::vector<uint8_t> data_mask,
tBTM_BLE_PF_CFG_CBACK cb);
void BTM_LE_PF_addr_filter(tBTM_BLE_SCAN_COND_OP action,
tBTM_BLE_PF_FILT_INDEX filt_index, tBLE_BD_ADDR addr,
tBTM_BLE_PF_CFG_CBACK cb);
void BTM_LE_PF_uuid_filter(tBTM_BLE_SCAN_COND_OP action,
tBTM_BLE_PF_FILT_INDEX filt_index,
tBTM_BLE_PF_COND_TYPE filter_type,
const bluetooth::Uuid& uuid,
tBTM_BLE_PF_LOGIC_TYPE cond_logic,
const bluetooth::Uuid& uuid_mask,
tBTM_BLE_PF_CFG_CBACK cb);
void BTM_LE_PF_set(tBTM_BLE_PF_FILT_INDEX filt_index,
std::vector<ApcfCommand> commands, tBTM_BLE_PF_CFG_CBACK cb);
void BTM_LE_PF_clear(tBTM_BLE_PF_FILT_INDEX filt_index,
tBTM_BLE_PF_CFG_CBACK cb);
/*******************************************************************************
*
* Function BTM_BleAdvFilterParamSetup
*
* Description This function is called to setup the adv data payload filter
* condition.
*
******************************************************************************/
void BTM_BleAdvFilterParamSetup(
tBTM_BLE_SCAN_COND_OP action, tBTM_BLE_PF_FILT_INDEX filt_index,
std::unique_ptr<btgatt_filt_param_setup_t> p_filt_params,
tBTM_BLE_PF_PARAM_CB cb);
/*******************************************************************************
*
* Function BTM_BleUpdateAdvFilterPolicy
*
* Description This function update the filter policy of advertiser.
*
* Parameter adv_policy: advertising filter policy
*
* Return void
******************************************************************************/
void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy);
/*******************************************************************************
*
* Function BTM_BleEnableDisableFilterFeature
*
* Description Enable or disable the APCF feature
*
* Parameters enable - true - enables APCF, false - disables APCF
*
******************************************************************************/
void BTM_BleEnableDisableFilterFeature(uint8_t enable,
tBTM_BLE_PF_STATUS_CBACK p_stat_cback);
/*******************************************************************************
*
* Function BTM_BleMaxMultiAdvInstanceCount
*
* Description Returns the maximum number of multi adv instances supported
* by the controller.
*
* Returns Max multi adv instance count
*
******************************************************************************/
uint8_t BTM_BleMaxMultiAdvInstanceCount();
void BTM_reset_complete();
/*******************************************************************************
*
* Function BTM_IsDeviceUp
*
* Description This function is called to check if the device is up.
*
* Returns true if device is up, else false
*
******************************************************************************/
bool BTM_IsDeviceUp(void);
/*******************************************************************************
*
* Function BTM_SetLocalDeviceName
*
* Description This function is called to set the local device name.
*
* Returns BTM_CMD_STARTED if successful, otherwise an error
*
******************************************************************************/
tBTM_STATUS BTM_SetLocalDeviceName(const char* p_name);
/*******************************************************************************
*
* Function BTM_SetDeviceClass
*
* Description This function is called to set the local device class
*
* Returns BTM_SUCCESS if successful, otherwise an error
*
******************************************************************************/
tBTM_STATUS BTM_SetDeviceClass(DEV_CLASS dev_class);
/*******************************************************************************
*
* Function BTM_ReadLocalDeviceName
*
* Description This function is called to read the local device name.
*
* Returns status of the operation
* If success, BTM_SUCCESS is returned and p_name points stored
* local device name
* If BTM doesn't store local device name, BTM_NO_RESOURCES is
* is returned and p_name is set to NULL
*
******************************************************************************/
tBTM_STATUS BTM_ReadLocalDeviceName(const char** p_name);
/*******************************************************************************
*
* Function BTM_ReadLocalDeviceNameFromController
*
* Description Get local device name from controller. Do not use cached
* name (used to get chip-id prior to btm reset complete).
*
* Returns BTM_CMD_STARTED if successful, otherwise an error
*
******************************************************************************/
tBTM_STATUS BTM_ReadLocalDeviceNameFromController(
tBTM_CMPL_CB* p_rln_cmpl_cback);
/*******************************************************************************
*
* Function BTM_ReadDeviceClass
*
* Description This function is called to read the local device class
*
* Returns pointer to the device class
*
******************************************************************************/
uint8_t* BTM_ReadDeviceClass(void);
/*******************************************************************************
*
* Function BTM_RegisterForVSEvents
*
* Description This function is called to register/deregister for vendor
* specific HCI events.
*
* If is_register=true, then the function will be registered;
* otherwise the function will be deregistered.
*
* Returns BTM_SUCCESS if successful,
* BTM_BUSY if maximum number of callbacks have already been
* registered.
*
******************************************************************************/
tBTM_STATUS BTM_RegisterForVSEvents(tBTM_VS_EVT_CB* p_cb, bool is_register);
/*******************************************************************************
*
* Function BTM_VendorSpecificCommand
*
* Description Send a vendor specific HCI command to the controller.
*
******************************************************************************/
void BTM_VendorSpecificCommand(uint16_t opcode, uint8_t param_len,
uint8_t* p_param_buf, tBTM_VSC_CMPL_CB* p_cb);
/*******************************************************************************
*
* Function BTM_AllocateSCN
*
* Description Look through the Server Channel Numbers for a free one to be
* used with an RFCOMM connection.
*
* Returns Allocated SCN number or 0 if none.
*
******************************************************************************/
uint8_t BTM_AllocateSCN(void);
/*******************************************************************************
*
* Function BTM_TryAllocateSCN
*
* Description Try to allocate a fixed server channel
*
* Returns Returns true if server channel was available
*
******************************************************************************/
bool BTM_TryAllocateSCN(uint8_t scn);
/*******************************************************************************
*
* Function BTM_FreeSCN
*
* Description Free the specified SCN.
*
* Returns true if successful, false if SCN is not in use or invalid
*
******************************************************************************/
bool BTM_FreeSCN(uint8_t scn);
/*******************************************************************************
*
* Function BTM_SetTraceLevel
*
* Description This function sets the trace level for BTM. If called with
* a value of 0xFF, it simply returns the current trace level.
*
* Returns The new or current trace level
*
******************************************************************************/
uint8_t BTM_SetTraceLevel(uint8_t new_level);
/*******************************************************************************
*
* Function BTM_WritePageTimeout
*
* Description Send HCI Wite Page Timeout.
*
******************************************************************************/
void BTM_WritePageTimeout(uint16_t timeout);
/*******************************************************************************
*
* Function BTM_WriteVoiceSettings
*
* Description Send HCI Write Voice Settings command.
* See hcidefs.h for settings bitmask values.
*
******************************************************************************/
void BTM_WriteVoiceSettings(uint16_t settings);
/*******************************************************************************
*
* Function BTM_EnableTestMode
*
* Description Send HCI the enable device under test command.
*
* Note: Controller can only be taken out of this mode by
* resetting the controller.
*
* Returns
* BTM_SUCCESS Command sent.
* BTM_NO_RESOURCES If out of resources to send the command.
*
*
******************************************************************************/
tBTM_STATUS BTM_EnableTestMode(void);
/*******************************************************************************
*
* Function BTM_ReadRemoteVersion
*
* Description This function is called to read a remote device's version
*
* Returns true if valid, false otherwise
*
******************************************************************************/
bool BTM_ReadRemoteVersion(const RawAddress& addr, uint8_t* lmp_version,
uint16_t* manufacturer, uint16_t* lmp_sub_version);
/*******************************************************************************
*
* Function BTM_ReadRemoteFeatures
*
* Description This function is called to read a remote device's
* supported features mask (features mask located at page 0)
*
* Returns pointer to the remote supported features mask
* The size of device features mask page is
* HCI_FEATURE_BYTES_PER_PAGE bytes.
*
******************************************************************************/
uint8_t* BTM_ReadRemoteFeatures(const RawAddress& addr);
/*****************************************************************************
* ACL CHANNEL MANAGEMENT FUNCTIONS
****************************************************************************/
void BTM_unblock_sniff_mode_for(const RawAddress& peer_addr);
void BTM_block_sniff_mode_for(const RawAddress& peer_addr);
void BTM_unblock_role_switch_for(const RawAddress& peer_addr);
void BTM_block_role_switch_for(const RawAddress& peer_addr);
void BTM_default_unblock_role_switch();
void BTM_default_block_role_switch();
/*******************************************************************************
*
* Function BTM_SetDefaultLinkSuperTout
*
* Description Set the default value for HCI "Write Link Supervision
* Timeout" command to use when an ACL link is created.
*
* Returns void
*
******************************************************************************/
void BTM_SetDefaultLinkSuperTout(uint16_t timeout);
/*******************************************************************************
*
* Function BTM_SetLinkSuperTout
*
* Description Create and send HCI "Write Link Supervision Timeout" command
*
* Returns BTM_CMD_STARTED if successfully initiated, otherwise error
*
******************************************************************************/
tBTM_STATUS BTM_SetLinkSuperTout(const RawAddress& remote_bda,
uint16_t timeout);
/*******************************************************************************
*
* Function BTM_GetLinkSuperTout
*
* Description Read the link supervision timeout value of the connection
*
* Returns status of the operation
*
******************************************************************************/
tBTM_STATUS BTM_GetLinkSuperTout(const RawAddress& remote_bda,
uint16_t* p_timeout);
/*******************************************************************************
*
* Function BTM_IsAclConnectionUp
*
* Description This function is called to check if an ACL connection exists
* to a specific remote BD Address.
*
* Returns true if connection is up, else false.
*
******************************************************************************/
bool BTM_IsAclConnectionUp(const RawAddress& remote_bda,
tBT_TRANSPORT transport);
/*******************************************************************************
*
* Function BTM_GetRole
*
* Description This function is called to get the role of the local device
* for the ACL connection with the specified remote device
*
* Returns BTM_SUCCESS if connection exists.
* BTM_UNKNOWN_ADDR if no active link with bd addr specified
*
******************************************************************************/
tBTM_STATUS BTM_GetRole(const RawAddress& remote_bd_addr, tHCI_ROLE* p_role);
/*******************************************************************************
*
* Function BTM_SwitchRole
*
* Description This function is called to switch role between central and
* peripheral. If role is already set it will do nothing.
*
* Returns BTM_SUCCESS if already in specified role.
* BTM_CMD_STARTED if command issued to controller.
* BTM_NO_RESOURCES if memory couldn't be allocated to issue
* the command
* BTM_UNKNOWN_ADDR if no active link with bd addr specified
* BTM_MODE_UNSUPPORTED if the local device does not support
* role switching
*
******************************************************************************/
tBTM_STATUS BTM_SwitchRole(const RawAddress& remote_bd_addr, uint8_t new_role);
/*******************************************************************************
*
* Function BTM_ReadRSSI
*
* Description This function is called to read the link policy settings.
* The address of link policy results are returned in the
* callback. (tBTM_RSSI_RESULT)
*
* Returns BTM_CMD_STARTED if command issued to controller.
* BTM_NO_RESOURCES if memory couldn't be allocated to issue
* the command
* BTM_UNKNOWN_ADDR if no active link with bd addr specified
* BTM_BUSY if command is already in progress
*
******************************************************************************/
tBTM_STATUS BTM_ReadRSSI(const RawAddress& remote_bda, tBTM_CMPL_CB* p_cb);
/*******************************************************************************
*
* Function BTM_ReadFailedContactCounter
*
* Description This function is called to read the failed contact counter.
* The result is returned in the callback.
* (tBTM_FAILED_CONTACT_COUNTER_RESULT)
*
* Returns BTM_CMD_STARTED if command issued to controller.
* BTM_NO_RESOURCES if memory couldn't be allocated to issue
* the command
* BTM_UNKNOWN_ADDR if no active link with bd addr specified
* BTM_BUSY if command is already in progress
*
******************************************************************************/
tBTM_STATUS BTM_ReadFailedContactCounter(const RawAddress& remote_bda,
tBTM_CMPL_CB* p_cb);
/*******************************************************************************
*
* Function BTM_ReadAutomaticFlushTimeout
*
* Description This function is called to read the automatic flush timeout.
* The result is returned in the callback.
* (tBTM_AUTOMATIC_FLUSH_TIMEOUT_RESULT)
*
* Returns BTM_CMD_STARTED if command issued to controller.
* BTM_NO_RESOURCES if memory couldn't be allocated to issue
* the command
* BTM_UNKNOWN_ADDR if no active link with bd addr specified
* BTM_BUSY if command is already in progress
*
******************************************************************************/
tBTM_STATUS BTM_ReadAutomaticFlushTimeout(const RawAddress& remote_bda,
tBTM_CMPL_CB* p_cb);
/*******************************************************************************
*
* Function BTM_ReadTxPower
*
* Description This function is called to read the current connection
* TX power of the connection. The TX power level results
* are returned in the callback.
* (tBTM_RSSI_RESULT)
*
* Returns BTM_CMD_STARTED if command issued to controller.
* BTM_NO_RESOURCES if memory couldn't be allocated to issue
* the command
* BTM_UNKNOWN_ADDR if no active link with bd addr specified
* BTM_BUSY if command is already in progress
*
******************************************************************************/
tBTM_STATUS BTM_ReadTxPower(const RawAddress& remote_bda,
tBT_TRANSPORT transport, tBTM_CMPL_CB* p_cb);
/*****************************************************************************
* (e)SCO CHANNEL MANAGEMENT FUNCTIONS
****************************************************************************/
/*******************************************************************************
*
* Function BTM_CreateSco
*
* Description This function is called to create an SCO connection. If the
* "is_orig" flag is true, the connection will be originated,
* otherwise BTM will wait for the other side to connect.
*
* Returns BTM_UNKNOWN_ADDR if the ACL connection is not up
* BTM_BUSY if another SCO being set up to
* the same BD address
* BTM_NO_RESOURCES if the max SCO limit has been reached
* BTM_CMD_STARTED if the connection establishment is started.
* In this case, "*p_sco_inx" is filled in
* with the sco index used for the connection.
*
******************************************************************************/
tBTM_STATUS BTM_CreateSco(const RawAddress* remote_bda, bool is_orig,
uint16_t pkt_types, uint16_t* p_sco_inx,
tBTM_SCO_CB* p_conn_cb, tBTM_SCO_CB* p_disc_cb);
/*******************************************************************************
*
* Function BTM_RemoveSco
*
* Description This function is called to remove a specific SCO connection.
*
* Returns BTM_CMD_STARTED if successfully initiated, otherwise error
*
******************************************************************************/
tBTM_STATUS BTM_RemoveSco(uint16_t sco_inx);
/*******************************************************************************
*
* Function BTM_ReadScoBdAddr
*
* Description This function is read the remote BD Address for a specific
* SCO connection,
*
* Returns pointer to BD address or NULL if not known
*
******************************************************************************/
const RawAddress* BTM_ReadScoBdAddr(uint16_t sco_inx);
/*******************************************************************************
*
* Function BTM_SetEScoMode
*
* Description This function sets up the negotiated parameters for SCO or
* eSCO, and sets as the default mode used for calls to
* BTM_CreateSco. It can be called only when there are no
* active (e)SCO links.
*
* Returns BTM_SUCCESS if the successful.
* BTM_BUSY if there are one or more active (e)SCO links.
*
******************************************************************************/
tBTM_STATUS BTM_SetEScoMode(enh_esco_params_t* p_parms);
/*******************************************************************************
*
* Function BTM_RegForEScoEvts
*
* Description This function registers a SCO event callback with the
* specified instance. It should be used to received
* connection indication events and change of link parameter
* events.
*
* Returns BTM_SUCCESS if the successful.
* BTM_ILLEGAL_VALUE if there is an illegal sco_inx
*
******************************************************************************/
tBTM_STATUS BTM_RegForEScoEvts(uint16_t sco_inx, tBTM_ESCO_CBACK* p_esco_cback);
/*******************************************************************************
*
* Function BTM_EScoConnRsp
*
* Description This function is called upon receipt of an (e)SCO connection
* request event (BTM_ESCO_CONN_REQ_EVT) to accept or reject
* the request. Parameters used to negotiate eSCO links.
* If p_parms is NULL, then values set through BTM_SetEScoMode
* are used.
* If the link type of the incoming request is SCO, then only
* the tx_bw, max_latency, content format, and packet_types are
* valid. The hci_status parameter should be
* ([0x0] to accept, [0x0d..0x0f] to reject)
*
*
* Returns void
*
******************************************************************************/
void BTM_EScoConnRsp(uint16_t sco_inx, uint8_t hci_status,
enh_esco_params_t* p_parms);
/*******************************************************************************
*
* Function BTM_GetNumScoLinks
*
* Description This function returns the number of active SCO links.
*
* Returns uint8_t
*
******************************************************************************/
uint8_t BTM_GetNumScoLinks(void);
/*****************************************************************************
* SECURITY MANAGEMENT FUNCTIONS
****************************************************************************/
/*******************************************************************************
*
* Function BTM_SecRegister
*
* Description Application manager calls this function to register for
* security services. There can be one and only one
* application saving link keys. BTM allows only first
* registration.
*
* Returns true if registered OK, else false
*
******************************************************************************/
bool BTM_SecRegister(const tBTM_APPL_INFO* p_cb_info);
/*******************************************************************************
*
* Function BTM_SecAddRmtNameNotifyCallback
*
* Description Profiles can register to be notified when name of the
* remote device is resolved (up to
* BTM_SEC_MAX_RMT_NAME_CALLBACKS).
*
* Returns true if registered OK, else false
*
******************************************************************************/
bool BTM_SecAddRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK* p_callback);
/*******************************************************************************
*
* Function BTM_SecDeleteRmtNameNotifyCallback
*
* Description A profile can deregister notification when a new Link Key
* is generated per connection.
*
* Returns true if OK, else false
*
******************************************************************************/
bool BTM_SecDeleteRmtNameNotifyCallback(tBTM_RMT_NAME_CALLBACK* p_callback);
/*******************************************************************************
*
* Function BTM_GetSecurityFlagsByTransport
*
* Description Get security flags for the device on a particular transport
*
* Parameters bd_addr: BD address of remote device
* p_sec_flags : Out parameter to be filled with security
* flags for the connection
* transport : Physical transport of the connection
* (BR/EDR or LE)
*
* Returns bool true or false is device found
*
******************************************************************************/
bool BTM_GetSecurityFlagsByTransport(const RawAddress& bd_addr,
uint8_t* p_sec_flags,
tBT_TRANSPORT transport);
/*******************************************************************************
*
* Function BTM_SetPinType
*
* Description Set PIN type for the device.
*
* Returns void
*
******************************************************************************/
void BTM_SetPinType(uint8_t pin_type, PIN_CODE pin_code, uint8_t pin_code_len);
/*******************************************************************************
*
* Function BTM_SetSecurityLevel
*
* Description Register service security level with Security Manager. Each
* service must register its requirements regardless of the
* security level that is used. This API is called once for
* originators and again for acceptors of connections.
*
* Returns true if registered OK, else false
*
******************************************************************************/
bool BTM_SetSecurityLevel(bool is_originator, const char* p_name,
uint8_t service_id, uint16_t sec_level, uint16_t psm,
uint32_t mx_proto_id, uint32_t mx_chan_id);
/*******************************************************************************
*
* Function BTM_SecClrService
*
* Description Removes specified service record(s) from the security
* database. All service records with the specified name are
* removed. Typically used only by devices with limited RAM
* so that it can reuse an old security service record.
*
* Returns Number of records that were freed.
*
******************************************************************************/
uint8_t BTM_SecClrService(uint8_t service_id);
/*******************************************************************************
*
* Function BTM_SecAddDevice
*
* Description Add/modify device. This function will be normally called
* during host startup to restore all required information
* stored in the NVRAM.
* dev_class, bd_name, link_key, and features are NULL if
* unknown
*
* Returns true if added OK, else false
*
******************************************************************************/
bool BTM_SecAddDevice(const RawAddress& bd_addr, DEV_CLASS dev_class,
const BD_NAME& bd_name, uint8_t* features,
LinkKey* link_key, uint8_t key_type, uint8_t pin_length);
/** Free resources associated with the device associated with |bd_addr| address.
*
* *** WARNING ***
* tBTM_SEC_DEV_REC associated with bd_addr becomes invalid after this function
* is called, also any of it's fields. i.e. if you use p_dev_rec->bd_addr, it is
* no longer valid!
* *** WARNING ***
*
* Returns true if removed OK, false if not found or ACL link is active.
*/
bool BTM_SecDeleteDevice(const RawAddress& bd_addr);
/*******************************************************************************
*
* Function BTM_SecClearSecurityFlags
*
* Description Reset the security flags (mark as not-paired) for a given
* remove device.
*
******************************************************************************/
void BTM_SecClearSecurityFlags(const RawAddress& bd_addr);
/*******************************************************************************
*
* Function BTM_SecGetDeviceLinkKeyType
*
* Description This function is called to obtain link key type for the
* device.
* it returns BTM_SUCCESS if link key is available, or
* BTM_UNKNOWN_ADDR if Security Manager does not know about
* the device or device record does not contain link key info
*
* Returns BTM_LKEY_TYPE_IGNORE if link key is unknown, link type
* otherwise.
*
******************************************************************************/
tBTM_LINK_KEY_TYPE BTM_SecGetDeviceLinkKeyType(const RawAddress& bd_addr);
/*******************************************************************************
*
* Function BTM_PINCodeReply
*
* Description This function is called after Security Manager submitted
* PIN code request to the UI.
*
* Parameters: bd_addr - Address of the device for which PIN was
* requested
* res - result of the operation BTM_SUCCESS if
* success
* pin_len - length in bytes of the PIN Code
* p_pin - pointer to array with the PIN Code
*
* Returns void
*
******************************************************************************/
void BTM_PINCodeReply(const RawAddress& bd_addr, tBTM_STATUS res,
uint8_t pin_len, uint8_t* p_pin);
/*******************************************************************************
*
* Function BTM_SecBond
*
* Description Perform bonding by designated transport
*
* Parameters: bd_addr - Address of the device to bond
* addr_type - address type for LE transport
* pin_len - length in bytes of the PIN Code
* p_pin - pointer to array with the PIN Code
* transport : Physical transport to use for bonding
* (BR/EDR or LE)
*
* Returns BTM_CMD_STARTED if successfully initiated, otherwise error
*
******************************************************************************/
tBTM_STATUS BTM_SecBond(const RawAddress& bd_addr, tBLE_ADDR_TYPE addr_type,
tBT_TRANSPORT transport, tBT_DEVICE_TYPE device_type);
/*******************************************************************************
*
* Function BTM_SecBondCancel
*
* Description This function is called to cancel ongoing bonding process
* with peer device.
*
* Returns BTM_CMD_STARTED if successfully initiated, otherwise error
*
******************************************************************************/
tBTM_STATUS BTM_SecBondCancel(const RawAddress& bd_addr);
/*******************************************************************************
*
* Function BTM_SetEncryption
*
* Description This function is called to ensure that connection is
* encrypted. Should be called only on an open connection.
* Typically only needed for connections that first want to
* bring up unencrypted links, then later encrypt them.
*
* Parameters: bd_addr - Address of the peer device
* transport - Link transport
* p_callback - Pointer to callback function called if
* this function returns PENDING after required
* procedures are completed. Can be set to
* NULL if status is not desired.
* p_ref_data - pointer to any data the caller wishes to
* receive in the callback function upon
* completion.
* can be set to NULL if not used.
* sec_act - LE security action, unused for BR/EDR
*
* Returns BTM_SUCCESS - already encrypted
* BTM_PENDING - command will be returned in the callback
* BTM_WRONG_MODE- connection not up.
* BTM_BUSY - security procedures are currently active
* BTM_MODE_UNSUPPORTED - if security manager not linked in.
*
******************************************************************************/
tBTM_STATUS BTM_SetEncryption(const RawAddress& bd_addr,
tBT_TRANSPORT transport,
tBTM_SEC_CALLBACK* p_callback, void* p_ref_data,
tBTM_BLE_SEC_ACT sec_act);
/*******************************************************************************
*
* Function BTM_ConfirmReqReply
*
* Description This function is called to confirm the numeric value for
* Simple Pairing in response to BTM_SP_CFM_REQ_EVT
*
* Parameters: res - result of the operation BTM_SUCCESS if
* success
* bd_addr - Address of the peer device
*
******************************************************************************/
void BTM_ConfirmReqReply(tBTM_STATUS res, const RawAddress& bd_addr);
/*******************************************************************************
*
* Function BTM_PasskeyReqReply
*
* Description This function is called to provide the passkey for
* Simple Pairing in response to BTM_SP_KEY_REQ_EVT
*
* Parameters: res - result of the operation BTM_SUCCESS if
* success
* bd_addr - Address of the peer device
* passkey - numeric value in the range of
* 0 - 999999(0xF423F).
*
******************************************************************************/
void BTM_PasskeyReqReply(tBTM_STATUS res, const RawAddress& bd_addr,
uint32_t passkey);
/*******************************************************************************
*
* Function BTM_IoCapRsp
*
* Description This function is called in response to BTM_SP_IO_REQ_EVT
* When the event data io_req.oob_data is set to
* BTM_OOB_UNKNOWN by the tBTM_SP_CALLBACK implementation, this
* function is called to provide the actual response
*
* Parameters: bd_addr - Address of the peer device
* io_cap - The IO capability of local device.
* oob - BTM_OOB_NONE or BTM_OOB_PRESENT.
* auth_req- MITM protection required or not.
*
******************************************************************************/
void BTM_IoCapRsp(const RawAddress& bd_addr, tBTM_IO_CAP io_cap,
tBTM_OOB_DATA oob, tBTM_AUTH_REQ auth_req);
/*******************************************************************************
*
* Function BTM_ReadLocalOobData
*
* Description This function is called to read the local OOB data from
* LM
*
******************************************************************************/
void BTM_ReadLocalOobData(void);
/*******************************************************************************
*
* Function BTM_RemoteOobDataReply
*
* Description This function is called to provide the remote OOB data for
* Simple Pairing in response to BTM_SP_RMT_OOB_EVT
*
* Parameters: bd_addr - Address of the peer device
* c - simple pairing Hash C.
* r - simple pairing Randomizer C.
*
******************************************************************************/
void BTM_RemoteOobDataReply(tBTM_STATUS res, const RawAddress& bd_addr,
const Octet16& c, const Octet16& r);
/*******************************************************************************
*
* Function BTM_BothEndsSupportSecureConnections
*
* Description This function is called to check if both the local device
* and the peer device specified by bd_addr support BR/EDR
* Secure Connections.
*
* Parameters: bd_addr - address of the peer
*
* Returns true if BR/EDR Secure Connections are supported by both
* local and the remote device.
* else false.
*
******************************************************************************/
bool BTM_BothEndsSupportSecureConnections(const RawAddress& bd_addr);
/*******************************************************************************
*
* Function BTM_PeerSupportsSecureConnections
*
* Description This function is called to check if the peer supports
* BR/EDR Secure Connections.
*
* Parameters: bd_addr - address of the peer
*
* Returns true if BR/EDR Secure Connections are supported by the peer,
* else false.
*
******************************************************************************/
bool BTM_PeerSupportsSecureConnections(const RawAddress& bd_addr);
/*******************************************************************************
*
* Function BTM_GetPeerDeviceTypeFromFeatures
*
* Description This function is called to retrieve the peer device type
* by referencing the remote features.
*
* Parameters: bd_addr - address of the peer
*
* Returns BT_DEVICE_TYPE_DUMO if both BR/EDR and BLE transports are
* supported by the peer,
* BT_DEVICE_TYPE_BREDR if only BR/EDR transport is supported,
* BT_DEVICE_TYPE_BLE if only BLE transport is supported.
*
******************************************************************************/
tBT_DEVICE_TYPE BTM_GetPeerDeviceTypeFromFeatures(const RawAddress& bd_addr);
/*******************************************************************************
*
* Function BTM_SecReadDevName
*
* Description Looks for the device name in the security database for the
* specified BD address.
*
* Returns Pointer to the name or NULL
*
******************************************************************************/
char* BTM_SecReadDevName(const RawAddress& bd_addr);
/*******************************************************************************
*
* Function BTM_GetHCIConnHandle
*
* Description This function is called to get the handle for an ACL
* connection to a specific remote BD Address.
*
* Returns the handle of the connection, or 0xFFFF if none.
*
******************************************************************************/
uint16_t BTM_GetHCIConnHandle(const RawAddress& remote_bda,
tBT_TRANSPORT transport);
/*******************************************************************************
*
* Function BTM_DeleteStoredLinkKey
*
* Description This function is called to delete link key for the specified
* device addresses from the NVRAM storage attached to the
* Bluetooth controller.
*
* Parameters: bd_addr - Addresses of the devices
* p_cb - Call back function to be called to return
* the results
*
******************************************************************************/
tBTM_STATUS BTM_DeleteStoredLinkKey(const RawAddress* bd_addr,
tBTM_CMPL_CB* p_cb);
tBTM_CONTRL_STATE BTM_PM_ReadControllerState(void);
/**
*
* BLE API
*/
/**
* This function is called to set scan parameters. |cb| is called with operation
* status
**/
void BTM_BleSetScanParams(std::vector<uint32_t> scan_interval, std::vector<uint32_t> scan_window,
tBLE_SCAN_MODE scan_type,
base::Callback<void(uint8_t)> cb);
/*******************************************************************************
*
* Function BTM_BleGetVendorCapabilities
*
* Description This function reads local LE features
*
* Parameters p_cmn_vsc_cb : Locala LE capability structure
*
* Returns void
*
******************************************************************************/
void BTM_BleGetVendorCapabilities(tBTM_BLE_VSC_CB* p_cmn_vsc_cb);
/*******************************************************************************
*
* Function BTM_BleSetStorageConfig
*
* Description This function is called to setup storage configuration and
* setup callbacks.
*
* Parameters uint8_t batch_scan_full_max -Batch scan full maximum
* uint8_t batch_scan_trunc_max - Batch scan truncated value
*maximum uint8_t batch_scan_notify_threshold - Threshold value cb - Setup
*callback tBTM_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback -Threshold callback void
**p_ref - Reference value
*
*
******************************************************************************/
void BTM_BleSetStorageConfig(uint8_t batch_scan_full_max,
uint8_t batch_scan_trunc_max,
uint8_t batch_scan_notify_threshold,
base::Callback<void(uint8_t /* status */)> cb,
tBTM_BLE_SCAN_THRESHOLD_CBACK* p_thres_cback,
tBTM_BLE_REF_VALUE ref_value);
/* This function is called to enable batch scan */
void BTM_BleEnableBatchScan(tBTM_BLE_BATCH_SCAN_MODE scan_mode,
uint32_t scan_interval, uint32_t scan_window,
tBTM_BLE_DISCARD_RULE discard_rule,
tBLE_ADDR_TYPE addr_type,
base::Callback<void(uint8_t /* status */)> cb);
/* This function is called to disable batch scanning */
void BTM_BleDisableBatchScan(base::Callback<void(uint8_t /* status */)> cb);
/* This function is called to read batch scan reports */
void BTM_BleReadScanReports(tBLE_SCAN_MODE scan_mode,
tBTM_BLE_SCAN_REP_CBACK cb);
/* This function is called to setup the callback for tracking */
void BTM_BleTrackAdvertiser(tBTM_BLE_TRACK_ADV_CBACK* p_track_cback,
tBTM_BLE_REF_VALUE ref_value);
/******************************************************************************
*
* Function BTM_BleReadControllerFeatures
*
* Description Reads BLE specific controller features
*
* Parameters: tBTM_BLE_CTRL_FEATURES_CBACK : Callback to notify when
* features are read
*
* Returns void
*
******************************************************************************/
void BTM_BleReadControllerFeatures(tBTM_BLE_CTRL_FEATURES_CBACK* p_vsc_cback);
/*******************************************************************************
*
* Function BTM__BLEReadDiscoverability
*
* Description This function is called to read the current LE
* discoverability mode of the device.
*
* Returns BTM_BLE_NON_DISCOVERABLE ,BTM_BLE_LIMITED_DISCOVERABLE or
* BTM_BLE_GENRAL_DISCOVERABLE
*
******************************************************************************/
uint16_t BTM_BleReadDiscoverability();
/*******************************************************************************
*
* Function BTM__BLEReadConnectability
*
* Description This function is called to read the current LE
* connectibility mode of the device.
*
* Returns BTM_BLE_NON_CONNECTABLE or BTM_BLE_CONNECTABLE
*
******************************************************************************/
uint16_t BTM_BleReadConnectability();
/*******************************************************************************
*
* Function BTM_BleConfigPrivacy
*
* Description This function is called to enable or disable the privacy in
* the local device.
*
* Parameters enable: true to enable it; false to disable it.
*
* Returns bool privacy mode set success; otherwise failed.
*
******************************************************************************/
bool BTM_BleConfigPrivacy(bool enable);
/*******************************************************************************
*
* Function BTM_BleLocalPrivacyEnabled
*
* Description Checks if local device supports private address
*
* Returns Return true if local privacy is enabled else false
*
******************************************************************************/
bool BTM_BleLocalPrivacyEnabled(void);
/**
* This functions are called to configure the adv data payload filter condition
*/
/*******************************************************************************
*
* Function BTM_BleGetEnergyInfo
*
* Description This function obtains the energy info
*
* Parameters p_ener_cback - Callback pointer
*
* Returns status
*
******************************************************************************/
tBTM_STATUS BTM_BleGetEnergyInfo(tBTM_BLE_ENERGY_INFO_CBACK* p_ener_cback);
/*******************************************************************************
*
* Function BTM_ClearEventFilter
*
* Description Clears the event filter in the controller
*
* Returns Return btm status
*
******************************************************************************/
tBTM_STATUS BTM_ClearEventFilter(void);
/**
* Send remote name request to GD shim Name module
*/
void SendRemoteNameRequest(const RawAddress& raw_address);
tBTM_STATUS btm_sec_mx_access_request(const RawAddress& bd_addr,
bool is_originator,
uint16_t security_requirement,
tBTM_SEC_CALLBACK* p_callback,
void* p_ref_data);
} // namespace shim
} // namespace bluetooth
|