• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2023 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15# This file contains Emboss definitions for Host Controller Interface packets
16# and types found in the Bluetooth Core Specification. The Emboss compiler is
17# used to generate a C++ header from this file.
18
19import "pw_bluetooth/hci_common.emb" as hci
20
21[$default byte_order: "LittleEndian"]
22[(cpp) namespace: "pw::bluetooth::emboss"]
23# =========================== Constants =================================
24
25
26enum CoreSpecificationVersion:
27  -- Bluetooth Core Specification version
28  [maximum_bits: 8]
29  V1_0B    = 0x00  # v1.0b
30  V1_1     = 0x01  # v1.1
31  V1_2     = 0x02  # v1.2
32  V2_0_EDR = 0x03  # v2.0+EDR
33  V2_1_EDR = 0x04  # v2.0+EDR
34  V3_0_HS  = 0x05  # v3.0+HS
35  V4_0     = 0x06  # v4.0
36  V4_1     = 0x07  # v4.1
37  V4_2     = 0x08  # v4.2
38  V5_0     = 0x09  # v5.0
39  V5_1     = 0x0A  # v5.1
40  V5_2     = 0x0B  # v5.2
41  V5_3     = 0x0C  # v5.3
42  V5_4     = 0x0D  # v5.4
43
44
45enum LinkType:
46  [maximum_bits: 8]
47  SCO  = 0x00
48  ACL  = 0x01
49  ESCO = 0x02
50
51
52enum EncryptionStatus:
53  OFF                                = 0x00
54  ON_WITH_E0_FOR_BREDR_OR_AES_FOR_LE = 0x01
55  ON_WITH_AES_FOR_BREDR              = 0x02
56
57
58enum LEAdvertisingDataStatus:
59  [maximum_bits: 2]
60  COMPLETE             = 0b00
61  INCOMPLETE           = 0b01
62  INCOMPLETE_TRUNCATED = 0b10
63
64
65enum LEDirectAddressType:
66  -- Possible values that can be reported for the |direct_address_type| parameter in LE Advertising
67  -- Report events.
68  [maximum_bits: 8]
69  PUBLIC                                = 0x00
70    -- Public Device Address
71
72  PRIVATE                               = 0x01
73    -- Non-resolvable Private Address or Static Device Address
74
75  RESOLVABLE_PRIVATE_OWN_ADDRESS_PUBLIC = 0x02
76    -- Resolvable Private Address (resolved by Controller; Own_Address_Type was 0x00 or 0x02)
77
78  RESOLVABLE_PRIVATE_OWN_ADDRESS_RANDOM = 0x03
79    -- Resolvable Private Address (resolved by Controller; Own_Address_Type was 0x01 or 0x03)
80
81  RESOLVABLE_PRIVATE                    = 0xFE
82    -- Resolvable Private Address (Controller unable to resolve)
83
84
85enum LEClockAccuracy:
86  -- Possible values that can be reported for the |central_clock_accuracy| and
87  -- |advertiser_clock_accuracy| parameters.
88  [maximum_bits: 8]
89  PPM_500 = 0x00
90  PPM_250 = 0x01
91  PPM_150 = 0x02
92  PPM_100 = 0x03
93  PPM_75  = 0x04
94  PPM_50  = 0x05
95  PPM_30  = 0x06
96  PPM_20  = 0x07
97
98
99enum KeyType:
100  -- The key type used during pairing.
101  [maximum_bits: 8]
102  COMBINATION                           = 0x00
103  DEBUG_COMBINATION                     = 0x03
104  UNAUTHENTICATED_COMBINATION_FROM_P192 = 0x04
105  AUTHENTICATED_COMBINATION_FROM_P192   = 0x05
106  CHANGED_COMBINATION_KEY               = 0x06
107  UNAUTHENTICATED_COMBINATION_FROM_P256 = 0x07
108  AUTHENTICATED_COMBINATION_FROM_P256   = 0x08
109
110
111enum IsoPhyType:
112  -- The PHY used for transmitting ISO frames
113  [maximum_bits: 8]
114  LE_1M    = 0x01
115  LE_2M    = 0x02
116  LE_CODED = 0x03
117
118# =========================== Field Types =================================
119
120
121bits LmpFeatures(page: UInt:8):
122  -- Bit mask of Link Manager Protocol features.
123  [requires: page <= 2]
124  if page == 0:
125    0  [+1]  Flag  three_slot_packets
126    1  [+1]  Flag  five_slot_packets
127    2  [+1]  Flag  encryption
128    3  [+1]  Flag  slot_offset
129    4  [+1]  Flag  timing_accuracy
130    5  [+1]  Flag  role_switch
131    6  [+1]  Flag  hold_mode
132    7  [+1]  Flag  sniff_mode
133    # 8: previously used
134    9  [+1]  Flag  power_control_requests
135    10 [+1]  Flag  channel_quality_driven_data_rate
136    11 [+1]  Flag  sco_link
137    12 [+1]  Flag  hv2_packets
138    13 [+1]  Flag  hv3_packets
139    14 [+1]  Flag  mu_law_log_synchronous_data
140    15 [+1]  Flag  a_law_log_synchronous_data
141    16 [+1]  Flag  cvsd_synchronous_data
142    17 [+1]  Flag  paging_parameter_negotiation
143    18 [+1]  Flag  power_control
144    19 [+1]  Flag  transparent_synchronous_data
145    20 [+3]  UInt  flow_control_lag
146    23 [+1]  Flag  broadcast_encryption
147    # 24: reserved for future use
148    25 [+1]  Flag  enhanced_data_rate_acl_2_mbs_mode
149    26 [+1]  Flag  enhanced_data_rate_acl_3_mbs_mode
150    27 [+1]  Flag  enhanced_inquiry_scan
151    28 [+1]  Flag  interlaced_inquiry_scan
152    29 [+1]  Flag  interlaced_page_scan
153    30 [+1]  Flag  rssi_with_inquiry_results
154    31 [+1]  Flag  extended_sco_link_ev3_packets
155    32 [+1]  Flag  ev4_packets
156    33 [+1]  Flag  ev5_packets
157    # 34: reserved for future use
158    35 [+1]  Flag  afh_capable_peripheral
159    36 [+1]  Flag  afh_classification_peripheral
160    37 [+1]  Flag  bredr_not_supported
161    38 [+1]  Flag  le_supported_controller
162    39 [+1]  Flag  three_slot_enhanced_data_rate_acl_packets
163    40 [+1]  Flag  five_slot_enhanced_data_rate_acl_packets
164    41 [+1]  Flag  sniff_subrating
165    42 [+1]  Flag  pause_encryption
166    43 [+1]  Flag  afh_capable_central
167    44 [+1]  Flag  afh_classification_central
168    45 [+1]  Flag  enhanced_data_rate_esco_2_mbs_mode
169    46 [+1]  Flag  enhanced_data_rate_esco_3_mbs_mode
170    47 [+1]  Flag  three_slot_enhanced_data_rate_esco_packets
171    48 [+1]  Flag  extended_inquiry_response
172    49 [+1]  Flag  simultaneous_le_and_bredr_to_same_device_capable_controller
173    # 50: reserved for future use
174    51 [+1]  Flag  secure_simple_pairing_controller_support
175    52 [+1]  Flag  encapsulated_pdu
176    53 [+1]  Flag  erroneous_data_reporting
177    54 [+1]  Flag  non_flushable_packet_boundary_flag
178    # 55: reserved for future use
179    56 [+1]  Flag  hci_link_supervision_timeout_changed_event
180    57 [+1]  Flag  variable_inquiry_tx_power_level
181    58 [+1]  Flag  enhanced_power_control
182    # 59-62: reserved for future use
183    63 [+1]  Flag  extended_features
184
185  if page == 1:
186    0  [+1]  Flag  secure_simple_pairing_host_support
187    1  [+1]  Flag  le_supported_host
188    # 2: previously used
189    3  [+1]  Flag  secure_connection_host_support
190
191  if page == 2:
192    0  [+1]  Flag  connectionless_peripheral_broadcast_transmitter_operation
193    1  [+1]  Flag  connectionless_peripheral_broadcast_receiver_operation
194    2  [+1]  Flag  synchronization_train
195    3  [+1]  Flag  synchronization_scan
196    4  [+1]  Flag  hci_inquiry_response_notification_event
197    5  [+1]  Flag  generalized_interlaced_scan
198    6  [+1]  Flag  coarse_clock_adjustment
199    # 7: reserved for future use
200    8  [+1]  Flag  secure_connections_controller_support
201    9  [+1]  Flag  ping
202    10 [+1]  Flag  slot_availability_mask
203    11 [+1]  Flag  train_nudging
204
205
206bits LEFeatureSet:
207  0     [+1]  Flag  le_encryption
208  $next [+1]  Flag  connection_parameters_request_procedure
209  $next [+1]  Flag  extended_reject_indication
210  $next [+1]  Flag  peripheral_initiated_features_exchange
211  $next [+1]  Flag  le_ping
212  $next [+1]  Flag  le_data_packet_length_extension
213  $next [+1]  Flag  ll_privacy
214  $next [+1]  Flag  extended_scanning_filter_policies
215  $next [+1]  Flag  le_2m_phy
216  $next [+1]  Flag  stable_modulation_index_transmitter
217  $next [+1]  Flag  stable_modulation_index_receiver
218  $next [+1]  Flag  le_coded_phy
219  $next [+1]  Flag  le_extended_advertising
220  $next [+1]  Flag  le_periodic_advertising
221  $next [+1]  Flag  channel_selection_algorithm_2
222  $next [+1]  Flag  le_power_class_1
223  $next [+1]  Flag  minimum_number_of_used_channels_procedure
224  $next [+1]  Flag  connection_cte_request
225  $next [+1]  Flag  connection_cte_response
226  $next [+1]  Flag  connectionless_cte_transmitter
227  $next [+1]  Flag  connectionless_cte_receiver
228  $next [+1]  Flag  antenna_switching_during_cte_transmission
229  $next [+1]  Flag  antenna_switching_during_cte_reception
230  $next [+1]  Flag  receiving_constant_tone_extensions
231  $next [+1]  Flag  periodic_advertising_sync_transfer_sender
232  $next [+1]  Flag  periodic_advertising_sync_transfer_recipient
233  $next [+1]  Flag  sleep_clock_accuracy_updates
234  $next [+1]  Flag  remote_public_key_validation
235  $next [+1]  Flag  connected_isochronous_stream_central
236  $next [+1]  Flag  connected_isochronous_stream_peripheral
237  $next [+1]  Flag  isochronous_broadcaster
238  $next [+1]  Flag  synchronized_receiver
239  $next [+1]  Flag  connected_isochronous_stream_host_support
240  $next [+1]  Flag  le_power_control_request_1
241  $next [+1]  Flag  le_power_control_request_2
242    -- Previous two bits shall always have the same value.
243
244  $next [+1]  Flag  le_path_loss_monitoring
245  $next [+1]  Flag  periodic_advertising_adi_support
246  $next [+1]  Flag  connection_subrating
247  $next [+1]  Flag  connection_subrating_host_support
248  $next [+1]  Flag  channel_classification
249  $next [+1]  Flag  advertising_coding_selection
250  $next [+1]  Flag  advertising_coding_selection_host_support
251  $next [+1]  Flag  reserved                                        # Bit 42 is skipped
252  $next [+1]  Flag  periodic_advertising_with_responses_advertiser
253  $next [+1]  Flag  periodic_advertising_with_responses_scanner
254
255
256enum LEAdvertisingEventType:
257  [maximum_bits: 8]
258  CONNECTABLE_AND_SCANNABLE_UNDIRECTED = 0x00
259    -- ADV_IND
260
261  CONNECTABLE_DIRECTED                 = 0x01
262    -- ADV_DIRECT_IND
263
264  SCANNABLE_UNDIRECTED                 = 0x02
265    --  ADV_SCAN_IND
266
267  NON_CONNECTABLE_UNDIRECTED           = 0x03
268    -- ADV_NONCONN_IND
269
270  SCAN_RESPONSE                        = 0x04
271    -- SCAN_RSP
272
273
274bits LEExtendedAdvertisingEventType:
275  0     [+1]  Flag                     connectable
276  $next [+1]  Flag                     scannable
277  $next [+1]  Flag                     directed
278  $next [+1]  Flag                     scan_response
279  $next [+1]  Flag                     legacy
280  $next [+2]  LEAdvertisingDataStatus  data_status
281
282
283bits SupportedCommands(octet: UInt:8):
284  [requires: octet <= 47]
285  if octet == 0:
286    0 [+1]  Flag  inquiry
287    1 [+1]  Flag  inquiry_cancel
288    2 [+1]  Flag  periodic_inquiry_mode
289    3 [+1]  Flag  exit_periodic_inquiry_mode
290    4 [+1]  Flag  create_connection
291    5 [+1]  Flag  disconnect
292    7 [+1]  Flag  create_connection_cancel
293
294  if octet == 1:
295    0 [+1]  Flag  accept_connection_request
296    1 [+1]  Flag  reject_connection_request
297    2 [+1]  Flag  link_key_request_reply
298    3 [+1]  Flag  link_key_request_negative_reply
299    4 [+1]  Flag  pin_code_request_reply
300    5 [+1]  Flag  pin_code_request_negative_reply
301    6 [+1]  Flag  change_connection_packet_type
302    7 [+1]  Flag  authentication_requested
303
304  if octet == 2:
305    0 [+1]  Flag  set_connection_encryption
306    1 [+1]  Flag  change_connection_link_key
307    2 [+1]  Flag  link_key_selection
308    3 [+1]  Flag  remote_name_request
309    4 [+1]  Flag  remote_name_request_cancel
310    5 [+1]  Flag  read_remote_supported_features
311    6 [+1]  Flag  read_remote_extended_features
312    7 [+1]  Flag  read_remote_version_information
313
314  if octet == 3:
315    0 [+1]  Flag  read_clock_offset
316    1 [+1]  Flag  read_lmp_handle
317
318  if octet == 4:
319    1 [+1]  Flag  hold_mode
320    2 [+1]  Flag  sniff_mode
321    3 [+1]  Flag  exit_sniff_mode
322    6 [+1]  Flag  qos_setup
323    7 [+1]  Flag  role_discovery
324
325  if octet == 5:
326    0 [+1]  Flag  switch_role
327    1 [+1]  Flag  read_link_policy_settings
328    2 [+1]  Flag  write_link_policy_settings
329    3 [+1]  Flag  read_default_link_policy_settings
330    4 [+1]  Flag  write_default_link_policy_settings
331    5 [+1]  Flag  flow_specification
332    6 [+1]  Flag  set_event_mask
333    7 [+1]  Flag  reset
334
335  if octet == 6:
336    0 [+1]  Flag  set_event_filter
337    1 [+1]  Flag  flush
338    2 [+1]  Flag  read_pin_type
339    3 [+1]  Flag  write_pin_type
340    5 [+1]  Flag  read_stored_link_key
341    6 [+1]  Flag  write_stored_link_key
342    7 [+1]  Flag  deleted_stored_link_key
343
344  if octet == 7:
345    0 [+1]  Flag  write_local_name
346    1 [+1]  Flag  read_local_name
347    2 [+1]  Flag  read_connection_attempt_timeout
348    3 [+1]  Flag  write_connection_attempt_timeout
349    4 [+1]  Flag  read_page_timeout
350    5 [+1]  Flag  write_page_timeout
351    6 [+1]  Flag  read_scan_enable
352    7 [+1]  Flag  write_scan_enable
353
354  if octet == 8:
355    0 [+1]  Flag  read_page_scan_activity
356    1 [+1]  Flag  write_page_scan_activity
357    2 [+1]  Flag  read_inquiry_scan_activity
358    3 [+1]  Flag  write_inquiry_scan_activity
359    4 [+1]  Flag  read_authentication_enable
360    5 [+1]  Flag  write_authentication_enable
361
362  if octet == 9:
363    0 [+1]  Flag  read_class_of_device
364    1 [+1]  Flag  write_class_of_device
365    2 [+1]  Flag  read_voice_setting
366    3 [+1]  Flag  write_voice_setting
367    4 [+1]  Flag  read_automatic_flush_timeout
368    5 [+1]  Flag  write_automatic_flush_timeout
369    6 [+1]  Flag  read_num_broadcast_retransmissions
370    7 [+1]  Flag  write_num_broadcast_retransmissions
371
372  if octet == 10:
373    0 [+1]  Flag  read_hold_mode_activity
374    1 [+1]  Flag  write_hold_mode_activity
375    2 [+1]  Flag  read_transmit_power_level
376    3 [+1]  Flag  read_synchronous_flow_control_enable
377    4 [+1]  Flag  write_synchronous_flow_control_enable
378    5 [+1]  Flag  set_controller_to_host_flow_control
379    6 [+1]  Flag  host_buffer_size
380    7 [+1]  Flag  host_number_of_completed_packets
381
382  if octet == 11:
383    0 [+1]  Flag  read_link_supervision_timeout
384    1 [+1]  Flag  write_link_supervision_timeout
385    2 [+1]  Flag  read_number_of_supported_iac
386    3 [+1]  Flag  read_current_iaclap
387    4 [+1]  Flag  write_current_iaclap
388
389  if octet == 12:
390    1 [+1]  Flag  set_afh_host_channel_classification
391    4 [+1]  Flag  read_inquiry_scan_type
392    5 [+1]  Flag  write_inquiry_scan_type
393    6 [+1]  Flag  read_inquiry_mode
394    7 [+1]  Flag  write_inquiry_mode
395
396  if octet == 13:
397    0 [+1]  Flag  read_page_scan_type
398    1 [+1]  Flag  write_page_scan_type
399    2 [+1]  Flag  read_afh_channel_assessment_mode
400    3 [+1]  Flag  write_afh_channel_assessment_mode
401
402  if octet == 14:
403    3 [+1]  Flag  read_local_version_information
404    5 [+1]  Flag  read_local_supported_features
405    6 [+1]  Flag  read_local_extended_features
406    7 [+1]  Flag  read_buffer_size
407
408  if octet == 15:
409    1 [+1]  Flag  read_bdaddr
410    2 [+1]  Flag  read_failed_contact_counter
411    3 [+1]  Flag  reset_failed_contact_c_ounter
412    4 [+1]  Flag  read_link_quality
413    5 [+1]  Flag  read_rssi
414    6 [+1]  Flag  read_afh_channel_map
415    7 [+1]  Flag  read_clock
416
417  if octet == 16:
418    0 [+1]  Flag  read_loopback_mode
419    1 [+1]  Flag  write_loopback_mode
420    2 [+1]  Flag  enable_device_under_test_mode
421    3 [+1]  Flag  setup_synchronous_connection_request
422    4 [+1]  Flag  accept_synchronous_connection_request
423    5 [+1]  Flag  reject_synchronous_connection_request
424
425  if octet == 17:
426    0 [+1]  Flag  read_extended_inquiry_response
427    1 [+1]  Flag  write_extended_inquiry_response
428    2 [+1]  Flag  refresh_encryption_key
429    4 [+1]  Flag  sniff_subrating
430    5 [+1]  Flag  read_simple_pairing_mode
431    6 [+1]  Flag  write_simple_pairing_mode
432    7 [+1]  Flag  read_local_oob_data
433
434  if octet == 18:
435    0 [+1]  Flag  read_inquiry_response_transmit_power_level
436    1 [+1]  Flag  write_inquiry_transmit_power_level
437    2 [+1]  Flag  read_default_erroneous_data_reporting
438    3 [+1]  Flag  write_default_erroneous_data_reporting
439    7 [+1]  Flag  io_capability_request_reply
440
441  if octet == 19:
442    0 [+1]  Flag  user_confirmation_request_reply
443    1 [+1]  Flag  user_confirmation_request_negative_reply
444    2 [+1]  Flag  user_passkey_request_reply
445    3 [+1]  Flag  user_passkey_request_negative_reply
446    4 [+1]  Flag  remote_oob_data_request_reply
447    5 [+1]  Flag  write_simple_pairing_debug_mode
448    6 [+1]  Flag  enhanced_flush
449    7 [+1]  Flag  remote_oob_data_request_negative_reply
450
451  if octet == 20:
452    2 [+1]  Flag  send_keypress_notification
453    3 [+1]  Flag  io_capability_request_negative_reply
454    4 [+1]  Flag  read_encryption_key_size
455
456  if octet == 21:
457    0 [+1]  Flag  create_physical_link
458    1 [+1]  Flag  accept_physical_link
459    2 [+1]  Flag  disconnect_physical_link
460    3 [+1]  Flag  create_logical_link
461    4 [+1]  Flag  accept_logical_link
462    5 [+1]  Flag  disconnect_logical_link
463    6 [+1]  Flag  logical_link_cancel
464    7 [+1]  Flag  flow_spec_modify
465
466  if octet == 22:
467    0 [+1]  Flag  read_logical_link_accept_timeout
468    1 [+1]  Flag  write_logical_link_accept_timeout
469    2 [+1]  Flag  set_event_mask_page_2
470    3 [+1]  Flag  read_location_data
471    4 [+1]  Flag  write_location_data
472    5 [+1]  Flag  read_local_amp_info
473    6 [+1]  Flag  read_local_ampassoc
474    7 [+1]  Flag  write_remote_ampassoc
475
476  if octet == 23:
477    0 [+1]  Flag  read_flow_control_mode
478    1 [+1]  Flag  write_flow_control_mode
479    2 [+1]  Flag  read_data_block_size
480
481  if octet == 24:
482    0 [+1]  Flag  read_enhanced_transmit_power_level
483    2 [+1]  Flag  read_best_effort_flush_timeout
484    3 [+1]  Flag  write_best_effort_flush_timeout
485    4 [+1]  Flag  short_range_mode
486    5 [+1]  Flag  read_le_host_supported
487    6 [+1]  Flag  write_le_host_support
488
489  if octet == 25:
490    0 [+1]  Flag  le_set_event_mask
491    1 [+1]  Flag  le_read_buffer_size_v1
492    2 [+1]  Flag  le_read_local_supported_features
493    4 [+1]  Flag  le_set_random_address
494    5 [+1]  Flag  le_set_advertising_parameters
495    6 [+1]  Flag  le_read_advertising_channel_tx_power
496    7 [+1]  Flag  le_set_advertising_data
497
498  if octet == 26:
499    0 [+1]  Flag  le_set_scan_response_data
500    1 [+1]  Flag  le_set_advertising_enable
501    2 [+1]  Flag  le_set_scan_parameters
502    3 [+1]  Flag  le_set_scan_enable
503    4 [+1]  Flag  le_create_connection
504    5 [+1]  Flag  le_create_connection_cancel
505    6 [+1]  Flag  le_read_filter_accept_list_size
506    7 [+1]  Flag  le_clear_filter_accept_list
507
508  if octet == 27:
509    0 [+1]  Flag  le_add_device_to_filter_accept_list
510    1 [+1]  Flag  le_remove_device_from_filter_accept_list
511    2 [+1]  Flag  le_connection_update
512    3 [+1]  Flag  le_set_host_channel_classification
513    4 [+1]  Flag  le_read_channel_map
514    5 [+1]  Flag  le_read_remote_features
515    6 [+1]  Flag  le_encrypt
516    7 [+1]  Flag  le_rand
517
518  if octet == 28:
519    0 [+1]  Flag  le_start_encryption
520    1 [+1]  Flag  le_long_term_key_request_reply
521    2 [+1]  Flag  le_long_term_key_request_negative_reply
522    3 [+1]  Flag  le_read_supported_states
523    4 [+1]  Flag  le_receiver_test_v1
524    5 [+1]  Flag  le_transmitter_test_v1
525    6 [+1]  Flag  le_test_end
526
527  if octet == 29:
528    3 [+1]  Flag  enhanced_setup_synchronous_connection
529    4 [+1]  Flag  enhanced_accept_synchronous_connection
530    5 [+1]  Flag  read_local_supported_codecs
531    6 [+1]  Flag  set_mws_channel_parameters
532    7 [+1]  Flag  set_external_frame_configuration
533
534  if octet == 30:
535    0 [+1]  Flag  set_mws_signaling
536    1 [+1]  Flag  set_mws_transport_layer
537    2 [+1]  Flag  set_mws_scan_frequency_table
538    3 [+1]  Flag  get_mws_transport_layer_configuration
539    4 [+1]  Flag  set_mws_pattern_configuration
540    5 [+1]  Flag  set_triggered_clock_capture
541    6 [+1]  Flag  truncated_page
542    7 [+1]  Flag  truncated_page_cancel
543
544  if octet == 31:
545    0 [+1]  Flag  set_connectionless_peripheral_broadcast
546    1 [+1]  Flag  set_connectionless_peripheral_broadcast_receive
547    2 [+1]  Flag  start_synchronization_train
548    3 [+1]  Flag  receive_synchronization_train
549    4 [+1]  Flag  set_reserved_ltaddr
550    5 [+1]  Flag  delete_reserved_ltaddr
551    6 [+1]  Flag  set_connectionless_peripheral_broadcast_data
552    7 [+1]  Flag  read_synchronization_train_parameters
553
554  if octet == 32:
555    0 [+1]  Flag  write_synchronization_train_parameters
556    1 [+1]  Flag  remote_oob_extended_data_request_reply
557    2 [+1]  Flag  read_secure_connections_host_support
558    3 [+1]  Flag  write_secure_connections_host_support
559    4 [+1]  Flag  read_authenticated_payload_timeout
560    5 [+1]  Flag  write_authenticated_payload_timeout
561    6 [+1]  Flag  read_local_oob_extended_data
562    7 [+1]  Flag  write_secure_connections_test_mode
563
564  if octet == 33:
565    0 [+1]  Flag  read_extended_page_timeout
566    1 [+1]  Flag  write_extended_page_timeout
567    2 [+1]  Flag  read_extended_inquiry_length
568    3 [+1]  Flag  write_extended_inquiry_length
569    4 [+1]  Flag  le_remote_connection_parameter_request_reply
570    5 [+1]  Flag  le_remote_connection_parameter_request_negative_reply
571    6 [+1]  Flag  le_set_data_length
572    7 [+1]  Flag  le_read_suggested_default_data_length
573
574  if octet == 34:
575    0 [+1]  Flag  le_write_suggested_default_data_length
576    1 [+1]  Flag  le_read_local_p256_public_key
577    2 [+1]  Flag  le_generate_dh_key_v1
578    3 [+1]  Flag  le_add_device_to_resolving_list
579    4 [+1]  Flag  le_remove_device_from_resolving_list
580    5 [+1]  Flag  le_clear_resolving_list
581    6 [+1]  Flag  le_read_resolving_list_size
582    7 [+1]  Flag  le_read_peer_resolvable_address
583
584  if octet == 35:
585    0 [+1]  Flag  le_read_local_resolvable_address
586    1 [+1]  Flag  le_set_address_resolution_enable
587    2 [+1]  Flag  le_set_resolvable_private_address_timeout
588    3 [+1]  Flag  le_read_maximum_data_length
589    4 [+1]  Flag  le_read_phy
590    5 [+1]  Flag  le_set_default_phy
591    6 [+1]  Flag  le_set_phy
592    7 [+1]  Flag  le_enhanced_receiver_test_v2
593
594  if octet == 36:
595    0 [+1]  Flag  le_enhanced_transmitter_test_v2
596    1 [+1]  Flag  le_set_advertising_set_random_address
597    2 [+1]  Flag  le_set_extended_advertising_parameters
598    3 [+1]  Flag  le_set_extended_advertising_data
599    4 [+1]  Flag  le_set_extended_scan_response_data
600    5 [+1]  Flag  le_set_extended_advertising_enable
601    6 [+1]  Flag  le_read_maximum_advertising_data_length
602    7 [+1]  Flag  le_read_number_of_supported_advertising_sets
603
604  if octet == 37:
605    0 [+1]  Flag  le_remove_advertising_set
606    1 [+1]  Flag  le_clear_advertising_sets
607    2 [+1]  Flag  le_set_periodic_advertising_parameters
608    3 [+1]  Flag  le_set_periodic_advertising_data
609    4 [+1]  Flag  le_set_periodic_advertising_enable
610    5 [+1]  Flag  le_set_extended_scan_parameters
611    6 [+1]  Flag  le_set_extended_scan_enable
612    7 [+1]  Flag  le_extended_create_connection
613
614  if octet == 38:
615    0 [+1]  Flag  le_periodic_advertising_create_sync
616    1 [+1]  Flag  le_periodic_advertising_create_sync_cancel
617    2 [+1]  Flag  le_periodic_advertising_terminate_sync
618    3 [+1]  Flag  le_add_device_to_periodic_advertiser_list
619    4 [+1]  Flag  le_remove_device_from_periodic_advertiser_list
620    5 [+1]  Flag  le_clear_periodic_advertiser_list
621    6 [+1]  Flag  le_read_periodic_advertiser_list_size
622    7 [+1]  Flag  le_read_transmit_power
623
624  if octet == 39:
625    0 [+1]  Flag  le_read_rf_path_compensation
626    1 [+1]  Flag  le_write_rf_path_compensation
627    2 [+1]  Flag  le_set_privacy_mode
628    3 [+1]  Flag  le_receiver_test_v3
629    4 [+1]  Flag  le_transmitter_test_v3
630    5 [+1]  Flag  le_set_connectionless_cte_transmit_parameters
631    6 [+1]  Flag  le_set_connectionless_cte_transmit_enable
632    7 [+1]  Flag  le_set_connectionless_iq_sampling_enable
633
634  if octet == 40:
635    0 [+1]  Flag  le_set_connection_cte_receive_parameters
636    1 [+1]  Flag  le_set_connection_cte_transmit_parameters
637    2 [+1]  Flag  le_connection_cte_request_enable
638    3 [+1]  Flag  le_connection_cte_response_enable
639    4 [+1]  Flag  le_read_antenna_information
640    5 [+1]  Flag  le_set_periodic_advertising_receive_enable
641    6 [+1]  Flag  le_periodic_advertising_sync_transfer
642    7 [+1]  Flag  le_periodic_advertising_set_info_transfer
643
644  if octet == 41:
645    0 [+1]  Flag  le_set_periodic_advertising_sync_transfer_parameters
646    1 [+1]  Flag  le_set_default_periodic_advertising_sync_transfer_parameters
647    2 [+1]  Flag  le_generate_dh_key_v3
648    3 [+1]  Flag  read_local_simple_pairing_options
649    4 [+1]  Flag  le_modify_sleep_clock_accuracy
650    5 [+1]  Flag  le_read_buffer_size_v2
651    6 [+1]  Flag  le_read_isotx_sync
652    7 [+1]  Flag  le_set_cig_parameters
653
654  if octet == 42:
655    0 [+1]  Flag  le_set_cig_parameters_test
656    1 [+1]  Flag  le_create_cis
657    2 [+1]  Flag  le_remove_cig
658    3 [+1]  Flag  le_accept_cis_request
659    4 [+1]  Flag  le_reject_cis_request
660    5 [+1]  Flag  le_create_big
661    6 [+1]  Flag  le_create_big_test
662    7 [+1]  Flag  le_terminate_big
663
664  if octet == 43:
665    0 [+1]  Flag  le_big_create_sync
666    1 [+1]  Flag  le_big_terminate_sync
667    2 [+1]  Flag  le_request_peer_sca
668    3 [+1]  Flag  le_setup_iso_data_path
669    4 [+1]  Flag  le_remove_iso_data_path
670    5 [+1]  Flag  le_iso_transmit_test
671    6 [+1]  Flag  le_iso_receive_test
672    7 [+1]  Flag  le_iso_read_test_counters
673
674  if octet == 44:
675    0 [+1]  Flag  le_iso_test_end
676    1 [+1]  Flag  le_set_host_feature
677    2 [+1]  Flag  le_read_iso_link_quality
678    3 [+1]  Flag  le_enhanced_read_transmit_power_level
679    4 [+1]  Flag  le_read_remote_transmit_power_level
680    5 [+1]  Flag  le_set_path_loss_reporting_parameters
681    6 [+1]  Flag  le_set_path_loss_reporting_enable
682    7 [+1]  Flag  le_set_transmit_power_reporting_enable
683
684  if octet == 45:
685    0 [+1]  Flag  le_transmitter_test_v4
686    1 [+1]  Flag  set_ecosystem_base_interval
687    2 [+1]  Flag  read_local_supported_codecs_v2
688    3 [+1]  Flag  read_local_supported_codec_capabilities
689    4 [+1]  Flag  read_local_supported_controller_delay
690    5 [+1]  Flag  configure_data_path
691
692  if octet == 46:
693    0 [+1]  Flag  le_set_default_subrate
694    1 [+1]  Flag  le_subrate_request
695    2 [+1]  Flag  le_set_extended_advertising_parameters_v2
696    5 [+1]  Flag  le_set_periodic_advertising_subevent_data
697    6 [+1]  Flag  le_set_periodic_advertising_response_data
698    7 [+1]  Flag  le_set_periodic_sync_subevent
699
700  if octet == 47:
701    0 [+1]  Flag  le_extended_create_connection_v2
702    1 [+1]  Flag  le_set_periodic_advertising_parameters_v2
703
704
705enum LEChannelSelectionAlgorithm:
706  [maximum_bits: 8]
707  ALGORITHM1 = 0x00
708  ALGORITHM2 = 0x01
709
710# ========================= HCI Event packets ===========================
711# Core Spec v5.3 Vol 4, Part E, Section 7.7
712
713
714struct InquiryCompleteEvent:
715  -- 7.7.1 Inquiry Complete event (v1.1) (BR/EDR)
716  -- HCI_Inquiry_Complete
717  let hdr_size = hci.EventHeader.$size_in_bytes
718  0     [+hdr_size]  hci.EventHeader  header
719  $next [+1]         hci.StatusCode   status
720
721
722struct InquiryResult:
723  0     [+hci.BdAddr.$size_in_bytes]  hci.BdAddr                  bd_addr
724    -- BD_ADDR for a device which responded.
725
726  $next [+1]                          hci.PageScanRepetitionMode  page_scan_repetition_mode
727  $next [+2]                          UInt                        reserved
728    -- Reserved for future use.
729
730  $next [+3]                          hci.ClassOfDevice           class_of_device
731    -- Class of Device for the device.
732
733  $next [+2]                          hci.ClockOffset             clock_offset
734    -- The lower 15 bits represent bits 16-2 of CLKNPeripheral-CLK.
735
736
737struct InquiryResultEvent:
738  -- 7.7.2 Inquiry Result event (v1.1) (BR/EDR)
739  -- HCI_Inquiry_Result
740  let hdr_size = hci.EventHeader.$size_in_bytes
741  0     [+hdr_size]                     hci.EventHeader  header
742  $next [+1]                            UInt             num_responses
743    -- Number of responses from the Inquiry.
744
745  let response_size = InquiryResult.$size_in_bytes
746  $next [+num_responses*response_size]  InquiryResult[]  responses
747
748
749struct ConnectionCompleteEvent:
750  -- 7.7.3 Connection Complete Event (v1.1) (BR/EDR)
751  -- HCI_Connection_Complete
752  let hdr_size = hci.EventHeader.$size_in_bytes
753  0     [+hdr_size]                   hci.EventHeader         header
754  $next [+1]                          hci.StatusCode          status
755  $next [+2]                          UInt                    connection_handle
756    [requires: 0x0000 <= this <= 0x0EFF]
757
758  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr              bd_addr
759    -- The address of the connected device
760
761  $next [+1]                          LinkType                link_type
762  $next [+1]                          hci.GenericEnableParam  encryption_enabled
763
764
765struct ConnectionRequestEvent:
766  -- 7.7.4 Connection Request event (v1.1) (BR/EDR)
767  -- HCI_Connection_Request
768  let hdr_size = hci.EventHeader.$size_in_bytes
769  0     [+hdr_size]                   hci.EventHeader    header
770  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr         bd_addr
771    -- The address of the device that's requesting the connection.
772
773  $next [+3]                          hci.ClassOfDevice  class_of_device
774    -- The Class of Device of the device which requests the connection.
775
776  $next [+1]                          LinkType           link_type
777
778
779struct DisconnectionCompleteEvent:
780  -- 7.7.5 Disconnection Complete event (v1.1) (BR/EDR & LE)
781  -- HCI_Disconnection_Complete
782  let hdr_size = hci.EventHeader.$size_in_bytes
783  0     [+hdr_size]  hci.EventHeader  header
784  $next [+1]         hci.StatusCode   status
785  $next [+2]         UInt             connection_handle
786    [requires: 0x0000 <= this <= 0x0EFF]
787
788  $next [+1]         hci.StatusCode   reason
789
790
791struct AuthenticationCompleteEvent:
792  -- 7.7.6 Authentication Complete event (v1.1) (BR/EDR)
793  -- HCI_Authentication_Complete
794  let hdr_size = hci.EventHeader.$size_in_bytes
795  0     [+hdr_size]  hci.EventHeader  header
796  $next [+1]         hci.StatusCode   status
797  $next [+2]         UInt             connection_handle
798    [requires: 0x0000 <= this <= 0x0EFF]
799
800
801struct RemoteNameRequestCompleteEvent:
802  -- 7.7.7 Remote Name Request Complete event (v1.1) (BR/EDR)
803  -- HCI_Remote_Name_Request_Complete
804  let hdr_size = hci.EventHeader.$size_in_bytes
805  0     [+hdr_size]                   hci.EventHeader  header
806  $next [+1]                          hci.StatusCode   status
807  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr       bd_addr
808  $next [+248]                        UInt:8[248]      remote_name
809    -- UTF-8 encoded friendly name. If the name is less than 248 characters, it
810    -- is null terminated and the remaining bytes are not valid.
811
812
813struct EncryptionChangeEventV1:
814  -- 7.7.8 Encryption Change event (v1.1) (BR/EDR & LE)
815  -- HCI_Encryption_Change [v1]
816  let hdr_size = hci.EventHeader.$size_in_bytes
817  0     [+hdr_size]  hci.EventHeader   header
818  $next [+1]         hci.StatusCode    status
819  $next [+2]         UInt              connection_handle
820    [requires: 0x0000 <= this <= 0x0EFF]
821
822  $next [+1]         EncryptionStatus  encryption_enabled
823
824
825struct ChangeConnectionLinkKeyCompleteEvent:
826  -- 7.7.9 Change Connection Link Key Complete event (v1.1) (BR/EDR)
827  -- HCI_Change_Connection_Link_Key_Complete
828  let hdr_size = hci.EventHeader.$size_in_bytes
829  0     [+hdr_size]  hci.EventHeader  header
830  $next [+1]         hci.StatusCode   status
831  $next [+2]         UInt             connection_handle
832    [requires: 0x0000 <= this <= 0x0EFF]
833
834# 7.7.10 Link Key Type Changed event
835# HCI_Link_Key_Type_Changed
836# TODO: b/265052417 - Definition needs to be added
837
838
839struct ReadRemoteSupportedFeaturesCompleteEvent:
840  -- 7.7.11 Read Remote Supported Features Complete event (v1.1) (BR/EDR)
841  -- HCI_Read_Remote_Supported_Features_Complete
842  let hdr_size = hci.EventHeader.$size_in_bytes
843  0     [+hdr_size]  hci.EventHeader  header
844  $next [+1]         hci.StatusCode   status
845  $next [+2]         UInt             connection_handle
846    [requires: 0x0000 <= this <= 0x0EFF]
847
848  $next [+8]         LmpFeatures(0)   lmp_features
849    -- Page 0 of the LMP features.
850
851
852struct ReadRemoteVersionInfoCompleteEvent:
853  -- 7.7.12 Read Remote Version Information Complete event (v1.1) (BR/EDR & LE)
854  -- HCI_Read_Remote_Version_Information_Complete
855  let hdr_size = hci.EventHeader.$size_in_bytes
856  0     [+hdr_size]  hci.EventHeader           header
857  $next [+1]         hci.StatusCode            status
858  $next [+2]         UInt                      connection_handle
859    [requires: 0x0000 <= this <= 0x0EFF]
860
861  $next [+1]         CoreSpecificationVersion  version
862    -- Version of the Current LMP or Link Layer supported by the remote Controller.
863
864  $next [+2]         UInt                      company_identifier
865    -- Company identifier for the manufacturer of the remote Controller. Assigned by Bluetooth SIG.
866
867  $next [+2]         UInt                      subversion
868    -- Revision of the LMP or Link Layer implementation in the remote Controller. This value is vendor-specific.
869
870# 7.7.13 QoS Setup Complete event
871# HCI_QoS_Setup_Complete
872# TODO: b/265052417 - Definition needs to be added
873
874
875struct SimpleCommandCompleteEvent:
876  -- 7.7.14 Command Complete event (status only)
877  -- HCI_Command_Complete
878  -- A Command Complete event where a StatusCode is the only return parameter.
879  -- Also useful for generically getting the status of a larger command complete
880  -- event.
881  let hdr_size = hci.CommandCompleteEvent.$size_in_bytes
882  0     [+hdr_size]  hci.CommandCompleteEvent  command_complete
883  let header = command_complete.header
884  $next [+1]         hci.StatusCode            status
885
886
887struct ReadLocalVersionInfoCommandCompleteEvent:
888  -- 7.7.14 Command Complete event (7.4.1 Read Local Version Information command)
889  let hdr_size = hci.CommandCompleteEvent.$size_in_bytes
890  0     [+hdr_size]  hci.CommandCompleteEvent  command_complete
891  let header = command_complete.header
892  $next [+1]         hci.StatusCode            status
893  $next [+1]         CoreSpecificationVersion  hci_version
894    -- Version of the HCI Specification supported by the Controller. See
895    -- Assigned Numbers
896
897  $next [+2]         UInt                      hci_subversion
898    -- Revision of the HCI implementation in the Controller. This value is
899    -- vendor-specific.
900
901  $next [+1]         UInt                      lmp_version
902    -- Version of the Current LMP supported by the Controller. See Assigned
903    -- Numbers
904
905  $next [+2]         UInt                      company_identifier
906    -- Company identifier for the manufacturer of the Controller. See Assigned
907    -- Numbers
908
909  $next [+2]         UInt                      lmp_subversion
910    -- Subversion of the Current LMP in the Controller. This value is
911    -- vendor-specific.
912
913
914struct ReadLocalSupportedCommandsCommandCompleteEvent:
915  -- 7.7.14 Command Complete event (7.4.2 Read Local Supported Commands command)
916  let hdr_size = hci.CommandCompleteEvent.$size_in_bytes
917  0     [+hdr_size]  hci.CommandCompleteEvent  command_complete
918  let header = command_complete.header
919  $next [+1]         hci.StatusCode            status
920  $next [+1]         SupportedCommands(0)      supported_commands_0
921  $next [+1]         SupportedCommands(1)      supported_commands_1
922  $next [+1]         SupportedCommands(2)      supported_commands_2
923  $next [+1]         SupportedCommands(3)      supported_commands_3
924  $next [+1]         SupportedCommands(4)      supported_commands_4
925  $next [+1]         SupportedCommands(5)      supported_commands_5
926  $next [+1]         SupportedCommands(6)      supported_commands_6
927  $next [+1]         SupportedCommands(7)      supported_commands_7
928  $next [+1]         SupportedCommands(8)      supported_commands_8
929  $next [+1]         SupportedCommands(9)      supported_commands_9
930  $next [+1]         SupportedCommands(10)     supported_commands_10
931  $next [+1]         SupportedCommands(11)     supported_commands_11
932  $next [+1]         SupportedCommands(12)     supported_commands_12
933  $next [+1]         SupportedCommands(13)     supported_commands_13
934  $next [+1]         SupportedCommands(14)     supported_commands_14
935  $next [+1]         SupportedCommands(15)     supported_commands_15
936  $next [+1]         SupportedCommands(16)     supported_commands_16
937  $next [+1]         SupportedCommands(17)     supported_commands_17
938  $next [+1]         SupportedCommands(18)     supported_commands_18
939  $next [+1]         SupportedCommands(19)     supported_commands_19
940  $next [+1]         SupportedCommands(20)     supported_commands_20
941  $next [+1]         SupportedCommands(21)     supported_commands_21
942  $next [+1]         SupportedCommands(22)     supported_commands_22
943  $next [+1]         SupportedCommands(23)     supported_commands_23
944  $next [+1]         SupportedCommands(24)     supported_commands_24
945  $next [+1]         SupportedCommands(25)     supported_commands_25
946  $next [+1]         SupportedCommands(26)     supported_commands_26
947  $next [+1]         SupportedCommands(27)     supported_commands_27
948  $next [+1]         SupportedCommands(28)     supported_commands_28
949  $next [+1]         SupportedCommands(29)     supported_commands_29
950  $next [+1]         SupportedCommands(30)     supported_commands_30
951  $next [+1]         SupportedCommands(31)     supported_commands_31
952  $next [+1]         SupportedCommands(32)     supported_commands_32
953  $next [+1]         SupportedCommands(33)     supported_commands_33
954  $next [+1]         SupportedCommands(34)     supported_commands_34
955  $next [+1]         SupportedCommands(35)     supported_commands_35
956  $next [+1]         SupportedCommands(36)     supported_commands_36
957  $next [+1]         SupportedCommands(37)     supported_commands_37
958  $next [+1]         SupportedCommands(38)     supported_commands_38
959  $next [+1]         SupportedCommands(39)     supported_commands_39
960  $next [+1]         SupportedCommands(40)     supported_commands_40
961  $next [+1]         SupportedCommands(41)     supported_commands_41
962  $next [+1]         SupportedCommands(42)     supported_commands_42
963  $next [+1]         SupportedCommands(43)     supported_commands_43
964  $next [+1]         SupportedCommands(44)     supported_commands_44
965  $next [+1]         SupportedCommands(45)     supported_commands_45
966  $next [+1]         SupportedCommands(46)     supported_commands_46
967  $next [+1]         SupportedCommands(47)     supported_commands_47
968
969
970struct ReadBufferSizeCommandCompleteEvent:
971  -- 7.7.14 Command Complete event (7.4.5 Read Buffer Size command)
972
973  let hdr_size = hci.CommandCompleteEvent.$size_in_bytes
974
975  0     [+hdr_size]  hci.CommandCompleteEvent  command_complete
976
977  let header = command_complete.header
978
979  $next [+1]         hci.StatusCode            status
980
981  $next [+2]         UInt                      acl_data_packet_length
982    -- Maximum length (in octets) of the data portion of each HCI ACL Data
983    -- packet that the Controller is able to accept.
984    [requires: 0x0001 <= this <= 0xFFFF]
985
986  $next [+1]         UInt                      synchronous_data_packet_length
987    -- Maximum length (in octets) of the data portion of each HCI Synchronous
988    -- Data packet that the Controller is able to accept.
989    [requires: 0x01 <= this <= 0xFF]
990
991  $next [+2]         UInt                      total_num_acl_data_packets
992    -- Total number of HCI ACL Data packets that can be stored in the data
993    -- buffers of the Controller.
994
995  $next [+2]         UInt                      total_num_synchronous_data_packets
996    -- Total number of HCI Synchronous Data packets that can be stored in the
997    -- data buffers of the Controller. A value of 0 indicates that the
998    -- Controller does not support SCO or eSCO over HCI.
999
1000
1001struct ReadBdAddrCommandCompleteEvent:
1002  -- 7.7.14 Command Complete event (7.4.6 Read BD_ADDR command)
1003  let hdr_size = hci.CommandCompleteEvent.$size_in_bytes
1004  0     [+hdr_size]                   hci.CommandCompleteEvent  command_complete
1005  let header = command_complete.header
1006  $next [+1]                          hci.StatusCode            status
1007  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr                bd_addr
1008
1009
1010struct ReadLocalSupportedControllerDelayCommandCompleteEvent:
1011  -- 7.7.14 Command Complete event (7.4.11 Read Local Supported Controller Delay command)
1012  let hdr_size = hci.CommandCompleteEvent.$size_in_bytes
1013  0     [+hdr_size]  hci.CommandCompleteEvent  command_complete
1014  let header = command_complete.header
1015  $next [+1]         hci.StatusCode            status
1016  let max_delay_usecs = 0x3D0900
1017    -- 4 seconds
1018
1019  $next [+3]         UInt                      min_controller_delay
1020    -- Minimum controller delay in microseconds for the specified configuration
1021    [requires: this <= ReadLocalSupportedControllerDelayCommandCompleteEvent.max_delay_usecs]
1022
1023  $next [+3]         UInt                      max_controller_delay
1024    -- Maximum controller delay in microseconds for the specified configuration
1025    [requires: this <= ReadLocalSupportedControllerDelayCommandCompleteEvent.max_delay_usecs]
1026
1027
1028struct ReadRssiCommandCompleteEvent:
1029  -- 7.7.14 Command Complete event (7.5.4 Read RSSI command)
1030  let hdr_size = hci.CommandCompleteEvent.$size_in_bytes
1031  0     [+hdr_size]  hci.CommandCompleteEvent  command_complete
1032  $next [+1]         hci.StatusCode            status
1033  $next [+2]         UInt                      connection_handle
1034    [requires: 0x0000 <= this <= 0x0EFF]
1035
1036  $next [+1]         Int                       rssi
1037    -- BR/EDR (Range: -128 to 127, Units: dB)
1038    -- LE (Range: -127 to 20, 127, Units: dBm)
1039
1040
1041struct LEReadBufferSizeV1CommandCompleteEvent:
1042  -- 7.7.14 Command Complete event (7.8.2 LE Read Buffer Size [v1] command)
1043  let hdr_size = hci.CommandCompleteEvent.$size_in_bytes
1044  0     [+hdr_size]  hci.CommandCompleteEvent  command_complete
1045  let header = command_complete.header
1046  $next [+1]         hci.StatusCode            status
1047  $next [+2]         UInt                      le_acl_data_packet_length
1048    -- Maximum length (in octets) of the data portion of each HCI ACL data packet,
1049    -- or 0 if no dedicated LE buffer exists.
1050    [requires: 0x001b <= this <= 0xFFFF || this == 0x0000]
1051
1052  $next [+1]         UInt                      total_num_le_acl_data_packets
1053    -- The total number of HCI ACL data packets that can be stored in the data
1054    -- buffers of the Controller, or 0 if no dedicated LE buffer exists.
1055
1056
1057struct LEReadBufferSizeV2CommandCompleteEvent:
1058  -- 7.7.14 Command Complete event (7.8.2 LE Read Buffer Size [v2] command)
1059  let hdr_size = hci.CommandCompleteEvent.$size_in_bytes
1060  0     [+hdr_size]  hci.CommandCompleteEvent  command_complete
1061  let header = command_complete.header
1062  $next [+1]         hci.StatusCode            status
1063  $next [+2]         UInt                      le_acl_data_packet_length
1064    -- Maximum length (in octets) of the data portion of each HCI ACL data packet,
1065    -- or 0 if no dedicated LE buffer exists.
1066    [requires: 0x001b <= this <= 0xFFFF || this == 0x0000]
1067
1068  $next [+1]         UInt                      total_num_le_acl_data_packets
1069    -- The total number of HCI ACL data packets that can be stored in the data
1070    -- buffers of the Controller, or 0 if no dedicated LE buffer exists.
1071
1072  $next [+2]         UInt                      iso_data_packet_length
1073    -- The maximum length (in octets) of the data portion of each HCI ISO data
1074    -- packet, or 0 if no dedicated ISO buffer exists.
1075
1076  $next [+1]         UInt                      total_num_iso_data_packets
1077    -- The total number of HCI ISO data packets that can be stored in the ISO
1078    -- buffers of the controller, or 0 if no dedicated ISO buffer exists.
1079
1080
1081struct LEReadLocalSupportedFeaturesCommandCompleteEvent:
1082  -- 7.7.14 Command Complete event (7.8.3 LE Read Local Supported Features command)
1083  let hdr_size = hci.CommandCompleteEvent.$size_in_bytes
1084  0     [+hdr_size]                      hci.CommandCompleteEvent  command_complete
1085  let header = command_complete.header
1086  $next [+1]                             hci.StatusCode            status
1087  $next [+8]  bits:
1088    0     [+LEFeatureSet.$size_in_bits]  LEFeatureSet              le_features
1089
1090
1091struct LEReadMaximumAdvertisingDataLengthCommandCompleteEvent:
1092  -- 7.7.14 Command Complete event (7.8.57 LE Read Maximum Advertising Data
1093  -- Length command)
1094  let hdr_size = hci.CommandCompleteEvent.$size_in_bytes
1095  0     [+hdr_size]  hci.CommandCompleteEvent  command_complete
1096  let header = command_complete.header
1097  $next [+1]         hci.StatusCode            status
1098  $next [+2]         UInt                      max_advertising_data_length
1099    -- The maximum length of data supported by the Controller for use as
1100    -- advertisement data or scan response data in an advertising event or as
1101    -- periodic advertisement data
1102    [requires: 0x001F <= this <= 0x0672]
1103
1104
1105struct LESetupISODataPathCommandCompleteEvent:
1106  -- 7.7.14 Command Complete event (7.8.109 LE Setup ISO Data Path command)
1107  let hdr_size = hci.CommandCompleteEvent.$size_in_bytes
1108  0     [+hdr_size]  hci.CommandCompleteEvent  command_complete
1109  let header = command_complete.header
1110  $next [+1]         hci.StatusCode            status
1111  $next [+2]         UInt                      connection_handle
1112
1113
1114struct CommandStatusEvent:
1115  -- 7.7.15 Command Status event
1116  -- HCI_Command_Status
1117  let hdr_size = hci.EventHeader.$size_in_bytes
1118  0     [+hdr_size]  hci.EventHeader  header
1119  $next [+1]         hci.StatusCode   status
1120  $next [+1]         UInt             num_hci_command_packets
1121  $next [+2]         hci.OpCodeBits   command_opcode
1122
1123# 7.7.16 Hardware Error event
1124# HCI_Hardware_Error
1125# TODO: b/265052417 - Definition needs to be added
1126
1127
1128# 7.7.17 Flush Occurred event
1129# HCI_Flush_Occurred
1130# TODO: b/265052417 - Definition needs to be added
1131
1132
1133struct RoleChangeEvent:
1134  -- 7.7.18 Role Change event (BR/EDR) (v1.1)
1135  -- HCI_Role_Change
1136  let hdr_size = hci.EventHeader.$size_in_bytes
1137  0     [+hdr_size]                   hci.EventHeader     header
1138  $next [+1]                          hci.StatusCode      status
1139  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr          bd_addr
1140    -- The address of the device for which a role change has completed.
1141
1142  $next [+1]                          hci.ConnectionRole  role
1143    -- The new role for the specified address.
1144
1145# 7.7.19 Number Of Completed Packets event
1146# HCI_Number_Of_Completed_Packets
1147# TODO: b/265052417 - Definition needs to be added
1148
1149
1150# 7.7.20 Mode Change event
1151# HCI_Mode_Change
1152# TODO: b/265052417 - Definition needs to be added
1153
1154
1155# 7.7.21 Return Link Keys event
1156# HCI_Return_Link_Keys
1157# TODO: b/265052417 - Definition needs to be added
1158
1159
1160# 7.7.22 PIN Code Request event
1161# HCI_PIN_Code_Request
1162# TODO: b/265052417 - Definition needs to be added
1163
1164
1165struct LinkKeyRequestEvent:
1166  -- 7.7.23 Link Key Request event (v1.1) (BR/EDR)
1167  -- HCI_Link_Key_Request
1168  let hdr_size = hci.EventHeader.$size_in_bytes
1169  0     [+hdr_size]                   hci.EventHeader  header
1170  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr       bd_addr
1171    -- The address for the device that a host-stored link key is being requested.
1172
1173
1174struct LinkKeyNotificationEvent:
1175  -- 7.7.24 Link Key Notification event (v1.1) (BR/EDR)
1176  -- HCI_Link_Key_Notification
1177  let hdr_size = hci.EventHeader.$size_in_bytes
1178  0     [+hdr_size]                    hci.EventHeader  header
1179  $next [+hci.BdAddr.$size_in_bytes]   hci.BdAddr       bd_addr
1180    -- The address for the device for which a new link key has been generated.
1181
1182  $next [+hci.LinkKey.$size_in_bytes]  hci.LinkKey      link_key
1183    -- Link key for the associated address.
1184
1185  $next [+1]                           KeyType          key_type
1186    -- Type of key used when pairing.
1187
1188
1189struct LoopbackCommandEvent:
1190  -- 7.7.25 Loopback Command event (v5.3)
1191  -- HCI_Loopback_Command
1192  let hdr_size = hci.EventHeader.$size_in_bytes
1193  0     [+hdr_size]      hci.EventHeader       header
1194  let payload_size = header.parameter_total_size
1195    [requires: this >= hci.CommandHeader.$size_in_bytes]
1196
1197  $next [+payload_size]  UInt:8[payload_size]  command
1198
1199
1200struct DataBufferOverflowEvent:
1201  -- 7.7.26 Data Buffer Overflow event (v1.1) (BR/EDR & LE)
1202  -- HCI_Data_Buffer_Overflow
1203  let hdr_size = hci.EventHeader.$size_in_bytes
1204  0     [+hdr_size]  hci.EventHeader  header
1205  $next [+1]         LinkType         ll_type
1206
1207# 7.7.27 Max Slots Change event
1208# HCI_Max_Slots_Change
1209# TODO: b/265052417 - Definition needs to be added
1210
1211
1212# 7.7.28 Read Clock Offset Complete event
1213# HCI_Read_Clock_Offset_Complete
1214# TODO: b/265052417 - Definition needs to be added
1215
1216
1217# 7.7.29 Connection Packet Type Changed event
1218# HCI_Connection_Packet_Type_Changed
1219# TODO: b/265052417 - Definition needs to be added
1220
1221
1222# 7.7.30 QoS Violation event
1223# HCI_QoS_Violation
1224# TODO: b/265052417 - Definition needs to be added
1225
1226
1227# 7.7.31 Page Scan Repetition Mode Change event
1228# HCI_Page_Scan_Repetition_Mode_Change
1229# TODO: b/265052417 - Definition needs to be added
1230
1231
1232# 7.7.32 Flow Specification Complete event
1233# HCI_Flow_Specification_Complete
1234# TODO: b/265052417 - Definition needs to be added
1235
1236
1237struct InquiryResultWithRssi:
1238  -- A single inquiry result (with RSSI).
1239  0     [+hci.BdAddr.$size_in_bytes]  hci.BdAddr                  bd_addr
1240    -- The address for the device which responded.
1241
1242  $next [+1]                          hci.PageScanRepetitionMode  page_scan_repetition_mode
1243    -- The Page Scan Repetition Mode being used by the remote device.
1244
1245  $next [+1]                          UInt                        reserved
1246  $next [+3]                          hci.ClassOfDevice           class_of_device
1247  $next [+2]                          hci.ClockOffset             clock_offset
1248    -- The lower 15 bits represent bits 16-2 of CLKNPeripheral-CLK. The most
1249    -- significant bit is reserved.
1250
1251  $next [+1]                          Int                         rssi
1252    -- Units: dBm
1253    [requires: -127 <= this <= 20]
1254
1255
1256struct InquiryResultWithRssiEvent:
1257  -- 7.7.33 Inquiry Result with RSSI event (v1.2) (BR/EDR)
1258  -- HCI_Inquiry_Result_with_RSSI
1259  let hdr_size = hci.EventHeader.$size_in_bytes
1260  0     [+hdr_size]                     hci.EventHeader          header
1261  $next [+1]                            UInt                     num_responses
1262    -- The number of responses included.
1263
1264  let response_size = InquiryResultWithRssi.$size_in_bytes
1265  $next [+num_responses*response_size]  InquiryResultWithRssi[]  responses
1266
1267
1268struct ReadRemoteExtendedFeaturesCompleteEvent:
1269  -- 7.7.34 Read Remote Extended Features Complete event (v1.1) (BR/EDR)
1270  -- HCI_Read_Remote_Extended_Features_Complete
1271  let hdr_size = hci.EventHeader.$size_in_bytes
1272  0     [+hdr_size]  hci.EventHeader           header
1273  $next [+1]         hci.StatusCode            status
1274  $next [+2]         UInt                      connection_handle
1275    -- Only the lower 12-bits are meaningful.
1276    [requires: 0x0000 <= this <= 0x0EFF]
1277
1278  $next [+1]         UInt                      page_number
1279    -- 0x00: The normal LMP features as returned by HCI_Read_Remote_Supported_Features command.
1280    -- 0x01 to 0xFF: The page number of the features returned.
1281
1282  $next [+1]         UInt                      max_page_number
1283    -- The highest features page number which contains non-zero bits for the remote device.
1284
1285  $next [+8]         LmpFeatures(page_number)  lmp_features
1286    -- Bit map of requested page of LMP features.
1287
1288
1289struct SynchronousConnectionCompleteEvent:
1290  -- 7.7.35 Synchronous Connection Complete event (BR/EDR)
1291  -- HCI_Synchronous_Connection_Complete
1292
1293  let hdr_size = hci.EventHeader.$size_in_bytes
1294
1295  0     [+hdr_size]                   hci.EventHeader   header
1296
1297  $next [+1]                          hci.StatusCode    status
1298
1299  $next [+2]                          UInt              connection_handle
1300    -- A connection handle for the newly created SCO connection.
1301    [requires: 0x0000 <= this <= 0x0EFF]
1302
1303  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr        bd_addr
1304    -- BD_ADDR of the other connected device forming the connection.
1305
1306  $next [+1]                          LinkType          link_type
1307
1308  $next [+1]                          UInt              transmission_interval
1309    -- Time between two consecutive eSCO instants measured in slots. Shall be
1310    -- zero for SCO links.
1311
1312  $next [+1]                          UInt              retransmission_window
1313    -- The size of the retransmission window measured in slots. Shall be zero
1314    -- for SCO links.
1315
1316  $next [+2]                          UInt              rx_packet_length
1317    -- Length in bytes of the eSCO payload in the receive direction. Shall be
1318    -- zero for SCO links.
1319
1320  $next [+2]                          UInt              tx_packet_length
1321    -- Length in bytes of the eSCO payload in the transmit direction. Shall be
1322    -- zero for SCO links.
1323
1324  $next [+1]                          hci.CodingFormat  air_mode
1325
1326# 7.7.36 Synchronous Connection Changed event
1327# HCI_Synchronous_Connection_Changed
1328# TODO: b/265052417 - Definition needs to be added
1329
1330
1331# 7.7.37 Sniff Subrating event
1332# HCI_Sniff_Subrating
1333# TODO: b/265052417 - Definition needs to be added
1334
1335
1336struct ExtendedInquiryResultEvent:
1337  -- 7.7.38 Extended Inquiry Result event (v1.2) (BR/EDR)
1338  -- HCI_Extended_Inquiry_Result
1339  let hdr_size = hci.EventHeader.$size_in_bytes
1340  0     [+hdr_size]                   hci.EventHeader             header
1341  $next [+1]                          UInt                        num_responses
1342    -- Number of responses from the inquiry. The HCI_Extended_Inquiry_Result
1343    -- event always contains a single response.
1344    [requires: this == 0x01]
1345
1346  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr                  bd_addr
1347    -- BD_ADDR of the device that responded.
1348
1349  $next [+1]                          hci.PageScanRepetitionMode  page_scan_repetition_mode
1350    -- The Page Scan Repetition Mode being used by the remote device.
1351
1352  $next [+1]                          UInt                        reserved
1353  $next [+3]                          hci.ClassOfDevice           class_of_device
1354  $next [+2]                          hci.ClockOffset             clock_offset
1355    -- The lower 15 bits represent bits 16-2 of CLKNPeripheral-CLK.
1356
1357  $next [+1]                          Int                         rssi
1358    -- Units: dBm
1359    [requires: -127 <= this <= 20]
1360
1361  $next [+240]                        UInt:8[240]                 extended_inquiry_response
1362    -- Extended inquiey response data as defined in Vol 3, Part C, Sec 8
1363
1364
1365struct EncryptionKeyRefreshCompleteEvent:
1366  -- 7.7.39 Encryption Key Refresh Complete event (v2.1 + EDR) (BR/EDR & LE)
1367  -- HCI_Encryption_Key_Refresh_Complete
1368  let hdr_size = hci.EventHeader.$size_in_bytes
1369  0     [+hdr_size]  hci.EventHeader  header
1370  $next [+1]         hci.StatusCode   status
1371  $next [+2]         UInt             connection_handle
1372    -- The connection_handle on which the encryption key was refreshed due to
1373    -- encryption being started or resumed.
1374    [requires: 0x0000 <= this <= 0x0EFF]
1375
1376
1377struct IoCapabilityRequestEvent:
1378  -- 7.7.40 IO Capability Request event (v2.1 + EDR) (BR/EDR)
1379  -- HCI_IO_Capability_Request
1380  let hdr_size = hci.EventHeader.$size_in_bytes
1381  0     [+hdr_size]                   hci.EventHeader  header
1382  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr       bd_addr
1383    -- The address of the remote device involved in the Secure Simple Pairing
1384    -- process.
1385
1386
1387struct IoCapabilityResponseEvent:
1388  -- 7.7.41 IO Capability Response event (v2.1 + EDR) (BR/EDR)
1389  -- HCI_IO_Capability_Response
1390  let hdr_size = hci.EventHeader.$size_in_bytes
1391  0     [+hdr_size]                   hci.EventHeader                 header
1392  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr                      bd_addr
1393    -- The address of the remote device which the IO capabilities apply
1394
1395  $next [+1]                          hci.IoCapability                io_capability
1396    -- IO Capabilities of the device
1397
1398  $next [+1]                          hci.GenericPresenceParam        oob_data_present
1399    -- Whether out-of-band authentication data is present.
1400
1401  $next [+1]                          hci.AuthenticationRequirements  authentication_requirements
1402
1403
1404struct UserConfirmationRequestEvent:
1405  -- 7.7.42 User Confirmation Request event (v2.1 + EDR) (BR/EDR)
1406  -- HCI_User_Confirmation_Request
1407  let hdr_size = hci.EventHeader.$size_in_bytes
1408  0     [+hdr_size]                   hci.EventHeader  header
1409  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr       bd_addr
1410    -- Address of the device involved in simple pairing process
1411
1412  $next [+4]                          UInt             numeric_value
1413    -- Numeric value to be displayed.
1414    [requires: 0 <= this <= 999999]
1415
1416
1417struct UserPasskeyRequestEvent:
1418  -- 7.7.43 User Passkey Request event (v2.1 + EDR) (BR/EDR)
1419  -- HCI_User_Passkey_Request
1420  let hdr_size = hci.EventHeader.$size_in_bytes
1421  0     [+hdr_size]                   hci.EventHeader  header
1422  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr       bd_addr
1423    -- Address of the device involved in simple pairing process
1424
1425# 7.7.44 Remote OOB Data Request event
1426# HCI_Remote_OOB_Data_Request
1427# TODO: b/265052417 - Definition needs to be added
1428
1429
1430struct SimplePairingCompleteEvent:
1431  -- 7.7.45 Simple Pairing Complete event (v2.1 + EDR) (BR/EDR)
1432  -- HCI_Simple_Pairing_Complete
1433  let hdr_size = hci.EventHeader.$size_in_bytes
1434  0     [+hdr_size]                   hci.EventHeader  header
1435  $next [+1]                          hci.StatusCode   status
1436  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr       bd_addr
1437    -- Address of the device involved in simple pairing process
1438
1439# 7.7.46 Link Supervision Timeout Changed event
1440# HCI_Link_Supervision_Timeout_Changed
1441# TODO: b/265052417 - Definition needs to be added
1442
1443
1444# 7.7.47 Enhanced Flush Complete event
1445# HCI_Enhanced_Flush_Complete
1446# TODO: b/265052417 - Definition needs to be added
1447
1448
1449struct UserPasskeyNotificationEvent:
1450  -- 7.7.48 User Passkey Notification event (v2.1 + EDR) (BR/EDR)
1451  -- HCI_User_Passkey_Notification
1452  let hdr_size = hci.EventHeader.$size_in_bytes
1453  0     [+hdr_size]                   hci.EventHeader  header
1454  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr       bd_addr
1455    -- Address of the device involved in simple pairing process
1456
1457  $next [+4]                          UInt             passkey
1458    -- Numeric value (passkey) entered by user.
1459    [requires: 0 <= this <= 999999]
1460
1461# 7.7.49 Keypress Notification event
1462# HCI_Keypress_Notification
1463# TODO: b/265052417 - Definition needs to be added
1464
1465
1466# 7.7.50 Remote Host Supported Features Notification event
1467# HCI_Remote_Host_Supported_Features_Notification
1468# TODO: b/265052417 - Definition needs to be added
1469
1470
1471# 7.7.59 Number Of Completed Data Blocks event
1472# HCI_Number_Of_Completed_Data_Blocks
1473# TODO: b/265052417 - Definition needs to be added
1474
1475
1476struct LEMetaEvent:
1477  -- 7.7.65 LE Meta event
1478  let hdr_size = hci.EventHeader.$size_in_bytes
1479  0     [+hdr_size]  hci.EventHeader  header
1480  $next [+1]         UInt             subevent_code
1481    -- The event code for the LE subevent.
1482
1483
1484struct LEConnectionCompleteSubevent:
1485  -- 7.7.65.1 LE Connection Complete event
1486  -- HCI_LE_Connection_Complete
1487
1488  0     [+LEMetaEvent.$size_in_bytes]  LEMetaEvent            le_meta_event
1489
1490  $next [+1]                           hci.StatusCode         status
1491
1492  $next [+2]                           UInt                   connection_handle
1493    -- Only the lower 12-bits are meaningful.
1494    [requires: 0x0000 <= this <= 0x0EFF]
1495
1496  $next [+1]                           hci.ConnectionRole     role
1497
1498  $next [+1]                           hci.LEPeerAddressType  peer_address_type
1499
1500  $next [+hci.BdAddr.$size_in_bytes]   hci.BdAddr             peer_address
1501    -- Public Device Address or Random Device Address of the peer device.
1502
1503  $next [+2]                           UInt                   connection_interval
1504    -- Time: N * 1.25 ms
1505    -- Range: 7.5 ms to 4 s
1506    [requires: 0x0006 <= this <= 0x0C80]
1507
1508  $next [+2]                           UInt                   peripheral_latency
1509    [requires: 0x0000 <= this <= 0x01F3]
1510
1511  $next [+2]                           UInt                   supervision_timeout
1512    -- Time: N * 10 ms
1513    -- Range: 100 ms to 32 s
1514    [requires: 0x000A <= this <= 0x0C80]
1515
1516  $next [+1]                           LEClockAccuracy        central_clock_accuracy
1517    -- Only valid for a peripheral. On a central, this parameter shall be set to 0x00.
1518
1519# 7.7.65.2 LE Advertising Report event
1520# HCI_LE_Advertising_Report
1521# TODO: b/265052417 - Definition needs to be added
1522
1523
1524struct LEAdvertisingReportData:
1525  0     [+1]                          LEAdvertisingEventType  event_type
1526  $next [+1]                          hci.LEAddressType       address_type
1527  $next [+hci.BdAddr.$size_in_bytes]  hci.BdAddr              address
1528  $next [+1]                          UInt                    data_length
1529    -- Length of the |data| field for the device which responded.
1530    [requires: 0 <= this <= 0x1F]
1531
1532  $next [+data_length]                UInt:8[data_length]     data
1533    -- |data_length| octets of advertising or scan response data formatted as defined in Core
1534    -- Spec [Vol 3] Part C, Section 11. Note: Each element of this array has a variable length.
1535
1536  $next [+1]                          Int                     rssi
1537    -- Units: dBm. A value of 0x7F means RSSI is not available.
1538    [requires: -127 <= this <= 20 || this == 0x7F]
1539
1540
1541struct LEAdvertisingReportSubevent:
1542  0     [+LEMetaEvent.$size_in_bytes]  LEMetaEvent           le_meta_event
1543  $next [+1]                           UInt                  num_reports
1544    [requires: this <= 0x19]
1545
1546  # The -1 at the end is sizeof(num_reports).
1547  let reports_size = le_meta_event.header.parameter_total_size-(LEMetaEvent.$size_in_bytes-hci.EventHeader.$size_in_bytes)-1
1548  $next [+reports_size]                UInt:8[reports_size]  reports
1549    -- Since each report has a variable length, they are stored in a UInt:8 array.
1550
1551
1552struct LEConnectionUpdateCompleteSubevent:
1553  -- 7.7.65.3 LE Connection Update Complete event
1554  -- HCI_LE_Connection_Update_Complete
1555
1556  0     [+LEMetaEvent.$size_in_bytes]  LEMetaEvent     le_meta_event
1557
1558  $next [+1]                           hci.StatusCode  status
1559
1560  $next [+2]                           UInt            connection_handle
1561    -- Only the lower 12-bits are meaningful.
1562    [requires: 0x0000 <= this <= 0x0EFF]
1563
1564  $next [+2]                           UInt            connection_interval
1565    -- Time: N * 1.25 ms
1566    -- Range: 7.5 ms to 4 s
1567    [requires: 0x0006 <= this <= 0x0C80]
1568
1569  $next [+2]                           UInt            peripheral_latency
1570    [requires: 0x0000 <= this <= 0x01F3]
1571
1572  $next [+2]                           UInt            supervision_timeout
1573    -- Time: N * 10 ms
1574    -- Range: 100 ms to 32 s
1575    [requires: 0x000A <= this <= 0x0C80]
1576
1577
1578struct LEReadRemoteFeaturesCompleteSubevent:
1579  -- 7.7.65.4 LE Read Remote Features Complete event
1580  -- HCI_LE_Read_Remote_Features_Complete
1581  0     [+LEMetaEvent.$size_in_bytes]    LEMetaEvent     le_meta_event
1582  $next [+1]                             hci.StatusCode  status
1583  $next [+2]                             UInt            connection_handle
1584    -- Only the lower 12-bits are meaningful.
1585    [requires: 0x0000 <= this <= 0x0EFF]
1586
1587  $next [+8]  bits:
1588    0     [+LEFeatureSet.$size_in_bits]  LEFeatureSet    le_features
1589
1590
1591struct LELongTermKeyRequestSubevent:
1592  -- 7.7.65.5 LE Long Term Key Request event (v4.0) (LE)
1593  -- HCI_LE_Long_Term_Key_Request
1594  0     [+LEMetaEvent.$size_in_bytes]  LEMetaEvent  le_meta_event
1595  $next [+2]                           UInt         connection_handle
1596    [requires: 0x0000 <= this <= 0x0EFF]
1597
1598  $next [+8]                           UInt         random_number
1599  $next [+2]                           UInt         encrypted_diversifier
1600
1601# 7.7.65.6 LE Remote Connection Parameter Request event
1602# HCI_LE_Remote_Connection_Parameter_Request
1603# TODO: b/265052417 - Definition needs to be added
1604
1605
1606# 7.7.65.7 LE Data Length Change event
1607# HCI_LE_Data_Length_Change
1608# TODO: b/265052417 - Definition needs to be added
1609
1610
1611# 7.7.65.8 LE Read Local P-256 Public Key Complete event
1612# HCI_LE_Read_Local_P-256_Public_Key_Complete
1613# TODO: b/265052417 - Definition needs to be added
1614
1615
1616# 7.7.65.9 LE Generate DHKey Complete event
1617# HCI_LE_Generate_DHKey_Complete
1618# TODO: b/265052417 - Definition needs to be added
1619
1620
1621struct LEEnhancedConnectionCompleteSubeventV1:
1622  -- 7.7.65.10 LE Enhanced Connection Complete event
1623  -- HCI_LE_Enhanced_Connection_Complete
1624  0     [+LEMetaEvent.$size_in_bytes]  LEMetaEvent         le_meta_event
1625  $next [+1]                           hci.StatusCode      status
1626  $next [+2]                           UInt                connection_handle
1627    [requires: 0x0000 <= this <= 0x0EFF]
1628
1629  $next [+1]                           hci.ConnectionRole  role
1630  $next [+1]                           hci.LEAddressType   peer_address_type
1631  $next [+hci.BdAddr.$size_in_bytes]   hci.BdAddr          peer_address
1632  $next [+hci.BdAddr.$size_in_bytes]   hci.BdAddr          local_resolvable_private_address
1633  $next [+hci.BdAddr.$size_in_bytes]   hci.BdAddr          peer_resolvable_private_address
1634  $next [+2]                           UInt                connection_interval
1635    -- Time: N * 1.25 ms
1636    -- Range: 7.5 ms to 4 s
1637    [requires: 0x0006 <= this <= 0x0C80]
1638
1639  $next [+2]                           UInt                peripheral_latency
1640    [requires: 0x0000 <= this <= 0x01F3]
1641
1642  $next [+2]                           UInt                supervision_timeout
1643    -- Time: N * 10 ms
1644    -- Range: 100 ms to 32 s
1645    [requires: 0x000A <= this <= 0x0C80]
1646
1647  $next [+1]                           LEClockAccuracy     central_clock_accuracy
1648    -- Only valid for a peripheral. On a central, this parameter shall be set to 0x00.
1649
1650# 7.7.65.10 LE Enhanced Connection Complete event
1651# HCI_LE_Enhanced_Connection_Complete
1652# TODO: b/265052417 - Definition needs to be added
1653
1654
1655# 7.7.65.11 LE Directed Advertising Report event
1656# HCI_LE_Directed_Advertising_Report
1657# TODO: b/265052417 - Definition needs to be added
1658
1659
1660# 7.7.65.12 LE PHY Update Complete event
1661# HCI_LE_PHY_Update_Complete
1662# TODO: b/265052417 - Definition needs to be added
1663
1664
1665struct LEExtendedAdvertisingReportData:
1666  0     [+2]  bits:
1667
1668    0     [+LEExtendedAdvertisingEventType.$size_in_bits]  LEExtendedAdvertisingEventType  event_type
1669
1670  $next [+1]                                               hci.LEExtendedAddressType       address_type
1671    -- Address type of the advertiser.
1672
1673  $next [+hci.BdAddr.$size_in_bytes]                       hci.BdAddr                      address
1674    -- Public Device Address, Random Device Address, Public Identity Address or
1675    -- Random (static) Identity Address of the advertising device.
1676
1677  $next [+1]                                               hci.LEPrimaryAdvertisingPHY     primary_phy
1678    -- Indicates the PHY used to send the advertising PDU on the primary advertising
1679    -- channel. Legacy PDUs always use LE_1M. NONE, LE_2M, and LE_CODED_S2 are excluded.
1680
1681  $next [+1]                                               hci.LESecondaryAdvertisingPHY   secondary_phy
1682    -- Indicates the PHY used to send the advertising PDU(s), if any, on the secondary
1683    -- advertising channel. A value of NONE means that no packets were received on the
1684    -- secondary advertising channel.
1685
1686  $next [+1]                                               UInt                            advertising_sid
1687    -- Value of the Advertising SID subfield in the ADI field of the PDU. A value of
1688    -- 0xFF means no ADI field provided.
1689    [requires: 0x00 <= this <= 0x0F || this == 0xFF]
1690
1691  $next [+1]                                               Int                             tx_power
1692    -- Units: dBm. A value of 0x7F means Tx Power information is not available.
1693    [requires: -127 <= this <= 20 || this == 0x7F]
1694
1695  $next [+1]                                               Int                             rssi
1696    -- Units: dBm. A value of 0x7F means RSSI is not available.
1697    [requires: -127 <= this <= 20 || this == 0x7F]
1698
1699  $next [+2]                                               UInt                            periodic_advertising_interval
1700    -- 0x0000: No periodic advertising.
1701    -- 0xXXXX:
1702    --   Time = N * 1.25 ms
1703    --   Time Range: 7.5 ms to 81,918.75 s
1704    [requires: 0x0006 <= this <= 0xFFFF || this == 0x0000]
1705
1706  $next [+1]                                               LEDirectAddressType             direct_address_type
1707
1708  $next [+hci.BdAddr.$size_in_bytes]                       hci.BdAddr                      direct_address
1709    -- TargetA field in the advertisement or either Public Identity Address or Random (static)
1710    -- Identity Address of the target device.
1711
1712  let data_length_max = 229
1713
1714  $next [+1]                                               UInt                            data_length
1715    -- Length of the |data| field.
1716    # NOTE(https://github.com/google/emboss/issues/124): Emboss doesn't
1717    # currently support referring to other fields (i.e. virtual fields) when
1718    # [requires] itself is set on a field.
1719    [requires: 0 <= this <= 229]
1720
1721  $next [+data_length]                                     UInt:8[data_length]             data
1722    -- |data_length| octets of advertising or scan response data formatted as defined in
1723    -- [Vol 3] Part C, Section 11. Note: Each element of this array has a variable length.
1724
1725
1726struct LEExtendedAdvertisingReportSubevent(reports_size: UInt:8):
1727  -- 7.7.65.13 LE Extended Advertising Report event (v5.0) (LE)
1728  -- HCI_LE_Extended_Advertising_Report
1729  0     [+LEMetaEvent.$size_in_bytes]  LEMetaEvent           le_meta_event
1730  $next [+1]                           UInt                  num_reports
1731    -- Number of separate reports in the event.
1732    [requires: 0x01 <= this <= 0x0A]
1733
1734  $next [+reports_size]                UInt:8[reports_size]  reports
1735    -- Since each report has a variable length, they are stored in a UInt:8 array.
1736
1737# 7.7.65.14 LE Periodic Advertising Sync Established event
1738# HCI_LE_Periodic_Advertising_Sync_Established
1739# TODO: b/265052417 - Definition needs to be added
1740
1741
1742# 7.7.65.15 LE Periodic Advertising Report event
1743# HCI_LE_Periodic_Advertising_Report
1744# TODO: b/265052417 - Definition needs to be added
1745
1746
1747# 7.7.65.16 LE Periodic Advertising Sync Lost event
1748# HCI_LE_Periodic_Advertising_Sync_Lost
1749# TODO: b/265052417 - Definition needs to be added
1750
1751
1752struct LEScanTimeoutSubevent:
1753  -- 7.7.65.17 LE Scan Timeout event
1754  -- HCI_LE_Scan_Timeout
1755  0 [+LEMetaEvent.$size_in_bytes]  LEMetaEvent  le_meta_event
1756
1757# 7.7.65.18 LE Advertising Set Terminated event
1758# HCI_LE_Advertising_Set_Terminated
1759# TODO: b/265052417 - Definition needs to be added
1760
1761
1762# 7.7.65.19 LE Scan Request Received event
1763# HCI_LE_Scan_Request_Received
1764# TODO: b/265052417 - Definition needs to be added
1765
1766
1767struct LEChannelSelectionAlgorithmSubevent:
1768  -- 7.7.65.20 LE Channel Selection Algorithm event
1769  -- HCI_LE_Channel_Selection_Algorithm
1770  0     [+LEMetaEvent.$size_in_bytes]  LEMetaEvent                  le_meta_event
1771  $next [+2]                           UInt                         connection_handle
1772    -- Only the lower 12-bits are meaningful.
1773    [requires: 0x0000 <= this <= 0x0EFF]
1774
1775  $next [+1]                           LEChannelSelectionAlgorithm  channel_selection_algorithm
1776
1777# 7.7.65.21 LE Connectionless IQ Report event
1778# HCI_LE_Connectionless_IQ_Report
1779# TODO: b/265052417 - Definition needs to be added
1780
1781
1782# 7.7.65.22 LE Connection IQ Report event
1783# HCI_LE_Connection_IQ_Report
1784# TODO: b/265052417 - Definition needs to be added
1785
1786
1787# 7.7.65.23 LE CTE Request Failed event
1788# HCI_LE_CTE_Request_Failed
1789# TODO: b/265052417 - Definition needs to be added
1790
1791
1792# 7.7.65.24 LE Periodic Advertising Sync Transfer Received event
1793# HCI_LE_Periodic_Advertising_Sync_Transfer_Received
1794# TODO: b/265052417 - Definition needs to be added
1795
1796
1797struct LECISEstablishedSubevent:
1798  -- 7.7.65.25 LE CIS Established event
1799  -- HCI_LE_CIS_Established
1800
1801  0     [+LEMetaEvent.$size_in_bytes]  LEMetaEvent     le_meta_event
1802
1803  $next [+1]                           hci.StatusCode  status
1804
1805  $next [+2]                           UInt            connection_handle
1806    -- Connection handle of the CIS. Only the lower 12 bits are meaningful.
1807    [requires: 0x0000 <= 0x0EFF]
1808
1809  $next [+3]                           UInt            cig_sync_delay
1810    -- The maximum time, in microseconds, for transmission of PDUs of all CISes
1811    -- in a CIG event.
1812    [requires: 0x0000EA <= 0x7FFFFF]
1813
1814  $next [+3]                           UInt            cis_sync_delay
1815    -- The maximum time, in microseconds, for transmission of PDUs of the
1816    -- specified CIS in a CIG event.
1817    [requires: 0x0000EA <= 0x7FFFFF]
1818
1819  $next [+3]                           UInt            transport_latency_c_to_p
1820    -- The actual transport latency, in microseconds, from Central to
1821    -- Peripheral.
1822    [requires: 0x0000EA <= 0x7FFFFF]
1823
1824  $next [+3]                           UInt            transport_latency_p_to_c
1825    -- The actual transport latency, in microseconds, from Peripheral to
1826    -- Central.
1827    [requires: 0x0000EA <= 0x7FFFFF]
1828
1829  $next [+1]                           IsoPhyType      phy_c_to_p
1830    -- PHY used by the Central to transmit
1831
1832  $next [+1]                           IsoPhyType      phy_p_to_c
1833    -- PHY used by the Peripheral to transmit
1834
1835  $next [+1]                           UInt            nse
1836    -- Maximum number of subevents in each CIS event
1837    [requires: 0x01 <= 0x1F]
1838
1839  $next [+1]                           UInt            bn_c_to_p
1840    -- The burst number for Central to Peripheral transmission.
1841    -- 0 indicates no isochronous data from the Central to the Peripheral.
1842    [requires: 0x00 <= 0x0F]
1843
1844  $next [+1]                           UInt            bn_p_to_c
1845    -- The burst number for Peripheral to Central transmission.
1846    -- 0 indicates no isochronous data from the Peripheral to the Central.
1847    [requires: 0x00 <= 0x0F]
1848
1849  $next [+1]                           UInt            ft_c_to_p
1850    -- The flush timeout, in multiples of the ISO_Interval for the CIS, for each
1851    -- payload sent from the Central to the Peripheral.
1852    [requires: 0x01 <= 0xFF]
1853
1854  $next [+1]                           UInt            ft_p_to_c
1855    -- The flush timeout, in multiples of the ISO_Interval for the CIS, for each
1856    -- payload sent from the Peripheral to the Central.
1857    [requires: 0x01 <= 0xFF]
1858
1859  $next [+2]                           UInt            max_pdu_c_to_p
1860    -- Maximum size, in octets, of the payload from Central to Peripheral.
1861    [requires: 0x0000 <= 0x00FB]
1862
1863  $next [+2]                           UInt            max_pdu_p_to_c
1864    -- Maximum size, in octets, of the payload from Peripheral to Central.
1865    [requires: 0x0000 <= 0x00FB]
1866
1867  $next [+2]                           UInt            iso_interval
1868    -- The time between two consecutive CIS anchor points.
1869    -- Time = N * 1.25ms
1870    -- Time Range: 5ms to 4s
1871    [requires: 0x0004 <= 0x0C80]
1872
1873
1874struct LECISRequestSubevent:
1875  -- 7.7.65.26 LE CIS Request event
1876  -- HCI_LE_CIS_Request
1877
1878  0     [+LEMetaEvent.$size_in_bytes]  LEMetaEvent  le_meta_event
1879
1880  $next [+2]                           UInt         acl_connection_handle
1881    -- Only the lower 12 bits are meaningful.
1882    [requires: 0x0000 <= 0x0EFF]
1883
1884  $next [+2]                           UInt         cis_connection_handle
1885    -- Only the lower 12 bits are meaningful.
1886    [requires: 0x0000 <= 0x0EFF]
1887
1888  $next [+1]                           UInt         cig_id
1889    [requires: 0x00 <= 0xEF]
1890
1891  $next [+1]                           UInt         cis_id
1892    [requires: 0x00 <= 0xEF]
1893
1894# 7.7.65.27 LE Create BIG Complete event
1895# HCI_LE_Create_BIG_Complete
1896# TODO: b/265052417 - Definition needs to be added
1897
1898
1899# 7.7.65.28 LE Terminate BIG Complete event
1900# HCI_LE_Terminate_BIG_Complete
1901# TODO: b/265052417 - Definition needs to be added
1902
1903
1904# 7.7.65.29 LE BIG Sync Established event
1905# HCI_LE_BIG_Sync_Established
1906# TODO: b/265052417 - Definition needs to be added
1907
1908
1909# 7.7.65.30 LE BIG Sync Lost event
1910# HCI_LE_BIG_Sync_Lost
1911# TODO: b/265052417 - Definition needs to be added
1912
1913
1914struct LERequestPeerSCACompleteSubevent:
1915  -- 7.7.65.31 LE Request Peer SCA Complete event
1916  -- HCI_LE_Request_Peer_SCA_Complete
1917  0     [+LEMetaEvent.$size_in_bytes]  LEMetaEvent                    le_meta_event
1918  $next [+1]                           hci.StatusCode                 status
1919  $next [+2]                           UInt                           connection_handle
1920    -- Connection handle of the ACL connection. Only the lower 12-bits are meaningful.
1921    [requires: 0x0000 <= this <= 0x0EFF]
1922
1923  $next [+1]                           hci.LESleepClockAccuracyRange  peer_clock_accuracy
1924
1925# 7.7.65.32 LE Path Loss Threshold event
1926# HCI_LE_Path_Loss_Threshold
1927# TODO: b/265052417 - Definition needs to be added
1928
1929
1930# 7.7.65.33 LE Transmit Power Reporting event
1931# HCI_LE_Transmit_Power_Reporting
1932# TODO: b/265052417 - Definition needs to be added
1933
1934
1935# 7.7.65.34 LE BIGInfo Advertising Report event
1936# HCI_LE_BIGInfo_Advertising_Report
1937# TODO: b/265052417 - Definition needs to be added
1938
1939
1940# 7.7.65.35 LE Subrate Change event
1941# HCI_LE_Subrate_Change
1942# TODO: b/265052417 - Definition needs to be added
1943
1944
1945# 7.7.65.36 LE Periodic Advertising Subevent Data Request event
1946# HCI_LE_Periodic_Advertising_Subevent_Data_Request
1947# TODO: b/265052417 - Definition needs to be added
1948
1949
1950# 7.7.65.37 LE Periodic Advertising Response Report event
1951# HCI_LE_Periodic_Advertising_Response_Report
1952# TODO: b/265052417 - Definition needs to be added
1953
1954
1955# 7.7.66 Triggered Clock Capture event
1956# HCI_Triggered_Clock_Capture
1957# TODO: b/265052417 - Definition needs to be added
1958
1959
1960# 7.7.67 Synchronization Train Complete event
1961# HCI_Synchronization_Train_Complete
1962# TODO: b/265052417 - Definition needs to be added
1963
1964
1965# 7.7.68 Synchronization Train Received event
1966# HCI_Synchronization_Train_Received
1967# TODO: b/265052417 - Definition needs to be added
1968
1969
1970# 7.7.69 Connectionless Peripheral Broadcast Receive event
1971# HCI_Connectionless_Peripheral_Broadcast_Receive
1972# TODO: b/265052417 - Definition needs to be added
1973
1974
1975# 7.7.70 Connectionless Peripheral Broadcast Timeout event
1976# HCI_Connectionless_Peripheral_Broadcast_Timeout
1977# TODO: b/265052417 - Definition needs to be added
1978
1979
1980# 7.7.71 Truncated Page Complete event
1981# HCI_Truncated_Page_Complete
1982# TODO: b/265052417 - Definition needs to be added
1983
1984
1985# 7.7.72 Peripheral Page Response Timeout event
1986# HCI_Peripheral_Page_Response_Timeout
1987# TODO: b/265052417 - Definition needs to be added
1988
1989
1990# 7.7.73 Connectionless Peripheral Broadcast Channel Map Change event
1991# HCI_Connectionless_Peripheral_Broadcast_Channel_Map_Change
1992# TODO: b/265052417 - Definition needs to be added
1993
1994
1995# 7.7.74 Inquiry Response Notification event
1996# HCI_Inquiry_Response_Notification
1997# TODO: b/265052417 - Definition needs to be added
1998
1999
2000# 7.7.75 Authenticated Payload Timeout Expired event
2001# HCI_Authenticated_Payload_Timeout_Expired
2002# TODO: b/265052417 - Definition needs to be added
2003
2004
2005# 7.7.76 SAM Status Change event
2006# HCI_SAM_Status_Change
2007# TODO: b/265052417 - Definition needs to be added
2008