aboutsummaryrefslogtreecommitdiff
path: root/pw_bluetooth/public/pw_bluetooth/hci_events.emb
blob: aa5f52931e22b8b65e8347c6b883983260343e7b (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
# 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 CoreSpecificationVersion:
  -- Bluetooth Core Specification version
  [maximum_bits: 8]
  V1_0B    = 0x00  # v1.0b
  V1_1     = 0x01  # v1.1
  V1_2     = 0x02  # v1.2
  V2_0_EDR = 0x03  # v2.0+EDR
  V2_1_EDR = 0x04  # v2.0+EDR
  V3_0_HS  = 0x05  # v3.0+HS
  V4_0     = 0x06  # v4.0
  V4_1     = 0x07  # v4.1
  V4_2     = 0x08  # v4.2
  V5_0     = 0x09  # v5.0
  V5_1     = 0x0A  # v5.1
  V5_2     = 0x0B  # v5.2
  V5_3     = 0x0C  # v5.3
  V5_4     = 0x0D  # v5.4


enum LinkType:
  [maximum_bits: 8]
  SCO  = 0x00
  ACL  = 0x01
  ESCO = 0x02


enum EncryptionStatus:
  OFF                                = 0x00
  ON_WITH_E0_FOR_BREDR_OR_AES_FOR_LE = 0x01
  ON_WITH_AES_FOR_BREDR              = 0x02


enum LEAdvertisingDataStatus:
  [maximum_bits: 2]
  COMPLETE             = 0b00
  INCOMPLETE           = 0b01
  INCOMPLETE_TRUNCATED = 0b10


enum LEDirectAddressType:
  -- Possible values that can be reported for the |direct_address_type| parameter in LE Advertising
  -- Report events.
  [maximum_bits: 8]
  PUBLIC                                = 0x00
    -- Public Device Address

  PRIVATE                               = 0x01
    -- Non-resolvable Private Address or Static Device Address

  RESOLVABLE_PRIVATE_OWN_ADDRESS_PUBLIC = 0x02
    -- Resolvable Private Address (resolved by Controller; Own_Address_Type was 0x00 or 0x02)

  RESOLVABLE_PRIVATE_OWN_ADDRESS_RANDOM = 0x03
    -- Resolvable Private Address (resolved by Controller; Own_Address_Type was 0x01 or 0x03)

  RESOLVABLE_PRIVATE                    = 0xFE
    -- Resolvable Private Address (Controller unable to resolve)


enum LEClockAccuracy:
  -- Possible values that can be reported for the |central_clock_accuracy| and
  -- |advertiser_clock_accuracy| parameters.
  [maximum_bits: 8]
  PPM_500 = 0x00
  PPM_250 = 0x01
  PPM_150 = 0x02
  PPM_100 = 0x03
  PPM_75  = 0x04
  PPM_50  = 0x05
  PPM_30  = 0x06
  PPM_20  = 0x07


enum KeyType:
  -- The key type used during pairing.
  [maximum_bits: 8]
  COMBINATION                           = 0x00
  DEBUG_COMBINATION                     = 0x03
  UNAUTHENTICATED_COMBINATION_FROM_P192 = 0x04
  AUTHENTICATED_COMBINATION_FROM_P192   = 0x05
  CHANGED_COMBINATION_KEY               = 0x06
  UNAUTHENTICATED_COMBINATION_FROM_P256 = 0x07
  AUTHENTICATED_COMBINATION_FROM_P256   = 0x08

# =========================== Field Types =================================


bits LmpFeatures(page: UInt:8):
  -- Bit mask of Link Manager Protocol features.
  [requires: page <= 2]
  if page == 0:
    0  [+1]  Flag  three_slot_packets
    1  [+1]  Flag  five_slot_packets
    2  [+1]  Flag  encryption
    3  [+1]  Flag  slot_offset
    4  [+1]  Flag  timing_accuracy
    5  [+1]  Flag  role_switch
    6  [+1]  Flag  hold_mode
    7  [+1]  Flag  sniff_mode
    # 8: previously used
    9  [+1]  Flag  power_control_requests
    10 [+1]  Flag  channel_quality_driven_data_rate
    11 [+1]  Flag  sco_link
    12 [+1]  Flag  hv2_packets
    13 [+1]  Flag  hv3_packets
    14 [+1]  Flag  mu_law_log_synchronous_data
    15 [+1]  Flag  a_law_log_synchronous_data
    16 [+1]  Flag  cvsd_synchronous_data
    17 [+1]  Flag  paging_parameter_negotiation
    18 [+1]  Flag  power_control
    19 [+1]  Flag  transparent_synchronous_data
    20 [+3]  UInt  flow_control_lag
    23 [+1]  Flag  broadcast_encryption
    # 24: reserved for future use
    25 [+1]  Flag  enhanced_data_rate_acl_2_mbs_mode
    26 [+1]  Flag  enhanced_data_rate_acl_3_mbs_mode
    27 [+1]  Flag  enhanced_inquiry_scan
    28 [+1]  Flag  interlaced_inquiry_scan
    29 [+1]  Flag  interlaced_page_scan
    30 [+1]  Flag  rssi_with_inquiry_results
    31 [+1]  Flag  extended_sco_link_ev3_packets
    32 [+1]  Flag  ev4_packets
    33 [+1]  Flag  ev5_packets
    # 34: reserved for future use
    35 [+1]  Flag  afh_capable_peripheral
    36 [+1]  Flag  afh_classification_peripheral
    37 [+1]  Flag  bredr_not_supported
    38 [+1]  Flag  le_supported_controller
    39 [+1]  Flag  three_slot_enhanced_data_rate_acl_packets
    40 [+1]  Flag  five_slot_enhanced_data_rate_acl_packets
    41 [+1]  Flag  sniff_subrating
    42 [+1]  Flag  pause_encryption
    43 [+1]  Flag  afh_capable_central
    44 [+1]  Flag  afh_classification_central
    45 [+1]  Flag  enhanced_data_rate_esco_2_mbs_mode
    46 [+1]  Flag  enhanced_data_rate_esco_3_mbs_mode
    47 [+1]  Flag  three_slot_enhanced_data_rate_esco_packets
    48 [+1]  Flag  extended_inquiry_response
    49 [+1]  Flag  simultaneous_le_and_bredr_to_same_device_capable_controller
    # 50: reserved for future use
    51 [+1]  Flag  secure_simple_pairing_controller_support
    52 [+1]  Flag  encapsulated_pdu
    53 [+1]  Flag  erroneous_data_reporting
    54 [+1]  Flag  non_flushable_packet_boundary_flag
    # 55: reserved for future use
    56 [+1]  Flag  hci_link_supervision_timeout_changed_event
    57 [+1]  Flag  variable_inquiry_tx_power_level
    58 [+1]  Flag  enhanced_power_control
    # 59-62: reserved for future use
    63 [+1]  Flag  extended_features

  if page == 1:
    0  [+1]  Flag  secure_simple_pairing_host_support
    1  [+1]  Flag  le_supported_host
    # 2: previously used
    3  [+1]  Flag  secure_connection_host_support

  if page == 2:
    0  [+1]  Flag  connectionless_peripheral_broadcast_transmitter_operation
    1  [+1]  Flag  connectionless_peripheral_broadcast_receiver_operation
    2  [+1]  Flag  synchronization_train
    3  [+1]  Flag  synchronization_scan
    4  [+1]  Flag  hci_inquiry_response_notification_event
    5  [+1]  Flag  generalized_interlaced_scan
    6  [+1]  Flag  coarse_clock_adjustment
    # 7: reserved for future use
    8  [+1]  Flag  secure_connections_controller_support
    9  [+1]  Flag  ping
    10 [+1]  Flag  slot_availability_mask
    11 [+1]  Flag  train_nudging


bits LEFeatureSet:
  0     [+1]  Flag  le_encryption
  $next [+1]  Flag  connection_parameters_request_procedure
  $next [+1]  Flag  extended_reject_indication
  $next [+1]  Flag  peripheral_initiated_features_exchange
  $next [+1]  Flag  le_ping
  $next [+1]  Flag  le_data_packet_length_extension
  $next [+1]  Flag  ll_privacy
  $next [+1]  Flag  extended_scanning_filter_policies
  $next [+1]  Flag  le_2m_phy
  $next [+1]  Flag  stable_modulation_index_transmitter
  $next [+1]  Flag  stable_modulation_index_receiver
  $next [+1]  Flag  le_coded_phy
  $next [+1]  Flag  le_extended_advertising
  $next [+1]  Flag  le_periodic_advertising
  $next [+1]  Flag  channel_selection_algorithm_2
  $next [+1]  Flag  le_power_class_1
  $next [+1]  Flag  minimum_number_of_used_channels_procedure
  $next [+1]  Flag  connection_cte_request
  $next [+1]  Flag  connection_cte_response
  $next [+1]  Flag  connectionless_cte_transmitter
  $next [+1]  Flag  connectionless_cte_receiver
  $next [+1]  Flag  antenna_switching_during_cte_transmission
  $next [+1]  Flag  antenna_switching_during_cte_reception
  $next [+1]  Flag  receiving_constant_tone_extensions
  $next [+1]  Flag  periodic_advertising_sync_transfer_sender
  $next [+1]  Flag  periodic_advertising_sync_transfer_recipient
  $next [+1]  Flag  sleep_clock_accuracy_updates
  $next [+1]  Flag  remote_public_key_validation
  $next [+1]  Flag  connected_isochronous_stream_central
  $next [+1]  Flag  connected_isochronous_stream_peripheral
  $next [+1]  Flag  isochronous_broadcaster
  $next [+1]  Flag  synchronized_receiver
  $next [+1]  Flag  connected_isochronous_stream_host_support
  $next [+1]  Flag  le_power_control_request_1
  $next [+1]  Flag  le_power_control_request_2
    -- Previous two bits shall always have the same value.

  $next [+1]  Flag  le_path_loss_monitoring
  $next [+1]  Flag  periodic_advertising_adi_support
  $next [+1]  Flag  connection_subrating
  $next [+1]  Flag  connection_subrating_host_support
  $next [+1]  Flag  channel_classification
  $next [+1]  Flag  advertising_coding_selection
  $next [+1]  Flag  advertising_coding_selection_host_support
  $next [+1]  Flag  reserved                                        # Bit 42 is skipped
  $next [+1]  Flag  periodic_advertising_with_responses_advertiser
  $next [+1]  Flag  periodic_advertising_with_responses_scanner


bits LEExtendedAdvertisingEventType:
  0     [+1]  Flag                     connectable
  $next [+1]  Flag                     scannable
  $next [+1]  Flag                     directed
  $next [+1]  Flag                     scan_response
  $next [+1]  Flag                     legacy
  $next [+2]  LEAdvertisingDataStatus  data_status


bits SupportedCommands(octet: UInt:8):
  [requires: octet <= 47]
  if octet == 0:
    0 [+1]  Flag  inquiry
    1 [+1]  Flag  inquiry_cancel
    2 [+1]  Flag  periodic_inquiry_mode
    3 [+1]  Flag  exit_periodic_inquiry_mode
    4 [+1]  Flag  create_connection
    5 [+1]  Flag  disconnect
    7 [+1]  Flag  create_connection_cancel

  if octet == 1:
    0 [+1]  Flag  accept_connection_request
    1 [+1]  Flag  reject_connection_request
    2 [+1]  Flag  link_key_request_reply
    3 [+1]  Flag  link_key_request_negative_reply
    4 [+1]  Flag  pin_code_request_reply
    5 [+1]  Flag  pin_code_request_negative_reply
    6 [+1]  Flag  change_connection_packet_type
    7 [+1]  Flag  authentication_requested

  if octet == 2:
    0 [+1]  Flag  set_connection_encryption
    1 [+1]  Flag  change_connection_link_key
    2 [+1]  Flag  link_key_selection
    3 [+1]  Flag  remote_name_request
    4 [+1]  Flag  remote_name_request_cancel
    5 [+1]  Flag  read_remote_supported_features
    6 [+1]  Flag  read_remote_extended_features
    7 [+1]  Flag  read_remote_version_information

  if octet == 3:
    0 [+1]  Flag  read_clock_offset
    1 [+1]  Flag  read_lmp_handle

  if octet == 4:
    1 [+1]  Flag  hold_mode
    2 [+1]  Flag  sniff_mode
    3 [+1]  Flag  exit_sniff_mode
    6 [+1]  Flag  qos_setup
    7 [+1]  Flag  role_discovery

  if octet == 5:
    0 [+1]  Flag  switch_role
    1 [+1]  Flag  read_link_policy_settings
    2 [+1]  Flag  write_link_policy_settings
    3 [+1]  Flag  read_default_link_policy_settings
    4 [+1]  Flag  write_default_link_policy_settings
    5 [+1]  Flag  flow_specification
    6 [+1]  Flag  set_event_mask
    7 [+1]  Flag  reset

  if octet == 6:
    0 [+1]  Flag  set_event_filter
    1 [+1]  Flag  flush
    2 [+1]  Flag  read_pin_type
    3 [+1]  Flag  write_pin_type
    5 [+1]  Flag  read_stored_link_key
    6 [+1]  Flag  write_stored_link_key
    7 [+1]  Flag  deleted_stored_link_key

  if octet == 7:
    0 [+1]  Flag  write_local_name
    1 [+1]  Flag  read_local_name
    2 [+1]  Flag  read_connection_attempt_timeout
    3 [+1]  Flag  write_connection_attempt_timeout
    4 [+1]  Flag  read_page_timeout
    5 [+1]  Flag  write_page_timeout
    6 [+1]  Flag  read_scan_enable
    7 [+1]  Flag  write_scan_enable

  if octet == 8:
    0 [+1]  Flag  read_page_scan_activity
    1 [+1]  Flag  write_page_scan_activity
    2 [+1]  Flag  read_inquiry_scan_activity
    3 [+1]  Flag  write_inquiry_scan_activity
    4 [+1]  Flag  read_authentication_enable
    5 [+1]  Flag  write_authentication_enable

  if octet == 9:
    0 [+1]  Flag  read_class_of_device
    1 [+1]  Flag  write_class_of_device
    2 [+1]  Flag  read_voice_setting
    3 [+1]  Flag  write_voice_setting
    4 [+1]  Flag  read_automatic_flush_timeout
    5 [+1]  Flag  write_automatic_flush_timeout
    6 [+1]  Flag  read_num_broadcast_retransmissions
    7 [+1]  Flag  write_num_broadcast_retransmissions

  if octet == 10:
    0 [+1]  Flag  read_hold_mode_activity
    1 [+1]  Flag  write_hold_mode_activity
    2 [+1]  Flag  read_transmit_power_level
    3 [+1]  Flag  read_synchronous_flow_control_enable
    4 [+1]  Flag  write_synchronous_flow_control_enable
    5 [+1]  Flag  set_controller_to_host_flow_control
    6 [+1]  Flag  host_buffer_size
    7 [+1]  Flag  host_number_of_completed_packets

  if octet == 11:
    0 [+1]  Flag  read_link_supervision_timeout
    1 [+1]  Flag  write_link_supervision_timeout
    2 [+1]  Flag  read_number_of_supported_iac
    3 [+1]  Flag  read_current_iaclap
    4 [+1]  Flag  write_current_iaclap

  if octet == 12:
    1 [+1]  Flag  set_afh_host_channel_classification
    4 [+1]  Flag  read_inquiry_scan_type
    5 [+1]  Flag  write_inquiry_scan_type
    6 [+1]  Flag  read_inquiry_mode
    7 [+1]  Flag  write_inquiry_mode

  if octet == 13:
    0 [+1]  Flag  read_page_scan_type
    1 [+1]  Flag  write_page_scan_type
    2 [+1]  Flag  read_afh_channel_assessment_mode
    3 [+1]  Flag  write_afh_channel_assessment_mode

  if octet == 14:
    3 [+1]  Flag  read_local_version_information
    5 [+1]  Flag  read_local_supported_features
    6 [+1]  Flag  read_local_extended_features
    7 [+1]  Flag  read_buffer_size

  if octet == 15:
    1 [+1]  Flag  read_bdaddr
    2 [+1]  Flag  read_failed_contact_counter
    3 [+1]  Flag  reset_failed_contact_c_ounter
    4 [+1]  Flag  read_link_quality
    5 [+1]  Flag  read_rssi
    6 [+1]  Flag  read_afh_channel_map
    7 [+1]  Flag  read_clock

  if octet == 16:
    0 [+1]  Flag  read_loopback_mode
    1 [+1]  Flag  write_loopback_mode
    2 [+1]  Flag  enable_device_under_test_mode
    3 [+1]  Flag  setup_synchronous_connection_request
    4 [+1]  Flag  accept_synchronous_connection_request
    5 [+1]  Flag  reject_synchronous_connection_request

  if octet == 17:
    0 [+1]  Flag  read_extended_inquiry_response
    1 [+1]  Flag  write_extended_inquiry_response
    2 [+1]  Flag  refresh_encryption_key
    4 [+1]  Flag  sniff_subrating
    5 [+1]  Flag  read_simple_pairing_mode
    6 [+1]  Flag  write_simple_pairing_mode
    7 [+1]  Flag  read_local_oob_data

  if octet == 18:
    0 [+1]  Flag  read_inquiry_response_transmit_power_level
    1 [+1]  Flag  write_inquiry_transmit_power_level
    2 [+1]  Flag  read_default_erroneous_data_reporting
    3 [+1]  Flag  write_default_erroneous_data_reporting
    7 [+1]  Flag  io_capability_request_reply

  if octet == 19:
    0 [+1]  Flag  user_confirmation_request_reply
    1 [+1]  Flag  user_confirmation_request_negative_reply
    2 [+1]  Flag  user_passkey_request_reply
    3 [+1]  Flag  user_passkey_request_negative_reply
    4 [+1]  Flag  remote_oob_data_request_reply
    5 [+1]  Flag  write_simple_pairing_debug_mode
    6 [+1]  Flag  enhanced_flush
    7 [+1]  Flag  remote_oob_data_request_negative_reply

  if octet == 20:
    2 [+1]  Flag  send_keypress_notification
    3 [+1]  Flag  io_capability_request_negative_reply
    4 [+1]  Flag  read_encryption_key_size

  if octet == 21:
    0 [+1]  Flag  create_physical_link
    1 [+1]  Flag  accept_physical_link
    2 [+1]  Flag  disconnect_physical_link
    3 [+1]  Flag  create_logical_link
    4 [+1]  Flag  accept_logical_link
    5 [+1]  Flag  disconnect_logical_link
    6 [+1]  Flag  logical_link_cancel
    7 [+1]  Flag  flow_spec_modify

  if octet == 22:
    0 [+1]  Flag  read_logical_link_accept_timeout
    1 [+1]  Flag  write_logical_link_accept_timeout
    2 [+1]  Flag  set_event_mask_page_2
    3 [+1]  Flag  read_location_data
    4 [+1]  Flag  write_location_data
    5 [+1]  Flag  read_local_amp_info
    6 [+1]  Flag  read_local_ampassoc
    7 [+1]  Flag  write_remote_ampassoc

  if octet == 23:
    0 [+1]  Flag  read_flow_control_mode
    1 [+1]  Flag  write_flow_control_mode
    2 [+1]  Flag  read_data_block_size

  if octet == 24:
    0 [+1]  Flag  read_enhanced_transmit_power_level
    2 [+1]  Flag  read_best_effort_flush_timeout
    3 [+1]  Flag  write_best_effort_flush_timeout
    4 [+1]  Flag  short_range_mode
    5 [+1]  Flag  read_le_host_supported
    6 [+1]  Flag  write_le_host_support

  if octet == 25:
    0 [+1]  Flag  le_set_event_mask
    1 [+1]  Flag  le_read_buffer_size_v1
    2 [+1]  Flag  le_read_local_supported_features
    4 [+1]  Flag  le_set_random_address
    5 [+1]  Flag  le_set_advertising_parameters
    6 [+1]  Flag  le_read_advertising_channel_tx_power
    7 [+1]  Flag  le_set_advertising_data

  if octet == 26:
    0 [+1]  Flag  le_set_scan_response_data
    1 [+1]  Flag  le_set_advertising_enable
    2 [+1]  Flag  le_set_scan_parameters
    3 [+1]  Flag  le_set_scan_enable
    4 [+1]  Flag  le_create_connection
    5 [+1]  Flag  le_create_connection_cancel
    6 [+1]  Flag  le_read_filter_accept_list_size
    7 [+1]  Flag  le_clear_filter_accept_list

  if octet == 27:
    0 [+1]  Flag  le_add_device_to_filter_accept_list
    1 [+1]  Flag  le_remove_device_from_filter_accept_list
    2 [+1]  Flag  le_connection_update
    3 [+1]  Flag  le_set_host_channel_classification
    4 [+1]  Flag  le_read_channel_map
    5 [+1]  Flag  le_read_remote_features
    6 [+1]  Flag  le_encrypt
    7 [+1]  Flag  le_rand

  if octet == 28:
    0 [+1]  Flag  le_start_encryption
    1 [+1]  Flag  le_long_term_key_request_reply
    2 [+1]  Flag  le_long_term_key_request_negative_reply
    3 [+1]  Flag  le_read_supported_states
    4 [+1]  Flag  le_receiver_test_v1
    5 [+1]  Flag  le_transmitter_test_v1
    6 [+1]  Flag  le_test_end

  if octet == 29:
    3 [+1]  Flag  enhanced_setup_synchronous_connection
    4 [+1]  Flag  enhanced_accept_synchronous_connection
    5 [+1]  Flag  read_local_supported_codecs
    6 [+1]  Flag  set_mws_channel_parameters
    7 [+1]  Flag  set_external_frame_configuration

  if octet == 30:
    0 [+1]  Flag  set_mws_signaling
    1 [+1]  Flag  set_mws_transport_layer
    2 [+1]  Flag  set_mws_scan_frequency_table
    3 [+1]  Flag  get_mws_transport_layer_configuration
    4 [+1]  Flag  set_mws_pattern_configuration
    5 [+1]  Flag  set_triggered_clock_capture
    6 [+1]  Flag  truncated_page
    7 [+1]  Flag  truncated_page_cancel

  if octet == 31:
    0 [+1]  Flag  set_connectionless_peripheral_broadcast
    1 [+1]  Flag  set_connectionless_peripheral_broadcast_receive
    2 [+1]  Flag  start_synchronization_train
    3 [+1]  Flag  receive_synchronization_train
    4 [+1]  Flag  set_reserved_ltaddr
    5 [+1]  Flag  delete_reserved_ltaddr
    6 [+1]  Flag  set_connectionless_peripheral_broadcast_data
    7 [+1]  Flag  read_synchronization_train_parameters

  if octet == 32:
    0 [+1]  Flag  write_synchronization_train_parameters
    1 [+1]  Flag  remote_oob_extended_data_request_reply
    2 [+1]  Flag  read_secure_connections_host_support
    3 [+1]  Flag  write_secure_connections_host_support
    4 [+1]  Flag  read_authenticated_payload_timeout
    5 [+1]  Flag  write_authenticated_payload_timeout
    6 [+1]  Flag  read_local_oob_extended_data
    7 [+1]  Flag  write_secure_connections_test_mode

  if octet == 33:
    0 [+1]  Flag  read_extended_page_timeout
    1 [+1]  Flag  write_extended_page_timeout
    2 [+1]  Flag  read_extended_inquiry_length
    3 [+1]  Flag  write_extended_inquiry_length
    4 [+1]  Flag  le_remote_connection_parameter_request_reply
    5 [+1]  Flag  le_remote_connection_parameter_request_negative_reply
    6 [+1]  Flag  le_set_data_length
    7 [+1]  Flag  le_read_suggested_default_data_length

  if octet == 34:
    0 [+1]  Flag  le_write_suggested_default_data_length
    1 [+1]  Flag  le_read_local_p256_public_key
    2 [+1]  Flag  le_generate_dh_key_v1
    3 [+1]  Flag  le_add_device_to_resolving_list
    4 [+1]  Flag  le_remove_device_from_resolving_list
    5 [+1]  Flag  le_clear_resolving_list
    6 [+1]  Flag  le_read_resolving_list_size
    7 [+1]  Flag  le_read_peer_resolvable_address

  if octet == 35:
    0 [+1]  Flag  le_read_local_resolvable_address
    1 [+1]  Flag  le_set_address_resolution_enable
    2 [+1]  Flag  le_set_resolvable_private_address_timeout
    3 [+1]  Flag  le_read_maximum_data_length
    4 [+1]  Flag  le_read_phy
    5 [+1]  Flag  le_set_default_phy
    6 [+1]  Flag  le_set_phy
    7 [+1]  Flag  le_enhanced_receiver_test_v2

  if octet == 36:
    0 [+1]  Flag  le_enhanced_transmitter_test_v2
    1 [+1]  Flag  le_set_advertising_set_random_address
    2 [+1]  Flag  le_set_extended_advertising_parameters
    3 [+1]  Flag  le_set_extended_advertising_data
    4 [+1]  Flag  le_set_extended_scan_response_data
    5 [+1]  Flag  le_set_extended_advertising_enable
    6 [+1]  Flag  le_read_maximum_advertising_data_length
    7 [+1]  Flag  le_read_number_of_supported_advertising_sets

  if octet == 37:
    0 [+1]  Flag  le_remove_advertising_set
    1 [+1]  Flag  le_clear_advertising_sets
    2 [+1]  Flag  le_set_periodic_advertising_parameters
    3 [+1]  Flag  le_set_periodic_advertising_data
    4 [+1]  Flag  le_set_periodic_advertising_enable
    5 [+1]  Flag  le_set_extended_scan_parameters
    6 [+1]  Flag  le_set_extended_scan_enable
    7 [+1]  Flag  le_extended_create_connection

  if octet == 38:
    0 [+1]  Flag  le_periodic_advertising_create_sync
    1 [+1]  Flag  le_periodic_advertising_create_sync_cancel
    2 [+1]  Flag  le_periodic_advertising_terminate_sync
    3 [+1]  Flag  le_add_device_to_periodic_advertiser_list
    4 [+1]  Flag  le_remove_device_from_periodic_advertiser_list
    5 [+1]  Flag  le_clear_periodic_advertiser_list
    6 [+1]  Flag  le_read_periodic_advertiser_list_size
    7 [+1]  Flag  le_read_transmit_power

  if octet == 39:
    0 [+1]  Flag  le_read_rf_path_compensation
    1 [+1]  Flag  le_write_rf_path_compensation
    2 [+1]  Flag  le_set_privacy_mode
    3 [+1]  Flag  le_receiver_test_v3
    4 [+1]  Flag  le_transmitter_test_v3
    5 [+1]  Flag  le_set_connectionless_cte_transmit_parameters
    6 [+1]  Flag  le_set_connectionless_cte_transmit_enable
    7 [+1]  Flag  le_set_connectionless_iq_sampling_enable

  if octet == 40:
    0 [+1]  Flag  le_set_connection_cte_receive_parameters
    1 [+1]  Flag  le_set_connection_cte_transmit_parameters
    2 [+1]  Flag  le_connection_cte_request_enable
    3 [+1]  Flag  le_connection_cte_response_enable
    4 [+1]  Flag  le_read_antenna_information
    5 [+1]  Flag  le_set_periodic_advertising_receive_enable
    6 [+1]  Flag  le_periodic_advertising_sync_transfer
    7 [+1]  Flag  le_periodic_advertising_set_info_transfer

  if octet == 41:
    0 [+1]  Flag  le_set_periodic_advertising_sync_transfer_parameters
    1 [+1]  Flag  le_set_default_periodic_advertising_sync_transfer_parameters
    2 [+1]  Flag  le_generate_dh_key_v3
    3 [+1]  Flag  read_local_simple_pairing_options
    4 [+1]  Flag  le_modify_sleep_clock_accuracy
    5 [+1]  Flag  le_read_buffer_size_v2
    6 [+1]  Flag  le_read_isotx_sync
    7 [+1]  Flag  le_set_cig_parameters

  if octet == 42:
    0 [+1]  Flag  le_set_cig_parameters_test
    1 [+1]  Flag  le_create_cis
    2 [+1]  Flag  le_remove_cig
    3 [+1]  Flag  le_accept_cis_request
    4 [+1]  Flag  le_reject_cis_request
    5 [+1]  Flag  le_create_big
    6 [+1]  Flag  le_create_big_test
    7 [+1]  Flag  le_terminate_big

  if octet == 43:
    0 [+1]  Flag  le_big_create_sync
    1 [+1]  Flag  le_big_terminate_sync
    2 [+1]  Flag  le_request_peer_sca
    3 [+1]  Flag  le_setup_iso_data_path
    4 [+1]  Flag  le_remove_iso_data_path
    5 [+1]  Flag  le_iso_transmit_test
    6 [+1]  Flag  le_iso_receive_test
    7 [+1]  Flag  le_iso_read_test_counters

  if octet == 44:
    0 [+1]  Flag  le_iso_test_end
    1 [+1]  Flag  le_set_host_feature
    2 [+1]  Flag  le_read_iso_link_quality
    3 [+1]  Flag  le_enhanced_read_transmit_power_level
    4 [+1]  Flag  le_read_remote_transmit_power_level
    5 [+1]  Flag  le_set_path_loss_reporting_parameters
    6 [+1]  Flag  le_set_path_loss_reporting_enable
    7 [+1]  Flag  le_set_transmit_power_reporting_enable

  if octet == 45:
    0 [+1]  Flag  le_transmitter_test_v4
    1 [+1]  Flag  set_ecosystem_base_interval
    2 [+1]  Flag  read_local_supported_codecs_v2
    3 [+1]  Flag  read_local_supported_codec_capabilities
    4 [+1]  Flag  read_local_supported_controller_delay
    5 [+1]  Flag  configure_data_path

  if octet == 46:
    0 [+1]  Flag  le_set_default_subrate
    1 [+1]  Flag  le_subrate_request
    2 [+1]  Flag  le_set_extended_advertising_parameters_v2
    5 [+1]  Flag  le_set_periodic_advertising_subevent_data
    6 [+1]  Flag  le_set_periodic_advertising_response_data
    7 [+1]  Flag  le_set_periodic_sync_subevent

  if octet == 47:
    0 [+1]  Flag  le_extended_create_connection_v2
    1 [+1]  Flag  le_set_periodic_advertising_parameters_v2


enum LEChannelSelectionAlgorithm:
  [maximum_bits: 8]
  ALGORITHM1 = 0x00
  ALGORITHM2 = 0x01

# ========================= HCI Event packets ===========================
# Core Spec v5.3 Vol 4, Part E, Section 7.7


struct InquiryCompleteEvent:
  -- 7.7.1 Inquiry Complete event (v1.1) (BR/EDR)
  -- HCI_Inquiry_Complete
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]  hci.EventHeader  header
  $next [+1]         hci.StatusCode   status


struct InquiryResult:
  0     [+hci.BdAddr.$size_in_bytes]  hci.BdAddr                  bd_addr
    -- BD_ADDR for a device which responded.

  $next [+1]                          hci.PageScanRepetitionMode  page_scan_repetition_mode
  $next [+2]                          UInt                        reserved
    -- Reserved for future use.

  $next [+3]                          hci.ClassOfDevice           class_of_device
    -- Class of Device for the device.

  $next [+2]                          hci.ClockOffset             clock_offset
    -- The lower 15 bits represent bits 16-2 of CLKNPeripheral-CLK.


struct InquiryResultEvent:
  -- 7.7.2 Inquiry Result event (v1.1) (BR/EDR)
  -- HCI_Inquiry_Result
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]                     hci.EventHeader  header
  $next [+1]                            UInt             num_responses
    -- Number of responses from the Inquiry.

  let response_size = InquiryResult.$size_in_bytes
  $next [+num_responses*response_size]  InquiryResult[]  responses


struct ConnectionCompleteEvent:
  -- 7.7.3 Connection Complete Event (v1.1) (BR/EDR)
  -- HCI_Connection_Complete
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]                   hci.EventHeader         header
  $next [+1]                          hci.StatusCode          status
  $next [+2]                          UInt                    connection_handle
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr              bd_addr
    -- The address of the connected device

  $next [+1]                          LinkType                link_type
  $next [+1]                          hci.GenericEnableParam  encryption_enabled


struct ConnectionRequestEvent:
  -- 7.7.4 Connection Request event (v1.1) (BR/EDR)
  -- HCI_Connection_Request
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]                   hci.EventHeader    header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr         bd_addr
    -- The address of the device that's requesting the connection.

  $next [+3]                          hci.ClassOfDevice  class_of_device
    -- The Class of Device of the device which requests the connection.

  $next [+1]                          LinkType           link_type


struct DisconnectionCompleteEvent:
  -- 7.7.5 Disconnection Complete event (v1.1) (BR/EDR & LE)
  -- HCI_Disconnection_Complete
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]  hci.EventHeader  header
  $next [+1]         hci.StatusCode   status
  $next [+2]         UInt             connection_handle
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+1]         hci.StatusCode   reason


struct AuthenticationCompleteEvent:
  -- 7.7.6 Authentication Complete event (v1.1) (BR/EDR)
  -- HCI_Authentication_Complete
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]  hci.EventHeader  header
  $next [+1]         hci.StatusCode   status
  $next [+2]         UInt             connection_handle
    [requires: 0x0000 <= this <= 0x0EFF]


struct RemoteNameRequestCompleteEvent:
  -- 7.7.7 Remote Name Request Complete event (v1.1) (BR/EDR)
  -- HCI_Remote_Name_Request_Complete
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]                   hci.EventHeader  header
  $next [+1]                          hci.StatusCode   status
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr       bd_addr
  $next [+248]                        UInt:8[248]      remote_name
    -- UTF-8 encoded friendly name. If the name is less than 248 characters, it
    -- is null terminated and the remaining bytes are not valid.


struct EncryptionChangeEventV1:
  -- 7.7.8 Encryption Change event (v1.1) (BR/EDR & LE)
  -- HCI_Encryption_Change [v1]
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]  hci.EventHeader   header
  $next [+1]         hci.StatusCode    status
  $next [+2]         UInt              connection_handle
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+1]         EncryptionStatus  encryption_enabled


struct ChangeConnectionLinkKeyCompleteEvent:
  -- 7.7.9 Change Connection Link Key Complete event (v1.1) (BR/EDR)
  -- HCI_Change_Connection_Link_Key_Complete
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]  hci.EventHeader  header
  $next [+1]         hci.StatusCode   status
  $next [+2]         UInt             connection_handle
    [requires: 0x0000 <= this <= 0x0EFF]

# 7.7.10 Link Key Type Changed event
# HCI_Link_Key_Type_Changed
# TODO: b/265052417 - Definition needs to be added


struct ReadRemoteSupportedFeaturesCompleteEvent:
  -- 7.7.11 Read Remote Supported Features Complete event (v1.1) (BR/EDR)
  -- HCI_Read_Remote_Supported_Features_Complete
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]  hci.EventHeader  header
  $next [+1]         hci.StatusCode   status
  $next [+2]         UInt             connection_handle
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+8]         LmpFeatures(0)   lmp_features
    -- Page 0 of the LMP features.


struct ReadRemoteVersionInfoCompleteEvent:
  -- 7.7.12 Read Remote Version Information Complete event (v1.1) (BR/EDR & LE)
  -- HCI_Read_Remote_Version_Information_Complete
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]  hci.EventHeader           header
  $next [+1]         hci.StatusCode            status
  $next [+2]         UInt                      connection_handle
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+1]         CoreSpecificationVersion  version
    -- Version of the Current LMP or Link Layer supported by the remote Controller.

  $next [+2]         UInt                      company_identifier
    -- Company identifier for the manufacturer of the remote Controller. Assigned by Bluetooth SIG.

  $next [+2]         UInt                      subversion
    -- Revision of the LMP or Link Layer implementation in the remote Controller. This value is vendor-specific.

# 7.7.13 QoS Setup Complete event
# HCI_QoS_Setup_Complete
# TODO: b/265052417 - Definition needs to be added


struct SimpleCommandCompleteEvent:
  -- 7.7.14 Command Complete event (status only)
  -- HCI_Command_Complete
  -- A Command Complete event where a StatusCode is the only return parameter.
  -- Also useful for generically getting the status of a larger command complete
  -- event.
  let hdr_size = hci.CommandCompleteEvent.$size_in_bytes
  0     [+hdr_size]  hci.CommandCompleteEvent  command_complete
  $next [+1]         hci.StatusCode            status


struct ReadLocalVersionInfoCommandCompleteEvent:
  -- 7.7.14 Command Complete event (7.4.1 Read Local Version Information command)

  let hdr_size = hci.CommandCompleteEvent.$size_in_bytes

  0     [+hdr_size]  hci.CommandCompleteEvent  command_complete

  $next [+1]         hci.StatusCode            status

  $next [+1]         CoreSpecificationVersion  hci_version
    -- Version of the HCI Specification supported by the Controller. See
    -- Assigned Numbers

  $next [+2]         UInt                      hci_subversion
    -- Revision of the HCI implementation in the Controller. This value is
    -- vendor-specific.

  $next [+1]         UInt                      lmp_version
    -- Version of the Current LMP supported by the Controller. See Assigned
    -- Numbers

  $next [+2]         UInt                      company_identifier
    -- Company identifier for the manufacturer of the Controller. See Assigned
    -- Numbers

  $next [+2]         UInt                      lmp_subversion
    -- Subversion of the Current LMP in the Controller. This value is
    -- vendor-specific.


struct ReadLocalSupportedCommandsCommandCompleteEvent:
  -- 7.7.14 Command Complete event (7.4.2 Read Local Supported Commands command)
  let hdr_size = hci.CommandCompleteEvent.$size_in_bytes
  0     [+hdr_size]  hci.CommandCompleteEvent  command_complete
  $next [+1]         hci.StatusCode            status
  $next [+1]         SupportedCommands(0)      supported_commands_0
  $next [+1]         SupportedCommands(1)      supported_commands_1
  $next [+1]         SupportedCommands(2)      supported_commands_2
  $next [+1]         SupportedCommands(3)      supported_commands_3
  $next [+1]         SupportedCommands(4)      supported_commands_4
  $next [+1]         SupportedCommands(5)      supported_commands_5
  $next [+1]         SupportedCommands(6)      supported_commands_6
  $next [+1]         SupportedCommands(7)      supported_commands_7
  $next [+1]         SupportedCommands(8)      supported_commands_8
  $next [+1]         SupportedCommands(9)      supported_commands_9
  $next [+1]         SupportedCommands(10)     supported_commands_10
  $next [+1]         SupportedCommands(11)     supported_commands_11
  $next [+1]         SupportedCommands(12)     supported_commands_12
  $next [+1]         SupportedCommands(13)     supported_commands_13
  $next [+1]         SupportedCommands(14)     supported_commands_14
  $next [+1]         SupportedCommands(15)     supported_commands_15
  $next [+1]         SupportedCommands(16)     supported_commands_16
  $next [+1]         SupportedCommands(17)     supported_commands_17
  $next [+1]         SupportedCommands(18)     supported_commands_18
  $next [+1]         SupportedCommands(19)     supported_commands_19
  $next [+1]         SupportedCommands(20)     supported_commands_20
  $next [+1]         SupportedCommands(21)     supported_commands_21
  $next [+1]         SupportedCommands(22)     supported_commands_22
  $next [+1]         SupportedCommands(23)     supported_commands_23
  $next [+1]         SupportedCommands(24)     supported_commands_24
  $next [+1]         SupportedCommands(25)     supported_commands_25
  $next [+1]         SupportedCommands(26)     supported_commands_26
  $next [+1]         SupportedCommands(27)     supported_commands_27
  $next [+1]         SupportedCommands(28)     supported_commands_28
  $next [+1]         SupportedCommands(29)     supported_commands_29
  $next [+1]         SupportedCommands(30)     supported_commands_30
  $next [+1]         SupportedCommands(31)     supported_commands_31
  $next [+1]         SupportedCommands(32)     supported_commands_32
  $next [+1]         SupportedCommands(33)     supported_commands_33
  $next [+1]         SupportedCommands(34)     supported_commands_34
  $next [+1]         SupportedCommands(35)     supported_commands_35
  $next [+1]         SupportedCommands(36)     supported_commands_36
  $next [+1]         SupportedCommands(37)     supported_commands_37
  $next [+1]         SupportedCommands(38)     supported_commands_38
  $next [+1]         SupportedCommands(39)     supported_commands_39
  $next [+1]         SupportedCommands(40)     supported_commands_40
  $next [+1]         SupportedCommands(41)     supported_commands_41
  $next [+1]         SupportedCommands(42)     supported_commands_42
  $next [+1]         SupportedCommands(43)     supported_commands_43
  $next [+1]         SupportedCommands(44)     supported_commands_44
  $next [+1]         SupportedCommands(45)     supported_commands_45
  $next [+1]         SupportedCommands(46)     supported_commands_46
  $next [+1]         SupportedCommands(47)     supported_commands_47


struct ReadBufferSizeCommandCompleteEvent:
  -- 7.7.14 Command Complete event (7.4.5 Read Buffer Size command)

  let hdr_size = hci.CommandCompleteEvent.$size_in_bytes

  0     [+hdr_size]  hci.CommandCompleteEvent  command_complete

  $next [+1]         hci.StatusCode            status

  $next [+2]         UInt                      acl_data_packet_length
    -- Maximum length (in octets) of the data portion of each HCI ACL Data
    -- packet that the Controller is able to accept.
    [requires: 0x0001 <= this <= 0xFFFF]

  $next [+1]         UInt                      synchronous_data_packet_length
    -- Maximum length (in octets) of the data portion of each HCI Synchronous
    -- Data packet that the Controller is able to accept.
    [requires: 0x01 <= this <= 0xFF]

  $next [+2]         UInt                      total_num_acl_data_packets
    -- Total number of HCI ACL Data packets that can be stored in the data
    -- buffers of the Controller.
    [requires: 0x0001 <= this <= 0xFFFF]

  $next [+2]         UInt                      total_num_synchronous_data_packets
    -- Total number of HCI Synchronous Data packets that can be stored in the
    -- data buffers of the Controller. A value of 0 indicates that the
    -- Controller does not support SCO or eSCO over HCI.


struct ReadBdAddrCommandCompleteEvent:
  -- 7.7.14 Command Complete event (7.4.6 Read BD_ADDR command)
  let hdr_size = hci.CommandCompleteEvent.$size_in_bytes
  0     [+hdr_size]                   hci.CommandCompleteEvent  command_complete
  $next [+1]                          hci.StatusCode            status
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr                bd_addr


struct LEReadLocalSupportedFeaturesCommandCompleteEvent:
  -- 7.7.14 Command Complete event (7.8.3 LE Read Local Supported Features command)
  let hdr_size = hci.CommandCompleteEvent.$size_in_bytes
  0     [+hdr_size]                      hci.CommandCompleteEvent  command_complete
  $next [+1]                             hci.StatusCode            status
  $next [+8]  bits:
    0     [+LEFeatureSet.$size_in_bits]  LEFeatureSet              le_features


struct CommandStatusEvent:
  -- 7.7.15 Command Status event
  -- HCI_Command_Status
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]  hci.EventHeader  header
  $next [+1]         hci.StatusCode   status
  $next [+1]         UInt             num_hci_command_packets
  $next [+2]         hci.OpCodeBits   command_opcode

# 7.7.16 Hardware Error event
# HCI_Hardware_Error
# TODO: b/265052417 - Definition needs to be added


# 7.7.17 Flush Occurred event
# HCI_Flush_Occurred
# TODO: b/265052417 - Definition needs to be added


struct RoleChangeEvent:
  -- 7.7.18 Role Change event (BR/EDR) (v1.1)
  -- HCI_Role_Change
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]                   hci.EventHeader     header
  $next [+1]                          hci.StatusCode      status
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr          bd_addr
    -- The address of the device for which a role change has completed.

  $next [+1]                          hci.ConnectionRole  role
    -- The new role for the specified address.

# 7.7.19 Number Of Completed Packets event
# HCI_Number_Of_Completed_Packets
# TODO: b/265052417 - Definition needs to be added


# 7.7.20 Mode Change event
# HCI_Mode_Change
# TODO: b/265052417 - Definition needs to be added


# 7.7.21 Return Link Keys event
# HCI_Return_Link_Keys
# TODO: b/265052417 - Definition needs to be added


# 7.7.22 PIN Code Request event
# HCI_PIN_Code_Request
# TODO: b/265052417 - Definition needs to be added


struct LinkKeyRequestEvent:
  -- 7.7.23 Link Key Request event (v1.1) (BR/EDR)
  -- HCI_Link_Key_Request
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]                   hci.EventHeader  header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr       bd_addr
    -- The address for the device that a host-stored link key is being requested.


struct LinkKeyNotificationEvent:
  -- 7.7.24 Link Key Notification event (v1.1) (BR/EDR)
  -- HCI_Link_Key_Notification
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]                    hci.EventHeader  header
  $next [+hci.BdAddr.$size_in_bytes]   hci.BdAddr       bd_addr
    -- The address for the device for which a new link key has been generated.

  $next [+hci.LinkKey.$size_in_bytes]  hci.LinkKey      link_key
    -- Link key for the associated address.

  $next [+1]                           KeyType          key_type
    -- Type of key used when pairing.

# 7.7.25 Loopback Command event
# HCI_Loopback_Command
# TODO: b/265052417 - Definition needs to be added


struct DataBufferOverflowEvent:
  -- 7.7.26 Data Buffer Overflow event (v1.1) (BR/EDR & LE)
  -- HCI_Data_Buffer_Overflow
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]  hci.EventHeader  header
  $next [+1]         LinkType         ll_type

# 7.7.27 Max Slots Change event
# HCI_Max_Slots_Change
# TODO: b/265052417 - Definition needs to be added


# 7.7.28 Read Clock Offset Complete event
# HCI_Read_Clock_Offset_Complete
# TODO: b/265052417 - Definition needs to be added


# 7.7.29 Connection Packet Type Changed event
# HCI_Connection_Packet_Type_Changed
# TODO: b/265052417 - Definition needs to be added


# 7.7.30 QoS Violation event
# HCI_QoS_Violation
# TODO: b/265052417 - Definition needs to be added


# 7.7.31 Page Scan Repetition Mode Change event
# HCI_Page_Scan_Repetition_Mode_Change
# TODO: b/265052417 - Definition needs to be added


# 7.7.32 Flow Specification Complete event
# HCI_Flow_Specification_Complete
# TODO: b/265052417 - Definition needs to be added


struct InquiryResultWithRssi:
  -- A single inquiry result (with RSSI).
  0     [+hci.BdAddr.$size_in_bytes]  hci.BdAddr                  bd_addr
    -- The address for the device which responded.

  $next [+1]                          hci.PageScanRepetitionMode  page_scan_repetition_mode
    -- The Page Scan Repetition Mode being used by the remote device.

  $next [+1]                          UInt                        reserved
  $next [+3]                          hci.ClassOfDevice           class_of_device
  $next [+2]                          hci.ClockOffset             clock_offset
    -- The lower 15 bits represent bits 16-2 of CLKNPeripheral-CLK. The most
    -- significant bit is reserved.

  $next [+1]                          Int                         rssi
    -- Units: dBm
    [requires: -127 <= this <= 20]


struct InquiryResultWithRssiEvent:
  -- 7.7.33 Inquiry Result with RSSI event (v1.2) (BR/EDR)
  -- HCI_Inquiry_Result_with_RSSI
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]                     hci.EventHeader          header
  $next [+1]                            UInt                     num_responses
    -- The number of responses included.

  let response_size = InquiryResultWithRssi.$size_in_bytes
  $next [+num_responses*response_size]  InquiryResultWithRssi[]  responses


struct ReadRemoteExtendedFeaturesCompleteEvent:
  -- 7.7.34 Read Remote Extended Features Complete event (v1.1) (BR/EDR)
  -- HCI_Read_Remote_Extended_Features_Complete
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]  hci.EventHeader           header
  $next [+1]         hci.StatusCode            status
  $next [+2]         UInt                      connection_handle
    -- Only the lower 12-bits are meaningful.
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+1]         UInt                      page_number
    -- 0x00: The normal LMP features as returned by HCI_Read_Remote_Supported_Features command.
    -- 0x01 to 0xFF: The page number of the features returned.

  $next [+1]         UInt                      max_page_number
    -- The highest features page number which contains non-zero bits for the remote device.

  $next [+8]         LmpFeatures(page_number)  lmp_features
    -- Bit map of requested page of LMP features.


struct SynchronousConnectionCompleteEvent:
  -- 7.7.35 Synchronous Connection Complete event (BR/EDR)
  -- HCI_Synchronous_Connection_Complete

  let hdr_size = hci.EventHeader.$size_in_bytes

  0     [+hdr_size]                   hci.EventHeader   header

  $next [+1]                          hci.StatusCode    status

  $next [+2]                          UInt              connection_handle
    -- A connection handle for the newly created SCO connection.
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr        bd_addr
    -- BD_ADDR of the other connected device forming the connection.

  $next [+1]                          LinkType          link_type

  $next [+1]                          UInt              transmission_interval
    -- Time between two consecutive eSCO instants measured in slots. Shall be
    -- zero for SCO links.

  $next [+1]                          UInt              retransmission_window
    -- The size of the retransmission window measured in slots. Shall be zero
    -- for SCO links.

  $next [+2]                          UInt              rx_packet_length
    -- Length in bytes of the eSCO payload in the receive direction. Shall be
    -- zero for SCO links.

  $next [+2]                          UInt              tx_packet_length
    -- Length in bytes of the eSCO payload in the transmit direction. Shall be
    -- zero for SCO links.

  $next [+1]                          hci.CodingFormat  air_mode

# 7.7.36 Synchronous Connection Changed event
# HCI_Synchronous_Connection_Changed
# TODO: b/265052417 - Definition needs to be added


# 7.7.37 Sniff Subrating event
# HCI_Sniff_Subrating
# TODO: b/265052417 - Definition needs to be added


struct ExtendedInquiryResultEvent:
  -- 7.7.38 Extended Inquiry Result event (v1.2) (BR/EDR)
  -- HCI_Extended_Inquiry_Result
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]                   hci.EventHeader             header
  $next [+1]                          UInt                        num_responses
    -- Number of responses from the inquiry. The HCI_Extended_Inquiry_Result
    -- event always contains a single response.
    [requires: this == 0x01]

  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr                  bd_addr
    -- BD_ADDR of the device that responded.

  $next [+1]                          hci.PageScanRepetitionMode  page_scan_repetition_mode
    -- The Page Scan Repetition Mode being used by the remote device.

  $next [+1]                          UInt                        reserved
  $next [+3]                          hci.ClassOfDevice           class_of_device
  $next [+2]                          hci.ClockOffset             clock_offset
    -- The lower 15 bits represent bits 16-2 of CLKNPeripheral-CLK.

  $next [+1]                          Int                         rssi
    -- Units: dBm
    [requires: -127 <= this <= 20]

  $next [+240]                        UInt:8[240]                 extended_inquiry_response
    -- Extended inquiey response data as defined in Vol 3, Part C, Sec 8


struct EncryptionKeyRefreshCompleteEvent:
  -- 7.7.39 Encryption Key Refresh Complete event (v2.1 + EDR) (BR/EDR & LE)
  -- HCI_Encryption_Key_Refresh_Complete
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]  hci.EventHeader  header
  $next [+1]         hci.StatusCode   status
  $next [+2]         UInt             connection_handle
    -- The connection_handle on which the encryption key was refreshed due to
    -- encryption being started or resumed.
    [requires: 0x0000 <= this <= 0x0EFF]


struct IoCapabilityRequestEvent:
  -- 7.7.40 IO Capability Request event (v2.1 + EDR) (BR/EDR)
  -- HCI_IO_Capability_Request
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]                   hci.EventHeader  header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr       bd_addr
    -- The address of the remote device involved in the Secure Simple Pairing
    -- process.


struct IoCapabilityResponseEvent:
  -- 7.7.41 IO Capability Response event (v2.1 + EDR) (BR/EDR)
  -- HCI_IO_Capability_Response
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]                   hci.EventHeader                 header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr                      bd_addr
    -- The address of the remote device which the IO capabilities apply

  $next [+1]                          hci.IoCapability                io_capability
    -- IO Capabilities of the device

  $next [+1]                          hci.GenericPresenceParam        oob_data_present
    -- Whether out-of-band authentication data is present.

  $next [+1]                          hci.AuthenticationRequirements  authentication_requirements


struct UserConfirmationRequestEvent:
  -- 7.7.42 User Confirmation Request event (v2.1 + EDR) (BR/EDR)
  -- HCI_User_Confirmation_Request
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]                   hci.EventHeader  header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr       bd_addr
    -- Address of the device involved in simple pairing process

  $next [+4]                          UInt             numeric_value
    -- Numeric value to be displayed.
    [requires: 0 <= this <= 999999]


struct UserPasskeyRequestEvent:
  -- 7.7.43 User Passkey Request event (v2.1 + EDR) (BR/EDR)
  -- HCI_User_Passkey_Request
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]                   hci.EventHeader  header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr       bd_addr
    -- Address of the device involved in simple pairing process

# 7.7.44 Remote OOB Data Request event
# HCI_Remote_OOB_Data_Request
# TODO: b/265052417 - Definition needs to be added


struct SimplePairingCompleteEvent:
  -- 7.7.45 Simple Pairing Complete event (v2.1 + EDR) (BR/EDR)
  -- HCI_Simple_Pairing_Complete
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]                   hci.EventHeader  header
  $next [+1]                          hci.StatusCode   status
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr       bd_addr
    -- Address of the device involved in simple pairing process

# 7.7.46 Link Supervision Timeout Changed event
# HCI_Link_Supervision_Timeout_Changed
# TODO: b/265052417 - Definition needs to be added


# 7.7.47 Enhanced Flush Complete event
# HCI_Enhanced_Flush_Complete
# TODO: b/265052417 - Definition needs to be added


struct UserPasskeyNotificationEvent:
  -- 7.7.48 User Passkey Notification event (v2.1 + EDR) (BR/EDR)
  -- HCI_User_Passkey_Notification
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]                   hci.EventHeader  header
  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr       bd_addr
    -- Address of the device involved in simple pairing process

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

# 7.7.49 Keypress Notification event
# HCI_Keypress_Notification
# TODO: b/265052417 - Definition needs to be added


# 7.7.50 Remote Host Supported Features Notification event
# HCI_Remote_Host_Supported_Features_Notification
# TODO: b/265052417 - Definition needs to be added


# 7.7.59 Number Of Completed Data Blocks event
# HCI_Number_Of_Completed_Data_Blocks
# TODO: b/265052417 - Definition needs to be added


struct LEMetaEvent:
  -- 7.7.65 LE Meta event
  let hdr_size = hci.EventHeader.$size_in_bytes
  0     [+hdr_size]  hci.EventHeader  header
  $next [+1]         UInt             subevent_code
    -- The event code for the LE subevent.


struct LEConnectionCompleteSubevent:
  -- 7.7.65.1 LE Connection Complete event
  -- HCI_LE_Connection_Complete

  0     [+LEMetaEvent.$size_in_bytes]  LEMetaEvent            le_meta_event

  $next [+1]                           hci.StatusCode         status

  $next [+2]                           UInt                   connection_handle
    -- Only the lower 12-bits are meaningful.
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+1]                           hci.ConnectionRole     role

  $next [+1]                           hci.LEPeerAddressType  peer_address_type

  $next [+hci.BdAddr.$size_in_bytes]   hci.BdAddr             peer_address
    -- Public Device Address or Random Device Address of the peer device.

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

  $next [+2]                           UInt                   peripheral_latency
    [requires: 0x0000 <= this <= 0x01F3]

  $next [+2]                           UInt                   supervision_timeout
    -- Time: N * 10 ms
    -- Range: 100 ms to 32 s
    [requires: 0x000A <= this <= 0x0C80]

  $next [+1]                           LEClockAccuracy        central_clock_accuracy
    -- Only valid for a peripheral. On a central, this parameter shall be set to 0x00.

# 7.7.65.2 LE Advertising Report event
# HCI_LE_Advertising_Report
# TODO: b/265052417 - Definition needs to be added


struct LEConnectionUpdateCompleteSubevent:
  -- 7.7.65.3 LE Connection Update Complete event
  -- HCI_LE_Connection_Update_Complete

  0     [+LEMetaEvent.$size_in_bytes]  LEMetaEvent     le_meta_event

  $next [+1]                           hci.StatusCode  status

  $next [+2]                           UInt            connection_handle
    -- Only the lower 12-bits are meaningful.
    [requires: 0x0000 <= this <= 0x0EFF]

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

  $next [+2]                           UInt            peripheral_latency
    [requires: 0x0000 <= this <= 0x01F3]

  $next [+2]                           UInt            supervision_timeout
    -- Time: N * 10 ms
    -- Range: 100 ms to 32 s
    [requires: 0x000A <= this <= 0x0C80]


struct LEReadRemoteFeaturesCompleteSubevent:
  -- 7.7.65.4 LE Read Remote Features Complete event
  -- HCI_LE_Read_Remote_Features_Complete
  0     [+LEMetaEvent.$size_in_bytes]    LEMetaEvent     le_meta_event
  $next [+1]                             hci.StatusCode  status
  $next [+2]                             UInt            connection_handle
    -- Only the lower 12-bits are meaningful.
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+8]  bits:
    0     [+LEFeatureSet.$size_in_bits]  LEFeatureSet    le_features


struct LELongTermKeyRequestSubevent:
  -- 7.7.65.5 LE Long Term Key Request event (v4.0) (LE)
  -- HCI_LE_Long_Term_Key_Request
  0     [+LEMetaEvent.$size_in_bytes]  LEMetaEvent  le_meta_event
  $next [+2]                           UInt         connection_handle
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+8]                           UInt         random_number
  $next [+2]                           UInt         encrypted_diversifier

# 7.7.65.6 LE Remote Connection Parameter Request event
# HCI_LE_Remote_Connection_Parameter_Request
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.7 LE Data Length Change event
# HCI_LE_Data_Length_Change
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.8 LE Read Local P-256 Public Key Complete event
# HCI_LE_Read_Local_P-256_Public_Key_Complete
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.9 LE Generate DHKey Complete event
# HCI_LE_Generate_DHKey_Complete
# TODO: b/265052417 - Definition needs to be added


struct LEEnhancedConnectionCompleteSubeventV1:
  -- 7.7.65.10 LE Enhanced Connection Complete event
  -- HCI_LE_Enhanced_Connection_Complete
  0     [+LEMetaEvent.$size_in_bytes]  LEMetaEvent         le_meta_event
  $next [+1]                           hci.StatusCode      status
  $next [+2]                           UInt                connection_handle
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+1]                           hci.ConnectionRole  role
  $next [+1]                           hci.LEAddressType   peer_address_type
  $next [+hci.BdAddr.$size_in_bytes]   hci.BdAddr          peer_address
  $next [+hci.BdAddr.$size_in_bytes]   hci.BdAddr          local_resolvable_private_address
  $next [+hci.BdAddr.$size_in_bytes]   hci.BdAddr          peer_resolvable_private_address
  $next [+2]                           UInt                connection_interval
    -- Time: N * 1.25 ms
    -- Range: 7.5 ms to 4 s
    [requires: 0x0006 <= this <= 0x0C80]

  $next [+2]                           UInt                peripheral_latency
    [requires: 0x0000 <= this <= 0x01F3]

  $next [+2]                           UInt                supervision_timeout
    -- Time: N * 10 ms
    -- Range: 100 ms to 32 s
    [requires: 0x000A <= this <= 0x0C80]

  $next [+1]                           LEClockAccuracy     central_clock_accuracy
    -- Only valid for a peripheral. On a central, this parameter shall be set to 0x00.

# 7.7.65.10 LE Enhanced Connection Complete event
# HCI_LE_Enhanced_Connection_Complete
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.11 LE Directed Advertising Report event
# HCI_LE_Directed_Advertising_Report
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.12 LE PHY Update Complete event
# HCI_LE_PHY_Update_Complete
# TODO: b/265052417 - Definition needs to be added


struct LEExtendedAdvertisingReportData:
  0     [+2]  bits:

    0     [+LEExtendedAdvertisingEventType.$size_in_bits]  LEExtendedAdvertisingEventType  event_type

  $next [+1]                                               hci.LEExtendedAddressType       address_type
    -- Address type of the advertiser.

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

  $next [+1]                                               hci.LEPrimaryAdvertisingPHY     primary_phy
    -- Indicates the PHY used to send the advertising PDU on the primary advertising
    -- channel. Legacy PDUs always use LE_1M. NONE, LE_2M, and LE_CODED_S2 are excluded.

  $next [+1]                                               hci.LESecondaryAdvertisingPHY   secondary_phy
    -- Indicates the PHY used to send the advertising PDU(s), if any, on the secondary
    -- advertising channel. A value of NONE means that no packets were received on the
    -- secondary advertising channel.

  $next [+1]                                               UInt                            advertising_sid
    -- Value of the Advertising SID subfield in the ADI field of the PDU. A value of
    -- 0xFF means no ADI field provided.
    [requires: 0x00 <= this <= 0x0F || this == 0xFF]

  $next [+1]                                               UInt                            tx_power
    -- Units: dBm. A value of 0x7F means Tx Power information is not available.
    [requires: -127 <= this <= 20 || this == 0x7F]

  $next [+1]                                               Int                             rssi
    -- Units: dBm. A value of 0x7F means RSSI is not available.
    [requires: -127 <= this <= 20 || this == 0x7F]

  $next [+2]                                               UInt                            periodic_advertising_interval
    -- 0x0000: No periodic advertising.
    -- 0xXXXX:
    --   Time = N * 1.25 ms
    --   Time Range: 7.5 ms to 81,918.75 s
    [requires: 0x0006 <= this <= 0xFFFF || this == 0x0000]

  $next [+1]                                               LEDirectAddressType             direct_address_type

  $next [+hci.BdAddr.$size_in_bytes]                       hci.BdAddr                      direct_address
    -- TargetA field in the advertisement or either Public Identity Address or Random (static)
    -- Identity Address of the target device.

  $next [+1]                                               UInt                            data_length
    -- Length of the |data| field.

  $next [+data_length]                                     UInt:8[data_length]             data
    -- |data_length| octets of advertising or scan response data formatted as defined in
    -- [Vol 3] Part C, Section 11. Note: Each element of this array has a variable length.


struct LEExtendedAdvertisingReportSubevent(reports_size: UInt:8):
  -- 7.7.65.13 LE Extended Advertising Report event (v5.0) (LE)
  -- HCI_LE_Extended_Advertising_Report
  0     [+LEMetaEvent.$size_in_bytes]  LEMetaEvent           le_meta_event
  $next [+1]                           UInt                  num_reports
    -- Number of separate reports in the event.
    [requires: 0x01 <= this <= 0x0A]

  $next [+reports_size]                UInt:8[reports_size]  reports
    -- Since each report has a variable length, they are stored in a UInt:8 array.

# 7.7.65.14 LE Periodic Advertising Sync Established event
# HCI_LE_Periodic_Advertising_Sync_Established
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.15 LE Periodic Advertising Report event
# HCI_LE_Periodic_Advertising_Report
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.16 LE Periodic Advertising Sync Lost event
# HCI_LE_Periodic_Advertising_Sync_Lost
# TODO: b/265052417 - Definition needs to be added


struct LEScanTimeoutSubevent:
  -- 7.7.65.17 LE Scan Timeout event
  -- HCI_LE_Scan_Timeout
  0 [+LEMetaEvent.$size_in_bytes]  LEMetaEvent  le_meta_event

# 7.7.65.18 LE Advertising Set Terminated event
# HCI_LE_Advertising_Set_Terminated
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.19 LE Scan Request Received event
# HCI_LE_Scan_Request_Received
# TODO: b/265052417 - Definition needs to be added


struct LEChannelSelectionAlgorithmSubevent:
  -- 7.7.65.20 LE Channel Selection Algorithm event
  -- HCI_LE_Channel_Selection_Algorithm
  0     [+LEMetaEvent.$size_in_bytes]  LEMetaEvent                  le_meta_event
  $next [+2]                           UInt                         connection_handle
    -- Only the lower 12-bits are meaningful.
    [requires: 0x0000 <= this <= 0x0EFF]

  $next [+1]                           LEChannelSelectionAlgorithm  channel_selection_algorithm

# 7.7.65.21 LE Connectionless IQ Report event
# HCI_LE_Connectionless_IQ_Report
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.22 LE Connection IQ Report event
# HCI_LE_Connection_IQ_Report
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.23 LE CTE Request Failed event
# HCI_LE_CTE_Request_Failed
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.24 LE Periodic Advertising Sync Transfer Received event
# HCI_LE_Periodic_Advertising_Sync_Transfer_Received
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.25 LE CIS Established event
# HCI_LE_CIS_Established
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.26 LE CIS Request event
# HCI_LE_CIS_Request
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.27 LE Create BIG Complete event
# HCI_LE_Create_BIG_Complete
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.28 LE Terminate BIG Complete event
# HCI_LE_Terminate_BIG_Complete
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.29 LE BIG Sync Established event
# HCI_LE_BIG_Sync_Established
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.30 LE BIG Sync Lost event
# HCI_LE_BIG_Sync_Lost
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.31 LE Request Peer SCA Complete event
# HCI_LE_Request_Peer_SCA_Complete
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.32 LE Path Loss Threshold event
# HCI_LE_Path_Loss_Threshold
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.33 LE Transmit Power Reporting event
# HCI_LE_Transmit_Power_Reporting
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.34 LE BIGInfo Advertising Report event
# HCI_LE_BIGInfo_Advertising_Report
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.35 LE Subrate Change event
# HCI_LE_Subrate_Change
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.36 LE Periodic Advertising Subevent Data Request event
# HCI_LE_Periodic_Advertising_Subevent_Data_Request
# TODO: b/265052417 - Definition needs to be added


# 7.7.65.37 LE Periodic Advertising Response Report event
# HCI_LE_Periodic_Advertising_Response_Report
# TODO: b/265052417 - Definition needs to be added


# 7.7.66 Triggered Clock Capture event
# HCI_Triggered_Clock_Capture
# TODO: b/265052417 - Definition needs to be added


# 7.7.67 Synchronization Train Complete event
# HCI_Synchronization_Train_Complete
# TODO: b/265052417 - Definition needs to be added


# 7.7.68 Synchronization Train Received event
# HCI_Synchronization_Train_Received
# TODO: b/265052417 - Definition needs to be added


# 7.7.69 Connectionless Peripheral Broadcast Receive event
# HCI_Connectionless_Peripheral_Broadcast_Receive
# TODO: b/265052417 - Definition needs to be added


# 7.7.70 Connectionless Peripheral Broadcast Timeout event
# HCI_Connectionless_Peripheral_Broadcast_Timeout
# TODO: b/265052417 - Definition needs to be added


# 7.7.71 Truncated Page Complete event
# HCI_Truncated_Page_Complete
# TODO: b/265052417 - Definition needs to be added


# 7.7.72 Peripheral Page Response Timeout event
# HCI_Peripheral_Page_Response_Timeout
# TODO: b/265052417 - Definition needs to be added


# 7.7.73 Connectionless Peripheral Broadcast Channel Map Change event
# HCI_Connectionless_Peripheral_Broadcast_Channel_Map_Change
# TODO: b/265052417 - Definition needs to be added


# 7.7.74 Inquiry Response Notification event
# HCI_Inquiry_Response_Notification
# TODO: b/265052417 - Definition needs to be added


# 7.7.75 Authenticated Payload Timeout Expired event
# HCI_Authenticated_Payload_Timeout_Expired
# TODO: b/265052417 - Definition needs to be added


# 7.7.76 SAM Status Change event
# HCI_SAM_Status_Change
# TODO: b/265052417 - Definition needs to be added