aboutsummaryrefslogtreecommitdiff
path: root/pw_bluetooth/public/pw_bluetooth/hci_commands.emb
blob: fdabc7b6292094f1c0c95c5b07587342ee57f9f3 (plain)
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
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
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
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
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
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
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
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
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
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
# Copyright 2023 The Pigweed Authors
#
# 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
#
#     https://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.

# This file contains Emboss definitions for Host Controller Interface packets
# and types found in the Bluetooth Core Specification. The Emboss compiler is
# used to generate a C++ header from this file.

import "hci_common.emb" as hci

[$default byte_order: "LittleEndian"]
[(cpp) namespace: "pw::bluetooth::emboss"]
# =========================== Constants =================================


enum InquiryAccessCode:
  -- General- and Device-specific Inquiry Access Codes (DIACs) for use in Inquiry
  -- command LAP fields.
  -- (https://www.bluetooth.com/specifications/assigned-numbers/baseband)
  [maximum_bits: 24]
  GIAC = 0x9E8B33
    -- General Inquiry Access Code

  LIAC = 0x9E8B00
    -- Limited Dedicated Inquiry Access Code


enum PcmDataFormat:
  -- PCM data formats from assigned numbers.
  -- (https://www.bluetooth.com/specifications/assigned-numbers/host-controller-interface)
  [maximum_bits: 8]
  NOT_APPLICABLE  = 0x00
  ONES_COMPLEMENT = 0x01
  TWOS_COMPLEMENT = 0x02
  SIGN_MAGNITUDE  = 0x03
  UNSIGNED        = 0x04


enum ScoDataPath:
  [maximum_bits: 8]
  HCI             = 0x00
  AUDIO_TEST_MODE = 0xFF
    -- 0x01 - 0xFE specify the logical channel number (vendor specific)


enum PageTimeout:
  [maximum_bits: 16]
  MIN     = 0x0001
  MAX     = 0xFFFF
  DEFAULT = 0x2000


enum ScanInterval:
  -- The minimum and maximum range values for Page and Inquiry Scan Interval (in time slices)
  -- Page Scan Interval: (see Core Spec v5.0, Vol 2, Part E, Section 7.3.19)
  -- Inquiry Scan Interval: (see Core Spec v5.0, Vol 2, Part E, Section 7.3.21)
  [maximum_bits: 16]
  MIN = 0x0012
  MAX = 0x1000


enum ScanWindow:
  -- The minimum and maximum range valeus for Page and Inquiry Scan Window (in time slices)
  -- Page Scan Window: (see Core Spec v5.0, Vol 2, Part E, Section 7.3.19)
  -- Inquiry Scan Window: (see Core Spec v5.0, Vol 2, Part E, Section 7.3.21)
  [maximum_bits: 16]
  MIN = 0x0011
  MAX = 0x1000


bits ScoPacketType:
  -- Bitmask of SCO packet types.
  # SCO packet types
  0     [+1]  Flag  hv1
  $next [+1]  Flag  hv2
  $next [+1]  Flag  hv3
  # eSCO packet types
  $next [+1]  Flag  ev3
  $next [+1]  Flag  ev4
  $next [+1]  Flag  ev5
  $next [+1]  Flag  not_2_ev3
  $next [+1]  Flag  not_3_ev3
  $next [+1]  Flag  not_2_ev5
  $next [+1]  Flag  not_3_ev5


bits PacketType:
  -- Bitmask values for supported Packet Types
  -- Used for HCI_Create_Connection and HCI_Change_Connection_Packet_Type
  -- All other bits reserved for future use.
  1  [+1]  Flag  disable_2_dh1
  2  [+1]  Flag  disable_3_dh1
  3  [+1]  Flag  enable_dm1     # Note: always on in >= v1.2
  4  [+1]  Flag  enable_dh1
  8  [+1]  Flag  disable_2_dh3
  9  [+1]  Flag  disable_3_dh3
  10 [+1]  Flag  enable_dm3
  11 [+1]  Flag  enable_dh3
  12 [+1]  Flag  disable_2_dh5
  13 [+1]  Flag  disable_3_dh5
  14 [+1]  Flag  enable_dm5
  15 [+1]  Flag  enable_dh5


enum OobDataPresent:
  -- Whether there is out-of-band data present, and what type.
  -- All other values reserved for future use.
  [maximum_bits: 8]
  NOT_PRESENT   = 0x00
  P192_         = 0x01
  P256_         = 0x02
  P192_AND_P256 = 0x03


bits ScanEnableBits:
  -- Bitmask Values for the Scan_Enable parameter in a HCI_(Read,Write)_Scan_Enable command.
  0 [+1]  Flag  inquiry
    -- Inquiry scan enabled

  1 [+1]  Flag  page
    -- Page scan enabled


enum InquiryScanType:
  [maximum_bits: 8]
  STANDARD   = 0x00
    -- Standard scan (Default) (Mandatory)

  INTERLACED = 0x01


struct LocalName:
  0 [+248]  UInt:8[248]  local_name


struct ExtendedInquiryResponse:
  0 [+240]  UInt:8[240]  extended_inquiry_response


enum LEExtendedDuplicateFilteringOption:
  -- Possible values that can be used for the |filter_duplicates| parameter in a
  -- HCI_LE_Set_Extended_Scan_Enable command.
  [maximum_bits: 8]
  DISABLED                           = 0x00
  ENABLED                            = 0x01
  ENABLED_RESET_FOR_EACH_SCAN_PERIOD = 0x02
    -- Duplicate advertisements in a single scan period should not be sent to the
    -- Host in advertising report events; this setting shall only be used if the
    -- Period parameter is non-zero.


enum LEPeriodicAdvertisingCreateSyncUseParams:
  [maximum_bits: 1]

  USE_PARAMS                   = 0x00
    -- Use the Advertising_SID, Advertiser_Address_Type, and Adertiser_Address parameters to
    -- determine which advertiser to listen to.

  USE_PERIODIC_ADVERTISER_LIST = 0x01
    -- Use the Periodic Advertiser List to determine which advertiser to listen to.


bits LEPeriodicAdvertisingCreateSyncOptions:
  -- First parameter to the LE Periodic Advertising Create Sync command
  0     [+1]  LEPeriodicAdvertisingCreateSyncUseParams  advertiser_source
  $next [+1]  Flag                                      enable_reporting
    -- 0: Reporting initially enabled
    -- 1: Reporting initially disabled

  $next [+1]  Flag                                      enable_duplicate_filtering
    -- 0: Duplicate filtering initially disabled
    -- 1: Duplicate filtering initially enabled


enum LEPeriodicAdvertisingAddressType:
  -- Possible values that can be specified for the |advertiser_address_type| in an LE Periodic
  -- Advertising Create Sync command.
  [maximum_bits: 8]
  PUBLIC = 0x00
    -- Public Device Address or Public Identity Address

  RANDOM = 0x01
    -- Random Device Address or Random (static) Identity Address


bits LEPeriodicAdvertisingSyncCTEType:
  -- Bit definitions for a |sync_cte_type| field in an LE Periodic Advertising Create Sync command

  0     [+1]  Flag  dont_sync_aoa
    -- Do not sync to packets with an AoA Constant Tone Extension

  $next [+1]  Flag  dont_sync_aod_1us
    -- Do not sync to packets with an AoD Constant Tone Extension with 1 microsecond slots

  $next [+1]  Flag  dont_sync_aod_2us
    -- Do not sync to packets with an AoD Constant Tone Extension with 2 microsecond slots

  $next [+1]  Flag  dont_sync_type_3
    -- Do not sync to packets with a typoe 3 Constant Tone Extension (currently reserved for future
    -- use)

  $next [+1]  Flag  dont_sync_without_cte
    -- Do not sync to packets without a Constant Tone Extension


enum LEOwnAddressType:
  -- Possible values that can be used for the |own_address_type| parameter in various LE packets.

  [maximum_bits: 8]

  PUBLIC                    = 0x00
    -- Public Device Address

  RANDOM                    = 0x01
    -- Random Device Address

  PRIVATE_DEFAULT_TO_PUBLIC = 0x02
    -- Controller generates the Resolvable Private Address based on the local IRK from the resolving
    -- list. If the resolving list contains no matching entry, then use the public address.

  PRIVATE_DEFAULT_TO_RANDOM = 0x03
    -- Controller generates the Resolvable Private Address based on the local IRK from the resolving
    -- list. If the resolving list contains no matching entry, then use the random address from
    -- LE_Set_Random_Address.


enum LEScanType:
  -- Possible values that can be used for the |scan_type| parameter in various LE HCI commands.
  [maximum_bits: 8]
  PASSIVE = 0x00
    -- Passive Scanning. No scanning PDUs shall be sent (default)

  ACTIVE  = 0x01
    -- Active scanning. Scanning PDUs may be sent.


enum LEScanFilterPolicy:
  -- Possible values that can be used for the |filter_policy| parameter in various LE HCI commands
  [maximum_bits: 8]
  BASIC_UNFILTERED    = 0x00
  BASIC_FILTERED      = 0x01
  EXTENDED_UNFILTERED = 0x02
  EXTENDED_FILTERED   = 0x03


bits LEScanPHYBits:
  0 [+1]  Flag  le_1m
    -- Scan advertisements on the LE 1M PHY

  2 [+1]  Flag  le_coded
    -- Scan advertisements on the LE Coded PHY


bits LEInitiatingPHYBits:
  0 [+1]  Flag  le_1m
  1 [+1]  Flag  le_2m
  2 [+1]  Flag  le_coded


enum LEPrivacyMode:
  -- Possible values for the |privacy_mode| parameter in an LE Set Privacy Mode
  -- command
  [maximum_bits: 8]
  NETWORK = 0x00
    -- Use Network Privacy Mode for this peer device (default).

  DEVICE  = 0x01
    -- Use Device Privacy Mode for this peer device.


enum InquiryMode:
  [maximum_bits: 8]
  STANDARD = 0x00
    -- Standard Inquiry Result format (default)

  RSSI     = 0x01
    -- Inquiry Result format with RSSI

  EXTENDED = 0x02
    -- Inquiry Result format with RSSI or EIR format


enum PageScanType:
  [maximum_bits: 8]
  STANDARD_SCAN   = 0x00
    -- Standard scan (default) (mandatory)

  INTERLACED_SCAN = 0x01
    -- Interlaced scan (optional)


bits LEEventMask:
  0     [+1]  Flag  le_connection_complete
  $next [+1]  Flag  le_advertising_report
  $next [+1]  Flag  le_connection_update_complete
  $next [+1]  Flag  le_read_remote_features_complete
  $next [+1]  Flag  le_long_term_key_request
  $next [+1]  Flag  le_remote_connection_parameter_request
  $next [+1]  Flag  le_data_length_change
  $next [+1]  Flag  le_read_local_p256_public_key_complete
  $next [+1]  Flag  le_generate_dhkey_complete
  $next [+1]  Flag  le_enhanced_connection_complete
  $next [+1]  Flag  le_directed_advertising_report
  $next [+1]  Flag  le_phy_update_complete
  $next [+1]  Flag  le_extended_advertising_report
  $next [+1]  Flag  le_periodic_advertising_sync_established
  $next [+1]  Flag  le_periodic_advertising_report
  $next [+1]  Flag  le_periodic_advertising_sync_lost
  $next [+1]  Flag  le_extended_scan_timeout
  $next [+1]  Flag  le_extended_advertising_set_terminated
  $next [+1]  Flag  le_scan_request_received
  $next [+1]  Flag  le_channel_selection_algorithm
  $next [+1]  Flag  le_connectionless_iq_report
  $next [+1]  Flag  le_connection_iq_report
  $next [+1]  Flag  le_cte_request_failed
  $next [+1]  Flag  le_periodic_advertising_sync_transfer_received_event
  $next [+1]  Flag  le_cis_established_event
  $next [+1]  Flag  le_cis_request_event
  $next [+1]  Flag  le_create_big_complete_event
  $next [+1]  Flag  le_terminate_big_complete_event
  $next [+1]  Flag  le_big_sync_established_event
  $next [+1]  Flag  le_big_sync_lost_event
  $next [+1]  Flag  le_request_peer_sca_complete_event
  $next [+1]  Flag  le_path_loss_threshold_event
  $next [+1]  Flag  le_transmit_power_reporting_event
  $next [+1]  Flag  le_biginfo_advertising_report_event
  $next [+1]  Flag  le_subrate_change_event


enum LEAdvertisingType:
  [maximum_bits: 8]
  CONNECTABLE_AND_SCANNABLE_UNDIRECTED = 0x00
    -- ADV_IND

  CONNECTABLE_HIGH_DUTY_CYCLE_DIRECTED = 0x01
    -- ADV_DIRECT_IND

  SCANNABLE_UNDIRECTED                 = 0x02
    -- ADV_SCAN_IND

  NOT_CONNECTABLE_UNDIRECTED           = 0x03
    -- ADV_NONCONN_IND

  CONNECTABLE_LOW_DUTY_CYCLE_DIRECTED  = 0x04
    -- ADV_DIRECT_IND


bits LEAdvertisingChannels:
  0     [+1]  Flag  channel_37
  $next [+1]  Flag  channel_38
  $next [+1]  Flag  channel_39


enum LEAdvertisingFilterPolicy:
  [maximum_bits: 8]

  ALLOW_ALL                                                  = 0x00
    -- Process scan and connection requests from all devices (i.e., the Filter
    -- Accept List is not in use) (default).

  ALLOW_ALL_CONNECTIONS_AND_USE_FILTER_ACCEPT_LIST_FOR_SCANS = 0x01
    -- Process connection requests from all devices and scan requests only from
    -- devices that are in the Filter Accept List.

  ALLOW_ALL_SCANS_AND_USE_FILTER_ACCEPT_LIST_FOR_CONNECTIONS = 0x02
    -- Process scan requests from all devices and connection requests only from
    -- devices that are in the Filter Accept List.

  ALLOW_FILTER_ACCEPT_LIST_ONLY                              = 0x03
    -- Process scan and connection requests only from devices in the Filter
    -- Accept List.


enum ScanRequestNotifications:
  [maximum_bits: 8]
  DISABLED = 0x00
  ENABLED  = 0x01


enum LESetExtendedAdvDataOp:
  -- Potential values for the Operation parameter in a HCI_LE_Set_Extended_Advertising_Data command.
  [maximum_bits: 8]
  INTERMEDIATE_FRAGMENT = 0x00
    -- Intermediate fragment of fragmented extended advertising data.

  FIRST_FRAGMENT        = 0x01
    -- First fragment of fragmented extended advertising data.

  LAST_FRAGMENT         = 0x02
    -- Last fragment of fragmented extended advertising data.

  COMPLETE              = 0x03
    -- Complete extended advertising data.

  UNCHANGED_DATA        = 0x04
    -- Unchanged data (just update the Advertising DID)


enum LEExtendedAdvFragmentPreference:
  -- Potential values for the Fragment_Preference parameter in a
  -- HCI_LE_Set_Extended_Advertising_Data command.
  [maximum_bits: 8]
  MAY_FRAGMENT        = 0x00
    -- The Controller may fragment all Host advertising data

  SHOULD_NOT_FRAGMENT = 0x01
    -- The Controller should not fragment or should minimize fragmentation of Host advertising data


bits LEAdvertisingEventProperties:
  -- The Advertising_Event_Properties bitfield values used in a HCI LE Set Extended Advertising
  -- Parameters command.
  0     [+1]  Flag  connectable
  $next [+1]  Flag  scannable
  $next [+1]  Flag  directed
  $next [+1]  Flag  high_duty_cycle_directed_connectable
  $next [+1]  Flag  use_legacy_pdus
  $next [+1]  Flag  anonymous_advertising
  $next [+1]  Flag  include_tx_power


enum FlowControlMode:
  [maximum_bits: 8]
  PACKET_BASED     = 0x00
  DATA_BLOCK_BASED = 0x01


bits EventMaskPage2:
  8  [+1]  Flag  number_of_completed_data_blocks_event
  14 [+1]  Flag  triggered_clock_capture_event
  15 [+1]  Flag  synchronization_train_complete_event
  16 [+1]  Flag  synchronization_train_received_event
  17 [+1]  Flag  connectionless_peripheral_broadcast_receive_event
  18 [+1]  Flag  connectionless_peripheral_broadcast_timeout_event
  19 [+1]  Flag  truncated_page_complete_event
  20 [+1]  Flag  peripheral_page_response_timeout_event
  21 [+1]  Flag  connectionless_peripheral_broadcast_channel_map_event
  22 [+1]  Flag  inquiry_response_notification_event
  23 [+1]  Flag  authenticated_payload_timeout_expired_event
  24 [+1]  Flag  sam_status_change_event
  25 [+1]  Flag  encryption_change_event_v2


bits LECISPHYOptions:
  -- Identifies PHYs that can be used for transmission
  0     [+1]  Flag  le_1m
  $next [+1]  Flag  le_2m
  $next [+1]  Flag  le_coded


struct LESetCIGParametersCISOptions:
  -- Parameters for the CISes defined in a LESetCIGParametersCommand

  0     [+1]                                UInt             cis_id
    -- Used to identify a CIS
    [requires: 0x00 <= this <= 0xEF]

  $next [+2]                                UInt             max_sdu_c_to_p
    -- Maximum size, in octets, of the payload from the Central's Host
    [requires: 0x0000 <= this <= 0x0FFF]

  $next [+2]                                UInt             max_sdu_p_to_c
    -- Maximum size, in octets, of the payload from the Peripheral's Host
    [requires: 0x0000 <= this <= 0x0FFF]

  $next [+1]  bits:

    0     [+LECISPHYOptions.$size_in_bits]  LECISPHYOptions  phy_c_to_p
      -- Identifies which PHY to use for transmission from the Central to the Peripheral

  $next [+1]  bits:

    0     [+LECISPHYOptions.$size_in_bits]  LECISPHYOptions  phy_p_to_c
      -- Identifies which PHY to use for transmission from the Peripheral to the Central

  $next [+1]                                UInt             rtn_c_to_p
    -- Number of times every CIS Data PDU should be retransmitted from the Central to the
    -- Peripheral

  $next [+1]                                UInt             rtn_p_to_c
    -- Number of times every CIS Data PDU should be retransmitted from the Peripheral to the
    -- Central


enum LESleepClockAccuracyRange:
  -- Accuracy of the sleep clock, provided as a range
  [maximum_bits: 8]
  PPM_251_TO_500 = 0x00
  PPM_151_TO_250 = 0x01
  PPM_101_TO_150 = 0x02
  PPM_76_TO_100  = 0x03
  PPM_51_TO_75   = 0x04
  PPM_31_TO_50   = 0x05
  PPM_21_TO_30   = 0x06
  PPM_0_TO_20    = 0x07


enum LECISPacking:
  -- Preferred method of arranging subevents of multiple CISes
  [maximum_bits: 8]
  SEQUENTIAL  = 0x00
  INTERLEAVED = 0x01


enum LECISFraming:
  -- Format of CIS Data PDUs
  [maximum_bits: 8]
  UNFRAMED = 0x00
  FRAMED   = 0x01


enum DataPathDirection:
  [maximum_bits: 8]
  INPUT  = 0x00
    -- Host to Controller

  OUTPUT = 0x01
    -- Controller to Host

# ========================= HCI Command packets =========================
# Core Spec v5.3 Vol 4, Part E, Section 7

# ========== 7.1 Link Control Commands ==========


struct InquiryCommand:
  -- 7.1.1 Inquiry command (v1.1) (BR/EDR)
  -- HCI_Inquiry
  --
  -- Note: NO Command Complete; Sends Inquiry Complete at the end of the
  -- inquiry to indicate it's completion. No Inquiry Complete event is sent if
  -- Inquiry is cancelled.

  let hdr_size = hci.CommandHeader.$size_in_bytes

  0     [+hdr_size]  hci.CommandHeader  header

  $next [+3]         InquiryAccessCode  lap
    -- LAP (Lower Address Part)
    -- In the range 0x9E8B00 - 0x9E8B3F, defined by the Bluetooth SIG in
    -- Baseband Assigned Numbers.

  $next [+1]         UInt               inquiry_length
    -- Time before the inquiry is halted. Defined in 1.28s units.
    -- Range: 0x01 to kInquiryLengthMax in hci_constants.h

  $next [+1]         UInt               num_responses
    -- Maximum number of responses before inquiry is halted.
    -- Set to 0x00 for unlimited.


struct InquiryCancelCommand:
  -- 7.1.2 Inquiry Cancel command (v1.1) (BR/EDR)
  -- HCI_Inquiry_Cancel
  --
  -- No command parameters
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header

# 7.1.3 Periodic Inquiry Mode command
# HCI_Periodic_Inquiry_Mode
# TODO: b/265052417 - Definition needs to be added


# 7.1.4 Exit Periodic Inquiry Mode command
# HCI_Exit_Periodic_Inquiry_Mode
# TODO: b/265052417 - Definition needs to be added


struct CreateConnectionCommand:
  -- 7.1.5 Create Connection (v1.1) (BR/EDR)
  -- HCI_Create_Connection
  --
  -- NOTE on ReturnParams: No Command Complete event will be sent by the
  -- Controller to indicate that this command has been completed. Instead, the
  -- Connection Complete event will indicate that this command has been
  -- completed.
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader           header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr                  bd_addr
    -- BD_ADDR of the device to be connected

  $next [+2]                          PacketType                  packet_type
    -- Mask of allowable packet types.

  $next [+1]                          hci.PageScanRepetitionMode  page_scan_repetition_mode
    -- The Page Scan Repetition Mode of the remote device as retrieved by Inquiry.

  $next [+1]                          UInt                        reserved
    [requires: this == 0]

  $next [+2]                          hci.ClockOffset             clock_offset
    -- Clock Offset. The lower 15 bits are set to the clock offset as retrieved
    -- by an Inquiry. The highest bit is set to 1 if the rest of this parameter
    -- is valid.

  $next [+1]                          hci.GenericEnableParam      allow_role_switch
    -- Allow Role Switch.
    -- Allowed values:
    --  0x00 - No role switch allowed, this device will be the central
    --  0x01 - Role switch allowed, this device may become peripheral during
    --  connection setup


struct DisconnectCommand:
  -- 7.1.6 Disconnect command (v1.1) (BR/EDR & LE)
  -- HCI_Disconnect
  --
  -- NOTE on ReturnParams: No Command Complete event will be sent by the
  -- Controller to indicate that this command has been completed. Instead, the
  -- Disconnection Complete event will indicate that this command has been
  -- completed.
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         UInt               connection_handle
    -- Connection_Handle (only the lower 12-bits are meaningful).
    --   Range: 0x0000 to 0x0EFF

  $next [+1]         hci.StatusCode     reason
    -- Reason for the disconnect.


struct CreateConnectionCancelCommand:
  -- 7.1.7 Create Connection Cancel command (v1.1) (BR/EDR)
  -- HCI_Create_Connection_Cancel
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader  header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr         bd_addr
    -- BD_ADDR of the Create Connection Command request


struct AcceptConnectionRequestCommand:
  -- 7.1.8 Accept Connection Request command (v1.1) (BR/EDR)
  -- HCI_Accept_Connection_Request
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader   header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr          bd_addr
    -- The 48-bit BD_ADDR of the remote device requesting the connection.

  $next [+1]                          hci.ConnectionRole  role


struct RejectConnectionRequestCommand:
  -- 7.1.9 Reject Connection Request command (v1.1) (BR/EDR)
  -- HCI_Reject_Connection_Request
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader  header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr         bd_addr
    -- The 48-bit BD_ADDR of the remote device requesting the connection.

  $next [+1]                          hci.StatusCode     reason
    -- Must be one of CONNECTION_REJECTED* from hci.StatusCode in this file


struct LinkKeyRequestReplyCommand:
  -- 7.1.10 Link Key Request Reply command (v1.1) (BR/EDR)
  -- HCI_Link_Key_Request_Reply
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader  header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr         bd_addr
    -- The 48-bit BD_ADDR of the remote device requesting the connection.

  let bredr_link_key_size = hci.LinkKey.$size_in_bytes
  $next [+bredr_link_key_size]        hci.LinkKey        link_key
    -- Link key to use for the connection with the peer device.


struct LinkKeyRequestNegativeReplyCommand:
  -- 7.1.11 Link Key Request Negative Reply command (v1.1) (BR/EDR)
  -- HCI_Link_Key_Request_Negative_Reply
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader  header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr         bd_addr
    -- BD_ADDR of the peer device that the host does not have a link key for.

# 7.1.12 PIN Code Request Reply command
# HCI_PIN_Code_Request_Reply
# TODO: b/265052417 - Definition needs to be added


# 7.1.13 PIN Code Request Negative Reply command
# HCI_PIN_Code_Request_Negative_Reply
# TODO: b/265052417 - Definition needs to be added


# 7.1.14 Change Connection Packet Type command
# HCI_Change_Connection_Packet_Type
# TODO: b/265052417 - Definition needs to be added


struct AuthenticationRequestedCommand:
  -- 7.1.15 Authentication Requested command (v1.1) (BR/EDR)
  -- HCI_Authentication_Requested
  --
  -- NOTE on ReturnParams: No Command Complete event will be sent by the
  -- Controller to indicate that this command has been completed. Instead, the
  -- Authentication Complete event will indicate that this command has been
  -- completed.
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         UInt               connection_handle
    -- Connection_Handle (only the lower 12-bits are meaningful).
    --   Range: 0x0000 to 0x0EFF
    -- Must be the handle of a connected ACL-U logical link.


struct SetConnectionEncryptionCommand:
  -- 7.1.16 Set Connection Encryption command (v1.1) (BR/EDR)
  -- HCI_Set_Connection_Encryption
  --
  -- NOTE on ReturnParams: No Command Complete event will be sent by the
  -- Controller to indicate that this command has been completed. Instead, the
  -- Encryption Change event will indicate that this command has been completed.
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader       header
  $next [+2]         UInt                    connection_handle
    -- Connection_Handle (only the lower 12-bits are meaningful).
    --   Range: 0x0000 to 0x0EFF
    -- Must be the handle of a connected ACL-U logical link.

  $next [+1]         hci.GenericEnableParam  encryption_enable
    -- Whether link level encryption should be turned on or off.

# 7.1.17 Change Connection Link Key command
# HCI_Change_Connection_Link_Key
# TODO: b/265052417 - Definition needs to be added


# 7.1.18 Link Key Selection command
# HCI_Link_Key_Selection
# TODO: b/265052417 - Definition needs to be added


struct RemoteNameRequestCommand:
  -- 7.1.19 Remote Name Request command (v1.1) (BR/EDR)
  -- HCI_Remote_Name_Request
  --
  -- NOTE on ReturnParams: No Command Complete event will be sent by the
  -- Controller to indicate that this command has been completed. Instead, the
  -- Remote Name Request Complete event will indicate that this command has been
  -- completed.
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader           header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr                  bd_addr
    -- Address of the device whose name is to be requested.

  $next [+1]                          hci.PageScanRepetitionMode  page_scan_repetition_mode
    -- Page Scan Repetition Mode of the device, obtained by Inquiry.

  $next [+1]                          UInt                        reserved
    [requires: this == 0]

  $next [+2]                          hci.ClockOffset             clock_offset
    -- Clock offset.  The lower 15 bits of this represent bits 16-2
    -- of CLKNPeripheral-CLK, and the highest bit is set when the other
    -- bits are valid.

# 7.1.20 Remote Name Request Cancel command
# HCI_Remote_Name_Request_Cancel


struct ReadRemoteSupportedFeaturesCommand:
  -- 7.1.21 Read Remote Supported Features command (v1.1) (BR/EDR)
  -- HCI_Read_Remote_Supported_Features
  --
  -- NOTE on ReturnParams: No Command Complete event will be sent by the
  -- Controller to indicate that this command has been completed. Instead, the
  -- Read Remote Supported Features Complete event will indicate that this
  -- command has been completed.
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         UInt               connection_handle
    -- Connection_Handle (only the lower 12-bits are meaningful).
    --   Range: 0x0000 to 0x0EFF
    -- Must be the handle of a connected ACL-U logical link.


struct ReadRemoteExtendedFeaturesCommand:
  -- 7.1.22 Read Remote Extended Features command (v1.2) (BR/EDR)
  -- HCI_Read_Remote_Extended_Features
  --
  -- NOTE on ReturnParams: No Command Complete event will be sent by the
  -- Controller to indicate that this command has been completed. Instead, the
  -- Read Remote Extended Features Complete event will indicate that this
  -- command has been completed.
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         UInt               connection_handle
    -- Connection_Handle (only the lower 12-bits are meaningful).
    --   Range: 0x0000 to 0x0EFF
    -- Must be the handle of a connected ACL-U logical link.

  $next [+1]         UInt               page_number
    -- Page of features to read.
    -- Values:
    --  - 0x00 standard features as if requested by Read Remote Supported Features
    --  - 0x01-0xFF the corresponding features page (see Vol 2, Part C, Sec 3.3).


struct ReadRemoteVersionInfoCommand:
  -- 7.1.23 Read Remote Version Information command (v1.1) (BR/EDR & LE)
  -- HCI_Read_Remote_Version_Information
  --
  -- NOTE on ReturnParams: No Command Complete event will be sent by the
  -- Controller to indicate that this command has been completed. Instead, the
  -- Read Remote Version Information Complete event will indicate that this
  -- command has been completed.
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         UInt               connection_handle
    -- Connection_Handle (only the lower 12-bits are meaningful).
    --   Range: 0x0000 to 0x0EFF

# 7.1.24 Read Clock Offset command
# HCI_Read_Clock_Offset
# TODO: b/265052417 - Definition needs to be added


# 7.1.25 Read LMP Handle command
# HCI_Read_LMP_Handle
# TODO: b/265052417 - Definition needs to be added


# 7.1.26 Setup Synchronous Connection command
# HCI_Setup_Synchronous_Connection
# TODO: b/265052417 - Definition needs to be added


# 7.1.27 Accept Synchronous Connection Request command
# HCI_Accept_Synchronous_Connection_Request
# TODO: b/265052417 - Definition needs to be added


struct RejectSynchronousConnectionRequestCommand:
  -- 7.1.28 Reject Synchronous Connection command (BR/EDR)
  -- HCI_Reject_Synchronous_Connection_Request
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader  header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr         bd_addr
    -- Address of the remote device that sent the request.

  $next [+1]                          hci.StatusCode     reason
    -- Reason the connection request was rejected.


struct IoCapabilityRequestReplyCommand:
  -- 7.1.29 IO Capability Request Reply command (v2.1 + EDR) (BR/EDR)
  -- HCI_IO_Capability_Request_Reply
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader               header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr                      bd_addr
    -- The BD_ADDR of the remote device involved in simple pairing process

  $next [+1]                          hci.IoCapability                io_capability
    -- The IO capabilities of this device.

  $next [+1]                          OobDataPresent                  oob_data_present
    -- Whether there is out-of-band data present, and what type.

  $next [+1]                          hci.AuthenticationRequirements  authentication_requirements
    -- Authentication requirements of the host.


struct UserConfirmationRequestReplyCommand:
  -- 7.1.30 User Confirmation Request Reply command (v2.1 + EDR) (BR/EDR)
  -- HCI_User_Confirmation_Request_Reply
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader  header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr         bd_addr
    -- The BD_ADDR of the remote device involved in simple pairing process


struct UserConfirmationRequestNegativeReplyCommand:
  -- 7.1.31 User Confirmation Request Negative Reply command (v2.1 + EDR) (BR/EDR)
  -- HCI_User_Confirmation_Request_Negative_Reply
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader  header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr         bd_addr
    -- The BD_ADDR of the remote device involved in simple pairing process


struct UserPasskeyRequestReplyCommand:
  -- 7.1.32 User Passkey Request Reply command (v2.1 + EDR) (BR/EDR)
  -- HCI_User_Passkey_Request_Reply
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader  header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr         bd_addr
    -- The BD_ADDR of the remote device involved in simple pairing process

  $next [+4]                          UInt               numeric_value
    -- Numeric value (passkey) entered by user.
    [requires: 0 <= this <= 999999]


struct UserPasskeyRequestNegativeReplyCommand:
  -- 7.1.33 User Passkey Request Negative Reply command (v2.1 + EDR) (BR/EDR)
  -- HCI_User_Passkey_Request_Negative_Reply
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader  header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr         bd_addr
    -- The BD_ADDR of the remote device involved in the simple pairing process.

# 7.1.34 Remote OOB Data Request Reply command
# HCI_Remote_OOB_Data_Request_Reply
# TODO: b/265052417 - Definition needs to be added


# 7.1.35 Remote OOB Data Request Negative Reply command
# HCI_Remote_OOB_Data_Request_Negative_Reply
# TODO: b/265052417 - Definition needs to be added


struct IoCapabilityRequestNegativeReplyCommand:
  -- 7.1.36 IO Capability Request Negative Reply command (v2.1 + EDR) (BR/EDR)
  -- HCI_IO_Capability_Request_Negative_Reply
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader  header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr         bd_addr
    -- The BD_ADDR of the remote device involved in the simple pairing process.

  $next [+1]                          hci.StatusCode     reason
    -- Reason that Simple Pairing was rejected. See 7.1.36 for valid error codes.


struct CodecId:
  0     [+1]  hci.CodingFormat  coding_format
  $next [+2]  UInt              company_id
    -- See assigned numbers.

  $next [+2]  UInt              vendor_codec_id
    -- Shall be ignored if |coding_format| is not VENDOR_SPECIFIC.


struct SynchronousConnectionParameters:
  -- Enhanced Setup Synchronous Connection Command (CSA2) (BR/EDR)
  -- TODO: b/308794058 - Use CodecId instead of VendorCodingFormat
  struct VendorCodingFormat:
    0     [+1]  hci.CodingFormat  coding_format
    $next [+2]  UInt              company_id
      -- See assigned numbers.

    $next [+2]  UInt              vendor_codec_id
      -- Shall be ignored if |coding_format| is not VENDOR_SPECIFIC.

  enum ScoRetransmissionEffort:
    [maximum_bits: 8]
    NONE              = 0x00
      -- SCO or eSCO

    POWER_OPTIMIZED   = 0x01
      -- eSCO only

    QUALITY_OPTIMIZED = 0x02
      -- eSCO only

    DONT_CARE         = 0xFF
      -- SCO or eSCO

  0     [+4]                              UInt                     transmit_bandwidth
    -- Transmit bandwidth in octets per second.

  $next [+4]                              UInt                     receive_bandwidth
    -- Receive bandwidth in octets per second.

  let vcf_size = VendorCodingFormat.$size_in_bytes
  $next [+vcf_size]                       VendorCodingFormat       transmit_coding_format
    -- Local Controller -> Remote Controller coding format.

  $next [+vcf_size]                       VendorCodingFormat       receive_coding_format
    -- Remote Controller -> Local Controller coding format.

  $next [+2]                              UInt                     transmit_codec_frame_size_bytes
  $next [+2]                              UInt                     receive_codec_frame_size_bytes
  $next [+4]                              UInt                     input_bandwidth
    -- Host->Controller data rate in octets per second.

  $next [+4]                              UInt                     output_bandwidth
    -- Controller->Host data rate in octets per second.

  $next [+vcf_size]                       VendorCodingFormat       input_coding_format
    -- Host->Controller coding format.

  $next [+vcf_size]                       VendorCodingFormat       output_coding_format
    -- Controller->Host coding format.

  $next [+2]                              UInt                     input_coded_data_size_bits
    -- Size, in bits, of the sample or framed data.

  $next [+2]                              UInt                     output_coded_data_size_bits
    -- Size, in bits, of the sample or framed data.

  $next [+1]                              PcmDataFormat            input_pcm_data_format
  $next [+1]                              PcmDataFormat            output_pcm_data_format
  $next [+1]                              UInt                     input_pcm_sample_payload_msb_position
    -- The number of bit positions within an audio sample that the MSB of
    -- the sample is away from starting at the MSB of the data.

  $next [+1]                              UInt                     output_pcm_sample_payload_msb_position
    -- The number of bit positions within an audio sample that the MSB of
    -- the sample is away from starting at the MSB of the data.

  $next [+1]                              ScoDataPath              input_data_path
  $next [+1]                              ScoDataPath              output_data_path
  $next [+1]                              UInt                     input_transport_unit_size_bits
    -- The number of bits in each unit of data received from the Host over the audio data transport.
    -- 0 indicates "not applicable"  (implied by the choice of audio data transport).

  $next [+1]                              UInt                     output_transport_unit_size_bits
    -- The number of bits in each unit of data sent to the Host over the audio data transport.
    -- 0 indicates "not applicable"  (implied by the choice of audio data transport).

  $next [+2]                              UInt                     max_latency_ms
    -- The value in milliseconds representing the upper limit of the sum of
    -- the synchronous interval, and the size of the eSCO window, where the
    -- eSCO window is the reserved slots plus the retransmission window.
    -- Minimum: 0x0004
    -- Don't care: 0xFFFF

  $next [+2]  bits:
    0     [+ScoPacketType.$size_in_bits]  ScoPacketType            packet_types
      -- Bitmask of allowed packet types.

  $next [+1]                              ScoRetransmissionEffort  retransmission_effort


struct EnhancedSetupSynchronousConnectionCommand:
  -- 7.1.45 Enhanced Setup Synchronous Connection command
  -- HCI_Enhanced_Setup_Synchronous_Connection
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader                header
  $next [+2]         UInt                             connection_handle
    -- The connection handle of the associated ACL link if creating a new (e)SCO connection, or the
    -- handle of an existing eSCO link if updating connection parameters.

  let scp_size = SynchronousConnectionParameters.$size_in_bytes
  $next [+scp_size]  SynchronousConnectionParameters  connection_parameters


struct EnhancedAcceptSynchronousConnectionRequestCommand:
  -- 7.1.46 Enhanced Accept Synchronous Connection Request command (CSA2) (BR/EDR)
  -- HCI_Enhanced_Accept_Synchronous_Connection_Request
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader                header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr                       bd_addr
    -- The 48-bit BD_ADDR of the remote device requesting the connection.

  let scp_size = SynchronousConnectionParameters.$size_in_bytes
  $next [+scp_size]                   SynchronousConnectionParameters  connection_parameters

# 7.1.47 Truncated Page command
# HCI_Truncated_Page
# TODO: b/265052417 - Definition needs to be added


# 7.1.48 Truncated Page Cancel command
# HCI_Truncated_Page_Cancel
# TODO: b/265052417 - Definition needs to be added


# 7.1.49 Set Connectionless Peripheral Broadcast command
# HCI_Set_Connectionless_Peripheral_Broadcast
# TODO: b/265052417 - Definition needs to be added


# 7.1.50 Set Connectionless Peripheral Broadcast Receive command
# HCI_Set_Connectionless_Peripheral_Broadcast_Receive
# TODO: b/265052417 - Definition needs to be added


# 7.1.51 Start Synchronization Train command
# HCI_Start_Synchronization_Train
# TODO: b/265052417 - Definition needs to be added


# 7.1.52 Receive Synchronization Train command
# HCI_Receive_Synchronization_Train
# TODO: b/265052417 - Definition needs to be added


# 7.1.53 Remote OOB Extended Data Request Reply command
# HCI_Remote_OOB_Extended_Data_Request_Reply
# TODO: b/265052417 - Definition needs to be added


# ========== 7.3 Controller & Baseband Commands ==========


struct SetEventMaskCommand:
  -- 7.3.1 Set Event Mask command (v1.1)
  -- HCI_Set_Event_Mask
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+8]         UInt               event_mask
    -- 64-bit Bit mask used to control which HCI events are generated by the HCI for the
    -- Host. See enum class EventMask in hci_constants.h


struct ResetCommand:
  -- 7.3.2 Reset command (v1.1)
  -- HCI_Reset
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header

# 7.3.3 Set Event Filter command
# HCI_Set_Event_Filter
# TODO: b/265052417 - Definition needs to be added


# 7.3.4 Flush command
# HCI_Flush
# TODO: b/265052417 - Definition needs to be added


# 7.3.5 Read PIN Type command
# HCI_Read_PIN_Type
# TODO: b/265052417 - Definition needs to be added


# 7.3.6 Write PIN Type command
# HCI_Write_PIN_Type
# TODO: b/265052417 - Definition needs to be added


# 7.3.8 Read Stored Link Key command
# HCI_Read_Stored_Link_Key
# TODO: b/265052417 - Definition needs to be added


# 7.3.9 Write Stored Link Key command
# HCI_Write_Stored_Link_Key
# TODO: b/265052417 - Definition needs to be added


# 7.3.10 Delete Stored Link Key command
# HCI_Delete_Stored_Link_Key
# TODO: b/265052417 - Definition needs to be added


struct WriteLocalNameCommand:
  -- 7.3.11 Write Local Name command (v1.1) (BR/EDR)
  -- HCI_Write_Local_Name
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]         hci.CommandHeader  header
  let local_name_size = LocalName.$size_in_bytes
  $next [+local_name_size]  LocalName          local_name
    -- A UTF-8 encoded User Friendly Descriptive Name for the device.
    -- If the name contained in the parameter is shorter than 248 octets, the end
    -- of the name is indicated by a NULL octet (0x00), and the following octets
    -- (to fill up 248 octets, which is the length of the parameter) do not have
    -- valid values.


struct ReadLocalNameCommand:
  -- 7.3.12 Read Local Name command (v1.1) (BR/EDR)
  -- HCI_Read_Local_Name
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header

# 7.3.13 Read Connection Accept Timeout command
# HCI_Read_Connection_Accept_Timeout
# TODO: b/265052417 - Definition needs to be added


# 7.3.14 Write Connection Accept Timeout command
# HCI_Write_Connection_Accept_Timeout
# TODO: b/265052417 - Definition needs to be added


# 7.3.15 Read Page Timeout command
# HCI_Read_Page_Timeout
# TODO: b/265052417 - Definition needs to be added


struct WritePageTimeoutCommand:
  -- 7.3.16 Write Page Timeout command (v1.1) (BR/EDR)
  -- HCI_Write_Page_Timeout
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         UInt               page_timeout
    -- Page_Timeout, in time slices (0.625 ms)
    -- Range: From MIN to MAX in PageTimeout in this file
    [requires: 0x0001 <= this <= 0xFFFF]


struct ReadScanEnableCommand:
  -- 7.3.17 Read Scan Enable command (v1.1) (BR/EDR)
  -- HCI_Read_Scan_Enable
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct WriteScanEnableCommand:
  -- 7.3.18 Write Scan Enable command (v1.1) (BR/EDR)
  -- HCI_Write_Scan_Enable
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                        hci.CommandHeader  header
  $next [+1]  bits:
    0     [+ScanEnableBits.$size_in_bits]  ScanEnableBits     scan_enable


struct ReadPageScanActivityCommand:
  -- 7.3.19 Read Page Scan Activity command (v1.1) (BR/EDR)
  -- HCI_Read_Page_Scan_Activity
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct WritePageScanActivityCommand:
  -- 7.3.20 Write Page Scan Activity command (v1.1) (BR/EDR)
  -- HCI_Write_Page_Scan_Activity
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         UInt               page_scan_interval
    -- Page_Scan_Interval, in time slices (0.625ms)
    -- Valid Range: MIN - MAX in ScanInterval in this file
    [requires: 0x0012 <= this <= 0x1000]

  $next [+2]         UInt               page_scan_window
    -- Page_Scan_Window, in time slices
    -- Valid Range: MIN - MAX in ScanWindow in this file
    [requires: 0x0011 <= this <= 0x1000]


struct ReadInquiryScanActivityCommand:
  -- 7.3.21 Read Inquiry Scan Activity command (v1.1) (BR/EDR)
  -- HCI_Read_Inquiry_Scan_Activity
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct WriteInquiryScanActivityCommand:
  -- 7.3.22 Write Inquiry Scan Activity command (v1.1) (BR/EDR)
  -- HCI_Write_Inquiry_Scan_Activity
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         UInt               inquiry_scan_interval
    -- Inquiry_Scan_Interval, in time slices (0.625ms)
    -- Valid Range: MIN - MAX in ScanInterval in this file
    [requires: 0x0012 <= this <= 0x1000]

  $next [+2]         UInt               inquiry_scan_window
    -- Inquiry_Scan_Window, in time slices
    -- Valid Range: MIN - MAX in ScanWindow in this file
    [requires: 0x0011 <= this <= 0x1000]

# 7.3.23 Read Authentication Enable command
# HCI_Read_Authentication_Enable
# TODO: b/265052417 - Definition needs to be added


# 7.3.24 Write Authentication Enable command
# HCI_Write_Authentication_Enable
# TODO: b/265052417 - Definition needs to be added


struct ReadClassOfDeviceCommand:
  -- 7.3.25 Read Class of Device command (v1.1) (BR/EDR)
  -- HCI_Read_Class_Of_Device
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct WriteClassOfDeviceCommand:
  -- 7.3.26 Write Class Of Device command (v1.1) (BR/EDR)
  -- HCI_Write_Class_Of_Device
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+3]         hci.ClassOfDevice  class_of_device

# 7.3.27 Read Voice Setting command
# HCI_Read_Voice_Setting
# TODO: b/265052417 - Definition needs to be added


# 7.3.28 Write Voice Setting command
# HCI_Write_Voice_Setting
# TODO: b/265052417 - Definition needs to be added


# 7.3.29 Read Automatic Flush Timeout command
# HCI_Read_Automatic_Flush_Timeout
# TODO: b/265052417 - Definition needs to be added


struct WriteAutomaticFlushTimeoutCommand:
  -- 7.3.30 Write Automatic Flush Timeout command (v1.1) (BR/EDR)
  -- HCI_Write_Automatic_Flush_Timeout
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         UInt               connection_handle
    -- Connection_Handle (only the lower 12-bits are meaningful).
    --   Range: 0x0000 to 0x0EFF
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+2]         UInt               flush_timeout
    -- The value for the Flush_Timeout configuration parameter (Core Spec v5.2, Vol 4, Part E, Sec 6.19).
    -- Range: 0x0000 to 0x07FF. 0x0000 indicates infinite flush timeout (no automatic flush).
    -- Time = flush_timeout * 0.625ms.
    -- Time Range: 0.625ms to 1279.375ms.
    [requires: 0x0000 <= this <= 0x07FF]

# 7.3.31 Read Num Broadcast Retransmissions command
# HCI_Read_Num_Broadcast_Retransmissions
# TODO: b/265052417 - Definition needs to be added


# 7.3.32 Write Num Broadcast Retransmissions command
# HCI_Write_Num_Broadcast_Retransmissions
# TODO: b/265052417 - Definition needs to be added


# 7.3.33 Read Hold Mode Activity command
# HCI_Read_Hold_Mode_Activity
# TODO: b/265052417 - Definition needs to be added


# 7.3.34 Write Hold Mode Activity command
# HCI_Write_Hold_Mode_Activity
# TODO: b/265052417 - Definition needs to be added


# 7.3.35 Read Transmit Power Level command
# HCI_Read_Transmit_Power_Level
# TODO: b/265052417 - Definition needs to be added


# 7.3.36 Read Synchronous Flow Control Enable command
# HCI_Read_Synchronous_Flow_Control_Enable
# TODO: b/265052417 - Definition needs to be added


struct WriteSynchronousFlowControlEnableCommand:
  -- 7.3.37 Write Synchonous Flow Control Enable command (BR/EDR)
  -- HCI_Write_Synchronous_Flow_Control_Enable
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader       header
  $next [+1]         hci.GenericEnableParam  synchronous_flow_control_enable
    -- If enabled, HCI_Number_Of_Completed_Packets events shall be sent from the controller
    -- for synchronous connection handles.

# 7.3.38 Set Controller To Host Flow Control command
# HCI_Set_Controller_To_Host_Flow_Control
# TODO: b/265052417 - Definition needs to be added


# 7.3.39 Host Buffer Size command
# HCI_Host_Buffer_Size
# TODO: b/265052417 - Definition needs to be added


# 7.3.40 Host Number Of Completed Packets command
# HCI_Host_Number_Of_Completed_Packets
# TODO: b/265052417 - Definition needs to be added


# 7.3.41 Read Link Supervision Timeout command
# HCI_Read_Link_Supervision_Timeout
# TODO: b/265052417 - Definition needs to be added


# 7.3.42 Write Link Supervision Timeout command
# HCI_Write_Link_Supervision_Timeout
# TODO: b/265052417 - Definition needs to be added


# 7.3.43 Read Number Of Supported IAC command
# HCI_Read_Number_Of_Supported_IAC
# TODO: b/265052417 - Definition needs to be added


# 7.3.44 Read Current IAC LAP command
# HCI_Read_Current_IAC_LAP
# TODO: b/265052417 - Definition needs to be added


# 7.3.45 Write Current IAC LAP command
# HCI_Write_Current_IAC_LAP
# TODO: b/265052417 - Definition needs to be added


# 7.3.46 Set AFH Host Channel Classification command
# HCI_Set_AFH_Host_Channel_Classification
# TODO: b/265052417 - Definition needs to be added


# 7.3.47 Read Inquiry Scan Type command
# HCI_Read_Inquiry_Scan_Type
# TODO: b/265052417 - Definition needs to be added


struct WriteInquiryScanTypeCommand:
  -- 7.3.48 Write Inquiry Scan Type (v1.2) (BR/EDR)
  -- HCI_Write_Inquiry_Scan_Type
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+1]         InquiryScanType    inquiry_scan_type
    -- See enum class InquiryScanType in this file for possible values


struct ReadInquiryModeCommand:
  -- 7.3.49 Read Inquiry Mode (v1.2) (BR/EDR)
  -- HCI_Read_Inquiry_Mode
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct WriteInquiryModeCommand:
  -- 7.3.50 Write Inquiry Mode (v1.2) (BR/EDR)
  -- HCI_Write_Inquiry_Mode
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+1]         InquiryMode        inquiry_mode


struct ReadPageScanTypeCommand:
  -- 7.3.51 Read Page Scan Type (v1.2) (BR/EDR)
  -- HCI_Read_Page_Scan_Type
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct WritePageScanTypeCommand:
  -- 7.3.52 Write Page Scan Type (v1.2) (BR/EDR)
  -- HCI_Write_Page_Scan_Type
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+1]         PageScanType       page_scan_type

# 7.3.53 Read AFH Channel Assessment Mode command
# HCI_Read_AFH_Channel_Assessment_Mode
# TODO: b/265052417 - Definition needs to be added


# 7.3.54 Write AFH Channel Assessment Mode command
# HCI_Write_AFH_Channel_Assessment_Mode
# TODO: b/265052417 - Definition needs to be added


# 7.3.55 Read Extended Inquiry Response command
# HCI_Read_Extended_Inquiry_Response
# TODO: b/265052417 - Definition needs to be added


struct WriteExtendedInquiryResponseCommand:
  -- 7.3.56 Write Extended Inquiry Response (v1.2) (BR/EDR)
  -- HCI_Write_Extended_Inquiry_Response
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader        header
  $next [+1]         UInt                     fec_required
    -- If FEC Encoding is required. (v1.2) (7.3.56)

  let eir_size = ExtendedInquiryResponse.$size_in_bytes
  $next [+eir_size]  ExtendedInquiryResponse  extended_inquiry_response
    -- Extended inquiry response data as defined in Vol 3, Part C, Sec 8

# 7.3.57 Refresh Encryption Key command
# HCI_Refresh_Encryption_Key
# TODO: b/265052417 - Definition needs to be added


struct ReadSimplePairingModeCommand:
  -- 7.3.58 Read Simple Pairing Mode (v2.1 + EDR) (BR/EDR)
  -- HCI_Read_Simple_Pairing_Mode
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct WriteSimplePairingModeCommand:
  -- 7.3.59 Write Simple Pairing Mode (v2.1 + EDR) (BR/EDR)
  -- HCI_Write_Simple_Pairing_Mode
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader       header
  $next [+1]         hci.GenericEnableParam  simple_pairing_mode

# 7.3.60 Read Local OOB Data command
# HCI_Read_Local_OOB_Data
# TODO: b/265052417 - Definition needs to be added


# 7.3.61 Read Inquiry Response Transmit Power Level command
# HCI_Read_Inquiry_Response_Transmit_Power_Level
# TODO: b/265052417 - Definition needs to be added


# 7.3.62 Write Inquiry Transmit Power Level command
# HCI_Write_Inquiry_Transmit_Power_Level
# TODO: b/265052417 - Definition needs to be added


# 7.3.63 Send Keypress Notification command
# HCI_Send_Keypress_Notification
# TODO: b/265052417 - Definition needs to be added


# 7.3.64 Read Default Erroneous Data Reporting command
# HCI_Read_Default_Erroneous_Data_Reporting
# TODO: b/265052417 - Definition needs to be added


# 7.3.65 Write Default Erroneous Data Reporting command
# HCI_Write_Default_Erroneous_Data_Reporting
# TODO: b/265052417 - Definition needs to be added


# 7.3.66 Enhanced Flush command
# HCI_Enhanced_Flush
# TODO: b/265052417 - Definition needs to be added


struct SetEventMaskPage2Command:
  -- 7.3.69 Set Event Mask Page 2 command (v3.0 + HS)
  -- HCI_Set_Event_Mask_Page_2
  0     [+hci.CommandHeader.$size_in_bytes]  hci.CommandHeader  header
  $next [+8]  bits:
    0     [+26]                              EventMaskPage2     event_mask_page_2
      -- Bit mask used to control which HCI events are generated by the HCI for the Host.


struct ReadFlowControlModeCommand:
  -- 7.3.72 Read Flow Control Mode command (v3.0 + HS) (BR/EDR)
  -- HCI_Read_Flow_Control_Mode
  0 [+hci.CommandHeader.$size_in_bytes]  hci.CommandHeader  header


struct WriteFlowControlModeCommand:
  -- 7.3.73 Write Flow Control Mode command (v3.0 + HS) (BR/EDR)
  -- HCI_Write_Flow_Control_Mode
  0     [+hci.CommandHeader.$size_in_bytes]  hci.CommandHeader  header
  $next [+1]                                 FlowControlMode    flow_control_mode

# 7.3.74 Read Enhanced Transmit Power Level command
# HCI_Read_Enhanced_Transmit_Power_Level
# TODO: b/265052417 - Definition needs to be added


struct ReadLEHostSupportCommand:
  -- 7.3.78 Read LE Host Support command (v4.0) (BR/EDR)
  -- HCI_Read_LE_Host_Support
  0 [+hci.CommandHeader.$size_in_bytes]  hci.CommandHeader  header


struct WriteLEHostSupportCommand:
  -- 7.3.79 Write LE Host Support command (v4.0) (BR/EDR)
  -- HCI_Write_LE_Host_Support
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader       header
  $next [+1]         hci.GenericEnableParam  le_supported_host
    -- Sets the LE Supported (Host) Link Manager Protocol feature bit.

  $next [+1]         UInt                    unused
    -- Core Spec v5.0, Vol 2, Part E, Section 6.35: This parameter was named
    -- "Simultaneous_LE_Host" and the value is set to "disabled(0x00)" and
    -- "shall be ignored".
    -- Core Spec v5.3, Vol 4, Part E, Section 7.3.79: This parameter was renamed
    -- to "Unused" and "shall be ignored by the controller".

# 7.3.80 Set MWS Channel Parameters command
# HCI_Set_MWS_Channel_Parameters
# TODO: b/265052417 - Definition needs to be added


# 7.3.81 Set External Frame Configuration command
# HCI_Set_External_Frame_Configuration
# TODO: b/265052417 - Definition needs to be added


# 7.3.82 Set MWS Signaling command
# HCI_Set_MWS_Signaling
# TODO: b/265052417 - Definition needs to be added


# 7.3.83 Set MWS Transport Layer command
# HCI_Set_MWS_Transport_Layer
# TODO: b/265052417 - Definition needs to be added


# 7.3.84 Set MWS Scan Frequency Table command
# HCI_Set_MWS_Scan_Frequency_Table
# TODO: b/265052417 - Definition needs to be added


# 7.3.85 Set MWS_PATTERN Configuration command
# HCI_Set_MWS_PATTERN_Configuration
# TODO: b/265052417 - Definition needs to be added


# 7.3.86 Set Reserved LT_ADDR command
# HCI_Set_Reserved_LT_ADDR
# TODO: b/265052417 - Definition needs to be added


# 7.3.87 Delete Reserved LT_ADDR command
# HCI_Delete_Reserved_LT_ADDR
# TODO: b/265052417 - Definition needs to be added


# 7.3.88 Set Connectionless Peripheral Broadcast Data command
# HCI_Set_Connectionless_Peripheral_Broadcast_Data
# TODO: b/265052417 - Definition needs to be added


# 7.3.89 Read Synchronization Train Parameters command
# HCI_Read_Synchronization_Train_Parameters
# TODO: b/265052417 - Definition needs to be added


# 7.3.90 Write Synchronization Train Parameters command
# HCI_Write_Synchronization_Train_Parameters
# TODO: b/265052417 - Definition needs to be added


# 7.3.91 Read Secure Connections Host Support command
# HCI_Read_Secure_Connections_Host_Support
# TODO: b/265052417 - Definition needs to be added


struct WriteSecureConnectionsHostSupportCommand:
  -- 7.3.92 Write Secure Connections Host Support command
  -- HCI_Write_Secure_Connections_Host_Support
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader       header
  $next [+1]         hci.GenericEnableParam  secure_connections_host_support


struct ReadAuthenticatedPayloadTimeoutCommand:
  -- 7.3.93 Read Authenticated Payload Timeout command (v4.1) (BR/EDR & LE)
  -- HCI_Read_Authenticated_Payload_Timeout
  0     [+hci.CommandHeader.$size_in_bytes]  hci.CommandHeader  header
  $next [+2]                                 UInt               connection_handle
    [requires: 0x0000 <= this <= 0x0EFF]


struct WriteAuthenticatedPayloadTimeoutCommand:
  -- 7.3.94 Write Authenticated Payload Timeout command (v4.1) (BR/EDR & LE)
  -- HCI_Write_Authenticated_Payload_Timeout
  0     [+hci.CommandHeader.$size_in_bytes]  hci.CommandHeader  header
  $next [+2]                                 UInt               connection_handle
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+2]                                 UInt               authenticated_payload_timeout
    -- Default = 0x0BB8 (30 s)
    -- Time = N * 10 ms
    -- Time Range: 10 ms to 655,350 ms
    [requires: 0x0001 <= this <= 0xFFFF]

# 7.3.95 Read Local OOB Extended Data command
# HCI_Read_Local_OOB_Extended_Data
# TODO: b/265052417 - Definition needs to be added


# 7.3.96 Read Extended Page Timeout command
# HCI_Read_Extended_Page_Timeout
# TODO: b/265052417 - Definition needs to be added


# 7.3.97 Write Extended Page Timeout command
# HCI_Write_Extended_Page_Timeout
# TODO: b/265052417 - Definition needs to be added


# 7.3.98 Read Extended Inquiry Length command
# HCI_Read_Extended_Inquiry_Length
# TODO: b/265052417 - Definition needs to be added


# 7.3.99 Write Extended Inquiry Length command
# HCI_Write_Extended_Inquiry_Length
# TODO: b/265052417 - Definition needs to be added


# 7.3.100 Set Ecosystem Base Interval command
# HCI_Set_Ecosystem_Base_Interval
# TODO: b/265052417 - Definition needs to be added


# 7.3.101 Configure Data Path command
# HCI_Configure_Data_Path
# TODO: b/265052417 - Definition needs to be added


# 7.3.102 Set Min Encryption Key Size command
# HCI_Set_Min_Encryption_Key_size
# TODO: b/265052417 - Definition needs to be added


# ========== 7.4 Informational Parameters ==========


struct ReadLocalVersionInformationCommand:
  -- 7.4.1 Read Local Version Information command (v1.1)
  -- HCI_Read_Local_Version_Information
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct ReadLocalSupportedCommandsCommand:
  -- 7.4.2 Read Local Supported Commands command (v1.2)
  -- HCI_Read_Local_Supported_Commands
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct ReadLocalSupportedFeaturesCommand:
  -- 7.4.3 Read Local Supported Features command (v1.1)
  -- HCI_Read_Local_Supported_Features
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct ReadLocalExtendedFeaturesCommand:
  -- 7.4.4 Read Local Extended Features command (v1.2) (BR/EDR)
  -- HCI_Read_Local_Extended_Features
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+1]         UInt               page_number
    -- 0x00: Requests the normal LMP features as returned by
    -- Read_Local_Supported_Features.
    -- 0x01-0xFF: Return the corresponding page of features.


struct ReadBufferSizeCommand:
  -- 7.4.5 Read Buffer Size command (v1.1)
  -- HCI_Read_Buffer_Size
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct ReadBdAddrCommand:
  -- 7.4.6 Read BD_ADDR command (v1.1) (BR/EDR, LE)
  -- HCI_Read_BD_ADDR
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header

# 7.4.7 Read Data Block Size command
# HCI_Read_Data_Block_Size
# TODO: b/265052417 - Definition needs to be added


# 7.4.8 Read Local Supported Codecs command
# HCI_Read_Local_Supported_Codecs [v1][v2]
# TODO: b/265052417 - Definition needs to be added


# 7.4.9 Read Local Simple Pairing Options command
# HCI_Read_Local_Simple_Pairing_Options
# TODO: b/265052417 - Definition needs to be added


# 7.4.10 Read Local Supported Codec Capabilities command
# HCI_Read_Local_Supported_Codec_Capabilities
# TODO: b/265052417 - Definition needs to be added


# 7.4.11 Read Local Supported Controller Delay command
# HCI_Read_Local_Supported_Controller_Delay
# TODO: b/265052417 - Definition needs to be added


# ========== 7.5 Status Parameters ==========


struct ReadEncryptionKeySizeCommand:
  -- 7.5.6 Read Encryption Key Size (v1.1) (BR/EDR)
  -- HCI_Read_Encryption_Key_Size
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         UInt               connection_handle
    -- Identifies an active ACL link (only the lower 12 bits are meaningful).
    [requires: 0x0000 <= this <= 0x0EFF]

# ========== 7.8 LE Controller Commands ==========


struct LESetEventMaskCommand:
  -- 7.8.1 LE Set Event Mask command (v4.0) (LE)
  -- HCI_LE_Set_Event_Mask
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+8]  bits:
    0     [+35]      LEEventMask        le_event_mask
      -- Bitmask that indicates which LE events are generated by the HCI for the Host.


struct LEReadBufferSizeCommandV1:
  -- 7.8.2 LE Read Buffer Size command [v1] (v4.0) (LE)
  -- HCI_LE_Read_Buffer_Size [v1]
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct LEReadBufferSizeCommandV2:
  -- 7.8.2 LE Read Buffer Size command [v2] (v5.2) (LE)
  -- HCI_LE_Read_Buffer_Size [v2]
  -- Version 2 of this command changed the opcode and added ISO return
  -- parameters.
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct LEReadLocalSupportedFeaturesCommand:
  -- 7.8.3 LE Read Local Supported Features command (v4.0) (LE)
  -- HCI_LE_Read_Local_Supported_Features
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct LESetRandomAddressCommand:
  -- 7.8.4 LE Set Random Address command (v4.0) (LE)
  -- HCI_LE_Set_Random_Address
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader  header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr         random_address


struct LESetAdvertisingParametersCommand:
  -- 7.8.5 LE Set Advertising Parameters command (v4.0) (LE)
  -- HCI_LE_Set_Advertising_Parameters

  [requires: advertising_interval_min <= advertising_interval_max]

  let hdr_size = hci.CommandHeader.$size_in_bytes

  0     [+hdr_size]                   hci.CommandHeader          header

  $next [+2]                          UInt                       advertising_interval_min
    -- Default: 0x0800 (1.28 s)
    -- Time: N * 0.625 ms
    -- Time Range: 20 ms to 10.24 s
    [requires: 0x0020 <= this <= 0x4000]

  $next [+2]                          UInt                       advertising_interval_max
    -- Default: 0x0800 (1.28 s)
    -- Time: N * 0.625 ms
    -- Time Range: 20 ms to 10.24 s
    [requires: 0x0020 <= this <= 0x4000]

  $next [+1]                          LEAdvertisingType          adv_type
    -- Used to determine the packet type that is used for advertising when
    -- advertising is enabled.

  $next [+1]                          LEOwnAddressType           own_address_type

  $next [+1]                          hci.LEPeerAddressType      peer_address_type
    -- ANONYMOUS address type not allowed.

  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr                 peer_address
    -- Public Device Address, Random Device Address, Public Identity Address, or
    -- Random (static) Identity Address of the device to be connected.

  $next [+1]  bits:

    0     [+3]                        LEAdvertisingChannels      advertising_channel_map
      -- Indicates the advertising channels that shall be used when transmitting
      -- advertising packets. At least 1 channel must be enabled.
      -- Default: all channels enabled

  $next [+1]                          LEAdvertisingFilterPolicy  advertising_filter_policy
    -- This parameter shall be ignored when directed advertising is enabled.


struct LEReadAdvertisingChannelTxPowerCommand:
  -- 7.8.6 LE Read Advertising Channel Tx Power command (v4.0) (LE)
  -- HCI_LE_Read_Advertising_Channel_Tx_Power
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct LESetAdvertisingDataCommand:
  -- 7.8.7 LE Set Advertising Data command (v4.0) (LE)
  -- HCI_LE_Set_Advertising_Data
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+1]         UInt               advertising_data_length
    -- The number of significant octets in `advertising_data`.
    [requires: 0x00 <= this <= 0x1F]

  $next [+31]        UInt:8[31]         advertising_data
    -- 31 octets of advertising data formatted as defined in Core Spec
    -- v5.3, Vol 3, Part C, Section 11.
    -- Default: All octets zero


struct LESetScanResponseDataCommand:
  -- 7.8.8 LE Set Scan Response Data command (v4.0) (LE)
  -- HCI_LE_Set_Scan_Response_Data
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+1]         UInt               scan_response_data_length
    -- The number of significant octets in `scan_response_data`.
    [requires: 0x00 <= this <= 0x1F]

  $next [+31]        UInt:8[31]         scan_response_data
    -- 31 octets of scan response data formatted as defined in Core Spec
    -- v5.3, Vol 3, Part C, Section 11.
    -- Default: All octets zero


struct LESetAdvertisingEnableCommand:
  -- 7.8.9 LE Set Advertising Enable command (v4.0) (LE)
  -- HCI_LE_Set_Advertising_Enable
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader       header
  $next [+1]         hci.GenericEnableParam  advertising_enable


struct LESetScanParametersCommand:
  -- 7.8.10 LE Set Scan Parameters command (v4.0) (LE)
  -- HCI_LE_Set_Scan_Parameters

  [requires: le_scan_window <= le_scan_interval]

  let hdr_size = hci.CommandHeader.$size_in_bytes

  0     [+hdr_size]  hci.CommandHeader   header

  $next [+1]         LEScanType          le_scan_type
    -- Controls the type of scan to perform.

  $next [+2]         UInt                le_scan_interval
    -- Default: 0x0010 (10ms)
    -- Time: N * 0.625 ms
    -- Time Range: 2.5 ms to 10.24 s
    [requires: 0x0004 <= this <= 0x4000]

  $next [+2]         UInt                le_scan_window
    -- Default: 0x0010 (10ms)
    -- Time: N * 0.625 ms
    -- Time Range: 2.5ms to 10.24 s
    [requires: 0x0004 <= this <= 0x4000]

  $next [+1]         LEOwnAddressType    own_address_type
    -- The type of address being used in the scan request packets.

  $next [+1]         LEScanFilterPolicy  scanning_filter_policy


struct LESetScanEnableCommand:
  -- 7.8.11 LE Set Scan Enable command (v4.0) (LE)
  -- HCI_LE_Set_Scan_Enable
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader       header
  $next [+1]         hci.GenericEnableParam  le_scan_enable
  $next [+1]         hci.GenericEnableParam  filter_duplicates
    -- Controls whether the Link Layer should filter out duplicate advertising
    -- reports to the Host, or if the Link Layer should generate advertising
    -- reports for each packet received. Ignored if le_scan_enable is set to
    -- disabled.
    -- See Core Spec v5.3, Vol 6, Part B, Section 4.4.3.5


struct LECreateConnectionCommand:
  -- 7.8.12 LE Create Connection command (v4.0) (LE)
  -- HCI_LE_Create_Connection

  [requires: le_scan_window <= le_scan_interval && connection_interval_min <= connection_interval_max]

  let hdr_size = hci.CommandHeader.$size_in_bytes

  0     [+hdr_size]                   hci.CommandHeader       header

  $next [+2]                          UInt                    le_scan_interval
    -- The time interval from when the Controller started the last LE scan until
    -- it begins the subsequent LE scan.
    -- Time: N * 0.625 ms
    -- Time Range: 2.5 ms to 10.24 s
    [requires: 0x0004 <= this <= 0x4000]

  $next [+2]                          UInt                    le_scan_window
    -- Amount of time for the duration of the LE scan.
    -- Time: N * 0.625 ms
    -- Time Range: 2.5 ms to 10.24 s
    [requires: 0x0004 <= this <= 0x4000]

  $next [+1]                          hci.GenericEnableParam  initiator_filter_policy

  $next [+1]                          hci.LEAddressType       peer_address_type

  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr              peer_address

  $next [+1]                          LEOwnAddressType        own_address_type

  $next [+2]                          UInt                    connection_interval_min
    -- Time: N * 1.25 ms
    -- Time Range: 7.5 ms to 4 s.
    [requires: 0x0006 <= this <= 0x0C80]

  $next [+2]                          UInt                    connection_interval_max
    -- Time: N * 1.25 ms
    -- Time Range: 7.5 ms to 4 s.
    [requires: 0x0006 <= this <= 0x0C80]

  $next [+2]                          UInt                    max_latency
    -- Maximum Peripheral latency for the connection in number of connection
    -- events.
    [requires: 0x0000 <= this <= 0x01F3]

  $next [+2]                          UInt                    supervision_timeout
    -- See Core Spec v5.3, Vol 6, Part B, Section 4.5.2.
    -- Time: N * 10 ms
    -- Time Range: 100 ms to 32 s
    [requires: 0x000A <= this <= 0x0C80]

  $next [+2]                          UInt                    min_connection_event_length
    -- Time: N * 0.625 ms

  $next [+2]                          UInt                    max_connection_event_length
    -- Time: N * 0.625 ms


struct LECreateConnectionCancelCommand:
  -- 7.8.13 LE Create Connection Cancel command (v4.0) (LE)
  -- HCI_LE_Create_Connection_Cancel
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header

# 7.8.14 LE Read Filter Accept List Size command
# HCI_LE_Read_Filter_Accept_List_Size
# TODO: b/265052417 - Definition needs to be added


struct LEClearFilterAcceptListCommand:
  -- 7.8.15 LE Clear Filter Accept List command (v4.0) (LE)
  -- HCI_LE_Clear_Filter_Accept_List
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct LEAddDeviceToFilterAcceptListCommand:
  -- 7.8.16 LE Add Device To Filter Accept List command (v4.0) (LE)
  -- HCI_LE_Add_Device_To_Filter_Accept_List
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader      header
  $next [+1]                          hci.LEPeerAddressType  address_type
    -- The address type of the peer.

  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr             address
    -- Public Device Address or Random Device Address of the device to be added
    -- to the Filter Accept List. Ignored if `address_type` is ANONYMOUS.


struct LERemoveDeviceFromFilterAcceptListCommand:
  -- 7.8.17 LE Remove Device From Filter Accept List command (v4.0) (LE)
  -- HCI_LE_Remove_Device_From_Filter_Accept_List
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader      header
  $next [+1]                          hci.LEPeerAddressType  address_type
    -- The address type of the peer.

  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr             address
    -- Public Device Address or Random Device Address of the device to be added
    -- to the Filter Accept List. Ignored if `address_type` is ANONYMOUS.


struct LEConnectionUpdateCommand:
  -- 7.8.18 LE Connection Update command (v4.0) (LE)
  -- HCI_LE_Connection_Update

  [requires: connection_interval_min <= connection_interval_max && min_connection_event_length <= max_connection_event_length]

  let hdr_size = hci.CommandHeader.$size_in_bytes

  0     [+hdr_size]  hci.CommandHeader  header

  $next [+2]         UInt               connection_handle
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+2]         UInt               connection_interval_min
    -- Time: N * 1.25 ms
    -- Time Range: 7.5 ms to 4 s.
    [requires: 0x0006 <= this <= 0x0C80]

  $next [+2]         UInt               connection_interval_max
    -- Time: N * 1.25 ms
    -- Time Range: 7.5 ms to 4 s.
    [requires: 0x0006 <= this <= 0x0C80]

  $next [+2]         UInt               max_latency
    -- Maximum Peripheral latency for the connection in number of subrated
    -- connection events.
    [requires: 0x0000 <= this <= 0x01F3]

  $next [+2]         UInt               supervision_timeout
    -- See Core Spec v5.3, Vol 6, Part B, Section 4.5.2.
    -- Time: N * 10 ms
    -- Time Range: 100 ms to 32 s
    [requires: 0x000A <= this <= 0x0C80]

  $next [+2]         UInt               min_connection_event_length
    -- Time: N * 0.625 ms

  $next [+2]         UInt               max_connection_event_length
    -- Time: N * 0.625 ms

# 7.8.19 LE Set Host Channel Classification command
# HCI_LE_Set_Host_Channel_Classification
# TODO: b/265052417 - Definition needs to be added


# 7.8.20 LE Read Channel Map command
# HCI_LE_Read_Channel_Map
# TODO: b/265052417 - Definition needs to be added


struct LEReadRemoteFeaturesCommand:
  -- 7.8.21 LE Read Remote Features command (v4.0) (LE)
  -- HCI_LE_Read_Remote_Features
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         UInt               connection_handle
    [requires: 0x0000 <= this <= 0x0EFF]

# 7.8.22 LE Encrypt command
# HCI_LE_Encrypt
# TODO: b/265052417 - Definition needs to be added


# 7.8.23 LE Rand command
# HCI_LE_Rand
# TODO: b/265052417 - Definition needs to be added


struct LEEnableEncryptionCommand:
  -- 7.8.24 LE Enable Encryption command (v4.0) (LE)
  -- HCI_LE_Enable_Encryption
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                    hci.CommandHeader  header
  $next [+2]                           UInt               connection_handle
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+8]                           UInt               random_number
  $next [+2]                           UInt               encrypted_diversifier
  $next [+hci.LinkKey.$size_in_bytes]  hci.LinkKey        long_term_key


struct LELongTermKeyRequestReplyCommand:
  -- 7.8.25 LE Long Term Key Request Reply command (v4.0) (LE)
  -- HCI_LE_Long_Term_Key_Request_Reply
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                    hci.CommandHeader  header
  $next [+2]                           UInt               connection_handle
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+hci.LinkKey.$size_in_bytes]  hci.LinkKey        long_term_key


struct LELongTermKeyRequestNegativeReplyCommand:
  -- 7.8.26 LE Long Term Key Request Negative Reply command (v4.0) (LE)
  -- HCI_LE_Long_Term_Key_Request_Negative_Reply
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         UInt               connection_handle
    [requires: 0x0000 <= this <= 0x0EFF]


struct LEReadSupportedStatesCommand:
  -- 7.8.27 LE Read Supported States command (v4.0) (LE)
  -- HCI_LE_Read_Supported_States
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header

# 7.8.28 LE Receiver Test command
# HCI_LE_Receiver_Test [v1] [v2] [v3]
# TODO: b/265052417 - Definition needs to be added


# 7.8.29 LE Transmitter Test command
# HCI_LE_Transmitter_Test [v1] [v2] [v3] [v4]
# TODO: b/265052417 - Definition needs to be added


# 7.8.30 LE Test End command
# HCI_LE_Test_End
# TODO: b/265052417 - Definition needs to be added


# 7.8.31 LE Remote Connection Parameter Request Reply command
# HCI_LE_Remote_Connection_Parameter_Request_Reply
# TODO: b/265052417 - Definition needs to be added


# 7.8.32 LE Remote Connection Parameter Request Negative Reply command
# HCI_LE_Remote_Connection_Parameter_Request_Negative_Reply
# TODO: b/265052417 - Definition needs to be added


# 7.8.33 LE Set Data Length command
# HCI_LE_Set_Data_Length
# TODO: b/265052417 - Definition needs to be added


# 7.8.34 LE Read Suggested Default Data Length command
# HCI_LE_Read_Suggested_Default_Data_Length
# TODO: b/265052417 - Definition needs to be added


# 7.8.35 LE Write Suggested Default Data Length command
# HCI_LE_Write_Suggested_Default_Data_Length
# TODO: b/265052417 - Definition needs to be added


# 7.8.36 LE Read Local P-256 Public Key command
# HCI_LE_Read_Local_P-256_Public_Key
# TODO: b/265052417 - Definition needs to be added


# 7.8.37 LE Generate DHKey command
# HCI_LE_Generate_DHKey [v1] [v2]
# TODO: b/265052417 - Definition needs to be added


# 7.8.38 LE Add Device To Resolving List command
# HCI_LE_Add_Device_To_Resolving_List
# TODO: b/265052417 - Definition needs to be added


# 7.8.39 LE Remove Device From Resolving List command
# HCI_LE_Remove_Device_From_Resolving_List
# TODO: b/265052417 - Definition needs to be added


struct LEClearResolvingListCommand:
  -- 7.8.40 LE Clear Resolving List command (v4.2) (LE)
  -- HCI_LE_Clear_Resolving_List
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header

# 7.8.41 LE Read Resolving List Size command
# HCI_LE_Read_Resolving_List_Size
# TODO: b/265052417 - Definition needs to be added


# 7.8.42 LE Read Peer Resolvable Address command
# HCI_LE_Read_Peer_Resolvable_Address
# TODO: b/265052417 - Definition needs to be added


# 7.8.43 LE Read Local Resolvable Address command
# HCI_LE_Read_Local_Resolvable_Address
# TODO: b/265052417 - Definition needs to be added


struct LESetAddressResolutionEnableCommand:
  -- 7.8.44 LE Set Address Resolution Enable command (v4.2) (LE)
  -- HCI_LE_Set_Address_Resolution_Enable
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader       header
  $next [+1]         hci.GenericEnableParam  address_resolution_enable

# 7.8.45 LE Set Resolvable Private Address Timeout command
# HCI_LE_Set_Resolvable_Private_Address_Timeout
# TODO: b/265052417 - Definition needs to be added


# 7.8.46 LE Read Maximum Data Length command
# HCI_LE_Read_Maximum_Data_Length
# TODO: b/265052417 - Definition needs to be added


# 7.8.47 LE Read PHY command
# HCI_LE_Read_PHY
# TODO: b/265052417 - Definition needs to be added


# 7.8.48 LE Set Default PHY command
# HCI_LE_Set_Default_PHY
# TODO: b/265052417 - Definition needs to be added


# 7.8.49 LE Set PHY command
# HCI_LE_Set_PHY
# TODO: b/265052417 - Definition needs to be added


struct LESetAdvertisingSetRandomAddressCommand:
  -- 7.8.52 LE Set Advertising Set Random Address command (v5.0) (LE)
  -- HCI_LE_Set_Advertising_Set_Random_Address
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader  header
  $next [+1]                          UInt               advertising_handle
    -- Handle used to identify an advertising set.

  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr         random_address
    -- The random address to use in the advertising PDUs.


struct LESetExtendedAdvertisingParametersV1Command:
  -- 7.8.53 LE Set Extended Advertising Parameters [v1] command (v5.0) (LE)
  -- HCI_LE_Set_Extended_Advertising_Parameters [v1]

  let hdr_size = hci.CommandHeader.$size_in_bytes

  0     [+hdr_size]                   hci.CommandHeader              header

  $next [+1]                          UInt                           advertising_handle
    -- Handle used to identify an advertising set.

  $next [+2]  bits:

    0     [+7]                        LEAdvertisingEventProperties   advertising_event_properties

  $next [+3]                          UInt                           primary_advertising_interval_min
    -- Time = N * 0.625 s
    -- Time Range: 20 ms to 10,485.759375 s
    [requires: 0x000020 <= this]

  $next [+3]                          UInt                           primary_advertising_interval_max
    -- Time = N * 0.625 s
    -- Time Range: 20 ms to 10,485.759375 s
    [requires: 0x000020 <= this]

  $next [+1]  bits:

    0     [+3]                        LEAdvertisingChannels          primary_advertising_channel_map

  $next [+1]                          LEOwnAddressType               own_address_type

  $next [+1]                          hci.LEPeerAddressTypeNoAnon    peer_address_type

  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr                     peer_address
    -- Public Device Address, Random Device Address, Public Identity Address, or Random (static)
    -- Identity Address of the device to be connected.

  $next [+1]                          LEAdvertisingFilterPolicy      advertising_filter_policy

  $next [+1]                          Int                            advertising_tx_power
    -- Range: -127 <= N <= +126
    -- Units: dBm
    -- If N = 127: Host has no preference.
    [requires: -127 <= this]

  $next [+1]                          hci.LEPrimaryAdvertisingPHY    primary_advertising_phy
    -- LEPHY::kLE2M and LEPHY::kLECodedS2 are excluded.

  $next [+1]                          UInt                           secondary_advertising_max_skip
    -- Maximum advertising events the controller can skip before sending the AUX_ADV_IND packets on
    -- the secondary advertising physical channel. If this value is zero, AUX_ADV_IND shall be sent
    -- prior to the next advertising event.

  $next [+1]                          hci.LESecondaryAdvertisingPHY  secondary_advertising_phy

  $next [+1]                          UInt                           advertising_sid
    -- Value of the Advertising SID subfield in the ADI field of the PDU
    [requires: 0x00 <= this <= 0x0F]

  $next [+1]                          hci.GenericEnableParam         scan_request_notification_enable

# TODO: b/265052417 - LE Set Extended Advertising Parameters [v2] definition needs to be added


struct LESetExtendedAdvertisingDataCommand:
  -- 7.8.54 LE Set Extended Advertising Data command (v5.0) (LE)
  -- HCI_LE_Set_Extended_Advertising_Data

  let hdr_size = hci.CommandHeader.$size_in_bytes

  0     [+hdr_size]  hci.CommandHeader                header

  $next [+1]         UInt                             advertising_handle
    -- Handle used to identify an advertising set.

  $next [+1]         LESetExtendedAdvDataOp           operation

  $next [+1]         LEExtendedAdvFragmentPreference  fragment_preference
    -- Provides a hint to the Controller as to whether advertising data should be fragmented.

  $next [+1]         UInt                             advertising_data_length (sz)
    -- Length of the advertising data included in this command packet, up to
    -- kMaxLEExtendedAdvertisingDataLength bytes. If the advertising set uses legacy advertising
    -- PDUs that support advertising data then this shall not exceed kMaxLEAdvertisingDataLength
    -- bytes.
    [requires: 0 <= this <= 251]

  $next [+sz]        UInt:8[sz]                       advertising_data
    -- Variable length advertising data.


struct LESetExtendedScanResponseDataCommand:
  -- 7.8.55 LE Set Extended Scan Response Data command (v5.0) (LE)
  -- HCI_LE_Set_Extended_Scan_Response_Data
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader                header
  $next [+1]         UInt                             advertising_handle
    -- Used to identify an advertising set
    [requires: 0x00 <= this <= 0xEF]

  $next [+1]         LESetExtendedAdvDataOp           operation
  $next [+1]         LEExtendedAdvFragmentPreference  fragment_preference
    -- Provides a hint to the controller as to whether advertising data should be fragmented

  $next [+1]         UInt                             scan_response_data_length (sz)
    -- The number of octets in the scan_response_data parameter
    [requires: 0 <= this <= 251]

  $next [+sz]        UInt:8[sz]                       scan_response_data
    -- Scan response data formatted as defined in Core Spec v5.4, Vol 3, Part C, Section 11


struct LESetExtendedAdvertisingEnableData:
  -- Data fields for variable-length portion of an LE Set Extended Advertising Enable command
  0     [+1]  UInt  advertising_handle
  $next [+2]  UInt  duration
  $next [+1]  UInt  max_extended_advertising_events


struct LESetExtendedAdvertisingEnableCommand:
  -- 7.8.56 LE Set Extended Advertising Enable command (v5.0) (LE)
  -- HCI_LE_Set_Extended_Advertising_Enable
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader                     header
  $next [+1]                          hci.GenericEnableParam                enable
  $next [+1]                          UInt                                  num_sets
  let single_data_size = LESetExtendedAdvertisingEnableData.$size_in_bytes
  $next [+single_data_size*num_sets]  LESetExtendedAdvertisingEnableData[]  data


struct LEReadMaxAdvertisingDataLengthCommand:
  -- 7.8.57 LE Read Maximum Advertising Data Length command (v5.0) (LE)
  -- HCI_LE_Read_Maximum_Advertising_Data_Length
  -- This command has no parameters
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct LEReadNumSupportedAdvertisingSetsCommand:
  -- 7.8.58 LE Read Number of Supported Advertising Sets command (v5.0) (LE)
  -- HCI_LE_Read_Number_of_Supported_Advertising_Sets
  -- This command has no parameters
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct LERemoveAdvertisingSetCommand:
  -- 7.8.59 LE Remove Advertising Set command (v5.0) (LE)
  -- HCI_LE_Remove_Advertising_Set
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+1]         UInt               advertising_handle


struct LEClearAdvertisingSetsCommand:
  -- 7.8.60 LE Clear Advertising Sets command (v5.0) (LE)
  -- HCI_LE_Clear_Advertising_Sets
  -- This command has no parameters
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header

# 7.8.61 LE Set Periodic Advertising Parameters command
# HCI_LE_Set_Periodic_Advertising_Parameters [v1] [v2]
# TODO: b/265052417 - Definition needs to be added


# 7.8.62 LE Set Periodic Advertising Data command
# HCI_LE_Set_Periodic_Advertising_Data
# TODO: b/265052417 - Definition needs to be added


# 7.8.63 LE Set Periodic Advertising Enable command
# HCI_LE_Set_Periodic_Advertising_Enable
# TODO: b/265052417 - Definition needs to be added


struct LESetExtendedScanParametersData:
  -- Data fields for variable-length portion of an LE Set Extneded Scan Parameters command

  0     [+1]  LEScanType  scan_type

  $next [+2]  UInt        scan_interval
    -- Time interval from when the Controller started its last scan until it begins the subsequent
    -- scan on the primary advertising physical channel.
    -- Time = N × 0.625 ms
    -- Time Range: 2.5 ms to 40.959375 s
    [requires: 0x0004 <= this]

  $next [+2]  UInt        scan_window
    -- Duration of the scan on the primary advertising physical channel.
    -- Time = N × 0.625 ms
    -- Time Range: 2.5 ms to 40.959375 s
    [requires: 0x0004 <= this]


struct LESetExtendedScanParametersCommand:
  -- 7.8.64 LE Set Extended Scan Parameters command (v5.0) (LE)
  -- HCI_LE_Set_Extended_Scan_Parameters
  -- num_entries corresponds to the number of bits set in the |scanning_phys| field
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                       hci.CommandHeader                             header
  $next [+1]                              LEOwnAddressType                              own_address_type
  $next [+1]                              LEScanFilterPolicy                            scanning_filter_policy
  $next [+1]  bits:
    0     [+LEScanPHYBits.$size_in_bits]  LEScanPHYBits                                 scanning_phys

  let single_entry_size = LESetExtendedScanParametersData.$size_in_bytes
  let num_entries = (scanning_phys.le_1m ? 1 : 0)+(scanning_phys.le_coded ? 1 : 0)
  let total_entries_size = num_entries*single_entry_size
  $next [+total_entries_size]             LESetExtendedScanParametersData[num_entries]  data


struct LESetExtendedScanEnableCommand:
  -- 7.8.65 LE Set Extended Scan Enable command (v5.0) (LE)
  -- HCI_LE_Set_Extended_Scan_Enable

  let hdr_size = hci.CommandHeader.$size_in_bytes

  0     [+hdr_size]  hci.CommandHeader                   header

  $next [+1]         hci.GenericEnableParam              scanning_enabled

  $next [+1]         LEExtendedDuplicateFilteringOption  filter_duplicates
    -- See enum class LEExtendedDuplicateFilteringOption in this file for possible values

  $next [+2]         UInt                                duration
    -- Possible values:
    --   0x0000: Scan continuously until explicitly disabled
    --   0x0001-0xFFFF: Scan duration, where:
    --     Time = N * 10 ms
    --     Time Range: 10 ms to 655.35 s

  $next [+2]         UInt                                period
    -- Possible values:
    --   0x0000: Periodic scanning disabled (scan continuously)
    --   0x0001-0xFFFF: Time interval from when the Controller started its last
    --   Scan_Duration until it begins the subsequent Scan_Duration, where:
    --     Time = N * 1.28 sec
    --     Time Range: 1.28 s to 83,884.8 s


struct LEExtendedCreateConnectionV1:
  -- 7.8.66 LE Extended Create Connection command version 1
  -- HCI_LE_Extended_Create_Connection v1
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                             hci.CommandHeader       header
  $next [+1]                                    hci.GenericEnableParam  initiator_filter_policy
  $next [+1]                                    LEOwnAddressType        own_address_type
  $next [+1]                                    hci.LEPeerAddressType   peer_address_type
  $next [+hci.BdAddr.$size_in_bytes]            hci.BdAddr              peer_address
  $next [+1]  bits:
    0     [+LEInitiatingPHYBits.$size_in_bits]  LEInitiatingPHYBits     initiating_phys

  let num_entries = (initiating_phys.le_1m ? 1 : 0)+(initiating_phys.le_2m ? 1 : 0)+(initiating_phys.le_coded ? 1 : 0)
  $next [+2*num_entries]                        UInt:16[num_entries]    scan_interval
    -- Time interval from when the Controller started its last scan until it begins the subsequent
    -- scan on the primary advertising physical channel.
    -- Time = N × 0.625 ms
    -- Time Range: 2.5 ms to 40.959375 s

  $next [+2*num_entries]                        UInt:16[num_entries]    scan_window
    -- Duration of the scan on the primary advertising physical channel.
    -- Time = N × 0.625 ms
    -- Time Range: 2.5 ms to 40.959375 s

  $next [+2*num_entries]                        UInt:16[num_entries]    connection_interval_min
    -- Time: N * 1.25 ms
    -- Time Range: 7.5 ms to 4 s.

  $next [+2*num_entries]                        UInt:16[num_entries]    connection_interval_max
    -- Time: N * 1.25 ms
    -- Time Range: 7.5 ms to 4 s.

  $next [+2*num_entries]                        UInt:16[num_entries]    max_latency
    -- Maximum Peripheral latency for the connection in number of connection events.

  $next [+2*num_entries]                        UInt:16[num_entries]    supervision_timeout
    -- See Core Spec v5.3, Vol 6, Part B, Section 4.5.2.
    -- Time: N * 10 ms
    -- Time Range: 100 ms to 32 s

  $next [+2*num_entries]                        UInt:16[num_entries]    min_connection_event_length
    -- Time: N * 0.625 ms

  $next [+2*num_entries]                        UInt:16[num_entries]    max_connection_event_length
    -- Time: N * 0.625 ms

# 7.8.66 LE Extended Create Connection command version 2
# HCI_LE_Extended_Create_Connection v2
# TODO: b/265052417 - Definition needs to be added


struct LEPeriodicAdvertisingCreateSyncCommand:
  -- 7.8.67 LE Periodic Advertising Create Sync command (v5.0) (LE)
  -- HCI_LE_Periodic_Advertising_Create_Sync

  let hdr_size = hci.CommandHeader.$size_in_bytes

  0     [+hdr_size]                                                hci.CommandHeader                       header

  $next [+1]  bits:

    0     [+LEPeriodicAdvertisingCreateSyncOptions.$size_in_bits]  LEPeriodicAdvertisingCreateSyncOptions  options

  $next [+1]                                                       UInt                                    advertising_sid
    -- Advertising SID subfield in the ADI field used to identify the Periodic Advertising
    [requires: 0x00 <= this <= 0x0F]

  $next [+1]                                                       hci.LEPeerAddressTypeNoAnon             advertiser_address_type

  $next [+hci.BdAddr.$size_in_bytes]                               hci.BdAddr                              advertiser_address
    -- Public Device Address, Random Device Address, Public Identity Address, or Random (static)
    -- Identity Address of the advertiser

  $next [+2]                                                       UInt                                    skip
    -- The maximum number of periodic advertising events that can be skipped after a successful
    -- receive
    [requires: 0x0000 <= this <= 0x01F3]

  $next [+2]                                                       UInt                                    sync_timeout
    -- Synchronization timeout for the periodic advertising.
    -- Time = N * 10 ms
    -- Time Range: 100 ms to 163.84 s
    [requires: 0x000A <= this <= 0x4000]

  $next [+1]  bits:

    0     [+LEPeriodicAdvertisingSyncCTEType.$size_in_bits]        LEPeriodicAdvertisingSyncCTEType        sync_cte_type
      -- Constant Tone Extension sync options


struct LEPeriodicAdvertisingCreateSyncCancel:
  -- 7.8.68 LE Periodic Advertising Create Sync Cancel command (v5.0) (LE)
  -- HCI_LE_Periodic_Advertising_Create_Sync_Cancel
  -- Note that this command has no arguments
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct LEPeriodicAdvertisingTerminateSyncCommand:
  -- 7.8.69 LE Periodic Advertising Terminate Sync command (v5.0) (LE)
  -- HCI_LE_Periodic_Advertising_Terminate_Sync
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         UInt               sync_handle
    -- Identifies the periodic advertising train
    [requires: 0x0000 <= this <= 0x0EFF]


struct LEAddDeviceToPeriodicAdvertiserListCommand:
  -- 7.8.70 LE Add Device To Periodic Advertiser List command (v5.0) (LE)
  -- HCI_LE_Add_Device_To_Periodic_Advertiser_List
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader  header
  $next [+1]                          hci.LEAddressType  advertiser_address_type
    -- Address type of the advertiser. The LEAddressType::kPublicIdentity and
    -- LEAddressType::kRandomIdentity values are excluded for this command.

  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr         advertiser_address
    -- Public Device Address, Random Device Address, Public Identity Address, or
    -- Random (static) Identity Address of the advertiser.

  $next [+1]                          UInt               advertising_sid
    -- Advertising SID subfield in the ADI field used to identify the Periodic
    -- Advertising.


struct LERemoveDeviceFromPeriodicAdvertiserListCommand:
  -- 7.8.71 LE Remove Device From Periodic Advertiser List command (v5.0) (LE)
  -- HCI_LE_Remove_Device_From_Periodic_Advertiser_List
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader  header
  $next [+1]                          UInt               advertiser_address_type
    -- Address type of the advertiser. The LEAddressType::kPublicIdentity and
    -- LEAddressType::kRandomIdentity values are excluded for this command.

  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr         advertiser_address
    -- Public Device Address, Random Device Address, Public Identity Address, or
    -- Random (static) Identity Address of the advertiser.

  $next [+1]                          UInt               advertising_sid
    -- Advertising SID subfield in the ADI field used to identify the Periodic
    -- Advertising.


struct LEClearPeriodicAdvertiserListCommand:
  -- 7.8.72 LE Clear Periodic Advertiser List command (v5.0) (LE)
  -- HCI_LE_Clear_Periodic_Advertiser_List
  -- Note that this command has no arguments
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct LEReadPeriodicAdvertiserListSizeCommand:
  -- 7.8.73 LE Read Periodic Advertiser List Size command (v5.0) (LE)
  -- HCI_LE_Read_Periodic_Advertiser_List_Size
  -- Note that this command has no arguments
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct LEReadTransmitPowerCommand:
  -- 7.8.74 LE Read Transmit Power command (v5.0) (LE)
  -- HCI_LE_Read_Transmit_Power
  -- Note that this command has no arguments
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct LEReadRFPathCompensationCommand:
  -- 7.8.75 LE Read RF Path Compensation command (v5.0) (LE)
  -- HCI_LE_Read_RF_Path_Compensation
  -- Note that this command has no arguments
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0 [+hdr_size]  hci.CommandHeader  header


struct LEWriteRFPathCompensationCommand:
  -- 7.8.76 LE Write RF Path Compensation command (v5.0) (LE)
  -- HCI_LE_Write_RF_Path_Compensation
  -- Values provided are used in the Tx Power Level and RSSI calculation.
  --   Range: -128.0 dB (0xFB00) ≤ N ≤ 128.0 dB (0x0500)
  --   Units: 0.1 dB
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         Int                rf_tx_path_compensation_value
    [requires: -1280 <= this <= 1280]

  $next [+2]         Int                rf_rx_path_compensation_value
    [requires: -1280 <= this <= 1280]


struct LESetPrivacyModeCommand:
  -- 7.8.77 LE Set Privacy Mode command (v5.0) (LE)
  -- HCI_LE_Set_Privacy_Mode
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                   hci.CommandHeader            header
  $next [+1]                          hci.LEPeerAddressTypeNoAnon  peer_identity_address_type
    -- The peer identity address type (either Public Identity or Private
    -- Identity).

  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr                   peer_identity_address
    -- Public Identity Address or Random (static) Identity Address of the
    -- advertiser.

  $next [+1]                          LEPrivacyMode                privacy_mode
    -- The privacy mode to be used for the given entry on the resolving list.

# 7.8.93 [No longer used]
# 7.8.94 LE Modify Sleep Clock Accuracy command
# 7.8.95 [No longer used]


struct LEReadISOTXSyncCommand:
  -- 7.8.96 LE Read ISO TX Sync command (v5.2) (LE)
  -- HCI_LE_Read_ISO_TX_Sync
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         UInt               connection_handle
    -- Connection handle of the CIS or BIS
    [requires: 0x0000 <= this <= 0x0EFF]


struct LESetCIGParametersCommand:
  -- 7.8.97 LE Set CIG Parameters command (v5.2) (LE)
  -- HCI_LE_Set_CIG_Parameters

  let hdr_size = hci.CommandHeader.$size_in_bytes

  0     [+hdr_size]                hci.CommandHeader                        header

  $next [+1]                       UInt                                     cig_id
    -- Used to identify the CIG
    [requires: 0x00 <= this <= 0xEF]

  $next [+3]                       UInt                                     sdu_interval_c_to_p
    -- The interval, in microseconds, of periodic SDUs (Central => Peripheral)
    [requires: 0x0000FF <= this <= 0x0FFFFF]

  $next [+3]                       UInt                                     sdu_interval_p_to_c
    -- The interval, in microseconds, of periodic SDUs (Peripheral => Central)
    [requires: 0x0000FF <= this <= 0x0FFFFF]

  $next [+1]                       LESleepClockAccuracyRange                worst_case_sca
    -- Worst-case sleep clock accuracy of all Peripherals that will participate in the CIG

  $next [+1]                       LECISPacking                             packing
    -- Preferred method of arranging subevents of multiple CISes

  $next [+1]                       LECISFraming                             framing
    -- Format of the CIS Data PDUs

  $next [+2]                       UInt                                     max_transport_latency_c_to_p
    -- Maximum transport latency, in milliseconds, from the Central's Controller to the
    -- Peripheral's Controller
    [requires: 0x0005 <= this <= 0x0FA0]

  $next [+2]                       UInt                                     max_transport_latency_p_to_c
    -- Maximum transport latency, in milliseconds, from the Peripheral's Controller to the
    -- Central's Controller
    [requires: 0x0005 <= this <= 0x0FA0]

  $next [+1]                       UInt                                     cis_count
    -- Total number of CIS configurations in the CIG being added or modified
    [requires: 0x00 <= this <= 0x1F]

  let single_cis_options_size = LESetCIGParametersCISOptions.$size_in_bytes

  let total_cis_options_size = cis_count*single_cis_options_size

  $next [+total_cis_options_size]  LESetCIGParametersCISOptions[cis_count]  cis_options
    -- Array of parameters, one for each of the CISes in this CIG

# 7.8.98 LE Set CIG Parameters Test command


struct LECreateCISCommand:
  -- 7.8.99 LE Create CIS command (v5.2) (LE)
  -- HCI_LE_Create_CIS
  struct ConnectionInfo:
    -- Handles for each stream being created

    0     [+2]  UInt  cis_connection_handle
      -- Connection handle of a CIS
      [requires: 0x0000 <= this <= 0xEFFF]

    $next [+2]  UInt  acl_connection_handle
      -- Connection handle of an ACL connection
      [requires: 0x0000 <= this <= 0xEFFF]

  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]               hci.CommandHeader          header
  $next [+1]                      UInt                       cis_count
    -- Total number of CISes to be created
    [requires: 0x01 <= this <= 0x1F]

  let single_cis_params_size = ConnectionInfo.$size_in_bytes
  let total_cis_params_size = cis_count*single_cis_params_size
  $next [+total_cis_params_size]  ConnectionInfo[cis_count]  cis_connection_info
    -- Connection handle information for the CIS(es) being created


struct LERemoveCIGCommand:
  -- 7.8.100 LE Remove CIG command (v5.2) (LE)
  -- HCI_LE_Remove_CIG
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+1]         UInt               cig_id
    -- Identifier of a CIG
    [requires: 0x00 <= this <= 0xEF]


struct LEAcceptCISRequestCommand:
  -- 7.8.101 LE Accept CIS Request command (v5.2) (LE)
  -- HCI_LE_Accept_CIS_Request
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         UInt               connection_handle
    -- Connection handle of the CIS
    [requires: 0x0000 <= this <= 0x0EFF]


struct LERejectCISRequestCommand:
  -- 7.8.102 LE Reject CIS Request command (v5.2) (LE)
  -- HCI_LE_Reject_CIS_Request
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         UInt               connection_handle
    -- Connection handle of the CIS
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+1]         hci.StatusCode     reason
    -- Reason the CIS request was rejected

# 7.8.103 LE Create BIG command
# 7.8.104 LE Create BIG Test command
# 7.8.105 LE Terminate BIG command
# 7.8.106 LE BIG Create Sync command
# 7.8.107 LE BIG Terminate Sync command


struct LERequestPeerSCACommand:
  -- 7.8.108 LE Request Peer SCA command
  -- HCI_LE_Request_Peer_SCA
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         UInt               connection_handle
    -- Connection handle of the ACL
    [requires: 0x0000 <= this <= 0xEFF]


struct LESetupISODataPathCommand:
  -- 7.8.109 LE Setup ISO Data Path command
  -- HCI_LE_Setup_ISO_Data_Path
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]                    hci.CommandHeader                   header
  $next [+2]                           UInt                                connection_handle
    -- Connection handle of the CIS or BIS
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+1]                           DataPathDirection                   data_path_direction
    -- Specifies the direction for which the data path is being configured

  $next [+1]                           UInt                                data_path_id
    -- Data transport path used (0x00 for HCI).
    [requires: 0x00 <= this <= 0xFE]

  let vcf_size = CodecId.$size_in_bytes
  $next [+vcf_size]                    CodecId                             codec_id
    -- Codec to be used

  $next [+3]                           UInt                                controller_delay
    -- Controller delay in microseconds (0s to 4s)
    [requires: 0x000000 <= this <= 0x3D0900]

  $next [+1]                           UInt                                codec_configuration_length
    -- Length of codec configuration

  $next [+codec_configuration_length]  UInt:8[codec_configuration_length]  codec_configuration
    -- Codec-specific configuration data


struct LERemoveISODataPathCommand:
  -- 7.8.110 LE Remove ISO Data Path command
  -- HCI_LE_Remove_ISO_Data_Path
  let hdr_size = hci.CommandHeader.$size_in_bytes
  0     [+hdr_size]  hci.CommandHeader  header
  $next [+2]         UInt               connection_handle
    -- Connection handle of the CIS or BIS
    [requires: 0x0000 <= this <= 0x0EFFF]

  $next [+1]  bits:
    0     [+1]       Flag               remove_input_data_path
    1     [+1]       Flag               remove_output_data_path

# 7.8.111 LE ISO Transmit Test command
# 7.8.112 LE ISO Receive Test command
# 7.8.113 LE ISO Read Test Counters command
# 7.8.114 LE ISO Test End command