1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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
189
192
195
198
201
204
207
212
215
221
226
227
230
233
236
239
243
247
250
253
256
259
263
272
273
276
279
282
285
288
291
294
297
300
303
306
310
311
312
313
316
319
320
321
322
323
324
327
328
329
338
339
343
346
347
348
349
350
351
352
353
354
355
356
357
361
364
367
370
376
381
384
385
389
390
391
392
396
399
402
405
408
411
414
415
416
417
418
419
422
423
424
425
426
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
467
468
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
490
491
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
516
517
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
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
599
600
601
602
603
604
605
606
607
608
609
614
615
616
617
618
619
620
621
622
623
624
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
686
687
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
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
829
830
831
832
833
834
835
836
837
838
839
840
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
958
962
966
970
974
978
982
986
993
997
998
999
1000
1004
1007
1008
1009
1012
1013
1014
1015
1016
1017
1020
1024
1027
1052
1053
1059
1063
1067
1071
1072
1073
1076
1081
1082
1083
1084
1085
1089
1093
1097
1099
1102
1105
1106
1107
1108
1109
1110
1111
1112
1113
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1154
1155
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
1201
1205
1214
1218
1222
1224
1225
1226
1227
1228
1229
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1263
1264
1265
1266
1267
1268
1269
1270
1271
1284
1285
1286
1290
1291
1292
1293
1297
1298
1299
1300
1301
1302
1303
1307
1308
1309
1310
1311
1312
1313
1314
1315
1320
1321
1322
1323
1324
1325
1326
1327
1328
1333
1334
1335
1336
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1369
1376
1377
1378
1380
1381
1382
1383
1384
1385
1386
1387
1390
1391
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1412
1413
1414
1415
1416
1422
1427
1428
1429
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
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
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
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
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
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
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1847
1848
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2022
2025
2026
2027
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2044
2045
2046
2047
2048
2049
2053
2054
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2083
2084
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2182
2183
2184
2185
2188
2189
2190
2191
2192
2207
2208
2209
2210
2211
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2275
2276
2280
2281
2282
2283
2284
2285
2286
2287
2288
2292
2293
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2311
2312
2313
2314
2315
2316
2317
2323
2324
2325
2326
2327
2328
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2400
2401
2402
2403
2404
2405
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
/* ... */
/* ... */
#include <string.h>
#include "stack/bt_types.h"
#include "stack/hcimsgs.h"
#include "stack/btu.h"
#include "l2c_int.h"
#include "stack/btm_api.h"
#include "btm_int.h"
#include "stack/acl_hci_link_interface.h"
#include "device/controller.h"
#include "osi/osi.h"
#include "hci/hci_layer.h"
#include "common/bt_trace.h"
#include "osi/thread.h"
#include "osi/pkt_queue.h"
#include "stack/btu.h"15 includes
extern void btm_process_cancel_complete(UINT8 status, UINT8 mode);
extern void btm_ble_test_command_complete(UINT8 *p);
static void btu_hcif_inquiry_comp_evt (UINT8 *p);
static void btu_hcif_inquiry_result_evt (UINT8 *p);
static void btu_hcif_inquiry_rssi_result_evt (UINT8 *p);
static void btu_hcif_extended_inquiry_result_evt (UINT8 *p);
static void btu_hcif_connection_comp_evt (UINT8 *p);
static void btu_hcif_connection_request_evt (UINT8 *p);
static void btu_hcif_disconnection_comp_evt (UINT8 *p);
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_authentication_comp_evt (UINT8 *p);
#endif
static void btu_hcif_rmt_name_request_comp_evt (UINT8 *p, UINT16 evt_len);
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_encryption_change_evt (UINT8 *p);
#endif
static void btu_hcif_read_rmt_features_comp_evt (UINT8 *p);
static void btu_hcif_read_rmt_ext_features_comp_evt (UINT8 *p);
static void btu_hcif_read_rmt_version_comp_evt (UINT8 *p);
static void btu_hcif_qos_setup_comp_evt (UINT8 *p);
static void btu_hcif_command_complete_evt (BT_HDR *response, void *context);
static void btu_hcif_command_status_evt (uint8_t status, BT_HDR *command, void *context);
static void btu_hcif_hardware_error_evt (UINT8 *p);
static void btu_hcif_flush_occured_evt (void);
static void btu_hcif_role_change_evt (UINT8 *p);
static void btu_hcif_num_compl_data_pkts_evt (UINT8 *p);
static void btu_hcif_mode_change_evt (UINT8 *p);
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_pin_code_request_evt (UINT8 *p);
static void btu_hcif_link_key_request_evt (UINT8 *p);
static void btu_hcif_link_key_notification_evt (UINT8 *p);/* ... */
#endif
static void btu_hcif_loopback_command_evt (void);
static void btu_hcif_data_buf_overflow_evt (void);
static void btu_hcif_max_slots_changed_evt (void);
static void btu_hcif_read_clock_off_comp_evt (UINT8 *p);
static void btu_hcif_conn_pkt_type_change_evt (UINT8 *p);
static void btu_hcif_qos_violation_evt (UINT8 *p);
static void btu_hcif_page_scan_mode_change_evt (void);
static void btu_hcif_page_scan_rep_mode_chng_evt (void);
static void btu_hcif_esco_connection_comp_evt(UINT8 *p);
static void btu_hcif_esco_connection_chg_evt(UINT8 *p);
static void btu_hcif_host_support_evt (UINT8 *p);
#if (CLASSIC_BT_INCLUDED == TRUE)
static void btu_hcif_io_cap_request_evt (UINT8 *p);
static void btu_hcif_io_cap_response_evt (UINT8 *p);
static void btu_hcif_user_conf_request_evt (UINT8 *p);
static void btu_hcif_user_passkey_request_evt (UINT8 *p);
static void btu_hcif_simple_pair_complete_evt (UINT8 *p);
static void btu_hcif_user_passkey_notif_evt (UINT8 *p);
static void btu_hcif_keypress_notif_evt (UINT8 *p);/* ... */
#endif
#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE
static void btu_hcif_rem_oob_request_evt (UINT8 *p);
#endif
static void btu_hcif_link_supv_to_changed_evt (UINT8 *p);
#if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE
static void btu_hcif_enhanced_flush_complete_evt (void);
#endif
static void btu_hcif_ssr_evt (UINT8 *p, UINT16 evt_len);
#if BLE_INCLUDED == TRUE
static void btu_ble_ll_conn_complete_evt (UINT8 *p, UINT16 evt_len);
static void btu_ble_read_remote_feat_evt (UINT8 *p);
static void btu_ble_ll_conn_param_upd_evt (UINT8 *p, UINT16 evt_len);
static void btu_ble_ll_get_conn_param_format_err_from_contoller (UINT8 status, UINT16 handle);
#if (SMP_INCLUDED == TRUE)
static void btu_ble_proc_ltk_req (UINT8 *p);
static void btu_hcif_encryption_key_refresh_cmpl_evt (UINT8 *p);/* ... */
#endif
static void btu_ble_data_length_change_evt (UINT8 *p, UINT16 evt_len);
#if (BLE_LLT_INCLUDED == TRUE)
static void btu_ble_rc_param_req_evt(UINT8 *p);
#endif
static void btu_ble_proc_enhanced_conn_cmpl (UINT8 *p, UINT16 evt_len);
#if (BLE_50_FEATURE_SUPPORT == TRUE)
static void btu_ble_phy_update_complete_evt(UINT8 *p);
static void btu_ble_ext_adv_report_evt(UINT8 *p, UINT16 evt_len);
static void btu_ble_periodic_adv_sync_establish_evt(UINT8 *p);
static void btu_ble_periodic_adv_report_evt(UINT8 *p, UINT8 evt_len);
static void btu_ble_periodic_adv_sync_lost_evt(UINT8 *p);
static void btu_ble_scan_timeout_evt(UINT8 *p);
static void btu_ble_adv_set_terminate_evt(UINT8 *p);
static void btu_ble_scan_req_received_evt(UINT8 *p);
static void btu_ble_channel_select_alg_evt(UINT8 *p);/* ... */
#endif
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
static void btu_ble_periodic_adv_sync_trans_recv(UINT8 *p);
#endif
extern osi_sem_t adv_enable_sem;
extern osi_sem_t adv_data_sem;
extern osi_sem_t adv_param_sem;
extern osi_sem_t scan_enable_sem;
extern osi_sem_t scan_param_sem;
extern uint8_t adv_enable_status;
extern uint8_t adv_data_status;
extern uint8_t adv_param_status;
extern uint8_t scan_enable_status;
extern uint8_t scan_param_status;
/* ... */
#endif
/* ... */
void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg)
{
UINT8 *p = (UINT8 *)(p_msg + 1) + p_msg->offset;
UINT8 hci_evt_code, hci_evt_len;
#if BLE_INCLUDED == TRUE
UINT8 ble_sub_code;
#endif
STREAM_TO_UINT8 (hci_evt_code, p);
STREAM_TO_UINT8 (hci_evt_len, p);
switch (hci_evt_code) {
case HCI_INQUIRY_COMP_EVT:
btu_hcif_inquiry_comp_evt (p);
break;...
case HCI_INQUIRY_RESULT_EVT:
btu_hcif_inquiry_result_evt (p);
break;...
case HCI_INQUIRY_RSSI_RESULT_EVT:
btu_hcif_inquiry_rssi_result_evt (p);
break;...
case HCI_EXTENDED_INQUIRY_RESULT_EVT:
btu_hcif_extended_inquiry_result_evt (p);
break;...
case HCI_CONNECTION_COMP_EVT:
btu_hcif_connection_comp_evt (p);
break;...
case HCI_CONNECTION_REQUEST_EVT:
btu_hcif_connection_request_evt (p);
break;...
case HCI_DISCONNECTION_COMP_EVT:
btu_hcif_disconnection_comp_evt (p);
break;...
case HCI_AUTHENTICATION_COMP_EVT:
#if (SMP_INCLUDED == TRUE)
btu_hcif_authentication_comp_evt (p);
#endif
break;...
case HCI_RMT_NAME_REQUEST_COMP_EVT:
btu_hcif_rmt_name_request_comp_evt (p, hci_evt_len);
break;...
case HCI_ENCRYPTION_CHANGE_EVT:
#if (SMP_INCLUDED == TRUE)
btu_hcif_encryption_change_evt (p);
#endif
break;
#if BLE_INCLUDED == TRUE...
case HCI_ENCRYPTION_KEY_REFRESH_COMP_EVT:
#if (SMP_INCLUDED == TRUE)
btu_hcif_encryption_key_refresh_cmpl_evt(p);
#endif
break;/* ... */
#endif
case HCI_READ_RMT_FEATURES_COMP_EVT:
btu_hcif_read_rmt_features_comp_evt (p);
break;...
case HCI_READ_RMT_EXT_FEATURES_COMP_EVT:
btu_hcif_read_rmt_ext_features_comp_evt (p);
break;...
case HCI_READ_RMT_VERSION_COMP_EVT:
btu_hcif_read_rmt_version_comp_evt (p);
break;...
case HCI_QOS_SETUP_COMP_EVT:
btu_hcif_qos_setup_comp_evt (p);
break;...
case HCI_COMMAND_COMPLETE_EVT:
break;...
case HCI_COMMAND_STATUS_EVT:
break;...
case HCI_HARDWARE_ERROR_EVT:
btu_hcif_hardware_error_evt (p);
break;...
case HCI_FLUSH_OCCURED_EVT:
btu_hcif_flush_occured_evt ();
break;...
case HCI_ROLE_CHANGE_EVT:
btu_hcif_role_change_evt (p);
break;...
case HCI_NUM_COMPL_DATA_PKTS_EVT:
btu_hcif_num_compl_data_pkts_evt (p);
break;...
case HCI_MODE_CHANGE_EVT:
btu_hcif_mode_change_evt (p);
break;
#if (SMP_INCLUDED == TRUE)...
case HCI_PIN_CODE_REQUEST_EVT:
btu_hcif_pin_code_request_evt (p);
break;...
case HCI_LINK_KEY_REQUEST_EVT:
btu_hcif_link_key_request_evt (p);
break;...
case HCI_LINK_KEY_NOTIFICATION_EVT:
btu_hcif_link_key_notification_evt (p);
break;/* ... */
#endif
case HCI_LOOPBACK_COMMAND_EVT:
btu_hcif_loopback_command_evt ();
break;...
case HCI_DATA_BUF_OVERFLOW_EVT:
btu_hcif_data_buf_overflow_evt ();
break;...
case HCI_MAX_SLOTS_CHANGED_EVT:
btu_hcif_max_slots_changed_evt ();
break;...
case HCI_READ_CLOCK_OFF_COMP_EVT:
btu_hcif_read_clock_off_comp_evt (p);
break;...
case HCI_CONN_PKT_TYPE_CHANGE_EVT:
btu_hcif_conn_pkt_type_change_evt (p);
break;...
case HCI_QOS_VIOLATION_EVT:
btu_hcif_qos_violation_evt (p);
break;...
case HCI_PAGE_SCAN_MODE_CHANGE_EVT:
btu_hcif_page_scan_mode_change_evt ();
break;...
case HCI_PAGE_SCAN_REP_MODE_CHNG_EVT:
btu_hcif_page_scan_rep_mode_chng_evt ();
break;...
case HCI_ESCO_CONNECTION_COMP_EVT:
btu_hcif_esco_connection_comp_evt (p);
break;...
case HCI_ESCO_CONNECTION_CHANGED_EVT:
btu_hcif_esco_connection_chg_evt (p);
break;...
case HCI_SNIFF_SUB_RATE_EVT:
btu_hcif_ssr_evt (p, hci_evt_len);
break;...
case HCI_RMT_HOST_SUP_FEAT_NOTIFY_EVT:
btu_hcif_host_support_evt (p);
break;
#if (CLASSIC_BT_INCLUDED == TRUE)...
case HCI_IO_CAPABILITY_REQUEST_EVT:
btu_hcif_io_cap_request_evt (p);
break;...
case HCI_IO_CAPABILITY_RESPONSE_EVT:
btu_hcif_io_cap_response_evt (p);
break;...
case HCI_USER_CONFIRMATION_REQUEST_EVT:
btu_hcif_user_conf_request_evt (p);
break;...
case HCI_USER_PASSKEY_REQUEST_EVT:
btu_hcif_user_passkey_request_evt (p);
break;/* ... */
#endif
#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE
case HCI_REMOTE_OOB_DATA_REQUEST_EVT:
btu_hcif_rem_oob_request_evt (p);
break;/* ... */
#endif
#if (CLASSIC_BT_INCLUDED == TRUE)
case HCI_SIMPLE_PAIRING_COMPLETE_EVT:
btu_hcif_simple_pair_complete_evt (p);
break;...
case HCI_USER_PASSKEY_NOTIFY_EVT:
btu_hcif_user_passkey_notif_evt (p);
break;...
case HCI_KEYPRESS_NOTIFY_EVT:
btu_hcif_keypress_notif_evt (p);
break;/* ... */
#endif
case HCI_LINK_SUPER_TOUT_CHANGED_EVT:
btu_hcif_link_supv_to_changed_evt (p);
break;
#if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE...
case HCI_ENHANCED_FLUSH_COMPLETE_EVT:
btu_hcif_enhanced_flush_complete_evt ();
break;/* ... */
#endif
#if (BLE_INCLUDED == TRUE)
case HCI_BLE_EVENT:
STREAM_TO_UINT8 (ble_sub_code, p);
hci_evt_len--;
HCI_TRACE_DEBUG("BLE HCI(id=%d) event = 0x%02x)", hci_evt_code, ble_sub_code);
switch (ble_sub_code) {
case HCI_BLE_ADV_PKT_RPT_EVT:
case HCI_BLE_ADV_DISCARD_REPORT_EVT:
case HCI_BLE_DIRECT_ADV_EVT:
HCI_TRACE_ERROR("Unexpected HCI BLE event = 0x%02x", ble_sub_code);
break;...
case HCI_BLE_CONN_COMPLETE_EVT:
btu_ble_ll_conn_complete_evt(p, hci_evt_len);
break;...
case HCI_BLE_LL_CONN_PARAM_UPD_EVT:
btu_ble_ll_conn_param_upd_evt(p, hci_evt_len);
break;...
case HCI_BLE_READ_REMOTE_FEAT_CMPL_EVT:
btu_ble_read_remote_feat_evt(p);
break;...
case HCI_BLE_LTK_REQ_EVT:
#if (SMP_INCLUDED == TRUE)
btu_ble_proc_ltk_req(p);
#endif
break;
...
case HCI_BLE_ENHANCED_CONN_COMPLETE_EVT:
btu_ble_proc_enhanced_conn_cmpl(p, hci_evt_len);
break;
#if (BLE_LLT_INCLUDED == TRUE)...
case HCI_BLE_RC_PARAM_REQ_EVT:
btu_ble_rc_param_req_evt(p);
break;/* ... */
#endif
case HCI_BLE_DATA_LENGTH_CHANGE_EVT:
btu_ble_data_length_change_evt(p, hci_evt_len);
break;
#if (BLE_50_FEATURE_SUPPORT == TRUE)...
case HCI_BLE_PHY_UPDATE_COMPLETE_EVT:
btu_ble_phy_update_complete_evt(p);
break;...
case HCI_BLE_EXT_ADV_REPORT_EVT:
btu_ble_ext_adv_report_evt(p, hci_evt_len);
break;...
case HCI_BLE_PERIOD_ADV_SYNC_ESTAB_EVT:
btu_ble_periodic_adv_sync_establish_evt(p);
break;...
case HCI_BLE_PERIOD_ADV_REPORT_EVT:
btu_ble_periodic_adv_report_evt(p, hci_evt_len);
break;...
case HCI_BLE_PERIOD_ADV_SYNC_LOST_EVT:
btu_ble_periodic_adv_sync_lost_evt(p);
break;...
case HCI_BLE_SCAN_TIMEOUT_EVT:
btu_ble_scan_timeout_evt(p);
break;...
case HCI_BLE_ADV_SET_TERMINATED_EVT:
btu_ble_adv_set_terminate_evt(p);
break;...
case HCI_BLE_SCAN_REQ_RECEIVED_EVT:
btu_ble_scan_req_received_evt(p);
break;...
case HCI_BLE_CHANNEL_SELECT_ALG:
btu_ble_channel_select_alg_evt(p);
break;/* ... */
#endif
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
case HCI_BLE_PERIOD_ADV_SYNC_TRANS_RECV_EVT:
btu_ble_periodic_adv_sync_trans_recv(p);
break;/* ... */
#endif
}{...}
break;/* ... */
#endif
case HCI_VENDOR_SPECIFIC_EVT:
btm_vendor_specific_evt (p, hci_evt_len);
break;...
}{...}
}{ ... }
/* ... */
void btu_hcif_send_cmd (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_buf)
{
if (!p_buf) {
HCI_TRACE_ERROR("%s p_buf is NULL", __func__);
return;
}{...}
uint16_t opcode;
uint8_t *stream = p_buf->data + p_buf->offset;
void *vsc_callback = NULL;
STREAM_TO_UINT16(opcode, stream);
assert (p_buf->layer_specific == HCI_CMD_BUF_TYPE_METADATA);
hci_cmd_metadata_t *metadata = HCI_GET_CMD_METAMSG(p_buf);
metadata->command_complete_cb = btu_hcif_command_complete_evt;
metadata->command_status_cb = btu_hcif_command_status_evt;
metadata->opcode = opcode;
vsc_callback = metadata->context;
if ((opcode & HCI_GRP_VENDOR_SPECIFIC) != HCI_GRP_VENDOR_SPECIFIC
#if BLE_INCLUDED == TRUE
&& (opcode != HCI_BLE_RAND)
&& (opcode != HCI_BLE_ENCRYPT)/* ... */
#endif
) {
assert (vsc_callback == NULL);
}{...}
hci_layer_get_interface()->transmit_command(
p_buf,
btu_hcif_command_complete_evt,
btu_hcif_command_status_evt,
vsc_callback);
#if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE)
btu_check_bt_sleep ();
#endif
}{ ... }
#if (BLE_50_FEATURE_SUPPORT == TRUE)
UINT8 btu_hcif_send_cmd_sync (UINT8 controller_id, BT_HDR *p_buf)
{
if (!p_buf) {
HCI_TRACE_ERROR("%s p_buf is NULL", __func__);
return HCI_ERR_ILLEGAL_PARAMETER_FMT;
}{...}
BlE_SYNC *sync_info = btsnd_hcic_ble_get_sync_info();
if((sync_info == NULL) || (sync_info->sync_sem == NULL)) {
HCI_TRACE_ERROR("%s sync_info error", __func__);
return HCI_ERR_ILLEGAL_PARAMETER_FMT;
}{...}
uint16_t opcode;
uint8_t *stream = p_buf->data + p_buf->offset;
void *vsc_callback = NULL;
STREAM_TO_UINT16(opcode, stream);
sync_info->opcode = opcode;
assert (p_buf->layer_specific == HCI_CMD_BUF_TYPE_METADATA);
hci_cmd_metadata_t *metadata = HCI_GET_CMD_METAMSG(p_buf);
metadata->command_complete_cb = btu_hcif_command_complete_evt;
metadata->command_status_cb = btu_hcif_command_status_evt;
metadata->command_free_cb = NULL;
metadata->opcode = opcode;
vsc_callback = metadata->context;
if ((opcode & HCI_GRP_VENDOR_SPECIFIC) != HCI_GRP_VENDOR_SPECIFIC
#if BLE_INCLUDED == TRUE
&& (opcode != HCI_BLE_RAND)
&& (opcode != HCI_BLE_ENCRYPT)/* ... */
#endif
) {
assert (vsc_callback == NULL);
}{...}
hci_layer_get_interface()->transmit_command(
p_buf,
btu_hcif_command_complete_evt,
btu_hcif_command_status_evt,
vsc_callback);
osi_sem_take(&sync_info->sync_sem, OSI_SEM_MAX_TIMEOUT);
#if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE)
btu_check_bt_sleep ();
#endif
return btsnd_hcic_ble_get_status();
}{...}
/* ... */#endif
/* ... */
void btu_hcif_send_host_rdy_for_data(void)
{
UINT16 num_pkts[MAX_L2CAP_LINKS + 4];
UINT16 handles[MAX_L2CAP_LINKS + 4];
UINT8 num_ents;
num_ents = l2c_link_pkts_rcvd (num_pkts, handles);
if (num_ents) {
btsnd_hcic_host_num_xmitted_pkts (num_ents, handles, num_pkts);
}{...}
}{ ... }
/* ... */
static void btu_hcif_inquiry_comp_evt (UINT8 *p)
{
UINT8 status;
STREAM_TO_UINT8 (status, p);
btm_process_inq_complete(status, BTM_BR_INQUIRY_MASK);
}{ ... }
/* ... */
static void btu_hcif_inquiry_result_evt (UINT8 *p)
{
btm_process_inq_results (p, BTM_INQ_RESULT_STANDARD);
}{ ... }
/* ... */
static void btu_hcif_inquiry_rssi_result_evt (UINT8 *p)
{
btm_process_inq_results (p, BTM_INQ_RESULT_WITH_RSSI);
}{ ... }
/* ... */
static void btu_hcif_extended_inquiry_result_evt (UINT8 *p)
{
btm_process_inq_results (p, BTM_INQ_RESULT_EXTENDED);
}{ ... }
/* ... */
static void btu_hcif_connection_comp_evt (UINT8 *p)
{
UINT8 status;
UINT16 handle;
BD_ADDR bda;
UINT8 link_type;
UINT8 enc_mode;
STREAM_TO_UINT8 (status, p);
STREAM_TO_UINT16 (handle, p);
STREAM_TO_BDADDR (bda, p);
STREAM_TO_UINT8 (link_type, p);
STREAM_TO_UINT8 (enc_mode, p);
handle = HCID_GET_HANDLE (handle);
btm_acl_connected(bda, handle, link_type, enc_mode, status);
HCI_TRACE_WARNING("hcif conn complete: hdl 0x%x, st 0x%x", handle, status);
}{ ... }
/* ... */
static void btu_hcif_connection_request_evt (UINT8 *p)
{
BD_ADDR bda;
DEV_CLASS dc;
UINT8 link_type;
STREAM_TO_BDADDR (bda, p);
STREAM_TO_DEVCLASS (dc, p);
STREAM_TO_UINT8 (link_type, p);
if (link_type == HCI_LINK_TYPE_ACL) {
#if (SMP_INCLUDED == TRUE)
btm_sec_conn_req (bda, dc);
#endif
}{...}
#if BTM_SCO_INCLUDED == TRUE
else {
btm_sco_conn_req (bda, dc, link_type);
}{...}
#endif/* ... */
}{ ... }
/* ... */
static void btu_hcif_disconnection_comp_evt (UINT8 *p)
{
UINT16 handle;
UINT8 reason;
++p;
STREAM_TO_UINT16 (handle, p);
STREAM_TO_UINT8 (reason, p);
handle = HCID_GET_HANDLE (handle);
btm_acl_disconnected(handle, reason);
HCI_TRACE_WARNING("hcif disc complete: hdl 0x%x, rsn 0x%x", handle, reason);
}{ ... }
/* ... */
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_authentication_comp_evt (UINT8 *p)
{
UINT8 status;
UINT16 handle;
STREAM_TO_UINT8 (status, p);
STREAM_TO_UINT16 (handle, p);
btm_sec_auth_complete (handle, status);
}{ ... }
/* ... */#endif
/* ... */
static void btu_hcif_rmt_name_request_comp_evt (UINT8 *p, UINT16 evt_len)
{
UINT8 status;
BD_ADDR bd_addr;
STREAM_TO_UINT8 (status, p);
STREAM_TO_BDADDR (bd_addr, p);
evt_len -= (1 + BD_ADDR_LEN);
btm_process_remote_name (bd_addr, p, evt_len, status);
#if (SMP_INCLUDED == TRUE)
btm_sec_rmt_name_request_complete (bd_addr, p, status);
#endif
}{ ... }
/* ... */
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_encryption_change_evt (UINT8 *p)
{
UINT8 status;
UINT16 handle;
UINT8 encr_enable;
STREAM_TO_UINT8 (status, p);
STREAM_TO_UINT16 (handle, p);
STREAM_TO_UINT8 (encr_enable, p);
btm_acl_encrypt_change (handle, status, encr_enable);
btm_sec_encrypt_change (handle, status, encr_enable);
}{ ... }
/* ... */#endif
/* ... */
static void btu_hcif_read_rmt_features_comp_evt (UINT8 *p)
{
btm_read_remote_features_complete(p);
}{ ... }
/* ... */
static void btu_hcif_read_rmt_ext_features_comp_evt (UINT8 *p)
{
UINT8 *p_cur = p;
UINT8 status;
UINT16 handle;
STREAM_TO_UINT8 (status, p_cur);
if (status == HCI_SUCCESS) {
btm_read_remote_ext_features_complete(p);
}{...} else {
STREAM_TO_UINT16 (handle, p_cur);
btm_read_remote_ext_features_failed(status, handle);
}{...}
}{ ... }
/* ... */
static void btu_hcif_read_rmt_version_comp_evt (UINT8 *p)
{
btm_read_remote_version_complete (p);
}{ ... }
/* ... */
static void btu_hcif_qos_setup_comp_evt (UINT8 *p)
{
UINT8 status;
UINT16 handle;
FLOW_SPEC flow;
STREAM_TO_UINT8 (status, p);
STREAM_TO_UINT16 (handle, p);
STREAM_TO_UINT8 (flow.qos_flags, p);
STREAM_TO_UINT8 (flow.service_type, p);
STREAM_TO_UINT32 (flow.token_rate, p);
STREAM_TO_UINT32 (flow.peak_bandwidth, p);
STREAM_TO_UINT32 (flow.latency, p);
STREAM_TO_UINT32 (flow.delay_variation, p);
btm_qos_setup_complete(status, handle, &flow);
}{ ... }
/* ... */
static void btu_hcif_esco_connection_comp_evt (UINT8 *p)
{
#if BTM_SCO_INCLUDED == TRUE
tBTM_ESCO_DATA data;
UINT16 handle;
BD_ADDR bda;
UINT8 status;
STREAM_TO_UINT8 (status, p);
STREAM_TO_UINT16 (handle, p);
STREAM_TO_BDADDR (bda, p);
STREAM_TO_UINT8 (data.link_type, p);
STREAM_TO_UINT8 (data.tx_interval, p);
STREAM_TO_UINT8 (data.retrans_window, p);
STREAM_TO_UINT16 (data.rx_pkt_len, p);
STREAM_TO_UINT16 (data.tx_pkt_len, p);
STREAM_TO_UINT8 (data.air_mode, p);
memcpy (data.bd_addr, bda, BD_ADDR_LEN);
btm_sco_connected (status, bda, handle, &data);/* ... */
#endif
}{ ... }
/* ... */
static void btu_hcif_esco_connection_chg_evt (UINT8 *p)
{
#if BTM_SCO_INCLUDED == TRUE
UINT16 handle;
UINT16 tx_pkt_len;
UINT16 rx_pkt_len;
UINT8 status;
UINT8 tx_interval;
UINT8 retrans_window;
STREAM_TO_UINT8 (status, p);
STREAM_TO_UINT16 (handle, p);
STREAM_TO_UINT8 (tx_interval, p);
STREAM_TO_UINT8 (retrans_window, p);
STREAM_TO_UINT16 (rx_pkt_len, p);
STREAM_TO_UINT16 (tx_pkt_len, p);
btm_esco_proc_conn_chg (status, handle, tx_interval, retrans_window,
rx_pkt_len, tx_pkt_len);/* ... */
#endif
}{ ... }
/* ... */
static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_len,
void *p_cplt_cback)
{
uint8_t status;
switch (opcode) {
case HCI_INQUIRY_CANCEL:
btm_process_cancel_complete(HCI_SUCCESS, BTM_BR_INQUIRY_MASK);
break;...
case HCI_SET_EVENT_FILTER:
btm_event_filter_complete (p);
break;
...
case HCI_DELETE_STORED_LINK_KEY:
btm_delete_stored_link_key_complete (p);
break;
...
case HCI_READ_LOCAL_NAME:
btm_read_local_name_complete (p, evt_len);
break;
...
case HCI_GET_LINK_QUALITY:
btm_read_link_quality_complete (p);
break;
...
case HCI_READ_RSSI:
btm_read_rssi_complete (p);
break;
...
case HCI_READ_TRANSMIT_POWER_LEVEL:
btm_read_tx_power_complete(p, FALSE);
break;
...
case HCI_CREATE_CONNECTION_CANCEL:
btm_create_conn_cancel_complete(p);
break;
...
case HCI_READ_LOCAL_OOB_DATA:
#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE
btm_read_local_oob_complete(p);
#endif
break;
...
case HCI_READ_INQ_TX_POWER_LEVEL:
btm_read_linq_tx_power_complete (p);
break;
#if (CLASSIC_BT_INCLUDED == TRUE)...
case HCI_SET_AFH_CHANNELS:
btm_set_afh_channels_complete(p);
break;...
case HCI_WRITE_PAGE_TOUT:
btm_set_page_timeout_complete(p);
break;
#if (ENC_KEY_SIZE_CTRL_MODE == ENC_KEY_SIZE_CTRL_MODE_STD)...
case HCI_SET_MIN_ENC_KEY_SIZE:
btm_set_min_enc_key_size_complete(p);
break;/* ... */
#endif
#if (ENC_KEY_SIZE_CTRL_MODE == ENC_KEY_SIZE_CTRL_MODE_VSC)
case HCI_VENDOR_BT_SET_MIN_ENC_KEY_SIZE:
btm_set_min_enc_key_size_complete(p);
break;/* ... */
#endif/* ... */
#endif
#if (BLE_INCLUDED == TRUE)
case HCI_BLE_SET_HOST_CHNL_CLASS:
btm_ble_set_channels_complete(p);
break;...
case HCI_BLE_ADD_WHITE_LIST:
btm_ble_add_2_white_list_complete(*p);
break;
...
case HCI_BLE_CLEAR_WHITE_LIST:
btm_ble_clear_white_list_complete(p, evt_len);
break;...
case HCI_BLE_WRITE_ADV_PARAMS: {
STREAM_TO_UINT8 (status, p);
if(status != HCI_SUCCESS) {
HCI_TRACE_ERROR("hci write adv params error 0x%x", status);
}{...}
break;
}{...}
... case HCI_BLE_RC_PARAM_REQ_REPLY: {
STREAM_TO_UINT8 (status, p);
if(status != HCI_SUCCESS) {
HCI_TRACE_ERROR("hci connection params reply command error 0x%x", status);
}{...}
break;
}{...}
... case HCI_BLE_RC_PARAM_REQ_NEG_REPLY: {
STREAM_TO_UINT8 (status, p);
if(status != HCI_SUCCESS) {
HCI_TRACE_ERROR("hci connection params neg reply command error %x", status);
}{...}
break;
}{...}
... case HCI_BLE_REMOVE_WHITE_LIST:
btm_ble_remove_from_white_list_complete(p, evt_len);
break;
...
case HCI_BLE_RAND:
case HCI_BLE_ENCRYPT:
#if (SMP_INCLUDED == TRUE)
btm_ble_rand_enc_complete (p, opcode, (tBTM_RAND_ENC_CB *)p_cplt_cback);
#endif
break;
...
case HCI_BLE_READ_ADV_CHNL_TX_POWER:
btm_read_tx_power_complete(p, TRUE);
break;
...
case HCI_BLE_WRITE_ADV_ENABLE:
btm_ble_write_adv_enable_complete(p);
break;
...
case HCI_BLE_CREATE_LL_CONN:
btm_ble_create_ll_conn_complete(*p);
break;
...
case HCI_BLE_TRANSMITTER_TEST:
case HCI_BLE_RECEIVER_TEST:
case HCI_BLE_TEST_END:
btm_ble_test_command_complete(p);
break;...
case HCI_BLE_CREATE_CONN_CANCEL:
btm_ble_create_conn_cancel_complete(p);
break;
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)...
case HCI_BLE_ADD_DEV_RESOLVING_LIST:
btm_ble_add_resolving_list_entry_complete(p, evt_len);
break;
...
case HCI_BLE_RM_DEV_RESOLVING_LIST:
btm_ble_remove_resolving_list_entry_complete(p, evt_len);
break;
...
case HCI_BLE_CLEAR_RESOLVING_LIST:
btm_ble_clear_resolving_list_complete(p, evt_len);
break;
...
case HCI_BLE_READ_RESOLVABLE_ADDR_PEER:
btm_ble_read_resolving_list_entry_complete(p, evt_len);
break;
...
case HCI_BLE_READ_RESOLVABLE_ADDR_LOCAL:
break;...
case HCI_BLE_SET_ADDR_RESOLUTION_ENABLE:
btm_ble_set_addr_resolution_enable_complete(p, evt_len);
break;...
case HCI_BLE_SET_RAND_PRIV_ADDR_TIMOUT:
btm_ble_set_rpa_timeout_complete(p, evt_len);
break;...
case HCI_BLE_SET_PRIVACY_MODE:
btm_ble_set_privacy_mode_complete(p, evt_len);
break;/* ... */
#endif
#if (BLE_50_FEATURE_SUPPORT == TRUE)
case HCI_BLE_SET_EXT_ADV_PARAM:
case HCI_BLE_SET_EXT_ADV_DATA:
case HCI_BLE_SET_EXT_SCAN_RSP_DATA:
case HCI_BLE_SET_EXT_ADV_ENABLE: {
STREAM_TO_UINT8 (status, p);
HCI_TRACE_EVENT("%s opcode 0x%x status 0x%x", __func__, opcode, status);
break;
}{...}
... case HCI_BLE_READ_PHY: {
uint16_t conn_handle;
uint8_t tx_phy;
uint8_t rx_phy;
STREAM_TO_UINT8(status, p);
STREAM_TO_UINT16(conn_handle, p);
STREAM_TO_UINT8(tx_phy, p);
STREAM_TO_UINT8(rx_phy, p);
btm_read_phy_callback(status, conn_handle, tx_phy, rx_phy);
break;
}{...}
... case HCI_BLE_ENH_RX_TEST:
case HCI_BLE_ENH_TX_TEST:
btm_ble_test_command_complete(p);
break;/* ... */
#endif
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
case HCI_BLE_SET_PERIOD_ADV_RECV_ENABLE:
case HCI_BLE_SET_DEFAULT_PAST_PARAMS:
break;...
case HCI_BLE_PERIOD_ADV_SYNC_TRANS:
case HCI_BLE_PERIOD_ADV_SET_INFO_TRANS:
case HCI_BLE_SET_PAST_PARAMS: {
UINT16 conn_handle;
STREAM_TO_UINT8(status, p);
STREAM_TO_UINT16(conn_handle, p);
btm_ble_periodic_adv_sync_trans_complete(opcode, status, conn_handle);
break;
}{...}
/* ... */#endif /* ... */
#endif
default: {
if ((opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC) {
btm_vsc_complete (p, opcode, evt_len, (tBTM_CMPL_CB *)p_cplt_cback);
}{...}
STREAM_TO_UINT8 (status, p);
if(status != HCI_SUCCESS) {
HCI_TRACE_ERROR("CC evt: op=0x%x, status=0x%x", opcode, status);
}{...}
break;
}{...}
... }{...}
}{ ... }
/* ... */
static void btu_hcif_command_complete_evt_on_task(BT_HDR *event)
{
command_complete_hack_t *hack = (command_complete_hack_t *)&event->data[0];
command_opcode_t opcode;
uint8_t *stream = hack->response->data + hack->response->offset + 3;
STREAM_TO_UINT16(opcode, stream);
btu_hcif_hdl_command_complete(
opcode,
stream,
hack->response->len - 5,
hack->context);
osi_free(hack->response);
osi_free(event);
}{ ... }
static void btu_hcif_command_complete_evt(BT_HDR *response, void *context)
{
#if (BLE_INCLUDED == TRUE)
command_opcode_t opcode;
uint8_t *stream = response->data + response->offset + 3;
STREAM_TO_UINT16(opcode, stream);
switch (opcode) {
case HCI_BLE_WRITE_ADV_DATA:
adv_data_status = *stream;
osi_sem_give(&adv_data_sem);
break;...
case HCI_BLE_WRITE_SCAN_RSP_DATA:
adv_data_status = *stream;
osi_sem_give(&adv_data_sem);
break;...
case HCI_BLE_WRITE_ADV_ENABLE: {
adv_enable_status = *stream;
osi_sem_give(&adv_enable_sem);
break;
}{...}
... case HCI_BLE_WRITE_ADV_PARAMS:
adv_param_status = *stream;
osi_sem_give(&adv_param_sem);
break;...
case HCI_BLE_WRITE_SCAN_PARAMS:
scan_param_status = *stream;
osi_sem_give(&scan_param_sem);
break;...
case HCI_BLE_WRITE_SCAN_ENABLE:
scan_enable_status = *stream;
osi_sem_give(&scan_enable_sem);
break;...
default:
break;...
}{...}
/* ... */#endif
BT_HDR *event = osi_calloc(sizeof(BT_HDR) + sizeof(command_complete_hack_t));
command_complete_hack_t *hack = (command_complete_hack_t *)&event->data[0];
#if (BLE_50_FEATURE_SUPPORT == TRUE)
UINT8 status = 0;
stream = response->data + response->offset + 3 + 2;
STREAM_TO_UINT8(status, stream);
btsnd_hci_ble_set_status(status);/* ... */
#endif
HCI_TRACE_DEBUG("btu_hcif_command_complete_evt\n");
hack->callback = btu_hcif_command_complete_evt_on_task;
hack->response = response;
hack->context = context;
event->event = BTU_POST_TO_TASK_NO_GOOD_HORRIBLE_HACK;
if (btu_task_post(SIG_BTU_HCI_MSG, event, OSI_THREAD_MAX_TIMEOUT) == false) {
osi_free(event);
}{...}
}{ ... }
/* ... */
static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_cmd,
void *p_vsc_status_cback)
{
if (status != HCI_SUCCESS){
HCI_TRACE_WARNING("%s,opcode:0x%04x,status:0x%02x", __func__, opcode,status);
}{...}
BD_ADDR bd_addr;
UINT16 handle;
#if BTM_SCO_INCLUDED == TRUE
tBTM_ESCO_DATA esco_data;
#endif
switch (opcode) {
case HCI_EXIT_SNIFF_MODE:
case HCI_EXIT_PARK_MODE:
#if BTM_SCO_WAKE_PARKED_LINK == TRUE
if (status != HCI_SUCCESS) {
if (p_cmd != NULL) {
p_cmd++;
STREAM_TO_UINT16 (handle, p_cmd);
btm_sco_chk_pend_unpark (status, handle);
}{...}
}{...}
#endif/* ... */
...
case HCI_HOLD_MODE:
case HCI_SNIFF_MODE:
case HCI_PARK_MODE:
btm_pm_proc_cmd_status(status);
break;
#if (BLE_50_FEATURE_SUPPORT == TRUE)...
case HCI_BLE_PERIOD_ADV_CREATE_SYNC:
{
uint8_t btm_status = BTM_SUCCESS;
if(status != HCI_SUCCESS) {
HCI_TRACE_ERROR("CS evt: LE PA CreateSync status=0x%x", status);
btm_status = BTM_ILLEGAL_VALUE;
}{...}
btm_create_sync_callback(btm_status);
break;
}{...}
case HCI_BLE_SET_PHY:
{
uint8_t btm_status = BTM_SUCCESS;
if(status != HCI_SUCCESS) {
HCI_TRACE_ERROR("CS evt: LE SetPhy status=0x%x", status);
btm_status = BTM_ILLEGAL_VALUE;
}{...}
btm_set_phy_callback(btm_status);
break;
}{...}
/* ... */#endif
default:
if (status != HCI_SUCCESS) {
switch (opcode) {
case HCI_INQUIRY:
btm_process_inq_complete(status, BTM_BR_INQUIRY_MASK);
break;
...
case HCI_RMT_NAME_REQUEST:
btm_process_remote_name (NULL, NULL, 0, status);
#if (SMP_INCLUDED == TRUE)
btm_sec_rmt_name_request_complete (NULL, NULL, status);
#endif
break;
...
case HCI_QOS_SETUP_COMP_EVT:
btm_qos_setup_complete(status, 0, NULL);
break;
...
case HCI_SWITCH_ROLE:
if (p_cmd != NULL) {
p_cmd++;
STREAM_TO_BDADDR (bd_addr, p_cmd);
btm_acl_role_changed(status, bd_addr, BTM_ROLE_UNDEFINED);
}{...} else {
btm_acl_role_changed(status, NULL, BTM_ROLE_UNDEFINED);
}{...}
l2c_link_role_changed (NULL, BTM_ROLE_UNDEFINED, HCI_ERR_COMMAND_DISALLOWED);
break;
...
case HCI_CREATE_CONNECTION:
if (p_cmd != NULL) {
p_cmd++;
STREAM_TO_BDADDR (bd_addr, p_cmd);
#if (SMP_INCLUDED == TRUE)
btm_sec_connected (bd_addr, HCI_INVALID_HANDLE, status, 0);
#endif
l2c_link_hci_conn_comp (status, HCI_INVALID_HANDLE, bd_addr);
}{...}
break;
...
case HCI_READ_RMT_EXT_FEATURES:
if (p_cmd != NULL) {
p_cmd++;
STREAM_TO_UINT16 (handle, p_cmd);
}{...} else {
handle = HCI_INVALID_HANDLE;
}{...}
btm_read_remote_ext_features_failed(status, handle);
break;
...
case HCI_AUTHENTICATION_REQUESTED:
#if (SMP_INCLUDED == TRUE)
btm_sec_auth_complete (BTM_INVALID_HCI_HANDLE, status);/* ... */
#endif
break;
...
case HCI_SET_CONN_ENCRYPTION:
#if (SMP_INCLUDED == TRUE)
btm_sec_encrypt_change (BTM_INVALID_HCI_HANDLE, status, FALSE);/* ... */
#endif
break;
#if BLE_INCLUDED == TRUE
#if (BLE_50_FEATURE_SUPPORT == TRUE)
case HCI_BLE_EXT_CREATE_CONN:
#endif
case HCI_BLE_CREATE_LL_CONN:
btm_ble_create_ll_conn_complete(status);
break;...
case HCI_BLE_UPD_LL_CONN_PARAMS:
if (p_cmd != NULL){
p_cmd++;
STREAM_TO_UINT16 (handle, p_cmd);
btu_ble_ll_get_conn_param_format_err_from_contoller(status, handle);
}{...}
break;/* ... */
#endif
#if BTM_SCO_INCLUDED == TRUE
case HCI_SETUP_ESCO_CONNECTION:
if (p_cmd != NULL) {
p_cmd++;
STREAM_TO_UINT16 (handle, p_cmd);
if (btm_is_sco_active(handle)) {
btm_esco_proc_conn_chg (status, handle, 0, 0, 0, 0);
}{...} else {
btm_sco_connected (status, NULL, handle, &esco_data);
}{...}
}{...}
break;/* ... */
#endif
/* ... */
default:
if ((opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC) {
btm_vsc_complete (&status, opcode, 1, (tBTM_CMPL_CB *)p_vsc_status_cback);
}{...}
break;...
}{...}
}{...} else {
if ((opcode & HCI_GRP_VENDOR_SPECIFIC) == HCI_GRP_VENDOR_SPECIFIC) {
btm_vsc_complete (&status, opcode, 1, (tBTM_CMPL_CB *)p_vsc_status_cback);
}{...}
}{...}
... }{...}
}{ ... }
/* ... */
static void btu_hcif_command_status_evt_on_task(BT_HDR *event)
{
command_status_hack_t *hack = (command_status_hack_t *)&event->data[0];
command_opcode_t opcode;
uint8_t *stream = hack->command->data + hack->command->offset;
STREAM_TO_UINT16(opcode, stream);
btu_hcif_hdl_command_status(
opcode,
hack->status,
stream,
hack->context);
hci_cmd_metadata_t *metadata = HCI_GET_CMD_METAMSG(hack->command);
assert(metadata->opcode == opcode);
HCI_FREE_CMD_BUF(hack->command);
osi_free(event);
}{ ... }
static void btu_hcif_command_status_evt(uint8_t status, BT_HDR *command, void *context)
{
BT_HDR *event = osi_calloc(sizeof(BT_HDR) + sizeof(command_status_hack_t));
command_status_hack_t *hack = (command_status_hack_t *)&event->data[0];
hack->callback = btu_hcif_command_status_evt_on_task;
hack->status = status;
hack->command = command;
hack->context = context;
event->event = BTU_POST_TO_TASK_NO_GOOD_HORRIBLE_HACK;
if (btu_task_post(SIG_BTU_HCI_MSG, event, OSI_THREAD_MAX_TIMEOUT) == false) {
osi_free(event);
}{...}
}{ ... }
/* ... */
static void btu_hcif_hardware_error_evt (UINT8 *p)
{
HCI_TRACE_ERROR("Ctlr H/w error event - code:0x%x\n", *p);
btm_report_device_status (BTM_DEV_STATUS_DOWN);
if (BTM_IsDeviceUp()) {
BTM_DeviceReset (NULL);
}{...}
}{ ... }
/* ... */
static void btu_hcif_flush_occured_evt (void)
{
}{ ... }
/* ... */
static void btu_hcif_role_change_evt (UINT8 *p)
{
UINT8 status;
BD_ADDR bda;
UINT8 role;
STREAM_TO_UINT8 (status, p);
STREAM_TO_BDADDR (bda, p);
STREAM_TO_UINT8 (role, p);
l2c_link_role_changed (bda, role, status);
btm_acl_role_changed(status, bda, role);
}{ ... }
/* ... */
static void btu_hcif_num_compl_data_pkts_evt (UINT8 *p)
{
l2c_link_process_num_completed_pkts (p);
#if (BTM_SCO_HCI_INCLUDED == TRUE) && (BTM_SCO_INCLUDED == TRUE)
btm_sco_process_num_completed_pkts (p);
#endif
}{ ... }
/* ... */
static void btu_hcif_mode_change_evt (UINT8 *p)
{
UINT8 status;
UINT16 handle;
UINT8 current_mode;
UINT16 interval;
STREAM_TO_UINT8 (status, p);
STREAM_TO_UINT16 (handle, p);
STREAM_TO_UINT8 (current_mode, p);
STREAM_TO_UINT16 (interval, p);
#if BTM_SCO_WAKE_PARKED_LINK == TRUE
btm_sco_chk_pend_unpark (status, handle);
#endif
btm_pm_proc_mode_change (status, handle, current_mode, interval);
HCI_TRACE_WARNING("hcif mode change: hdl 0x%x, mode %d, intv %d, status 0x%x",
handle, current_mode, interval, status);
/* ... */
}{ ... }
/* ... */
static void btu_hcif_ssr_evt (UINT8 *p, UINT16 evt_len)
{
#if (BTM_SSR_INCLUDED == TRUE)
btm_pm_proc_ssr_evt(p, evt_len);
#endif
UINT8 status;
UINT16 handle;
UINT16 max_tx_lat;
UINT16 max_rx_lat;
STREAM_TO_UINT8 (status, p);
STREAM_TO_UINT16 (handle, p);
STREAM_TO_UINT16 (max_tx_lat, p);
STREAM_TO_UINT16 (max_rx_lat, p);
UNUSED(status);
UNUSED(handle);
UNUSED(max_tx_lat);
UNUSED(max_rx_lat);
HCI_TRACE_WARNING("hcif ssr evt: st 0x%x, hdl 0x%x, tx_lat %d rx_lat %d", status, handle, max_tx_lat, max_rx_lat);
}{ ... }
/* ... */
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_pin_code_request_evt (UINT8 *p)
{
#if (CLASSIC_BT_INCLUDED == TRUE)
BD_ADDR bda;
STREAM_TO_BDADDR (bda, p);
l2c_pin_code_request (bda);
btm_sec_pin_code_request (bda);/* ... */
#endif
}{ ... }
/* ... */
static void btu_hcif_link_key_request_evt (UINT8 *p)
{
BD_ADDR bda;
STREAM_TO_BDADDR (bda, p);
btm_sec_link_key_request (bda);
}{ ... }
/* ... */
static void btu_hcif_link_key_notification_evt (UINT8 *p)
{
BD_ADDR bda;
LINK_KEY key;
UINT8 key_type;
STREAM_TO_BDADDR (bda, p);
STREAM_TO_ARRAY16 (key, p);
STREAM_TO_UINT8 (key_type, p);
btm_sec_link_key_notification (bda, key, key_type);
}{ ... }
#endif/* ... */
/* ... */
static void btu_hcif_loopback_command_evt (void)
{
}{ ... }
/* ... */
static void btu_hcif_data_buf_overflow_evt (void)
{
}{ ... }
/* ... */
static void btu_hcif_max_slots_changed_evt (void)
{
}{ ... }
/* ... */
static void btu_hcif_read_clock_off_comp_evt (UINT8 *p)
{
UINT8 status;
UINT16 handle;
UINT16 clock_offset;
STREAM_TO_UINT8 (status, p);
if (status != HCI_SUCCESS) {
return;
}{...}
STREAM_TO_UINT16 (handle, p);
STREAM_TO_UINT16 (clock_offset, p);
handle = HCID_GET_HANDLE (handle);
btm_process_clk_off_comp_evt (handle, clock_offset);
btm_sec_update_clock_offset (handle, clock_offset);
}{ ... }
/* ... */
static void btu_hcif_conn_pkt_type_change_evt (UINT8 *p)
{
UINT8 status;
UINT16 handle;
UINT16 pkt_types;
STREAM_TO_UINT8 (status, p);
STREAM_TO_UINT16 (handle, p);
STREAM_TO_UINT16 (pkt_types, p);
handle = HCID_GET_HANDLE (handle);
btm_acl_pkt_types_changed(status, handle, pkt_types);
}{ ... }
/* ... */
static void btu_hcif_qos_violation_evt (UINT8 *p)
{
UINT16 handle;
STREAM_TO_UINT16 (handle, p);
handle = HCID_GET_HANDLE (handle);
l2c_link_hci_qos_violation (handle);
}{ ... }
/* ... */
static void btu_hcif_page_scan_mode_change_evt (void)
{
}{ ... }
/* ... */
static void btu_hcif_page_scan_rep_mode_chng_evt (void)
{
}{ ... }
/* ... */
/* ... */
static void btu_hcif_host_support_evt (UINT8 *p)
{
btm_sec_rmt_host_support_feat_evt(p);
}{ ... }
/* ... */
#if (CLASSIC_BT_INCLUDED == TRUE)
static void btu_hcif_io_cap_request_evt (UINT8 *p)
{
btm_io_capabilities_req(p);
}{...}
/* ... */
static void btu_hcif_io_cap_response_evt (UINT8 *p)
{
btm_io_capabilities_rsp(p);
}{...}
/* ... */
static void btu_hcif_user_conf_request_evt (UINT8 *p)
{
btm_proc_sp_req_evt(BTM_SP_CFM_REQ_EVT, p);
}{...}
/* ... */
static void btu_hcif_user_passkey_request_evt (UINT8 *p)
{
btm_proc_sp_req_evt(BTM_SP_KEY_REQ_EVT, p);
}{...}
/* ... */
static void btu_hcif_simple_pair_complete_evt (UINT8 *p)
{
btm_simple_pair_complete(p);
}{...}
/* ... */
static void btu_hcif_user_passkey_notif_evt (UINT8 *p)
{
btm_proc_sp_req_evt(BTM_SP_KEY_NOTIF_EVT, p);
}{...}
/* ... */
static void btu_hcif_keypress_notif_evt (UINT8 *p)
{
btm_keypress_notif_evt(p);
}{...}
/* ... */#endif
/* ... */
#if BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE
static void btu_hcif_rem_oob_request_evt (UINT8 *p)
{
btm_rem_oob_req(p);
}{ ... }
/* ... */#endif
/* ... */
static void btu_hcif_link_supv_to_changed_evt (UINT8 *p)
{
UINT16 handle;
UINT16 supv_to;
STREAM_TO_UINT16(handle, p);
STREAM_TO_UINT16(supv_to, p);
UNUSED(handle);
UNUSED(supv_to);
HCI_TRACE_WARNING("hcif link supv_to changed: hdl 0x%x, supv_to %d", handle, supv_to);
}{ ... }
/* ... */
#if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE
static void btu_hcif_enhanced_flush_complete_evt (void)
{
}{ ... }
/* ... */#endif
/* ... */
/* ... */
#if (defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE)
#if (SMP_INCLUDED == TRUE)
static void btu_hcif_encryption_key_refresh_cmpl_evt (UINT8 *p)
{
UINT8 status;
UINT8 enc_enable = 0;
UINT16 handle;
STREAM_TO_UINT8 (status, p);
STREAM_TO_UINT16 (handle, p);
if (status == HCI_SUCCESS) {
enc_enable = 1;
}{...}
btm_sec_encrypt_change (handle, status, enc_enable);
}{ ... }
/* ... */#endif
static void btu_ble_ll_conn_complete_evt ( UINT8 *p, UINT16 evt_len)
{
btm_ble_conn_complete(p, evt_len, FALSE);
}{ ... }
static void btu_ble_proc_enhanced_conn_cmpl( UINT8 *p, UINT16 evt_len)
{
btm_ble_conn_complete(p, evt_len, TRUE);
}{ ... }
static void btu_ble_ll_conn_param_upd_evt (UINT8 *p, UINT16 evt_len)
{
UINT8 status;
UINT16 handle, conn_interval, conn_latency, conn_timeout;
STREAM_TO_UINT8 (status, p);
STREAM_TO_UINT16 (handle, p);
STREAM_TO_UINT16 (conn_interval, p);
STREAM_TO_UINT16 (conn_latency, p);
STREAM_TO_UINT16 (conn_timeout, p);
l2cble_process_conn_update_evt(handle, status, conn_interval,
conn_latency, conn_timeout);
}{ ... }
static void btu_ble_ll_get_conn_param_format_err_from_contoller (UINT8 status, UINT16 handle)
{
/* ... */
l2cble_get_conn_param_format_err_from_contoller(status, handle);
}{ ... }
static void btu_ble_read_remote_feat_evt (UINT8 *p)
{
btm_ble_read_remote_features_complete(p);
}{ ... }
#if BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE
static void btu_ble_proc_ltk_req (UINT8 *p)
{
UINT16 ediv, handle;
UINT8 *pp;
STREAM_TO_UINT16(handle, p);
pp = p + 8;
STREAM_TO_UINT16(ediv, pp);
btm_ble_ltk_request(handle, p, ediv);
}{ ... }
/* ... */#endif
static void btu_ble_data_length_change_evt(UINT8 *p, UINT16 evt_len)
{
UINT16 handle;
UINT16 tx_data_len;
UINT16 rx_data_len;
if (!controller_get_interface()->supports_ble_packet_extension()) {
HCI_TRACE_WARNING("%s, request not supported", __FUNCTION__);
return;
}{...}
STREAM_TO_UINT16(handle, p);
STREAM_TO_UINT16(tx_data_len, p);
p += 2;
STREAM_TO_UINT16(rx_data_len, p);
l2cble_process_data_length_change_event(handle, tx_data_len, rx_data_len);
}{ ... }
#if (BLE_50_FEATURE_SUPPORT == TRUE)
static void btu_ble_phy_update_complete_evt(UINT8 *p)
{
if (!p) {
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
return;
}{...}
tBTM_BLE_UPDATE_PHY update_phy = {0};
STREAM_TO_UINT8(update_phy.status, p);
STREAM_TO_UINT16(update_phy.conn_idx, p);
STREAM_TO_UINT8(update_phy.tx_phy, p);
STREAM_TO_UINT8(update_phy.rx_phy, p);
btm_ble_update_phy_evt(&update_phy);
}{...}
#if BLE_PRIVACY_SPT == TRUE
/* ... */
static void btm_ble_resolve_random_addr_adv_ext(void *p_rec, void *p)
{
tBTM_SEC_DEV_REC *match_rec = (tBTM_SEC_DEV_REC *) p_rec;
BD_ADDR bda;
UINT8 *pp = (UINT8 *)p+4;
if (match_rec) {
memcpy(bda, match_rec->ble.pseudo_addr, BD_ADDR_LEN);
BDADDR_TO_STREAM(pp,bda);
}{...}
}{...}
/* ... */#endif
static void btu_ble_ext_adv_report_evt(UINT8 *p, UINT16 evt_len)
{
tBTM_BLE_EXT_ADV_REPORT ext_adv_report = {0};
UINT8 num_reports = {0};
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
UINT8 *pp = p;
#endif
UINT16 evt_type = 0;
uint8_t addr_type;
BD_ADDR bda;
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
BOOLEAN match = FALSE;
#endif
if (!p) {
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
return;
}{...}
STREAM_TO_UINT8(num_reports, p);
if (num_reports == 0) {
HCI_TRACE_ERROR("%s, Invalid number reports is 0", __func__);
}{...}
while (num_reports--) {
STREAM_TO_UINT16(evt_type, p);
ext_adv_report.event_type = evt_type & 0x1F;
if(ext_adv_report.event_type & BTM_BLE_ADV_LEGACY_MASK) {
ext_adv_report.data_status = BTM_BLE_EXT_ADV_DATA_COMPLETE;
}{...} else {
switch(evt_type & BTM_BLE_ADV_DATA_STATUS_MASK) {
case BTM_BLE_ADV_DATA_COMPLETE_MASK:
ext_adv_report.data_status = BTM_BLE_EXT_ADV_DATA_COMPLETE;
break;...
case BTM_BLE_ADV_DATA_INCOMPLETE_MASK:
ext_adv_report.data_status = BTM_BLE_EXT_ADV_DATA_INCOMPLETE;
break;...
case BTM_BLE_ADV_DATA_TRUNCATED_MASK:
ext_adv_report.data_status = BTM_BLE_EXT_ADV_DATA_TRUNCATED;
break;...
}{...}
}{...}
STREAM_TO_UINT8(addr_type, p);
STREAM_TO_BDADDR(bda, p);
#if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE)
if(addr_type != 0xFF) {
match = btm_identity_addr_to_random_pseudo(bda, &addr_type, FALSE);
if (!match && BTM_BLE_IS_RESOLVE_BDA(bda)) {
btm_ble_resolve_random_addr(bda, btm_ble_resolve_random_addr_adv_ext, pp);
p = p - sizeof(bda);
STREAM_TO_BDADDR(bda, p);
}{...}
}{...}
/* ... */#endif
ext_adv_report.addr_type = addr_type;
memcpy(ext_adv_report.addr, bda, 6);
STREAM_TO_UINT8(ext_adv_report.primary_phy, p);
STREAM_TO_UINT8(ext_adv_report.secondry_phy, p);
STREAM_TO_UINT8(ext_adv_report.sid, p);
STREAM_TO_UINT8(ext_adv_report.tx_power, p);
STREAM_TO_UINT8(ext_adv_report.rssi, p);
STREAM_TO_UINT16(ext_adv_report.per_adv_interval, p);
STREAM_TO_UINT8(ext_adv_report.dir_addr_type, p);
STREAM_TO_BDADDR(ext_adv_report.dir_addr, p);
STREAM_TO_UINT8(ext_adv_report.adv_data_len, p);
if (ext_adv_report.adv_data_len) {
ext_adv_report.adv_data = p;
}{...} else {
ext_adv_report.adv_data = NULL;
}{...}
btm_ble_ext_adv_report_evt(&ext_adv_report);
p += ext_adv_report.adv_data_len;
}{...}
}{...}
static void btu_ble_periodic_adv_sync_establish_evt(UINT8 *p)
{
tBTM_BLE_PERIOD_ADV_SYNC_ESTAB sync_estab = {0};
if (!p) {
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
return;
}{...}
STREAM_TO_UINT8(sync_estab.status, p);
STREAM_TO_UINT16(sync_estab.sync_handle, p);
STREAM_TO_UINT8(sync_estab.sid, p);
STREAM_TO_UINT8(sync_estab.adv_addr_type, p);
STREAM_TO_BDADDR(sync_estab.adv_addr, p);
STREAM_TO_UINT8(sync_estab.adv_phy, p);
STREAM_TO_UINT16(sync_estab.period_adv_interval, p);
STREAM_TO_UINT8(sync_estab.adv_clk_accuracy, p);
btm_ble_periodic_adv_sync_establish_evt(&sync_estab);
}{...}
static void btu_ble_periodic_adv_report_evt(UINT8 *p, UINT8 evt_len)
{
tBTM_PERIOD_ADV_REPORT adv_report = {0};
UINT8 unused = 0;
if (!p) {
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
return;
}{...}
if (evt_len < MIN_BLE_PERIODIC_ADV_REPORT_LEN) {
HCI_TRACE_ERROR("%s, Invalid params, the adv len is too short.", __func__);
return;
}{...}
STREAM_TO_UINT16(adv_report.sync_handle, p);
STREAM_TO_UINT8(adv_report.tx_power, p);
STREAM_TO_UINT8(adv_report.rssi, p);
STREAM_TO_UINT8(unused, p);
STREAM_TO_UINT8(adv_report.data_status, p);
STREAM_TO_UINT8(adv_report.data_length, p);
if ((evt_len - MIN_BLE_PERIODIC_ADV_REPORT_LEN) != adv_report.data_length) {
HCI_TRACE_ERROR("%s, Invalid ev_len = %d is less than adv len = %d", __func__, evt_len, adv_report.data_length);
return;
}{...}
if (adv_report.data_length) {
adv_report.data = p;
}{...} else {
adv_report.data = NULL;
}{...}
btm_ble_periodic_adv_report_evt(&adv_report);
UNUSED(unused);
}{...}
static void btu_ble_periodic_adv_sync_lost_evt(UINT8 *p)
{
tBTM_BLE_PERIOD_ADV_SYNC_LOST sync_lost = {0};
if (!p) {
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
return;
}{...}
STREAM_TO_UINT16(sync_lost.sync_handle, p);
btm_ble_periodic_adv_sync_lost_evt(&sync_lost);
}{...}
static void btu_ble_scan_timeout_evt(UINT8 *p)
{
UNUSED(p);
btm_ble_scan_timeout_evt();
}{...}
static void btu_ble_adv_set_terminate_evt(UINT8 *p)
{
tBTM_BLE_ADV_TERMINAT adv_term = {0};
if (!p) {
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
return;
}{...}
STREAM_TO_UINT8(adv_term.status, p);
STREAM_TO_UINT8(adv_term.adv_handle, p);
STREAM_TO_UINT16(adv_term.conn_handle, p);
STREAM_TO_UINT8(adv_term.completed_event, p);
btm_ble_adv_set_terminated_evt(&adv_term);
}{...}
static void btu_ble_scan_req_received_evt(UINT8 *p)
{
tBTM_BLE_SCAN_REQ_RECEIVED req_received = {0};
if (!p) {
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
return;
}{...}
STREAM_TO_UINT8(req_received.adv_handle, p);
STREAM_TO_UINT8(req_received.scan_addr_type, p);
STREAM_TO_BDADDR(req_received.scan_addr, p);
btm_ble_scan_req_received_evt(&req_received);
}{...}
static void btu_ble_channel_select_alg_evt(UINT8 *p)
{
tBTM_BLE_CHANNEL_SEL_ALG chan_sel_alg = {0};
if (!p) {
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
return;
}{...}
STREAM_TO_UINT16(chan_sel_alg.conn_handle, p);
STREAM_TO_UINT8(chan_sel_alg.channel_sel_alg, p);
btm_ble_channel_select_algorithm_evt(&chan_sel_alg);
}{...}
/* ... */#endif
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
static void btu_ble_periodic_adv_sync_trans_recv(UINT8 *p)
{
UINT16 conn_handle;
tL2C_LCB *p_lcb = NULL;
tBTM_BLE_PERIOD_ADV_SYNC_TRANS_RECV past_recv = {0};
if (!p) {
HCI_TRACE_ERROR("%s, Invalid params.", __func__);
return;
}{...}
STREAM_TO_UINT8(past_recv.status, p);
STREAM_TO_UINT16(conn_handle, p);
STREAM_TO_UINT16(past_recv.service_data, p);
STREAM_TO_UINT16(past_recv.sync_handle, p);
STREAM_TO_UINT8(past_recv.adv_sid, p);
STREAM_TO_UINT8(past_recv.adv_addr_type, p);
STREAM_TO_BDADDR(past_recv.adv_addr, p);
STREAM_TO_UINT8(past_recv.adv_phy, p);
STREAM_TO_UINT16(past_recv.adv_interval, p);
STREAM_TO_UINT8(past_recv.adv_clk_accuracy, p);
p_lcb = l2cu_find_lcb_by_handle(conn_handle);
if(p_lcb) {
memcpy(past_recv.addr, p_lcb->remote_bd_addr, BD_ADDR_LEN);
}{...}
btm_ble_periodic_adv_sync_trans_recv_evt(&past_recv);
}{...}
/* ... */#endif
/* ... */
#if (defined BLE_LLT_INCLUDED) && (BLE_LLT_INCLUDED == TRUE)
static void btu_ble_rc_param_req_evt(UINT8 *p)
{
UINT16 handle;
UINT16 int_min, int_max, latency, timeout;
STREAM_TO_UINT16(handle, p);
STREAM_TO_UINT16(int_min, p);
STREAM_TO_UINT16(int_max, p);
STREAM_TO_UINT16(latency, p);
STREAM_TO_UINT16(timeout, p);
l2cble_process_rc_param_request_evt(handle, int_min, int_max, latency, timeout);
}{ ... }
/* ... */#endif /* ... */
...#endif