• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1little_endian_packets
2
3custom_field Address : 48 "hci/"
4
5enum Enable : 8 {
6  DISABLED = 0x00,
7  ENABLED = 0x01,
8}
9
10// HCI ACL Packets
11
12enum PacketBoundaryFlag : 2 {
13  FIRST_NON_AUTOMATICALLY_FLUSHABLE = 0,
14  CONTINUING_FRAGMENT = 1,
15  FIRST_AUTOMATICALLY_FLUSHABLE = 2,
16}
17
18enum BroadcastFlag : 2 {
19  POINT_TO_POINT = 0,
20  ACTIVE_PERIPHERAL_BROADCAST = 1,
21}
22
23packet Acl {
24  handle : 12,
25  packet_boundary_flag : PacketBoundaryFlag,
26  broadcast_flag : BroadcastFlag,
27  _size_(_payload_) : 16,
28  _payload_,
29}
30
31// HCI SCO Packets
32
33enum PacketStatusFlag : 2 {
34  CORRECTLY_RECEIVED = 0,
35  POSSIBLY_INCOMPLETE = 1,
36  NO_DATA_RECEIVED = 2,
37  PARTIALLY_LOST = 3,
38}
39
40packet Sco {
41  handle : 12,
42  packet_status_flag : PacketStatusFlag,
43  _reserved_ : 2, // BroadcastFlag
44  _size_(data) : 8,
45  data : 8[],
46}
47
48// HCI Command Packets
49
50enum OpCode : 16 {
51  NONE = 0x0000,
52
53  // LINK_CONTROL
54  INQUIRY = 0x0401,
55  INQUIRY_CANCEL = 0x0402,
56  PERIODIC_INQUIRY_MODE = 0x0403,
57  EXIT_PERIODIC_INQUIRY_MODE = 0x0404,
58  CREATE_CONNECTION = 0x0405,
59  DISCONNECT = 0x0406,
60  ADD_SCO_CONNECTION = 0x0407,
61  CREATE_CONNECTION_CANCEL = 0x0408,
62  ACCEPT_CONNECTION_REQUEST = 0x0409,
63  REJECT_CONNECTION_REQUEST = 0x040A,
64  LINK_KEY_REQUEST_REPLY = 0x040B,
65  LINK_KEY_REQUEST_NEGATIVE_REPLY = 0x040C,
66  PIN_CODE_REQUEST_REPLY = 0x040D,
67  PIN_CODE_REQUEST_NEGATIVE_REPLY = 0x040E,
68  CHANGE_CONNECTION_PACKET_TYPE = 0x040F,
69  AUTHENTICATION_REQUESTED = 0x0411,
70  SET_CONNECTION_ENCRYPTION = 0x0413,
71  CHANGE_CONNECTION_LINK_KEY = 0x0415,
72  CENTRAL_LINK_KEY = 0x0417,
73  REMOTE_NAME_REQUEST = 0x0419,
74  REMOTE_NAME_REQUEST_CANCEL = 0x041A,
75  READ_REMOTE_SUPPORTED_FEATURES = 0x041B,
76  READ_REMOTE_EXTENDED_FEATURES = 0x041C,
77  READ_REMOTE_VERSION_INFORMATION = 0x041D,
78  READ_CLOCK_OFFSET = 0x041F,
79  READ_LMP_HANDLE = 0x0420,
80  SETUP_SYNCHRONOUS_CONNECTION = 0x0428,
81  ACCEPT_SYNCHRONOUS_CONNECTION = 0x0429,
82  REJECT_SYNCHRONOUS_CONNECTION = 0x042A,
83  IO_CAPABILITY_REQUEST_REPLY = 0x042B,
84  USER_CONFIRMATION_REQUEST_REPLY = 0x042C,
85  USER_CONFIRMATION_REQUEST_NEGATIVE_REPLY = 0x042D,
86  USER_PASSKEY_REQUEST_REPLY = 0x042E,
87  USER_PASSKEY_REQUEST_NEGATIVE_REPLY = 0x042F,
88  REMOTE_OOB_DATA_REQUEST_REPLY = 0x0430,
89  REMOTE_OOB_DATA_REQUEST_NEGATIVE_REPLY = 0x0433,
90  IO_CAPABILITY_REQUEST_NEGATIVE_REPLY = 0x0434,
91  ENHANCED_SETUP_SYNCHRONOUS_CONNECTION = 0x043D,
92  ENHANCED_ACCEPT_SYNCHRONOUS_CONNECTION = 0x043E,
93  TRUNCATED_PAGE = 0x043F,
94  TRUNCATED_PAGE_CANCEL = 0x0440,
95  SET_CONNECTIONLESS_PERIPHERAL_BROADCAST = 0x0441,
96  SET_CONNECTIONLESS_PERIPHERAL_BROADCAST_RECEIVE = 0x0442,
97  START_SYNCHRONIZATION_TRAIN = 0x0443,
98  RECEIVE_SYNCHRONIZATION_TRAIN = 0x0444,
99  REMOTE_OOB_EXTENDED_DATA_REQUEST_REPLY = 0x0445,
100
101  // LINK_POLICY
102  HOLD_MODE = 0x0801,
103  SNIFF_MODE = 0x0803,
104  EXIT_SNIFF_MODE = 0x0804,
105  QOS_SETUP = 0x0807,
106  ROLE_DISCOVERY = 0x0809,
107  SWITCH_ROLE = 0x080B,
108  READ_LINK_POLICY_SETTINGS = 0x080C,
109  WRITE_LINK_POLICY_SETTINGS = 0x080D,
110  READ_DEFAULT_LINK_POLICY_SETTINGS = 0x080E,
111  WRITE_DEFAULT_LINK_POLICY_SETTINGS = 0x080F,
112  FLOW_SPECIFICATION = 0x0810,
113  SNIFF_SUBRATING = 0x0811,
114
115  // CONTROLLER_AND_BASEBAND
116  SET_EVENT_MASK = 0x0C01,
117  RESET = 0x0C03,
118  SET_EVENT_FILTER = 0x0C05,
119  FLUSH = 0x0C08,
120  READ_PIN_TYPE = 0x0C09,
121  WRITE_PIN_TYPE = 0x0C0A,
122  READ_STORED_LINK_KEY = 0x0C0D,
123  WRITE_STORED_LINK_KEY = 0x0C11,
124  DELETE_STORED_LINK_KEY = 0x0C12,
125  WRITE_LOCAL_NAME = 0x0C13,
126  READ_LOCAL_NAME = 0x0C14,
127  READ_CONNECTION_ACCEPT_TIMEOUT = 0x0C15,
128  WRITE_CONNECTION_ACCEPT_TIMEOUT = 0x0C16,
129  READ_PAGE_TIMEOUT = 0x0C17,
130  WRITE_PAGE_TIMEOUT = 0x0C18,
131  READ_SCAN_ENABLE = 0x0C19,
132  WRITE_SCAN_ENABLE = 0x0C1A,
133  READ_PAGE_SCAN_ACTIVITY = 0x0C1B,
134  WRITE_PAGE_SCAN_ACTIVITY = 0x0C1C,
135  READ_INQUIRY_SCAN_ACTIVITY = 0x0C1D,
136  WRITE_INQUIRY_SCAN_ACTIVITY = 0x0C1E,
137  READ_AUTHENTICATION_ENABLE = 0x0C1F,
138  WRITE_AUTHENTICATION_ENABLE = 0x0C20,
139  READ_CLASS_OF_DEVICE = 0x0C23,
140  WRITE_CLASS_OF_DEVICE = 0x0C24,
141  READ_VOICE_SETTING = 0x0C25,
142  WRITE_VOICE_SETTING = 0x0C26,
143  READ_AUTOMATIC_FLUSH_TIMEOUT = 0x0C27,
144  WRITE_AUTOMATIC_FLUSH_TIMEOUT = 0x0C28,
145  READ_NUM_BROADCAST_RETRANSMITS = 0x0C29,
146  WRITE_NUM_BROADCAST_RETRANSMITS = 0x0C2A,
147  READ_HOLD_MODE_ACTIVITY = 0x0C2B,
148  WRITE_HOLD_MODE_ACTIVITY = 0x0C2C,
149  READ_TRANSMIT_POWER_LEVEL = 0x0C2D,
150  READ_SYNCHRONOUS_FLOW_CONTROL_ENABLE = 0x0C2E,
151  WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE = 0x0C2F,
152  SET_CONTROLLER_TO_HOST_FLOW_CONTROL = 0x0C31,
153  HOST_BUFFER_SIZE = 0x0C33,
154  HOST_NUMBER_OF_COMPLETED_PACKETS = 0x0C35,
155  READ_LINK_SUPERVISION_TIMEOUT = 0x0C36,
156  WRITE_LINK_SUPERVISION_TIMEOUT = 0x0C37,
157  READ_NUMBER_OF_SUPPORTED_IAC = 0x0C38,
158  READ_CURRENT_IAC_LAP = 0x0C39,
159  WRITE_CURRENT_IAC_LAP = 0x0C3A,
160  SET_AFH_HOST_CHANNEL_CLASSIFICATION = 0x0C3F,
161  READ_INQUIRY_SCAN_TYPE = 0x0C42,
162  WRITE_INQUIRY_SCAN_TYPE = 0x0C43,
163  READ_INQUIRY_MODE = 0x0C44,
164  WRITE_INQUIRY_MODE = 0x0C45,
165  READ_PAGE_SCAN_TYPE = 0x0C46,
166  WRITE_PAGE_SCAN_TYPE = 0x0C47,
167  READ_AFH_CHANNEL_ASSESSMENT_MODE = 0x0C48,
168  WRITE_AFH_CHANNEL_ASSESSMENT_MODE = 0x0C49,
169  READ_EXTENDED_INQUIRY_RESPONSE = 0x0C51,
170  WRITE_EXTENDED_INQUIRY_RESPONSE = 0x0C52,
171  REFRESH_ENCRYPTION_KEY = 0x0C53,
172  READ_SIMPLE_PAIRING_MODE = 0x0C55,
173  WRITE_SIMPLE_PAIRING_MODE = 0x0C56,
174  READ_LOCAL_OOB_DATA = 0x0C57,
175  READ_INQUIRY_RESPONSE_TRANSMIT_POWER_LEVEL = 0x0C58,
176  WRITE_INQUIRY_TRANSMIT_POWER_LEVEL = 0x0C59,
177  READ_DEFAULT_ERRONEOUS_DATA_REPORTING = 0x0C5A,
178  WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING = 0x0C5B,
179  ENHANCED_FLUSH = 0x0C5F,
180  SEND_KEYPRESS_NOTIFICATION = 0x0C60,
181  SET_EVENT_MASK_PAGE_2 = 0x0C63,
182  READ_FLOW_CONTROL_MODE = 0x0C66,
183  WRITE_FLOW_CONTROL_MODE = 0x0C67,
184  READ_ENHANCED_TRANSMIT_POWER_LEVEL = 0x0C68,
185  READ_LE_HOST_SUPPORT = 0x0C6C,
186  WRITE_LE_HOST_SUPPORT = 0x0C6D,
187  SET_MWS_CHANNEL_PARAMETERS = 0x0C6E,
188  SET_EXTERNAL_FRAME_CONFIGURATION = 0x0C6F,
189  SET_MWS_SIGNALING = 0x0C70,
190  SET_MWS_TRANSPORT_LAYER = 0x0C71,
191  SET_MWS_SCAN_FREQUENCY_TABLE = 0x0C72,
192  SET_MWS_PATTERN_CONFIGURATION = 0x0C73,
193  SET_RESERVED_LT_ADDR = 0x0C74,
194  DELETE_RESERVED_LT_ADDR = 0x0C75,
195  SET_CONNECTIONLESS_PERIPHERAL_BROADCAST_DATA = 0x0C76,
196  READ_SYNCHRONIZATION_TRAIN_PARAMETERS = 0x0C77,
197  WRITE_SYNCHRONIZATION_TRAIN_PARAMETERS = 0x0C78,
198  READ_SECURE_CONNECTIONS_HOST_SUPPORT = 0x0C79,
199  WRITE_SECURE_CONNECTIONS_HOST_SUPPORT = 0x0C7A,
200  READ_AUTHENTICATED_PAYLOAD_TIMEOUT = 0x0C7B,
201  WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT = 0x0C7C,
202  READ_LOCAL_OOB_EXTENDED_DATA = 0x0C7D,
203  READ_EXTENDED_PAGE_TIMEOUT = 0x0C7E,
204  WRITE_EXTENDED_PAGE_TIMEOUT = 0x0C7F,
205  READ_EXTENDED_INQUIRY_LENGTH = 0x0C80,
206  WRITE_EXTENDED_INQUIRY_LENGTH = 0x0C81,
207  SET_ECOSYSTEM_BASE_INTERVAL = 0x0C82,
208  CONFIGURE_DATA_PATH = 0x0C83,
209  SET_MIN_ENCRYPTION_KEY_SIZE = 0x0C84,
210
211  // INFORMATIONAL_PARAMETERS
212  READ_LOCAL_VERSION_INFORMATION = 0x1001,
213  READ_LOCAL_SUPPORTED_COMMANDS = 0x1002,
214  READ_LOCAL_SUPPORTED_FEATURES = 0x1003,
215  READ_LOCAL_EXTENDED_FEATURES = 0x1004,
216  READ_BUFFER_SIZE = 0x1005,
217  READ_BD_ADDR = 0x1009,
218  READ_DATA_BLOCK_SIZE = 0x100A,
219  READ_LOCAL_SUPPORTED_CODECS_V1 = 0x100B,
220  READ_LOCAL_SIMPLE_PAIRING_OPTIONS = 0x100C,
221  READ_LOCAL_SUPPORTED_CODECS_V2 = 0x100D,
222  READ_LOCAL_SUPPORTED_CODEC_CAPABILITIES = 0x100E,
223  READ_LOCAL_SUPPORTED_CONTROLLER_DELAY = 0x100F,
224
225  // STATUS_PARAMETERS
226  READ_FAILED_CONTACT_COUNTER = 0x1401,
227  RESET_FAILED_CONTACT_COUNTER = 0x1402,
228  READ_LINK_QUALITY = 0x1403,
229  READ_RSSI = 0x1405,
230  READ_AFH_CHANNEL_MAP = 0x1406,
231  READ_CLOCK = 0x1407,
232  READ_ENCRYPTION_KEY_SIZE = 0x1408,
233  GET_MWS_TRANSPORT_LAYER_CONFIGURATION = 0x140C,
234  SET_TRIGGERED_CLOCK_CAPTURE = 0x140D,
235
236  // TESTING
237  READ_LOOPBACK_MODE = 0x1801,
238  WRITE_LOOPBACK_MODE = 0x1802,
239  ENABLE_DEVICE_UNDER_TEST_MODE = 0x1803,
240  WRITE_SIMPLE_PAIRING_DEBUG_MODE = 0x1804,
241  WRITE_SECURE_CONNECTIONS_TEST_MODE = 0x180A,
242
243  // LE_CONTROLLER
244  LE_SET_EVENT_MASK = 0x2001,
245  LE_READ_BUFFER_SIZE_V1 = 0x2002,
246  LE_READ_LOCAL_SUPPORTED_FEATURES = 0x2003,
247  LE_SET_RANDOM_ADDRESS = 0x2005,
248  LE_SET_ADVERTISING_PARAMETERS = 0x2006,
249  LE_READ_ADVERTISING_PHYSICAL_CHANNEL_TX_POWER = 0x2007,
250  LE_SET_ADVERTISING_DATA = 0x2008,
251  LE_SET_SCAN_RESPONSE_DATA = 0x2009,
252  LE_SET_ADVERTISING_ENABLE = 0x200A,
253  LE_SET_SCAN_PARAMETERS = 0x200B,
254  LE_SET_SCAN_ENABLE = 0x200C,
255  LE_CREATE_CONNECTION = 0x200D,
256  LE_CREATE_CONNECTION_CANCEL = 0x200E,
257  LE_READ_FILTER_ACCEPT_LIST_SIZE = 0x200F,
258  LE_CLEAR_FILTER_ACCEPT_LIST = 0x2010,
259  LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST = 0x2011,
260  LE_REMOVE_DEVICE_FROM_FILTER_ACCEPT_LIST = 0x2012,
261  LE_CONNECTION_UPDATE = 0x2013,
262  LE_SET_HOST_CHANNEL_CLASSIFICATION = 0x2014,
263  LE_READ_CHANNEL_MAP = 0x2015,
264  LE_READ_REMOTE_FEATURES = 0x2016,
265  LE_ENCRYPT = 0x2017,
266  LE_RAND = 0x2018,
267  LE_START_ENCRYPTION = 0x2019,
268  LE_LONG_TERM_KEY_REQUEST_REPLY = 0x201A,
269  LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY = 0x201B,
270  LE_READ_SUPPORTED_STATES = 0x201C,
271  LE_RECEIVER_TEST_V1 = 0x201D,
272  LE_TRANSMITTER_TEST_V1 = 0x201E,
273  LE_TEST_END = 0x201F,
274  LE_REMOTE_CONNECTION_PARAMETER_REQUEST_REPLY = 0x2020,
275  LE_REMOTE_CONNECTION_PARAMETER_REQUEST_NEGATIVE_REPLY = 0x2021,
276  LE_SET_DATA_LENGTH = 0x2022,
277  LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH = 0x2023,
278  LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH = 0x2024,
279  LE_READ_LOCAL_P_256_PUBLIC_KEY = 0x2025,
280  LE_GENERATE_DHKEY_V1 = 0x2026,
281  LE_ADD_DEVICE_TO_RESOLVING_LIST = 0x2027,
282  LE_REMOVE_DEVICE_FROM_RESOLVING_LIST = 0x2028,
283  LE_CLEAR_RESOLVING_LIST = 0x2029,
284  LE_READ_RESOLVING_LIST_SIZE = 0x202A,
285  LE_READ_PEER_RESOLVABLE_ADDRESS = 0x202B,
286  LE_READ_LOCAL_RESOLVABLE_ADDRESS = 0x202C,
287  LE_SET_ADDRESS_RESOLUTION_ENABLE = 0x202D,
288  LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT = 0x202E,
289  LE_READ_MAXIMUM_DATA_LENGTH = 0x202F,
290  LE_READ_PHY = 0x2030,
291  LE_SET_DEFAULT_PHY = 0x2031,
292  LE_SET_PHY = 0x2032,
293  LE_RECEIVER_TEST_V2 = 0x2033,
294  LE_TRANSMITTER_TEST_V2 = 0x2034,
295  LE_SET_ADVERTISING_SET_RANDOM_ADDRESS = 0x2035,
296  LE_SET_EXTENDED_ADVERTISING_PARAMETERS = 0x2036,
297  LE_SET_EXTENDED_ADVERTISING_DATA = 0x2037,
298  LE_SET_EXTENDED_SCAN_RESPONSE_DATA = 0x2038,
299  LE_SET_EXTENDED_ADVERTISING_ENABLE = 0x2039,
300  LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH = 0x203A,
301  LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS = 0x203B,
302  LE_REMOVE_ADVERTISING_SET = 0x203C,
303  LE_CLEAR_ADVERTISING_SETS = 0x203D,
304  LE_SET_PERIODIC_ADVERTISING_PARAMETERS = 0x203E,
305  LE_SET_PERIODIC_ADVERTISING_DATA = 0x203F,
306  LE_SET_PERIODIC_ADVERTISING_ENABLE = 0x2040,
307  LE_SET_EXTENDED_SCAN_PARAMETERS = 0x2041,
308  LE_SET_EXTENDED_SCAN_ENABLE = 0x2042,
309  LE_EXTENDED_CREATE_CONNECTION = 0x2043,
310  LE_PERIODIC_ADVERTISING_CREATE_SYNC = 0x2044,
311  LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL = 0x2045,
312  LE_PERIODIC_ADVERTISING_TERMINATE_SYNC = 0x2046,
313  LE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST = 0x2047,
314  LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST = 0x2048,
315  LE_CLEAR_PERIODIC_ADVERTISER_LIST = 0x2049,
316  LE_READ_PERIODIC_ADVERTISER_LIST_SIZE = 0x204A,
317  LE_READ_TRANSMIT_POWER = 0x204B,
318  LE_READ_RF_PATH_COMPENSATION_POWER = 0x204C,
319  LE_WRITE_RF_PATH_COMPENSATION_POWER = 0x204D,
320  LE_SET_PRIVACY_MODE = 0x204E,
321  LE_RECEIVER_TEST_V3 = 0x204F,
322  LE_TRANSMITTER_TEST_V3 = 0x2050,
323  LE_SET_CONNECTIONLESS_CTE_TRANSMIT_PARAMETERS = 0x2051,
324  LE_SET_CONNECTIONLESS_CTE_TRANSMIT_ENABLE = 0x2052,
325  LE_SET_CONNECTIONLESS_IQ_SAMPLING_ENABLE = 0x2053,
326  LE_SET_CONNECTION_CTE_RECEIVE_PARAMETERS = 0x2054,
327  LE_SET_CONNECTION_CTE_TRANSMIT_PARAMETERS = 0x2055,
328  LE_CONNECTION_CTE_REQUEST_ENABLE = 0x2056,
329  LE_CONNECTION_CTE_RESPONSE_ENABLE = 0x2057,
330  LE_READ_ANTENNA_INFORMATION = 0x2058,
331  LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE = 0x2059,
332  LE_PERIODIC_ADVERTISING_SYNC_TRANSFER = 0x205A,
333  LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER = 0x205B,
334  LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS = 0x205C,
335  LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS = 0x205D,
336  LE_GENERATE_DHKEY_V2 = 0x205E,
337  LE_MODIFY_SLEEP_CLOCK_ACCURACY = 0x205F,
338  LE_READ_BUFFER_SIZE_V2 = 0x2060,
339  LE_READ_ISO_TX_SYNC = 0x2061,
340  LE_SET_CIG_PARAMETERS = 0x2062,
341  LE_SET_CIG_PARAMETERS_TEST = 0x2063,
342  LE_CREATE_CIS = 0x2064,
343  LE_REMOVE_CIG = 0x2065,
344  LE_ACCEPT_CIS_REQUEST = 0x2066,
345  LE_REJECT_CIS_REQUEST = 0x2067,
346  LE_CREATE_BIG = 0x2068,
347  LE_CREATE_BIG_TEST = 0x2069,
348  LE_TERMINATE_BIG = 0x206A,
349  LE_BIG_CREATE_SYNC = 0x206B,
350  LE_BIG_TERMINATE_SYNC = 0x206C,
351  LE_REQUEST_PEER_SCA = 0x206D,
352  LE_SETUP_ISO_DATA_PATH = 0x206E,
353  LE_REMOVE_ISO_DATA_PATH = 0x206F,
354  LE_ISO_TRANSMIT_TEST = 0x2070,
355  LE_ISO_RECEIVE_TEST = 0x2071,
356  LE_ISO_READ_TEST_COUNTERS = 0x2072,
357  LE_ISO_TEST_END = 0x2073,
358  LE_SET_HOST_FEATURE = 0x2074,
359  LE_READ_ISO_LINK_QUALITY = 0x2075,
360  LE_ENHANCED_READ_TRANSMIT_POWER_LEVEL = 0x2076,
361  LE_READ_REMOTE_TRANSMIT_POWER_LEVEL = 0x2077,
362  LE_SET_PATH_LOSS_REPORTING_PARAMETERS = 0x2078,
363  LE_SET_PATH_LOSS_REPORTING_ENABLE = 0x2079,
364  LE_SET_TRANSMIT_POWER_REPORTING_ENABLE = 0x207A,
365  LE_TRANSMITTER_TEST_V4 = 0x207B,
366  LE_SET_DATA_RELATED_ADDRESS_CHANGES = 0x207C,
367  LE_SET_DEFAULT_SUBRATE = 0x207D,
368  LE_SUBRATE_REQUEST = 0x207E,
369
370  // VENDOR_SPECIFIC
371  // MSFT_OPCODE_xxxx below is needed for the tests.
372  MSFT_OPCODE_INTEL = 0xFC1E,
373  LE_GET_VENDOR_CAPABILITIES = 0xFD53,
374  LE_BATCH_SCAN = 0xFD56,
375  LE_APCF = 0xFD57,
376  LE_GET_CONTROLLER_ACTIVITY_ENERGY_INFO = 0xFD59,
377  LE_EX_SET_SCAN_PARAMETERS = 0xFD5A,
378  GET_CONTROLLER_DEBUG_INFO = 0xFD5B,
379  // MSFT_OPCODE_xxxx below are needed for the tests.
380  MSFT_OPCODE_MEDIATEK = 0xFD30,
381  MSFT_OPCODE_QUALCOMM = 0xFD70,
382}
383
384// For mapping Local Supported Commands command
385// Value = Octet * 10 + bit
386enum OpCodeIndex : 16 {
387  INQUIRY = 0,
388  INQUIRY_CANCEL = 1,
389  PERIODIC_INQUIRY_MODE = 2,
390  EXIT_PERIODIC_INQUIRY_MODE = 3,
391  CREATE_CONNECTION = 4,
392  DISCONNECT = 5,
393  ADD_SCO_CONNECTION = 6,
394  CREATE_CONNECTION_CANCEL = 7,
395  ACCEPT_CONNECTION_REQUEST = 10,
396  REJECT_CONNECTION_REQUEST = 11,
397  LINK_KEY_REQUEST_REPLY = 12,
398  LINK_KEY_REQUEST_NEGATIVE_REPLY = 13,
399  PIN_CODE_REQUEST_REPLY = 14,
400  PIN_CODE_REQUEST_NEGATIVE_REPLY = 15,
401  CHANGE_CONNECTION_PACKET_TYPE = 16,
402  AUTHENTICATION_REQUESTED = 17,
403  SET_CONNECTION_ENCRYPTION = 20,
404  CHANGE_CONNECTION_LINK_KEY = 21,
405  CENTRAL_LINK_KEY = 22,
406  REMOTE_NAME_REQUEST = 23,
407  REMOTE_NAME_REQUEST_CANCEL = 24,
408  READ_REMOTE_SUPPORTED_FEATURES = 25,
409  READ_REMOTE_EXTENDED_FEATURES = 26,
410  READ_REMOTE_VERSION_INFORMATION = 27,
411  READ_CLOCK_OFFSET = 30,
412  READ_LMP_HANDLE = 31,
413  HOLD_MODE = 41,
414  SNIFF_MODE = 42,
415  EXIT_SNIFF_MODE = 43,
416  QOS_SETUP = 46,
417  ROLE_DISCOVERY = 47,
418  SWITCH_ROLE = 50,
419  READ_LINK_POLICY_SETTINGS = 51,
420  WRITE_LINK_POLICY_SETTINGS = 52,
421  READ_DEFAULT_LINK_POLICY_SETTINGS = 53,
422  WRITE_DEFAULT_LINK_POLICY_SETTINGS = 54,
423  FLOW_SPECIFICATION = 55,
424  SET_EVENT_MASK = 56,
425  RESET = 57,
426  SET_EVENT_FILTER = 60,
427  FLUSH = 61,
428  READ_PIN_TYPE = 62,
429  WRITE_PIN_TYPE = 63,
430  READ_STORED_LINK_KEY = 65,
431  WRITE_STORED_LINK_KEY = 66,
432  DELETE_STORED_LINK_KEY = 67,
433  WRITE_LOCAL_NAME = 70,
434  READ_LOCAL_NAME = 71,
435  READ_CONNECTION_ACCEPT_TIMEOUT = 72,
436  WRITE_CONNECTION_ACCEPT_TIMEOUT = 73,
437  READ_PAGE_TIMEOUT = 74,
438  WRITE_PAGE_TIMEOUT = 75,
439  READ_SCAN_ENABLE = 76,
440  WRITE_SCAN_ENABLE = 77,
441  READ_PAGE_SCAN_ACTIVITY = 80,
442  WRITE_PAGE_SCAN_ACTIVITY = 81,
443  READ_INQUIRY_SCAN_ACTIVITY = 82,
444  WRITE_INQUIRY_SCAN_ACTIVITY = 83,
445  READ_AUTHENTICATION_ENABLE = 84,
446  WRITE_AUTHENTICATION_ENABLE = 85,
447  READ_CLASS_OF_DEVICE = 90,
448  WRITE_CLASS_OF_DEVICE = 91,
449  READ_VOICE_SETTING = 92,
450  WRITE_VOICE_SETTING = 93,
451  READ_AUTOMATIC_FLUSH_TIMEOUT = 94,
452  WRITE_AUTOMATIC_FLUSH_TIMEOUT = 95,
453  READ_NUM_BROADCAST_RETRANSMITS = 96,
454  WRITE_NUM_BROADCAST_RETRANSMITS = 97,
455  READ_HOLD_MODE_ACTIVITY = 100,
456  WRITE_HOLD_MODE_ACTIVITY = 101,
457  READ_TRANSMIT_POWER_LEVEL = 102,
458  READ_SYNCHRONOUS_FLOW_CONTROL_ENABLE = 103,
459  WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE = 104,
460  SET_CONTROLLER_TO_HOST_FLOW_CONTROL = 105,
461  HOST_BUFFER_SIZE = 106,
462  HOST_NUMBER_OF_COMPLETED_PACKETS = 107,
463  READ_LINK_SUPERVISION_TIMEOUT = 110,
464  WRITE_LINK_SUPERVISION_TIMEOUT = 111,
465  READ_NUMBER_OF_SUPPORTED_IAC = 112,
466  READ_CURRENT_IAC_LAP = 113,
467  WRITE_CURRENT_IAC_LAP = 114,
468  SET_AFH_HOST_CHANNEL_CLASSIFICATION = 121,
469  READ_INQUIRY_SCAN_TYPE = 124,
470  WRITE_INQUIRY_SCAN_TYPE = 125,
471  READ_INQUIRY_MODE = 126,
472  WRITE_INQUIRY_MODE = 127,
473  READ_PAGE_SCAN_TYPE = 130,
474  WRITE_PAGE_SCAN_TYPE = 131,
475  READ_AFH_CHANNEL_ASSESSMENT_MODE = 132,
476  WRITE_AFH_CHANNEL_ASSESSMENT_MODE = 133,
477  READ_LOCAL_VERSION_INFORMATION = 143,
478  READ_LOCAL_SUPPORTED_FEATURES = 145,
479  READ_LOCAL_EXTENDED_FEATURES = 146,
480  READ_BUFFER_SIZE = 147,
481  READ_BD_ADDR = 151,
482  READ_FAILED_CONTACT_COUNTER = 152,
483  RESET_FAILED_CONTACT_COUNTER = 153,
484  READ_LINK_QUALITY = 154,
485  READ_RSSI = 155,
486  READ_AFH_CHANNEL_MAP = 156,
487  READ_CLOCK = 157,
488  READ_LOOPBACK_MODE = 160,
489  WRITE_LOOPBACK_MODE = 161,
490  ENABLE_DEVICE_UNDER_TEST_MODE = 162,
491  SETUP_SYNCHRONOUS_CONNECTION = 163,
492  ACCEPT_SYNCHRONOUS_CONNECTION = 164,
493  REJECT_SYNCHRONOUS_CONNECTION = 165,
494  READ_EXTENDED_INQUIRY_RESPONSE = 170,
495  WRITE_EXTENDED_INQUIRY_RESPONSE = 171,
496  REFRESH_ENCRYPTION_KEY = 172,
497  SNIFF_SUBRATING = 174,
498  READ_SIMPLE_PAIRING_MODE = 175,
499  WRITE_SIMPLE_PAIRING_MODE = 176,
500  READ_LOCAL_OOB_DATA = 177,
501  READ_INQUIRY_RESPONSE_TRANSMIT_POWER_LEVEL = 180,
502  WRITE_INQUIRY_TRANSMIT_POWER_LEVEL = 181,
503  READ_DEFAULT_ERRONEOUS_DATA_REPORTING = 182,
504  WRITE_DEFAULT_ERRONEOUS_DATA_REPORTING = 183,
505  IO_CAPABILITY_REQUEST_REPLY = 187,
506  USER_CONFIRMATION_REQUEST_REPLY = 190,
507  USER_CONFIRMATION_REQUEST_NEGATIVE_REPLY = 191,
508  USER_PASSKEY_REQUEST_REPLY = 192,
509  USER_PASSKEY_REQUEST_NEGATIVE_REPLY = 193,
510  REMOTE_OOB_DATA_REQUEST_REPLY = 194,
511  WRITE_SIMPLE_PAIRING_DEBUG_MODE = 195,
512  ENHANCED_FLUSH = 196,
513  REMOTE_OOB_DATA_REQUEST_NEGATIVE_REPLY = 197,
514  SEND_KEYPRESS_NOTIFICATION = 202,
515  IO_CAPABILITY_REQUEST_NEGATIVE_REPLY = 203,
516  READ_ENCRYPTION_KEY_SIZE = 204,
517  SET_EVENT_MASK_PAGE_2 = 222,
518  READ_FLOW_CONTROL_MODE = 230,
519  WRITE_FLOW_CONTROL_MODE = 231,
520  READ_DATA_BLOCK_SIZE = 232,
521  READ_ENHANCED_TRANSMIT_POWER_LEVEL = 240,
522  READ_LE_HOST_SUPPORT = 245,
523  WRITE_LE_HOST_SUPPORT = 246,
524  LE_SET_EVENT_MASK = 250,
525  LE_READ_BUFFER_SIZE_V1 = 251,
526  LE_READ_LOCAL_SUPPORTED_FEATURES = 252,
527  LE_SET_RANDOM_ADDRESS = 254,
528  LE_SET_ADVERTISING_PARAMETERS = 255,
529  LE_READ_ADVERTISING_PHYSICAL_CHANNEL_TX_POWER = 256,
530  LE_SET_ADVERTISING_DATA = 257,
531  LE_SET_SCAN_RESPONSE_DATA = 260,
532  LE_SET_ADVERTISING_ENABLE = 261,
533  LE_SET_SCAN_PARAMETERS = 262,
534  LE_SET_SCAN_ENABLE = 263,
535  LE_CREATE_CONNECTION = 264,
536  LE_CREATE_CONNECTION_CANCEL = 265,
537  LE_READ_FILTER_ACCEPT_LIST_SIZE = 266,
538  LE_CLEAR_FILTER_ACCEPT_LIST = 267,
539  LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST = 270,
540  LE_REMOVE_DEVICE_FROM_FILTER_ACCEPT_LIST = 271,
541  LE_CONNECTION_UPDATE = 272,
542  LE_SET_HOST_CHANNEL_CLASSIFICATION = 273,
543  LE_READ_CHANNEL_MAP = 274,
544  LE_READ_REMOTE_FEATURES = 275,
545  LE_ENCRYPT = 276,
546  LE_RAND = 277,
547  LE_START_ENCRYPTION = 280,
548  LE_LONG_TERM_KEY_REQUEST_REPLY = 281,
549  LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY = 282,
550  LE_READ_SUPPORTED_STATES = 283,
551  LE_RECEIVER_TEST_V1 = 284,
552  LE_TRANSMITTER_TEST_V1 = 285,
553  LE_TEST_END = 286,
554  ENHANCED_SETUP_SYNCHRONOUS_CONNECTION = 293,
555  ENHANCED_ACCEPT_SYNCHRONOUS_CONNECTION = 294,
556  READ_LOCAL_SUPPORTED_CODECS_V1 = 295,
557  SET_MWS_CHANNEL_PARAMETERS = 296,
558  SET_EXTERNAL_FRAME_CONFIGURATION = 297,
559  SET_MWS_SIGNALING = 300,
560  SET_MWS_TRANSPORT_LAYER = 301,
561  SET_MWS_SCAN_FREQUENCY_TABLE = 302,
562  GET_MWS_TRANSPORT_LAYER_CONFIGURATION = 303,
563  SET_MWS_PATTERN_CONFIGURATION = 304,
564  SET_TRIGGERED_CLOCK_CAPTURE = 305,
565  TRUNCATED_PAGE = 306,
566  TRUNCATED_PAGE_CANCEL = 307,
567  SET_CONNECTIONLESS_PERIPHERAL_BROADCAST = 310,
568  SET_CONNECTIONLESS_PERIPHERAL_BROADCAST_RECEIVE = 311,
569  START_SYNCHRONIZATION_TRAIN = 312,
570  RECEIVE_SYNCHRONIZATION_TRAIN = 313,
571  SET_RESERVED_LT_ADDR = 314,
572  DELETE_RESERVED_LT_ADDR = 315,
573  SET_CONNECTIONLESS_PERIPHERAL_BROADCAST_DATA = 316,
574  READ_SYNCHRONIZATION_TRAIN_PARAMETERS = 317,
575  WRITE_SYNCHRONIZATION_TRAIN_PARAMETERS = 320,
576  REMOTE_OOB_EXTENDED_DATA_REQUEST_REPLY = 321,
577  READ_SECURE_CONNECTIONS_HOST_SUPPORT = 322,
578  WRITE_SECURE_CONNECTIONS_HOST_SUPPORT = 323,
579  READ_AUTHENTICATED_PAYLOAD_TIMEOUT = 324,
580  WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT = 325,
581  READ_LOCAL_OOB_EXTENDED_DATA = 326,
582  WRITE_SECURE_CONNECTIONS_TEST_MODE = 327,
583  READ_EXTENDED_PAGE_TIMEOUT = 330,
584  WRITE_EXTENDED_PAGE_TIMEOUT = 331,
585  READ_EXTENDED_INQUIRY_LENGTH = 332,
586  WRITE_EXTENDED_INQUIRY_LENGTH = 333,
587  LE_REMOTE_CONNECTION_PARAMETER_REQUEST_REPLY = 334,
588  LE_REMOTE_CONNECTION_PARAMETER_REQUEST_NEGATIVE_REPLY = 335,
589  LE_SET_DATA_LENGTH = 336,
590  LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH = 337,
591  LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH = 340,
592  LE_READ_LOCAL_P_256_PUBLIC_KEY = 341,
593  LE_GENERATE_DHKEY_V1 = 342,
594  LE_ADD_DEVICE_TO_RESOLVING_LIST = 343,
595  LE_REMOVE_DEVICE_FROM_RESOLVING_LIST = 344,
596  LE_CLEAR_RESOLVING_LIST = 345,
597  LE_READ_RESOLVING_LIST_SIZE = 346,
598  LE_READ_PEER_RESOLVABLE_ADDRESS = 347,
599  LE_READ_LOCAL_RESOLVABLE_ADDRESS = 350,
600  LE_SET_ADDRESS_RESOLUTION_ENABLE = 351,
601  LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT = 352,
602  LE_READ_MAXIMUM_DATA_LENGTH = 353,
603  LE_READ_PHY = 354,
604  LE_SET_DEFAULT_PHY = 355,
605  LE_SET_PHY = 356,
606  LE_RECEIVER_TEST_V2 = 357,
607  LE_TRANSMITTER_TEST_V2 = 360,
608  LE_SET_ADVERTISING_SET_RANDOM_ADDRESS = 361,
609  LE_SET_EXTENDED_ADVERTISING_PARAMETERS = 362,
610  LE_SET_EXTENDED_ADVERTISING_DATA = 363,
611  LE_SET_EXTENDED_SCAN_RESPONSE_DATA = 364,
612  LE_SET_EXTENDED_ADVERTISING_ENABLE = 365,
613  LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH = 366,
614  LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS = 367,
615  LE_REMOVE_ADVERTISING_SET = 370,
616  LE_CLEAR_ADVERTISING_SETS = 371,
617  LE_SET_PERIODIC_ADVERTISING_PARAMETERS = 372,
618  LE_SET_PERIODIC_ADVERTISING_DATA = 373,
619  LE_SET_PERIODIC_ADVERTISING_ENABLE = 374,
620  LE_SET_EXTENDED_SCAN_PARAMETERS = 375,
621  LE_SET_EXTENDED_SCAN_ENABLE = 376,
622  LE_EXTENDED_CREATE_CONNECTION = 377,
623  LE_PERIODIC_ADVERTISING_CREATE_SYNC = 380,
624  LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL = 381,
625  LE_PERIODIC_ADVERTISING_TERMINATE_SYNC = 382,
626  LE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST = 383,
627  LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST = 384,
628  LE_CLEAR_PERIODIC_ADVERTISER_LIST = 385,
629  LE_READ_PERIODIC_ADVERTISER_LIST_SIZE = 386,
630  LE_READ_TRANSMIT_POWER = 387,
631  LE_READ_RF_PATH_COMPENSATION_POWER = 390,
632  LE_WRITE_RF_PATH_COMPENSATION_POWER = 391,
633  LE_SET_PRIVACY_MODE = 392,
634  LE_RECEIVER_TEST_V3 = 393,
635  LE_TRANSMITTER_TEST_V3 = 394,
636  LE_SET_CONNECTIONLESS_CTE_TRANSMIT_PARAMETERS = 395,
637  LE_SET_CONNECTIONLESS_CTE_TRANSMIT_ENABLE = 396,
638  LE_SET_CONNECTIONLESS_IQ_SAMPLING_ENABLE = 397,
639  LE_SET_CONNECTION_CTE_RECEIVE_PARAMETERS = 400,
640  LE_SET_CONNECTION_CTE_TRANSMIT_PARAMETERS = 401,
641  LE_CONNECTION_CTE_REQUEST_ENABLE = 402,
642  LE_CONNECTION_CTE_RESPONSE_ENABLE = 403,
643  LE_READ_ANTENNA_INFORMATION = 404,
644  LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE = 405,
645  LE_PERIODIC_ADVERTISING_SYNC_TRANSFER = 406,
646  LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER = 407,
647  LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS = 410,
648  LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS = 411,
649  LE_GENERATE_DHKEY_V2 = 412,
650  READ_LOCAL_SIMPLE_PAIRING_OPTIONS = 413,
651  LE_MODIFY_SLEEP_CLOCK_ACCURACY = 414,
652  LE_READ_BUFFER_SIZE_V2 = 415,
653  LE_READ_ISO_TX_SYNC = 416,
654  LE_SET_CIG_PARAMETERS = 417,
655  LE_SET_CIG_PARAMETERS_TEST = 420,
656  LE_CREATE_CIS = 421,
657  LE_REMOVE_CIG = 422,
658  LE_ACCEPT_CIS_REQUEST = 423,
659  LE_REJECT_CIS_REQUEST = 424,
660  LE_CREATE_BIG = 425,
661  LE_CREATE_BIG_TEST = 426,
662  LE_TERMINATE_BIG = 427,
663  LE_BIG_CREATE_SYNC = 430,
664  LE_BIG_TERMINATE_SYNC = 431,
665  LE_REQUEST_PEER_SCA = 432,
666  LE_SETUP_ISO_DATA_PATH = 433,
667  LE_REMOVE_ISO_DATA_PATH = 434,
668  LE_ISO_TRANSMIT_TEST = 435,
669  LE_ISO_RECEIVE_TEST = 436,
670  LE_ISO_READ_TEST_COUNTERS = 437,
671  LE_ISO_TEST_END = 440,
672  LE_SET_HOST_FEATURE = 441,
673  LE_READ_ISO_LINK_QUALITY = 442,
674  LE_ENHANCED_READ_TRANSMIT_POWER_LEVEL = 443,
675  LE_READ_REMOTE_TRANSMIT_POWER_LEVEL = 444,
676  LE_SET_PATH_LOSS_REPORTING_PARAMETERS = 445,
677  LE_SET_PATH_LOSS_REPORTING_ENABLE = 446,
678  LE_SET_TRANSMIT_POWER_REPORTING_ENABLE = 447,
679  LE_TRANSMITTER_TEST_V4 = 450,
680  SET_ECOSYSTEM_BASE_INTERVAL = 451,
681  READ_LOCAL_SUPPORTED_CODECS_V2 = 452,
682  READ_LOCAL_SUPPORTED_CODEC_CAPABILITIES = 453,
683  READ_LOCAL_SUPPORTED_CONTROLLER_DELAY = 454,
684  CONFIGURE_DATA_PATH = 455,
685  LE_SET_DATA_RELATED_ADDRESS_CHANGES = 456,
686  SET_MIN_ENCRYPTION_KEY_SIZE = 457,
687  LE_SET_DEFAULT_SUBRATE = 460,
688  LE_SUBRATE_REQUEST = 461,
689}
690
691packet Command {
692  op_code : OpCode,
693  _size_(_payload_) : 8,
694  _payload_,
695}
696
697// HCI Event Packets
698
699enum EventCode : 8 {
700  INQUIRY_COMPLETE = 0x01,
701  INQUIRY_RESULT = 0x02,
702  CONNECTION_COMPLETE = 0x03,
703  CONNECTION_REQUEST = 0x04,
704  DISCONNECTION_COMPLETE = 0x05,
705  AUTHENTICATION_COMPLETE = 0x06,
706  REMOTE_NAME_REQUEST_COMPLETE = 0x07,
707  ENCRYPTION_CHANGE = 0x08,
708  CHANGE_CONNECTION_LINK_KEY_COMPLETE = 0x09,
709  CENTRAL_LINK_KEY_COMPLETE = 0x0A,
710  READ_REMOTE_SUPPORTED_FEATURES_COMPLETE = 0x0B,
711  READ_REMOTE_VERSION_INFORMATION_COMPLETE = 0x0C,
712  QOS_SETUP_COMPLETE = 0x0D,
713  COMMAND_COMPLETE = 0x0E,
714  COMMAND_STATUS = 0x0F,
715  HARDWARE_ERROR = 0x10,
716  FLUSH_OCCURRED = 0x11,
717  ROLE_CHANGE = 0x12,
718  NUMBER_OF_COMPLETED_PACKETS = 0x13,
719  MODE_CHANGE = 0x14,
720  RETURN_LINK_KEYS = 0x15,
721  PIN_CODE_REQUEST = 0x16,
722  LINK_KEY_REQUEST = 0x17,
723  LINK_KEY_NOTIFICATION = 0x18,
724  LOOPBACK_COMMAND = 0x19,
725  DATA_BUFFER_OVERFLOW = 0x1A,
726  MAX_SLOTS_CHANGE = 0x1B,
727  READ_CLOCK_OFFSET_COMPLETE = 0x1C,
728  CONNECTION_PACKET_TYPE_CHANGED = 0x1D,
729  QOS_VIOLATION = 0x1E,
730  PAGE_SCAN_REPETITION_MODE_CHANGE = 0x20,
731  FLOW_SPECIFICATION_COMPLETE = 0x21,
732  INQUIRY_RESULT_WITH_RSSI = 0x22,
733  READ_REMOTE_EXTENDED_FEATURES_COMPLETE = 0x23,
734  SYNCHRONOUS_CONNECTION_COMPLETE = 0x2C,
735  SYNCHRONOUS_CONNECTION_CHANGED = 0x2D,
736  SNIFF_SUBRATING = 0x2E,
737  EXTENDED_INQUIRY_RESULT = 0x2F,
738  ENCRYPTION_KEY_REFRESH_COMPLETE = 0x30,
739  IO_CAPABILITY_REQUEST = 0x31,
740  IO_CAPABILITY_RESPONSE = 0x32,
741  USER_CONFIRMATION_REQUEST = 0x33,
742  USER_PASSKEY_REQUEST = 0x34,
743  REMOTE_OOB_DATA_REQUEST = 0x35,
744  SIMPLE_PAIRING_COMPLETE = 0x36,
745  LINK_SUPERVISION_TIMEOUT_CHANGED = 0x38,
746  ENHANCED_FLUSH_COMPLETE = 0x39,
747  USER_PASSKEY_NOTIFICATION = 0x3B,
748  KEYPRESS_NOTIFICATION = 0x3C,
749  REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION = 0x3D,
750  LE_META_EVENT = 0x3e,
751  NUMBER_OF_COMPLETED_DATA_BLOCKS = 0x48,
752  VENDOR_SPECIFIC = 0xFF,
753}
754
755// LE events
756enum SubeventCode : 8 {
757  CONNECTION_COMPLETE = 0x01,
758  ADVERTISING_REPORT = 0x02,
759  CONNECTION_UPDATE_COMPLETE = 0x03,
760  READ_REMOTE_FEATURES_COMPLETE = 0x04,
761  LONG_TERM_KEY_REQUEST = 0x05,
762  REMOTE_CONNECTION_PARAMETER_REQUEST = 0x06,
763  DATA_LENGTH_CHANGE = 0x07,
764  READ_LOCAL_P256_PUBLIC_KEY_COMPLETE = 0x08,
765  GENERATE_DHKEY_COMPLETE = 0x09,
766  ENHANCED_CONNECTION_COMPLETE = 0x0a,
767  DIRECTED_ADVERTISING_REPORT = 0x0b,
768  PHY_UPDATE_COMPLETE = 0x0c,
769  EXTENDED_ADVERTISING_REPORT = 0x0D,
770  PERIODIC_ADVERTISING_SYNC_ESTABLISHED = 0x0E,
771  PERIODIC_ADVERTISING_REPORT = 0x0F,
772  PERIODIC_ADVERTISING_SYNC_LOST = 0x10,
773  SCAN_TIMEOUT = 0x11,
774  ADVERTISING_SET_TERMINATED = 0x12,
775  SCAN_REQUEST_RECEIVED = 0x13,
776  CHANNEL_SELECTION_ALGORITHM = 0x14,
777  CONNECTIONLESS_IQ_REPORT = 0x15,
778  CONNECTION_IQ_REPORT = 0x16,
779  CTE_REQUEST_FAILED = 0x17,
780  PERIODIC_ADVERTISING_SYNC_TRANSFER_RECEIVED = 0x18,
781  CIS_ESTABLISHED = 0x19,
782  CIS_REQUEST = 0x1A,
783  CREATE_BIG_COMPLETE = 0x1B,
784  TERMINATE_BIG_COMPLETE = 0x1C,
785  BIG_SYNC_ESTABLISHED = 0x1D,
786  BIG_SYNC_LOST = 0x1E,
787  REQUEST_PEER_SCA_COMPLETE = 0x1F,
788  PATH_LOSS_THRESHOLD = 0x20,
789  TRANSMIT_POWER_REPORTING = 0x21,
790  BIG_INFO_ADVERTISING_REPORT = 0x22,
791  LE_SUBRATE_CHANGE = 0x23,
792}
793
794// Vendor specific events
795enum VseSubeventCode : 8 {
796  STORAGE_THRESHOLD_BREACH = 0x54,
797  LE_MULTI_ADVERTISING_STATE_CHANGE = 0x55,
798  LE_ADVERTISEMENT_TRACKING = 0x56,
799  CONTROLLER_DEBUG_INFO = 0x57,
800  BLUETOOTH_QUALITY_REPORT = 0x58,
801}
802
803packet Event {
804  event_code : EventCode,
805  _size_(_payload_) : 8,
806  _payload_,
807}
808
809// Common definitions for commands and events
810
811enum FeatureFlag : 1 {
812  UNSUPPORTED = 0,
813  SUPPORTED = 1,
814}
815
816enum ErrorCode: 8 {
817  STATUS_UNKNOWN = 0xFF,
818  SUCCESS = 0x00,
819  UNKNOWN_HCI_COMMAND = 0x01,
820  UNKNOWN_CONNECTION = 0x02,
821  HARDWARE_FAILURE = 0x03,
822  PAGE_TIMEOUT = 0x04,
823  AUTHENTICATION_FAILURE = 0x05,
824  PIN_OR_KEY_MISSING = 0x06,
825  MEMORY_CAPACITY_EXCEEDED = 0x07,
826  CONNECTION_TIMEOUT = 0x08,
827  CONNECTION_LIMIT_EXCEEDED = 0x09,
828  SYNCHRONOUS_CONNECTION_LIMIT_EXCEEDED = 0x0A,
829  CONNECTION_ALREADY_EXISTS = 0x0B,
830  COMMAND_DISALLOWED = 0x0C,
831  CONNECTION_REJECTED_LIMITED_RESOURCES = 0x0D,
832  CONNECTION_REJECTED_SECURITY_REASONS = 0x0E,
833  CONNECTION_REJECTED_UNACCEPTABLE_BD_ADDR = 0x0F,
834  CONNECTION_ACCEPT_TIMEOUT = 0x10,
835  UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE = 0x11,
836  INVALID_HCI_COMMAND_PARAMETERS = 0x12,
837  REMOTE_USER_TERMINATED_CONNECTION = 0x13,
838  REMOTE_DEVICE_TERMINATED_CONNECTION_LOW_RESOURCES = 0x14,
839  REMOTE_DEVICE_TERMINATED_CONNECTION_POWER_OFF = 0x15,
840  CONNECTION_TERMINATED_BY_LOCAL_HOST = 0x16,
841  REPEATED_ATTEMPTS = 0x17,
842  PAIRING_NOT_ALLOWED = 0x18,
843  UNKNOWN_LMP_PDU = 0x19,
844  UNSUPPORTED_REMOTE_OR_LMP_FEATURE = 0x1A,
845  SCO_OFFSET_REJECTED = 0x1B,
846  SCO_INTERVAL_REJECTED = 0x1C,
847  SCO_AIR_MODE_REJECTED = 0x1D,
848  INVALID_LMP_OR_LL_PARAMETERS = 0x1E,
849  UNSPECIFIED_ERROR = 0x1F,
850  UNSUPPORTED_LMP_OR_LL_PARAMETER = 0x20,
851  ROLE_CHANGE_NOT_ALLOWED = 0x21,
852  TRANSACTION_RESPONSE_TIMEOUT = 0x22,
853  LINK_LAYER_COLLISION = 0x23,
854  ENCRYPTION_MODE_NOT_ACCEPTABLE = 0x25,
855  ROLE_SWITCH_FAILED = 0x35,
856  HOST_BUSY = 0x38,
857  CONTROLLER_BUSY = 0x3A,
858  ADVERTISING_TIMEOUT = 0x3C,
859  CONNECTION_FAILED_ESTABLISHMENT = 0x3E,
860  UNKNOWN_ADVERTISING_IDENTIFIER = 0x42,
861  LIMIT_REACHED = 0x43,
862  OPERATION_CANCELLED_BY_HOST = 0x44,
863  PACKET_TOO_LONG = 0x45,
864}
865
866// Events that are defined with their respective commands
867
868packet CommandComplete : Event (event_code = COMMAND_COMPLETE) {
869  num_hci_command_packets : 8,
870  command_op_code : OpCode,
871  _payload_,
872}
873
874packet CommandStatus : Event (event_code = COMMAND_STATUS) {
875  status : ErrorCode, // SUCCESS means PENDING
876  num_hci_command_packets : 8,
877  command_op_code : OpCode,
878  _payload_,
879}
880
881packet VendorSpecificEvent : Event (event_code = VENDOR_SPECIFIC) {
882  subevent_code : VseSubeventCode,
883  _payload_,
884}
885
886  // Credits
887packet NoCommandComplete : CommandComplete (command_op_code = NONE) {
888}
889
890struct Lap { // Lower Address Part
891  lap : 6,
892  _reserved_ : 2,
893  _fixed_ = 0x9e8b : 16,
894}
895
896  // LINK_CONTROL
897packet Inquiry : Command (op_code = INQUIRY) {
898  lap : Lap,
899  inquiry_length : 8, // 0x1 - 0x30 (times 1.28s)
900  num_responses : 8, // 0x00 unlimited
901}
902
903test Inquiry {
904  "\x01\x04\x05\x33\x8b\x9e\xaa\xbb",
905}
906
907packet InquiryStatus : CommandStatus (command_op_code = INQUIRY) {
908}
909
910test InquiryStatus {
911  "\x0f\x04\x00\x01\x01\x04",
912}
913
914packet InquiryCancel : Command (op_code = INQUIRY_CANCEL) {
915}
916
917test InquiryCancel {
918  "\x02\x04\x00",
919}
920
921packet InquiryCancelComplete : CommandComplete (command_op_code = INQUIRY_CANCEL) {
922  status : ErrorCode,
923}
924
925test InquiryCancelComplete {
926  "\x0e\x04\x01\x02\x04\x00",
927}
928
929packet PeriodicInquiryMode : Command (op_code = PERIODIC_INQUIRY_MODE) {
930  max_period_length : 16, // Range 0x0003 to 0xffff (times 1.28s)
931  min_period_length : 16, // Range 0x0002 to 0xfffe (times 1.28s)
932  lap : Lap,
933  inquiry_length : 8, // 0x1 - 0x30 (times 1.28s)
934  num_responses : 8, // 0x00 unlimited
935}
936
937test PeriodicInquiryMode {
938  "\x03\x04\x09\x12\x34\x56\x78\x11\x8b\x9e\x9a\xbc",
939}
940
941packet PeriodicInquiryModeComplete : CommandComplete (command_op_code = PERIODIC_INQUIRY_MODE) {
942  status : ErrorCode,
943}
944
945test PeriodicInquiryModeComplete {
946  "\x0e\x04\x01\x03\x04\x00",
947}
948
949packet ExitPeriodicInquiryMode : Command (op_code = EXIT_PERIODIC_INQUIRY_MODE) {
950}
951
952test ExitPeriodicInquiryMode {
953  "\x04\x04\x00",
954}
955
956packet ExitPeriodicInquiryModeComplete : CommandComplete (command_op_code = EXIT_PERIODIC_INQUIRY_MODE) {
957  status : ErrorCode,
958}
959
960test ExitPeriodicInquiryModeComplete {
961  "\x0e\x04\x01\x04\x04\x00",
962}
963
964enum PageScanRepetitionMode : 8 {
965  R0 = 0x00,
966  R1 = 0x01,
967  R2 = 0x02,
968}
969
970enum ClockOffsetValid : 1 {
971  INVALID = 0,
972  VALID = 1,
973}
974
975enum CreateConnectionRoleSwitch : 8 {
976  REMAIN_CENTRAL = 0x00,
977  ALLOW_ROLE_SWITCH = 0x01,
978}
979
980packet CreateConnection : Command (op_code = CREATE_CONNECTION) {
981  bd_addr : Address,
982  packet_type : 16,
983  page_scan_repetition_mode : PageScanRepetitionMode,
984  _reserved_ : 8,
985  clock_offset : 15,
986  clock_offset_valid : ClockOffsetValid,
987  allow_role_switch : CreateConnectionRoleSwitch,
988}
989
990packet CreateConnectionStatus : CommandStatus (command_op_code = CREATE_CONNECTION) {
991}
992
993enum DisconnectReason : 8 {
994  AUTHENTICATION_FAILURE = 0x05,
995  REMOTE_USER_TERMINATED_CONNECTION = 0x13,
996  REMOTE_DEVICE_TERMINATED_CONNECTION_LOW_RESOURCES = 0x14,
997  REMOTE_DEVICE_TERMINATED_CONNECTION_POWER_OFF = 0x15,
998  UNSUPPORTED_REMOTE_FEATURE = 0x1A,
999  PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED = 0x29,
1000  UNACCEPTABLE_CONNECTION_PARAMETERS = 0x3B,
1001}
1002
1003packet Disconnect : Command (op_code = DISCONNECT) {
1004  connection_handle : 12,
1005  _reserved_ : 4,
1006  reason : DisconnectReason,
1007}
1008
1009packet DisconnectStatus : CommandStatus (command_op_code = DISCONNECT) {
1010}
1011
1012packet AddScoConnection : Command (op_code = ADD_SCO_CONNECTION) {
1013  connection_handle : 12,
1014  _reserved_ : 4,
1015  packet_type : 16,
1016}
1017
1018packet AddScoConnectionStatus : CommandStatus (command_op_code = ADD_SCO_CONNECTION) {
1019}
1020
1021packet CreateConnectionCancel : Command (op_code = CREATE_CONNECTION_CANCEL) {
1022  bd_addr : Address,
1023}
1024
1025packet CreateConnectionCancelComplete : CommandComplete (command_op_code = CREATE_CONNECTION_CANCEL) {
1026  status : ErrorCode,
1027  bd_addr : Address,
1028}
1029
1030enum AcceptConnectionRequestRole : 8 {
1031  BECOME_CENTRAL = 0x00,
1032  REMAIN_PERIPHERAL = 0x01,
1033}
1034
1035packet AcceptConnectionRequest : Command (op_code = ACCEPT_CONNECTION_REQUEST) {
1036  bd_addr : Address,
1037  role : AcceptConnectionRequestRole,
1038}
1039
1040packet AcceptConnectionRequestStatus : CommandStatus (command_op_code = ACCEPT_CONNECTION_REQUEST) {
1041}
1042
1043enum RejectConnectionReason : 8 {
1044  LIMITED_RESOURCES = 0x0D,
1045  SECURITY_REASONS = 0x0E,
1046  UNACCEPTABLE_BD_ADDR = 0x0F,
1047}
1048
1049packet RejectConnectionRequest : Command (op_code = REJECT_CONNECTION_REQUEST) {
1050  bd_addr : Address,
1051  reason : RejectConnectionReason,
1052}
1053
1054packet RejectConnectionRequestStatus : CommandStatus (command_op_code = REJECT_CONNECTION_REQUEST) {
1055}
1056
1057packet LinkKeyRequestReply : Command (op_code = LINK_KEY_REQUEST_REPLY) {
1058  bd_addr : Address,
1059  link_key : 8[16],
1060}
1061
1062packet LinkKeyRequestReplyComplete : CommandComplete (command_op_code = LINK_KEY_REQUEST_REPLY) {
1063  status : ErrorCode,
1064  bd_addr : Address,
1065}
1066
1067packet LinkKeyRequestNegativeReply : Command (op_code = LINK_KEY_REQUEST_NEGATIVE_REPLY) {
1068  bd_addr : Address,
1069}
1070
1071packet LinkKeyRequestNegativeReplyComplete : CommandComplete (command_op_code = LINK_KEY_REQUEST_NEGATIVE_REPLY) {
1072  status : ErrorCode,
1073  bd_addr : Address,
1074}
1075
1076packet PinCodeRequestReply : Command (op_code = PIN_CODE_REQUEST_REPLY) {
1077  bd_addr : Address,
1078  pin_code_length : 5, // 0x01 - 0x10
1079  _reserved_ : 3,
1080  pin_code : 8[16], // string parameter, first octet first
1081}
1082
1083packet PinCodeRequestReplyComplete : CommandComplete (command_op_code = PIN_CODE_REQUEST_REPLY) {
1084  status : ErrorCode,
1085  bd_addr : Address,
1086}
1087
1088packet PinCodeRequestNegativeReply : Command (op_code = PIN_CODE_REQUEST_NEGATIVE_REPLY) {
1089  bd_addr : Address,
1090}
1091
1092packet PinCodeRequestNegativeReplyComplete : CommandComplete (command_op_code = PIN_CODE_REQUEST_NEGATIVE_REPLY) {
1093  status : ErrorCode,
1094  bd_addr : Address,
1095}
1096
1097packet ChangeConnectionPacketType : Command (op_code = CHANGE_CONNECTION_PACKET_TYPE) {
1098  connection_handle : 12,
1099  _reserved_ : 4,
1100  packet_type : 16,
1101}
1102
1103packet ChangeConnectionPacketTypeStatus : CommandStatus (command_op_code = CHANGE_CONNECTION_PACKET_TYPE) {
1104}
1105
1106packet AuthenticationRequested : Command (op_code = AUTHENTICATION_REQUESTED) {
1107  connection_handle : 12,
1108  _reserved_ : 4,
1109}
1110
1111packet AuthenticationRequestedStatus : CommandStatus (command_op_code = AUTHENTICATION_REQUESTED) {
1112}
1113
1114packet SetConnectionEncryption : Command (op_code = SET_CONNECTION_ENCRYPTION) {
1115  connection_handle : 12,
1116  _reserved_ : 4,
1117  encryption_enable : Enable,
1118}
1119
1120packet SetConnectionEncryptionStatus : CommandStatus (command_op_code = SET_CONNECTION_ENCRYPTION) {
1121}
1122
1123packet ChangeConnectionLinkKey : Command (op_code = CHANGE_CONNECTION_LINK_KEY) {
1124  connection_handle : 12,
1125  _reserved_ : 4,
1126}
1127
1128packet ChangeConnectionLinkKeyStatus : CommandStatus (command_op_code = CHANGE_CONNECTION_LINK_KEY) {
1129}
1130
1131enum KeyFlag : 8 {
1132  SEMI_PERMANENT = 0x00,
1133  TEMPORARY = 0x01,
1134}
1135
1136packet CentralLinkKey : Command (op_code = CENTRAL_LINK_KEY) {
1137  key_flag : KeyFlag,
1138}
1139
1140packet CentralLinkKeyStatus : CommandStatus (command_op_code = CENTRAL_LINK_KEY) {
1141}
1142
1143packet RemoteNameRequest : Command (op_code = REMOTE_NAME_REQUEST) {
1144  bd_addr : Address,
1145  page_scan_repetition_mode : PageScanRepetitionMode,
1146  _reserved_ : 8,
1147  clock_offset : 15,
1148  clock_offset_valid : ClockOffsetValid,
1149}
1150
1151packet RemoteNameRequestStatus : CommandStatus (command_op_code = REMOTE_NAME_REQUEST) {
1152}
1153
1154packet RemoteNameRequestCancel : Command (op_code = REMOTE_NAME_REQUEST_CANCEL) {
1155  bd_addr : Address,
1156}
1157
1158packet RemoteNameRequestCancelComplete : CommandComplete (command_op_code = REMOTE_NAME_REQUEST_CANCEL) {
1159  status : ErrorCode,
1160  bd_addr : Address,
1161}
1162
1163packet ReadRemoteSupportedFeatures : Command (op_code = READ_REMOTE_SUPPORTED_FEATURES) {
1164  connection_handle : 12,
1165  _reserved_ : 4,
1166}
1167
1168packet ReadRemoteSupportedFeaturesStatus : CommandStatus (command_op_code = READ_REMOTE_SUPPORTED_FEATURES) {
1169}
1170
1171packet ReadRemoteExtendedFeatures : Command (op_code = READ_REMOTE_EXTENDED_FEATURES) {
1172  connection_handle : 12,
1173  _reserved_ : 4,
1174  page_number : 8,
1175}
1176
1177packet ReadRemoteExtendedFeaturesStatus : CommandStatus (command_op_code = READ_REMOTE_EXTENDED_FEATURES) {
1178}
1179
1180packet ReadRemoteVersionInformation : Command (op_code = READ_REMOTE_VERSION_INFORMATION) {
1181  connection_handle : 12,
1182  _reserved_ : 4,
1183}
1184
1185packet ReadRemoteVersionInformationStatus : CommandStatus (command_op_code = READ_REMOTE_VERSION_INFORMATION) {
1186}
1187
1188packet ReadClockOffset : Command (op_code = READ_CLOCK_OFFSET) {
1189  connection_handle : 12,
1190  _reserved_ : 4,
1191}
1192
1193packet ReadClockOffsetStatus : CommandStatus (command_op_code = READ_CLOCK_OFFSET) {
1194}
1195
1196packet ReadLmpHandle : Command (op_code = READ_LMP_HANDLE) {
1197  connection_handle : 12,
1198  _reserved_ : 4,
1199}
1200
1201packet ReadLmpHandleComplete : CommandComplete (command_op_code = READ_LMP_HANDLE) {
1202  status : ErrorCode,
1203  connection_handle : 12,
1204  _reserved_ : 4,
1205  lmp_handle : 8,
1206  _reserved_ : 32,
1207}
1208
1209enum SynchronousPacketTypeBits : 16 {
1210  HV1_ALLOWED = 0x0001,
1211  HV2_ALLOWED = 0x0002,
1212  HV3_ALLOWED = 0x0004,
1213  EV3_ALLOWED = 0x0008,
1214  EV4_ALLOWED = 0x0010,
1215  EV5_ALLOWED = 0x0020,
1216  NO_2_EV3_ALLOWED = 0x0040,
1217  NO_3_EV3_ALLOWED = 0x0080,
1218  NO_2_EV5_ALLOWED = 0x0100,
1219  NO_3_EV5_ALLOWED = 0x0200,
1220}
1221
1222enum RetransmissionEffort : 8 {
1223  NO_RETRANSMISSION = 0x00,
1224  OPTIMIZED_FOR_POWER = 0x01,
1225  OPTIMIZED_FOR_LINK_QUALITY = 0x02,
1226  DO_NOT_CARE = 0xFF,
1227}
1228
1229packet SetupSynchronousConnection : Command (op_code = SETUP_SYNCHRONOUS_CONNECTION) {
1230  connection_handle : 12,
1231  _reserved_ : 4,
1232  transmit_bandwidth : 32,
1233  receive_bandwidth : 32,
1234  max_latency : 16, // 0-3 reserved, 0xFFFF = don't care
1235  voice_setting : 10,
1236  _reserved_ : 6,
1237  retransmission_effort : RetransmissionEffort,
1238  packet_type : 16, // See SynchronousPacketTypeBits
1239}
1240
1241packet SetupSynchronousConnectionStatus : CommandStatus (command_op_code = SETUP_SYNCHRONOUS_CONNECTION) {
1242}
1243
1244packet AcceptSynchronousConnection : Command (op_code = ACCEPT_SYNCHRONOUS_CONNECTION) {
1245  bd_addr : Address,
1246  transmit_bandwidth : 32,
1247  receive_bandwidth : 32,
1248  max_latency : 16, // 0-3 reserved, 0xFFFF = don't care
1249  voice_setting : 10,
1250  _reserved_ : 6,
1251  retransmission_effort : RetransmissionEffort,
1252  packet_type : 16, // See SynchronousPacketTypeBits
1253}
1254
1255packet AcceptSynchronousConnectionStatus : CommandStatus (command_op_code = ACCEPT_SYNCHRONOUS_CONNECTION) {
1256}
1257
1258packet RejectSynchronousConnection : Command (op_code = REJECT_SYNCHRONOUS_CONNECTION) {
1259  bd_addr : Address,
1260  reason : RejectConnectionReason,
1261}
1262
1263packet RejectSynchronousConnectionStatus : CommandStatus (command_op_code = REJECT_SYNCHRONOUS_CONNECTION) {
1264}
1265
1266enum IoCapability : 8 {
1267  DISPLAY_ONLY = 0x00,
1268  DISPLAY_YES_NO = 0x01,
1269  KEYBOARD_ONLY = 0x02,
1270  NO_INPUT_NO_OUTPUT = 0x03,
1271}
1272
1273enum OobDataPresent : 8 {
1274  NOT_PRESENT = 0x00,
1275  P_192_PRESENT = 0x01,
1276  P_256_PRESENT = 0x02,
1277  P_192_AND_256_PRESENT = 0x03,
1278}
1279
1280enum AuthenticationRequirements : 8 {
1281  NO_BONDING = 0x00,
1282  NO_BONDING_MITM_PROTECTION = 0x01,
1283  DEDICATED_BONDING = 0x02,
1284  DEDICATED_BONDING_MITM_PROTECTION = 0x03,
1285  GENERAL_BONDING = 0x04,
1286  GENERAL_BONDING_MITM_PROTECTION = 0x05,
1287}
1288
1289packet IoCapabilityRequestReply : Command (op_code = IO_CAPABILITY_REQUEST_REPLY) {
1290  bd_addr : Address,
1291  io_capability : IoCapability,
1292  oob_present : OobDataPresent,
1293  authentication_requirements : AuthenticationRequirements,
1294}
1295
1296packet IoCapabilityRequestReplyComplete : CommandComplete (command_op_code = IO_CAPABILITY_REQUEST_REPLY) {
1297  status : ErrorCode,
1298  bd_addr : Address,
1299}
1300
1301packet UserConfirmationRequestReply : Command (op_code = USER_CONFIRMATION_REQUEST_REPLY) {
1302  bd_addr : Address,
1303}
1304
1305packet UserConfirmationRequestReplyComplete : CommandComplete (command_op_code = USER_CONFIRMATION_REQUEST_REPLY) {
1306  status : ErrorCode,
1307  bd_addr : Address,
1308}
1309
1310packet UserConfirmationRequestNegativeReply : Command (op_code = USER_CONFIRMATION_REQUEST_NEGATIVE_REPLY) {
1311  bd_addr : Address,
1312}
1313
1314packet UserConfirmationRequestNegativeReplyComplete : CommandComplete (command_op_code = USER_CONFIRMATION_REQUEST_NEGATIVE_REPLY) {
1315  status : ErrorCode,
1316  bd_addr : Address,
1317}
1318
1319packet UserPasskeyRequestReply : Command (op_code = USER_PASSKEY_REQUEST_REPLY) {
1320  bd_addr : Address,
1321  numeric_value : 32, // 000000-999999 decimal or 0x0-0xF423F
1322}
1323
1324packet UserPasskeyRequestReplyComplete : CommandComplete (command_op_code = USER_PASSKEY_REQUEST_REPLY) {
1325  status : ErrorCode,
1326  bd_addr : Address,
1327}
1328
1329packet UserPasskeyRequestNegativeReply : Command (op_code = USER_PASSKEY_REQUEST_NEGATIVE_REPLY) {
1330  bd_addr : Address,
1331}
1332
1333packet UserPasskeyRequestNegativeReplyComplete : CommandComplete (command_op_code = USER_PASSKEY_REQUEST_NEGATIVE_REPLY) {
1334  status : ErrorCode,
1335  bd_addr : Address,
1336}
1337
1338packet RemoteOobDataRequestReply : Command (op_code = REMOTE_OOB_DATA_REQUEST_REPLY) {
1339  bd_addr : Address,
1340  c : 8[16],
1341  r : 8[16],
1342}
1343
1344packet RemoteOobDataRequestReplyComplete : CommandComplete (command_op_code = REMOTE_OOB_DATA_REQUEST_REPLY) {
1345  status : ErrorCode,
1346  bd_addr : Address,
1347}
1348
1349packet RemoteOobDataRequestNegativeReply : Command (op_code = REMOTE_OOB_DATA_REQUEST_NEGATIVE_REPLY) {
1350  bd_addr : Address,
1351}
1352
1353packet RemoteOobDataRequestNegativeReplyComplete : CommandComplete (command_op_code = REMOTE_OOB_DATA_REQUEST_NEGATIVE_REPLY) {
1354  status : ErrorCode,
1355  bd_addr : Address,
1356}
1357
1358packet IoCapabilityRequestNegativeReply : Command (op_code = IO_CAPABILITY_REQUEST_NEGATIVE_REPLY) {
1359  bd_addr : Address,
1360  reason : ErrorCode,
1361}
1362
1363packet IoCapabilityRequestNegativeReplyComplete : CommandComplete (command_op_code = IO_CAPABILITY_REQUEST_NEGATIVE_REPLY) {
1364  status : ErrorCode,
1365  bd_addr : Address,
1366}
1367
1368enum ScoCodingFormatValues : 8 {
1369  ULAW_LONG = 0x00,
1370  ALAW_LONG = 0x01,
1371  CVSD = 0x02,
1372  TRANSPARENT = 0x03,
1373  LINEAR_PCM = 0x04,
1374  MSBC = 0x05,
1375  LC3 = 0x06,
1376  VENDOR_SPECIFIC = 0xFF,
1377}
1378
1379struct ScoCodingFormat {
1380  coding_format : ScoCodingFormatValues,
1381  company_id : 16,
1382  vendor_specific_codec_id : 16,
1383}
1384
1385enum ScoPcmDataFormat : 8 {
1386  NOT_USED = 0x00,
1387  ONES_COMPLEMENT = 0x01,
1388  TWOS_COMPLEMENT = 0x02,
1389  SIGN_MAGNITUDE = 0x03,
1390  UNSIGNED = 0x04,
1391}
1392
1393enum ScoDataPath : 8 {
1394  HCI = 0x00,
1395  // 0x01 to 0xFE are Logical_Channel_Number.
1396  // The meaning of the logical channels will be vendor specific.
1397  // In GD and legacy Android Bluetooth stack, we use channel 0x01 for hardware
1398  // offloaded SCO encoding
1399  GD_PCM = 0x01,
1400  AUDIO_TEST_MODE = 0xFF,
1401}
1402
1403packet EnhancedSetupSynchronousConnection : Command (op_code = ENHANCED_SETUP_SYNCHRONOUS_CONNECTION) {
1404  connection_handle: 12,
1405  _reserved_ : 4,
1406  // Next two items
1407  // [0x00000000, 0xFFFFFFFE] Bandwidth in octets per second.
1408  // [0xFFFFFFFF]: Don't care
1409  transmit_bandwidth : 32,
1410  receive_bandwidth : 32,
1411  transmit_coding_format : ScoCodingFormat,
1412  receive_coding_format : ScoCodingFormat,
1413  // Next two items
1414  // [0x0001, 0xFFFF]: the actual size of the over-the-air encoded frame in
1415  //                   octets.
1416  transmit_codec_frame_size : 16,
1417  receive_codec_frame_size : 16,
1418  // Next two items
1419  // Host to Controller nominal data rate in octets per second.
1420  input_bandwidth : 32,
1421  output_bandwidth : 32,
1422  input_coding_format : ScoCodingFormat,
1423  output_coding_format : ScoCodingFormat,
1424  // Next two items
1425  // Size, in bits, of the sample or framed data
1426  input_coded_data_bits : 16,
1427  output_coded_data_bits : 16,
1428  input_pcm_data_format : ScoPcmDataFormat,
1429  output_pcm_data_format : ScoPcmDataFormat,
1430  // Next two items
1431  // The number of bit positions within an audio sample that the MSB of the
1432  // sample is away from starting at the MSB of the data.
1433  input_pcm_sample_payload_msb_position : 8,
1434  output_pcm_sample_payload_msb_position : 8,
1435  input_data_path : ScoDataPath,
1436  output_data_path : ScoDataPath,
1437  // Next two items
1438  // [1, 255] The number of bits in each unit of data received from the Host
1439  //          over the audio data transport.
1440  // [0] Not applicable (implied by the choice of audio data transport)
1441  input_transport_unit_bits : 8,
1442  output_transport_unit_bits : 8,
1443  // [0x0004, 0xFFFE]: in milliseconds
1444  //     Upper limit represent the sum of the synchronous interval and the size
1445  //     of the eSCO window, where the eSCO window is reserved slots plus the
1446  //     retransmission window
1447  // [0xFFFF]: don't care
1448  max_latency: 16,
1449  packet_type : 16, // See SynchronousPacketTypeBits
1450  retransmission_effort : RetransmissionEffort,
1451}
1452
1453test EnhancedSetupSynchronousConnection {
1454  "\x3d\x04\x3b\x02\x00\x40\x1f\x00\x00\x40\x1f\x00\x00\x05\x00\x00\x00\x00\x05\x00\x00\x00\x00\x3c\x00\x3c\x00\x00\x7d\x00\x00\x00\x7d\x00\x00\x04\x00\x00\x00\x00\x04\x00\x00\x00\x00\x10\x00\x10\x00\x02\x02\x00\x00\x01\x01\x00\x00\x0d\x00\x88\x03\x02",
1455}
1456
1457packet EnhancedSetupSynchronousConnectionStatus : CommandStatus (command_op_code = ENHANCED_SETUP_SYNCHRONOUS_CONNECTION) {
1458}
1459
1460packet EnhancedAcceptSynchronousConnection : Command (op_code = ENHANCED_ACCEPT_SYNCHRONOUS_CONNECTION) {
1461  bd_addr : Address,
1462  // Next two items
1463  // [0x00000000, 0xFFFFFFFE] Bandwidth in octets per second.
1464  // [0xFFFFFFFF]: Don't care
1465  transmit_bandwidth : 32,
1466  receive_bandwidth : 32,
1467  transmit_coding_format : ScoCodingFormat,
1468  receive_coding_format : ScoCodingFormat,
1469  // Next two items
1470  // [0x0001, 0xFFFF]: the actual size of the over-the-air encoded frame in
1471  //                   octets.
1472  transmit_codec_frame_size : 16,
1473  receive_codec_frame_size : 16,
1474  // Next two items
1475  // Host to Controller nominal data rate in octets per second.
1476  input_bandwidth : 32,
1477  output_bandwidth : 32,
1478  input_coding_format : ScoCodingFormat,
1479  output_coding_format : ScoCodingFormat,
1480  // Next two items
1481  // Size, in bits, of the sample or framed data
1482  input_coded_data_bits : 16,
1483  output_coded_data_bits : 16,
1484  input_pcm_data_format : ScoPcmDataFormat,
1485  output_pcm_data_format : ScoPcmDataFormat,
1486  // Next two items
1487  // The number of bit positions within an audio sample that the MSB of the
1488  // sample is away from starting at the MSB of the data.
1489  input_pcm_sample_payload_msb_position : 8,
1490  output_pcm_sample_payload_msb_position : 8,
1491  input_data_path : ScoDataPath,
1492  output_data_path : ScoDataPath,
1493  // Next two items
1494  // [1, 255] The number of bits in each unit of data received from the Host
1495  //          over the audio data transport.
1496  // [0] Not applicable (implied by the choice of audio data transport)
1497  input_transport_unit_bits : 8,
1498  output_transport_unit_bits : 8,
1499  // [0x0004, 0xFFFE]: in milliseconds
1500  //     Upper limit represent the sum of the synchronous interval and the size
1501  //     of the eSCO window, where the eSCO window is reserved slots plus the
1502  //     retransmission window
1503  // [0xFFFF]: don't care
1504  max_latency : 16,
1505  packet_type : 16, // See SynchronousPacketTypeBits
1506  retransmission_effort : RetransmissionEffort,
1507}
1508
1509packet EnhancedAcceptSynchronousConnectionStatus : CommandStatus (command_op_code = ENHANCED_ACCEPT_SYNCHRONOUS_CONNECTION) {
1510}
1511
1512packet RemoteOobExtendedDataRequestReply : Command (op_code = REMOTE_OOB_EXTENDED_DATA_REQUEST_REPLY) {
1513  bd_addr : Address,
1514  c_192 : 8[16],
1515  r_192 : 8[16],
1516  c_256 : 8[16],
1517  r_256 : 8[16],
1518}
1519
1520packet RemoteOobExtendedDataRequestReplyComplete : CommandComplete (command_op_code = REMOTE_OOB_EXTENDED_DATA_REQUEST_REPLY) {
1521  status : ErrorCode,
1522  bd_addr : Address,
1523}
1524
1525
1526  // LINK_POLICY
1527packet HoldMode : Command (op_code = HOLD_MODE) {
1528  connection_handle : 12,
1529  _reserved_ : 4,
1530  hold_mode_max_interval: 16, // 0x0002-0xFFFE (1.25ms-40.9s)
1531  hold_mode_min_interval: 16, // 0x0002-0xFFFE (1.25ms-40.9s)
1532}
1533
1534packet HoldModeStatus : CommandStatus (command_op_code = HOLD_MODE) {
1535}
1536
1537
1538packet SniffMode : Command (op_code = SNIFF_MODE) {
1539  connection_handle : 12,
1540  _reserved_ : 4,
1541  sniff_max_interval: 16, // 0x0002-0xFFFE (1.25ms-40.9s)
1542  sniff_min_interval: 16, // 0x0002-0xFFFE (1.25ms-40.9s)
1543  sniff_attempt: 16, // 0x0001-0x7FFF (1.25ms-40.9s)
1544  sniff_timeout: 16, // 0x0000-0x7FFF (0ms-40.9s)
1545}
1546
1547packet SniffModeStatus : CommandStatus (command_op_code = SNIFF_MODE) {
1548}
1549
1550
1551packet ExitSniffMode : Command (op_code = EXIT_SNIFF_MODE) {
1552  connection_handle : 12,
1553  _reserved_ : 4,
1554}
1555
1556packet ExitSniffModeStatus : CommandStatus (command_op_code = EXIT_SNIFF_MODE) {
1557}
1558
1559enum ServiceType : 8 {
1560  NO_TRAFFIC = 0x00,
1561  BEST_EFFORT = 0x01,
1562  GUARANTEED = 0x02,
1563}
1564
1565packet QosSetup : Command (op_code = QOS_SETUP) {
1566  connection_handle : 12,
1567  _reserved_ : 4,
1568  _reserved_ : 8,
1569  service_type : ServiceType,
1570  token_rate : 32, // Octets/s
1571  peak_bandwidth : 32, // Octets/s
1572  latency : 32, // Octets/s
1573  delay_variation : 32, // microseconds
1574}
1575
1576packet QosSetupStatus : CommandStatus (command_op_code = QOS_SETUP) {
1577}
1578
1579packet RoleDiscovery : Command (op_code = ROLE_DISCOVERY) {
1580  connection_handle : 12,
1581  _reserved_ : 4,
1582}
1583
1584enum Role : 8 {
1585  CENTRAL = 0x00,
1586  PERIPHERAL = 0x01,
1587}
1588
1589packet RoleDiscoveryComplete : CommandComplete (command_op_code = ROLE_DISCOVERY) {
1590  status : ErrorCode,
1591  connection_handle : 12,
1592  _reserved_ : 4,
1593  current_role : Role,
1594}
1595
1596packet SwitchRole : Command (op_code = SWITCH_ROLE) {
1597  bd_addr : Address,
1598  role : Role,
1599}
1600
1601packet SwitchRoleStatus : CommandStatus (command_op_code = SWITCH_ROLE) {
1602}
1603
1604
1605packet ReadLinkPolicySettings : Command (op_code = READ_LINK_POLICY_SETTINGS) {
1606  connection_handle : 12,
1607  _reserved_ : 4,
1608}
1609
1610enum LinkPolicy : 16 {
1611  ENABLE_ROLE_SWITCH = 0x01,
1612  ENABLE_HOLD_MODE = 0x02,
1613  ENABLE_SNIFF_MODE = 0x04,
1614  ENABLE_PARK_MODE = 0x08, // deprecated after 5.0
1615}
1616
1617packet ReadLinkPolicySettingsComplete : CommandComplete (command_op_code = READ_LINK_POLICY_SETTINGS) {
1618  status : ErrorCode,
1619  connection_handle : 12,
1620  _reserved_ : 4,
1621  link_policy_settings : 16,
1622}
1623
1624packet WriteLinkPolicySettings : Command (op_code = WRITE_LINK_POLICY_SETTINGS) {
1625  connection_handle : 12,
1626  _reserved_ : 4,
1627  link_policy_settings : 16,
1628}
1629
1630packet WriteLinkPolicySettingsComplete : CommandComplete (command_op_code = WRITE_LINK_POLICY_SETTINGS) {
1631  status : ErrorCode,
1632  connection_handle : 12,
1633  _reserved_ : 4,
1634}
1635
1636packet ReadDefaultLinkPolicySettings : Command (op_code = READ_DEFAULT_LINK_POLICY_SETTINGS) {
1637}
1638
1639packet ReadDefaultLinkPolicySettingsComplete : CommandComplete (command_op_code = READ_DEFAULT_LINK_POLICY_SETTINGS) {
1640  status : ErrorCode,
1641  default_link_policy_settings : 16,
1642}
1643
1644packet WriteDefaultLinkPolicySettings : Command (op_code = WRITE_DEFAULT_LINK_POLICY_SETTINGS) {
1645  default_link_policy_settings : 16,
1646}
1647
1648packet WriteDefaultLinkPolicySettingsComplete : CommandComplete (command_op_code = WRITE_DEFAULT_LINK_POLICY_SETTINGS) {
1649  status : ErrorCode,
1650}
1651
1652enum FlowDirection : 8 {
1653  OUTGOING_FLOW = 0x00,
1654  INCOMING_FLOW = 0x01,
1655}
1656
1657packet FlowSpecification : Command (op_code = FLOW_SPECIFICATION) {
1658  connection_handle : 12,
1659  _reserved_ : 4,
1660  _reserved_ : 8,
1661  flow_direction : FlowDirection,
1662  service_type : ServiceType,
1663  token_rate : 32, // Octets/s
1664  token_bucket_size : 32,
1665  peak_bandwidth : 32, // Octets/s
1666  access_latency : 32, // Octets/s
1667}
1668
1669packet FlowSpecificationStatus : CommandStatus (command_op_code = FLOW_SPECIFICATION) {
1670}
1671
1672packet SniffSubrating : Command (op_code = SNIFF_SUBRATING) {
1673  connection_handle : 12,
1674  _reserved_ : 4,
1675  maximum_latency : 16,  // 0x0002-0xFFFE (1.25ms-40.9s)
1676  minimum_remote_timeout : 16, // 0x0000-0xFFFE (0-40.9s)
1677  minimum_local_timeout: 16, // 0x0000-0xFFFE (0-40.9s)
1678}
1679
1680packet SniffSubratingComplete : CommandComplete (command_op_code = SNIFF_SUBRATING) {
1681  status : ErrorCode,
1682  connection_handle : 12,
1683  _reserved_ : 4,
1684}
1685
1686  // CONTROLLER_AND_BASEBAND
1687packet SetEventMask : Command (op_code = SET_EVENT_MASK) {
1688  event_mask : 64,
1689}
1690
1691packet SetEventMaskComplete : CommandComplete (command_op_code = SET_EVENT_MASK) {
1692  status : ErrorCode,
1693}
1694
1695packet Reset : Command (op_code = RESET) {
1696}
1697
1698test Reset {
1699  "\x03\x0c\x00",
1700}
1701
1702packet ResetComplete : CommandComplete (command_op_code = RESET) {
1703  status : ErrorCode,
1704}
1705
1706test ResetComplete {
1707  "\x0e\x04\x01\x03\x0c\x00",
1708  "\x0e\x04\x01\x03\x0c\x01", // unknown command
1709}
1710
1711enum FilterType : 8 {
1712  CLEAR_ALL_FILTERS = 0x00,
1713  INQUIRY_RESULT = 0x01,
1714  CONNECTION_SETUP = 0x02,
1715}
1716
1717packet SetEventFilter : Command (op_code = SET_EVENT_FILTER) {
1718  filter_type : FilterType,
1719  _body_,
1720}
1721
1722packet SetEventFilterComplete : CommandComplete (command_op_code = SET_EVENT_FILTER) {
1723  status : ErrorCode,
1724}
1725
1726packet SetEventFilterClearAll : SetEventFilter (filter_type = CLEAR_ALL_FILTERS) {
1727}
1728
1729enum FilterConditionType : 8 {
1730  ALL_DEVICES = 0x00,
1731  CLASS_OF_DEVICE = 0x01,
1732  ADDRESS = 0x02,
1733}
1734
1735packet SetEventFilterInquiryResult : SetEventFilter (filter_type = INQUIRY_RESULT) {
1736  filter_condition_type : FilterConditionType,
1737  _body_,
1738}
1739
1740packet SetEventFilterInquiryResultAllDevices : SetEventFilterInquiryResult (filter_condition_type = ALL_DEVICES) {
1741}
1742
1743packet SetEventFilterInquiryResultClassOfDevice : SetEventFilterInquiryResult (filter_condition_type = CLASS_OF_DEVICE) {
1744  class_of_device : 24,
1745  class_of_device_mask : 24,
1746}
1747
1748packet SetEventFilterInquiryResultAddress : SetEventFilterInquiryResult (filter_condition_type = ADDRESS) {
1749  address : Address,
1750}
1751
1752packet SetEventFilterConnectionSetup : SetEventFilter (filter_type = CONNECTION_SETUP) {
1753  filter_condition_type : FilterConditionType,
1754  _body_,
1755}
1756
1757enum AutoAcceptFlag : 8 {
1758  AUTO_ACCEPT_OFF = 0x01,
1759  AUTO_ACCEPT_ON_ROLE_SWITCH_DISABLED = 0x02,
1760  AUTO_ACCEPT_ON_ROLE_SWITCH_ENABLED = 0x03,
1761}
1762
1763packet SetEventFilterConnectionSetupAllDevices : SetEventFilterConnectionSetup (filter_condition_type = ALL_DEVICES) {
1764  auto_accept_flag : AutoAcceptFlag,
1765}
1766
1767packet SetEventFilterConnectionSetupClassOfDevice : SetEventFilterConnectionSetup (filter_condition_type = CLASS_OF_DEVICE) {
1768  class_of_device : 24,
1769  class_of_device_mask : 24,
1770  auto_accept_flag : AutoAcceptFlag,
1771}
1772
1773packet SetEventFilterConnectionSetupAddress : SetEventFilterConnectionSetup (filter_condition_type = ADDRESS) {
1774  address : Address,
1775  auto_accept_flag : AutoAcceptFlag,
1776}
1777
1778packet Flush : Command (op_code = FLUSH) {
1779  connection_handle : 12,
1780  _reserved_ : 4,
1781}
1782
1783packet FlushComplete : CommandComplete (command_op_code = FLUSH) {
1784  status : ErrorCode,
1785  connection_handle : 12,
1786  _reserved_ : 4,
1787}
1788
1789enum PinType : 8 {
1790  VARIABLE = 0,
1791  FIXED = 1,
1792}
1793
1794packet ReadPinType : Command (op_code = READ_PIN_TYPE) {
1795}
1796
1797packet ReadPinTypeComplete : CommandComplete (command_op_code = READ_PIN_TYPE) {
1798  status : ErrorCode,
1799  pin_type : PinType,
1800}
1801
1802packet WritePinType : Command (op_code = WRITE_PIN_TYPE) {
1803  pin_type : PinType,
1804}
1805
1806packet WritePinTypeComplete : CommandComplete (command_op_code = WRITE_PIN_TYPE) {
1807  status : ErrorCode,
1808}
1809
1810enum ReadStoredLinkKeyReadAllFlag : 8 {
1811  SPECIFIED_BD_ADDR = 0x00,
1812  ALL = 0x01,
1813}
1814
1815packet ReadStoredLinkKey : Command (op_code = READ_STORED_LINK_KEY) {
1816  bd_addr : Address,
1817  read_all_flag : ReadStoredLinkKeyReadAllFlag,
1818}
1819
1820packet ReadStoredLinkKeyComplete : CommandComplete (command_op_code = READ_STORED_LINK_KEY) {
1821  status : ErrorCode,
1822  max_num_keys : 16,
1823  num_keys_read : 16,
1824}
1825
1826struct KeyAndAddress {
1827  address : Address,
1828  link_key : 8[16],
1829}
1830
1831packet WriteStoredLinkKey : Command (op_code = WRITE_STORED_LINK_KEY) {
1832  _count_(keys_to_write) : 8, // 0x01-0x0B
1833  keys_to_write : KeyAndAddress[],
1834}
1835
1836packet WriteStoredLinkKeyComplete : CommandComplete (command_op_code = WRITE_STORED_LINK_KEY) {
1837  status : ErrorCode,
1838  num_keys_written : 8,
1839}
1840
1841enum DeleteStoredLinkKeyDeleteAllFlag : 8 {
1842  SPECIFIED_BD_ADDR = 0x00,
1843  ALL = 0x01,
1844}
1845
1846packet DeleteStoredLinkKey : Command (op_code = DELETE_STORED_LINK_KEY) {
1847  bd_addr : Address,
1848  delete_all_flag : DeleteStoredLinkKeyDeleteAllFlag,
1849}
1850
1851packet DeleteStoredLinkKeyComplete : CommandComplete (command_op_code = DELETE_STORED_LINK_KEY) {
1852  status : ErrorCode,
1853  num_keys_deleted : 16,
1854}
1855
1856packet WriteLocalName : Command (op_code = WRITE_LOCAL_NAME) {
1857  local_name : 8[248], // Null-terminated UTF-8 encoded name
1858}
1859
1860packet WriteLocalNameComplete : CommandComplete (command_op_code = WRITE_LOCAL_NAME) {
1861  status : ErrorCode,
1862}
1863
1864packet ReadLocalName : Command (op_code = READ_LOCAL_NAME) {
1865}
1866
1867packet ReadLocalNameComplete : CommandComplete (command_op_code = READ_LOCAL_NAME) {
1868  status : ErrorCode,
1869  local_name : 8[248], // Null-terminated UTF-8 encoded name
1870}
1871
1872packet ReadConnectionAcceptTimeout : Command (op_code = READ_CONNECTION_ACCEPT_TIMEOUT) {
1873}
1874
1875packet ReadConnectionAcceptTimeoutComplete : CommandComplete (command_op_code = READ_CONNECTION_ACCEPT_TIMEOUT) {
1876  status : ErrorCode,
1877  conn_accept_timeout : 16, // 0x0001 to 0xB540 (N * 0.625 ms) 0.625 ms to 29 s
1878}
1879
1880packet WriteConnectionAcceptTimeout : Command (op_code = WRITE_CONNECTION_ACCEPT_TIMEOUT) {
1881  conn_accept_timeout : 16, // 0x0001 to 0xB540 (N * 0.625 ms) 0.625 ms to 29 s, Default 0x1FA0, 5.06s
1882}
1883
1884packet WriteConnectionAcceptTimeoutComplete : CommandComplete (command_op_code = WRITE_CONNECTION_ACCEPT_TIMEOUT) {
1885  status : ErrorCode,
1886}
1887
1888packet ReadPageTimeout : Command (op_code = READ_PAGE_TIMEOUT) {
1889}
1890
1891test ReadPageTimeout {
1892  "\x17\x0c\x00",
1893}
1894
1895packet ReadPageTimeoutComplete : CommandComplete (command_op_code = READ_PAGE_TIMEOUT) {
1896  status : ErrorCode,
1897  page_timeout : 16,
1898}
1899
1900test ReadPageTimeoutComplete {
1901  "\x0e\x06\x01\x17\x0c\x00\x11\x22",
1902}
1903
1904packet WritePageTimeout : Command (op_code = WRITE_PAGE_TIMEOUT) {
1905  page_timeout : 16,
1906}
1907
1908test WritePageTimeout {
1909  "\x18\x0c\x02\x00\x20",
1910}
1911
1912packet WritePageTimeoutComplete : CommandComplete (command_op_code = WRITE_PAGE_TIMEOUT) {
1913  status : ErrorCode,
1914}
1915
1916test WritePageTimeoutComplete {
1917  "\x0e\x04\x01\x18\x0c\x00",
1918}
1919
1920enum ScanEnable : 8 {
1921  NO_SCANS = 0x00,
1922  INQUIRY_SCAN_ONLY = 0x01,
1923  PAGE_SCAN_ONLY = 0x02,
1924  INQUIRY_AND_PAGE_SCAN = 0x03,
1925}
1926
1927packet ReadScanEnable : Command (op_code = READ_SCAN_ENABLE) {
1928}
1929
1930packet ReadScanEnableComplete : CommandComplete (command_op_code = READ_SCAN_ENABLE) {
1931  status : ErrorCode,
1932  scan_enable : ScanEnable,
1933}
1934
1935packet WriteScanEnable : Command (op_code = WRITE_SCAN_ENABLE) {
1936  scan_enable : ScanEnable,
1937}
1938
1939packet WriteScanEnableComplete : CommandComplete (command_op_code = WRITE_SCAN_ENABLE) {
1940  status : ErrorCode,
1941}
1942
1943packet ReadPageScanActivity : Command (op_code = READ_PAGE_SCAN_ACTIVITY) {
1944}
1945
1946packet ReadPageScanActivityComplete : CommandComplete (command_op_code = READ_PAGE_SCAN_ACTIVITY) {
1947  status : ErrorCode,
1948  page_scan_interval : 16, // Range: 0x0012 to 0x1000; only even values are valid * 0x625 ms
1949  page_scan_window : 16, // 0x0011 to PageScanInterval
1950}
1951
1952packet WritePageScanActivity : Command (op_code = WRITE_PAGE_SCAN_ACTIVITY) {
1953  page_scan_interval : 16, // Range: 0x0012 to 0x1000; only even values are valid * 0x625 ms
1954  page_scan_window : 16, // 0x0011 to PageScanInterval
1955}
1956
1957packet WritePageScanActivityComplete : CommandComplete (command_op_code = WRITE_PAGE_SCAN_ACTIVITY) {
1958  status : ErrorCode,
1959}
1960
1961packet ReadInquiryScanActivity : Command (op_code = READ_INQUIRY_SCAN_ACTIVITY) {
1962}
1963
1964test ReadInquiryScanActivity {
1965  "\x1d\x0c\x00",
1966}
1967
1968packet ReadInquiryScanActivityComplete : CommandComplete (command_op_code = READ_INQUIRY_SCAN_ACTIVITY) {
1969  status : ErrorCode,
1970  inquiry_scan_interval : 16, // Range: 0x0012 to 0x1000; only even values are valid * 0x625 ms
1971  inquiry_scan_window : 16, // Range: 0x0011 to 0x1000
1972}
1973
1974test ReadInquiryScanActivityComplete {
1975  "\x0e\x08\x01\x1d\x0c\x00\xaa\xbb\xcc\xdd",
1976}
1977
1978packet WriteInquiryScanActivity : Command (op_code = WRITE_INQUIRY_SCAN_ACTIVITY) {
1979  inquiry_scan_interval : 16, // Range: 0x0012 to 0x1000; only even values are valid * 0x625 ms
1980  inquiry_scan_window : 16, // Range: 0x0011 to 0x1000
1981}
1982
1983test WriteInquiryScanActivity {
1984  "\x1e\x0c\x04\x00\x08\x12\x00",
1985}
1986
1987packet WriteInquiryScanActivityComplete : CommandComplete (command_op_code = WRITE_INQUIRY_SCAN_ACTIVITY) {
1988  status : ErrorCode,
1989}
1990
1991test WriteInquiryScanActivityComplete {
1992  "\x0e\x04\x01\x1e\x0c\x00",
1993}
1994
1995enum AuthenticationEnable : 8 {
1996  NOT_REQUIRED = 0x00,
1997  REQUIRED = 0x01,
1998}
1999
2000packet ReadAuthenticationEnable : Command (op_code = READ_AUTHENTICATION_ENABLE) {
2001}
2002
2003packet ReadAuthenticationEnableComplete : CommandComplete (command_op_code = READ_AUTHENTICATION_ENABLE) {
2004  status : ErrorCode,
2005  authentication_enable : AuthenticationEnable,
2006}
2007
2008packet WriteAuthenticationEnable : Command (op_code = WRITE_AUTHENTICATION_ENABLE) {
2009  authentication_enable : AuthenticationEnable,
2010}
2011
2012packet WriteAuthenticationEnableComplete : CommandComplete (command_op_code = WRITE_AUTHENTICATION_ENABLE) {
2013  status : ErrorCode,
2014}
2015
2016packet ReadClassOfDevice : Command (op_code = READ_CLASS_OF_DEVICE) {
2017}
2018
2019packet ReadClassOfDeviceComplete : CommandComplete (command_op_code = READ_CLASS_OF_DEVICE) {
2020  status : ErrorCode,
2021  class_of_device : 24,
2022}
2023
2024packet WriteClassOfDevice : Command (op_code = WRITE_CLASS_OF_DEVICE) {
2025  class_of_device : 24,
2026}
2027
2028packet WriteClassOfDeviceComplete : CommandComplete (command_op_code = WRITE_CLASS_OF_DEVICE) {
2029  status : ErrorCode,
2030}
2031
2032packet ReadVoiceSetting : Command (op_code = READ_VOICE_SETTING) {
2033}
2034
2035packet ReadVoiceSettingComplete : CommandComplete (command_op_code = READ_VOICE_SETTING) {
2036  status : ErrorCode,
2037  voice_setting : 10,
2038  _reserved_ : 6,
2039}
2040
2041packet WriteVoiceSetting : Command (op_code = WRITE_VOICE_SETTING) {
2042  voice_setting : 10,
2043  _reserved_ : 6,
2044}
2045
2046packet WriteVoiceSettingComplete : CommandComplete (command_op_code = WRITE_VOICE_SETTING) {
2047  status : ErrorCode,
2048}
2049
2050packet ReadAutomaticFlushTimeout : Command (op_code = READ_AUTOMATIC_FLUSH_TIMEOUT) {
2051  connection_handle : 12,
2052  _reserved_ : 4,
2053}
2054
2055packet ReadAutomaticFlushTimeoutComplete : CommandComplete (command_op_code = READ_AUTOMATIC_FLUSH_TIMEOUT) {
2056  status : ErrorCode,
2057  connection_handle : 12,
2058  _reserved_ : 4,
2059  flush_timeout : 16,
2060}
2061
2062packet WriteAutomaticFlushTimeout : Command (op_code = WRITE_AUTOMATIC_FLUSH_TIMEOUT) {
2063  connection_handle : 12,
2064  _reserved_ : 4,
2065  flush_timeout : 16, // 0x0000-0x07FF Default 0x0000 (No Automatic Flush)
2066}
2067
2068packet WriteAutomaticFlushTimeoutComplete : CommandComplete (command_op_code = WRITE_AUTOMATIC_FLUSH_TIMEOUT) {
2069  status : ErrorCode,
2070  connection_handle : 12,
2071  _reserved_ : 4,
2072}
2073
2074packet ReadNumBroadcastRetransmits : Command (op_code = READ_NUM_BROADCAST_RETRANSMITS) {
2075}
2076
2077packet ReadNumBroadcastRetransmitsComplete : CommandComplete (command_op_code = READ_NUM_BROADCAST_RETRANSMITS) {
2078  status : ErrorCode,
2079  num_broadcast_retransmissions : 8,
2080}
2081
2082packet WriteNumBroadcastRetransmits : Command (op_code = WRITE_NUM_BROADCAST_RETRANSMITS) {
2083  num_broadcast_retransmissions : 8,
2084}
2085
2086packet WriteNumBroadcastRetransmitsComplete : CommandComplete (command_op_code = WRITE_NUM_BROADCAST_RETRANSMITS) {
2087  status : ErrorCode,
2088}
2089
2090enum HoldModeActivity : 8 {
2091  MAINTAIN_CURRENT_POWER_STATE = 0x00,
2092  SUSPEND_PAGE_SCAN = 0x01,
2093  SUSPEND_INQUIRY_SCAN = 0x02,
2094  SUSPEND_PERIODIC_INQUIRY = 0x03,
2095}
2096
2097packet ReadHoldModeActivity : Command (op_code = READ_HOLD_MODE_ACTIVITY) {
2098}
2099
2100packet ReadHoldModeActivityComplete : CommandComplete (command_op_code = READ_HOLD_MODE_ACTIVITY) {
2101  status : ErrorCode,
2102  hold_mode_activity : HoldModeActivity,
2103}
2104
2105packet WriteHoldModeActivity : Command (op_code = WRITE_HOLD_MODE_ACTIVITY) {
2106  hold_mode_activity : HoldModeActivity,
2107}
2108
2109packet WriteHoldModeActivityComplete : CommandComplete (command_op_code = WRITE_HOLD_MODE_ACTIVITY) {
2110  status : ErrorCode,
2111}
2112
2113enum TransmitPowerLevelType : 8 {
2114  CURRENT = 0x00,
2115  MAXIMUM = 0x01,
2116}
2117
2118packet ReadTransmitPowerLevel : Command (op_code = READ_TRANSMIT_POWER_LEVEL) {
2119  connection_handle : 12,
2120  _reserved_ : 4,
2121  transmit_power_level_type : TransmitPowerLevelType,
2122}
2123
2124packet ReadTransmitPowerLevelComplete : CommandComplete (command_op_code = READ_TRANSMIT_POWER_LEVEL) {
2125  status : ErrorCode,
2126  connection_handle : 12,
2127  _reserved_ : 4,
2128  transmit_power_level : 8,
2129}
2130
2131packet ReadSynchronousFlowControlEnable : Command (op_code = READ_SYNCHRONOUS_FLOW_CONTROL_ENABLE) {
2132}
2133
2134packet ReadSynchronousFlowControlEnableComplete : CommandComplete (command_op_code = READ_SYNCHRONOUS_FLOW_CONTROL_ENABLE) {
2135  status : ErrorCode,
2136  enable : Enable,
2137}
2138
2139packet WriteSynchronousFlowControlEnable : Command (op_code = WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE) {
2140  enable : Enable,
2141}
2142
2143packet WriteSynchronousFlowControlEnableComplete : CommandComplete (command_op_code = WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE) {
2144  status : ErrorCode,
2145}
2146
2147packet SetControllerToHostFlowControl : Command (op_code = SET_CONTROLLER_TO_HOST_FLOW_CONTROL) {
2148  acl : 1,
2149  synchronous : 1,
2150  _reserved_ : 6,
2151}
2152
2153packet SetControllerToHostFlowControlComplete : CommandComplete (command_op_code = SET_CONTROLLER_TO_HOST_FLOW_CONTROL) {
2154  status : ErrorCode,
2155}
2156
2157packet HostBufferSize : Command (op_code = HOST_BUFFER_SIZE) {
2158  host_acl_data_packet_length : 16,
2159  host_synchronous_data_packet_length : 8,
2160  host_total_num_acl_data_packets : 16,
2161  host_total_num_synchronous_data_packets : 16,
2162}
2163
2164test HostBufferSize {
2165  "\x33\x0c\x07\x9b\x06\xff\x14\x00\x0a\x00",
2166}
2167
2168packet HostBufferSizeComplete : CommandComplete (command_op_code = HOST_BUFFER_SIZE) {
2169  status : ErrorCode,
2170}
2171
2172test HostBufferSizeComplete {
2173  "\x0e\x04\x01\x33\x0c\x00",
2174}
2175
2176struct CompletedPackets {
2177  connection_handle : 12,
2178  _reserved_ : 4,
2179  host_num_of_completed_packets : 16,
2180}
2181
2182packet HostNumCompletedPackets : Command (op_code = HOST_NUMBER_OF_COMPLETED_PACKETS) {
2183  _count_(completed_packets) : 8,
2184  completed_packets : CompletedPackets[],
2185}
2186
2187packet HostNumCompletedPacketsError : CommandComplete (command_op_code = HOST_NUMBER_OF_COMPLETED_PACKETS) {
2188  error_code : ErrorCode,
2189}
2190
2191packet ReadLinkSupervisionTimeout : Command (op_code = READ_LINK_SUPERVISION_TIMEOUT) {
2192  connection_handle : 12,
2193  _reserved_ : 4,
2194}
2195
2196packet ReadLinkSupervisionTimeoutComplete : CommandComplete (command_op_code = READ_LINK_SUPERVISION_TIMEOUT) {
2197  status : ErrorCode,
2198  connection_handle : 12,
2199  _reserved_ : 4,
2200  link_supervision_timeout : 16, // 0x001-0xFFFF (0.625ms-40.9s)
2201}
2202
2203packet WriteLinkSupervisionTimeout : Command (op_code = WRITE_LINK_SUPERVISION_TIMEOUT) {
2204  connection_handle : 12,
2205  _reserved_ : 4,
2206  link_supervision_timeout : 16, // 0x001-0xFFFF (0.625ms-40.9s)
2207}
2208
2209packet WriteLinkSupervisionTimeoutComplete : CommandComplete (command_op_code = WRITE_LINK_SUPERVISION_TIMEOUT) {
2210  status : ErrorCode,
2211  connection_handle : 12,
2212  _reserved_ : 4,
2213}
2214
2215packet ReadNumberOfSupportedIac : Command (op_code = READ_NUMBER_OF_SUPPORTED_IAC) {
2216}
2217
2218test ReadNumberOfSupportedIac {
2219  "\x38\x0c\x00",
2220}
2221
2222packet ReadNumberOfSupportedIacComplete : CommandComplete (command_op_code = READ_NUMBER_OF_SUPPORTED_IAC) {
2223  status : ErrorCode,
2224  num_support_iac : 8,
2225}
2226
2227test ReadNumberOfSupportedIacComplete {
2228  "\x0e\x05\x01\x38\x0c\x00\x99",
2229}
2230
2231packet ReadCurrentIacLap : Command (op_code = READ_CURRENT_IAC_LAP) {
2232}
2233
2234test ReadCurrentIacLap {
2235  "\x39\x0c\x00",
2236}
2237
2238packet ReadCurrentIacLapComplete : CommandComplete (command_op_code = READ_CURRENT_IAC_LAP) {
2239  status : ErrorCode,
2240  _count_(laps_to_read) : 8,
2241  laps_to_read : Lap[],
2242}
2243
2244test ReadCurrentIacLapComplete {
2245  "\x0e\x0b\x01\x39\x0c\x00\x02\x11\x8b\x9e\x22\x8b\x9e",
2246}
2247
2248packet WriteCurrentIacLap : Command (op_code = WRITE_CURRENT_IAC_LAP) {
2249  _count_(laps_to_write) : 8,
2250  laps_to_write : Lap[],
2251}
2252
2253test WriteCurrentIacLap {
2254  "\x3a\x0c\x07\x02\x11\x8b\x9e\x22\x8b\x9e",
2255}
2256
2257packet WriteCurrentIacLapComplete : CommandComplete (command_op_code = WRITE_CURRENT_IAC_LAP) {
2258  status : ErrorCode,
2259}
2260
2261test WriteCurrentIacLapComplete {
2262  "\x0e\x04\x01\x3a\x0c\x00",
2263}
2264
2265packet SetAfhHostChannelClassification : Command (op_code = SET_AFH_HOST_CHANNEL_CLASSIFICATION) {
2266  afh_host_channel_classification : 8[10],
2267}
2268
2269packet SetAfhHostChannelClassificationComplete : CommandComplete (command_op_code = SET_AFH_HOST_CHANNEL_CLASSIFICATION) {
2270  status : ErrorCode,
2271}
2272
2273enum InquiryScanType : 8 {
2274  STANDARD = 0x00,
2275  INTERLACED = 0x01,
2276}
2277
2278packet ReadInquiryScanType : Command (op_code = READ_INQUIRY_SCAN_TYPE) {
2279}
2280
2281packet ReadInquiryScanTypeComplete : CommandComplete (command_op_code = READ_INQUIRY_SCAN_TYPE) {
2282  status : ErrorCode,
2283  inquiry_scan_type : InquiryScanType,
2284}
2285
2286packet WriteInquiryScanType : Command (op_code = WRITE_INQUIRY_SCAN_TYPE) {
2287  inquiry_scan_type : InquiryScanType,
2288}
2289
2290packet WriteInquiryScanTypeComplete : CommandComplete (command_op_code = WRITE_INQUIRY_SCAN_TYPE) {
2291  status : ErrorCode,
2292}
2293
2294enum InquiryMode : 8 {
2295  STANDARD = 0x00,
2296  RSSI = 0x01,
2297  RSSI_OR_EXTENDED = 0x02,
2298}
2299
2300packet ReadInquiryMode : Command (op_code = READ_INQUIRY_MODE) {
2301}
2302
2303packet ReadInquiryModeComplete : CommandComplete (command_op_code = READ_INQUIRY_MODE) {
2304  status : ErrorCode,
2305  inquiry_mode : InquiryMode,
2306}
2307
2308packet WriteInquiryMode : Command (op_code = WRITE_INQUIRY_MODE) {
2309  inquiry_mode : InquiryMode,
2310}
2311
2312packet WriteInquiryModeComplete : CommandComplete (command_op_code = WRITE_INQUIRY_MODE) {
2313  status : ErrorCode,
2314}
2315
2316enum PageScanType : 8 {
2317  STANDARD = 0x00,
2318  INTERLACED = 0x01,
2319}
2320
2321packet ReadPageScanType : Command (op_code = READ_PAGE_SCAN_TYPE) {
2322}
2323
2324packet ReadPageScanTypeComplete : CommandComplete (command_op_code = READ_PAGE_SCAN_TYPE) {
2325  status : ErrorCode,
2326  page_scan_type : PageScanType,
2327}
2328
2329packet WritePageScanType : Command (op_code = WRITE_PAGE_SCAN_TYPE) {
2330  page_scan_type : PageScanType,
2331}
2332
2333packet WritePageScanTypeComplete : CommandComplete (command_op_code = WRITE_PAGE_SCAN_TYPE) {
2334  status : ErrorCode,
2335}
2336
2337packet ReadAfhChannelAssessmentMode : Command (op_code = READ_AFH_CHANNEL_ASSESSMENT_MODE) {
2338}
2339
2340packet ReadAfhChannelAssessmentModeComplete : CommandComplete (command_op_code = READ_AFH_CHANNEL_ASSESSMENT_MODE) {
2341  status : ErrorCode,
2342  controller_channel_assessment : Enable,
2343}
2344
2345packet WriteAfhChannelAssessmentMode : Command (op_code = WRITE_AFH_CHANNEL_ASSESSMENT_MODE) {
2346  controller_channel_assessment : Enable,
2347}
2348
2349packet WriteAfhChannelAssessmentModeComplete : CommandComplete (command_op_code = WRITE_AFH_CHANNEL_ASSESSMENT_MODE) {
2350  status : ErrorCode,
2351}
2352
2353enum FecRequired : 8 {
2354  NOT_REQUIRED = 0x00,
2355  REQUIRED = 0x01,
2356}
2357
2358packet ReadExtendedInquiryResponse : Command (op_code = READ_EXTENDED_INQUIRY_RESPONSE) {
2359}
2360
2361packet ReadExtendedInquiryResponseComplete : CommandComplete (command_op_code = READ_EXTENDED_INQUIRY_RESPONSE) {
2362  status : ErrorCode,
2363  fec_required : FecRequired,
2364  extended_inquiry_response : 8[240],
2365}
2366
2367packet WriteExtendedInquiryResponse : Command (op_code = WRITE_EXTENDED_INQUIRY_RESPONSE) {
2368  fec_required : FecRequired,
2369  extended_inquiry_response : 8[240],
2370}
2371
2372packet WriteExtendedInquiryResponseComplete : CommandComplete (command_op_code = WRITE_EXTENDED_INQUIRY_RESPONSE) {
2373  status : ErrorCode,
2374}
2375
2376packet RefreshEncryptionKey : Command (op_code = REFRESH_ENCRYPTION_KEY) {
2377  connection_handle : 12,
2378  _reserved_ : 4,
2379}
2380
2381packet RefreshEncryptionKeyStatus : CommandStatus (command_op_code = REFRESH_ENCRYPTION_KEY) {
2382}
2383
2384packet ReadSimplePairingMode : Command (op_code = READ_SIMPLE_PAIRING_MODE) {
2385}
2386
2387packet ReadSimplePairingModeComplete : CommandComplete (command_op_code = READ_SIMPLE_PAIRING_MODE) {
2388  status : ErrorCode,
2389  simple_pairing_mode : Enable,
2390}
2391
2392packet WriteSimplePairingMode : Command (op_code = WRITE_SIMPLE_PAIRING_MODE) {
2393  simple_pairing_mode : Enable,
2394}
2395
2396test WriteSimplePairingMode {
2397  "\x56\x0c\x01\x01",
2398}
2399
2400packet WriteSimplePairingModeComplete : CommandComplete (command_op_code = WRITE_SIMPLE_PAIRING_MODE) {
2401  status : ErrorCode,
2402}
2403
2404test WriteSimplePairingModeComplete {
2405  "\x0e\x04\x01\x56\x0c\x00",
2406}
2407
2408packet ReadLocalOobData : Command (op_code = READ_LOCAL_OOB_DATA) {
2409}
2410
2411packet ReadLocalOobDataComplete : CommandComplete (command_op_code = READ_LOCAL_OOB_DATA) {
2412  status : ErrorCode,
2413  c : 8[16],
2414  r : 8[16],
2415}
2416
2417packet ReadInquiryResponseTransmitPowerLevel : Command (op_code = READ_INQUIRY_RESPONSE_TRANSMIT_POWER_LEVEL) {
2418}
2419
2420packet ReadInquiryResponseTransmitPowerLevelComplete : CommandComplete (command_op_code = READ_INQUIRY_RESPONSE_TRANSMIT_POWER_LEVEL) {
2421  status : ErrorCode,
2422  tx_power : 8, // (-70dBm to 20dBm)
2423}
2424
2425packet WriteInquiryTransmitPowerLevel : Command (op_code = WRITE_INQUIRY_TRANSMIT_POWER_LEVEL) {
2426  tx_power : 8,
2427}
2428
2429packet WriteInquiryResponseTransmitPowerLevelComplete : CommandComplete (command_op_code = WRITE_INQUIRY_TRANSMIT_POWER_LEVEL) {
2430  status : ErrorCode,
2431}
2432
2433enum KeypressNotificationType : 8 {
2434  ENTRY_STARTED = 0,
2435  DIGIT_ENTERED = 1,
2436  DIGIT_ERASED = 2,
2437  CLEARED = 3,
2438  ENTRY_COMPLETED = 4,
2439}
2440
2441packet SendKeypressNotification : Command (op_code = SEND_KEYPRESS_NOTIFICATION) {
2442  bd_addr : Address,
2443  notification_type : KeypressNotificationType,
2444}
2445
2446packet SendKeypressNotificationComplete : CommandComplete (command_op_code = SEND_KEYPRESS_NOTIFICATION) {
2447  status : ErrorCode,
2448  bd_addr : Address,
2449}
2450
2451packet SetEventMaskPage2 : Command (op_code = SET_EVENT_MASK_PAGE_2) {
2452  event_mask_page_2: 64,
2453}
2454
2455packet SetEventMaskPage2Complete : CommandComplete (command_op_code = SET_EVENT_MASK_PAGE_2) {
2456  status: ErrorCode,
2457}
2458
2459packet ReadEnhancedTransmitPowerLevel : Command (op_code = READ_ENHANCED_TRANSMIT_POWER_LEVEL) {
2460  connection_handle : 12,
2461  _reserved_ : 4,
2462  transmit_power_level_type : TransmitPowerLevelType,
2463}
2464
2465packet ReadEnhancedTransmitPowerLevelComplete : CommandComplete (command_op_code = READ_ENHANCED_TRANSMIT_POWER_LEVEL) {
2466  status : ErrorCode,
2467  connection_handle : 12,
2468  _reserved_ : 4,
2469  tx_power_level_gfsk : 8,
2470  tx_power_level_dqpsk : 8,
2471  tx_power_level_8dpsk : 8,
2472}
2473
2474packet ReadLeHostSupport : Command (op_code = READ_LE_HOST_SUPPORT) {
2475}
2476
2477packet ReadLeHostSupportComplete : CommandComplete (command_op_code = READ_LE_HOST_SUPPORT) {
2478  status : ErrorCode,
2479  le_supported_host : Enable,
2480  _reserved_ : 8, // simultaneous_le_host reserved since 4.1
2481}
2482
2483packet WriteLeHostSupport : Command (op_code = WRITE_LE_HOST_SUPPORT) {
2484  le_supported_host : Enable,
2485  simultaneous_le_host : Enable,  // According to the spec, this should be 0x00 since 4.1
2486}
2487
2488test WriteLeHostSupport {
2489  "\x6d\x0c\x02\x01\x01",
2490}
2491
2492packet WriteLeHostSupportComplete : CommandComplete (command_op_code = WRITE_LE_HOST_SUPPORT) {
2493  status : ErrorCode,
2494}
2495
2496test WriteLeHostSupportComplete {
2497  "\x0e\x04\x01\x6d\x0c\x00",
2498}
2499
2500packet ReadSecureConnectionsHostSupport : Command (op_code = READ_SECURE_CONNECTIONS_HOST_SUPPORT) {
2501}
2502
2503packet ReadSecureConnectionsHostSupportComplete : CommandComplete (command_op_code = READ_SECURE_CONNECTIONS_HOST_SUPPORT) {
2504  status : ErrorCode,
2505  secure_connections_host_support : Enable,
2506}
2507
2508packet WriteSecureConnectionsHostSupport : Command (op_code = WRITE_SECURE_CONNECTIONS_HOST_SUPPORT) {
2509  secure_connections_host_support : Enable,
2510}
2511
2512test WriteSecureConnectionsHostSupport {
2513  "\x7a\x0c\x01\x01",
2514}
2515
2516packet WriteSecureConnectionsHostSupportComplete : CommandComplete (command_op_code = WRITE_SECURE_CONNECTIONS_HOST_SUPPORT) {
2517  status : ErrorCode,
2518}
2519
2520test WriteSecureConnectionsHostSupportComplete {
2521  "\x0e\x04\x01\x7a\x0c\x00",
2522}
2523
2524packet ReadLocalOobExtendedData : Command (op_code = READ_LOCAL_OOB_EXTENDED_DATA) {
2525}
2526
2527packet ReadLocalOobExtendedDataComplete : CommandComplete (command_op_code = READ_LOCAL_OOB_EXTENDED_DATA) {
2528  status : ErrorCode,
2529  c_192 : 8[16],
2530  r_192 : 8[16],
2531  c_256 : 8[16],
2532  r_256 : 8[16],
2533}
2534
2535packet SetEcosystemBaseInterval : Command (op_code = SET_ECOSYSTEM_BASE_INTERVAL) {
2536  interval : 16,
2537}
2538
2539packet SetEcosystemBaseIntervalComplete : CommandComplete (command_op_code = SET_ECOSYSTEM_BASE_INTERVAL) {
2540  status : ErrorCode,
2541}
2542
2543enum DataPathDirection : 8 {
2544  INPUT = 0,
2545  OUTPUT = 1,
2546}
2547
2548packet ConfigureDataPath : Command (op_code = CONFIGURE_DATA_PATH) {
2549  data_path_direction : DataPathDirection,
2550  data_path_id : 8,
2551  _size_(vendor_specific_config) : 8,
2552  vendor_specific_config : 8[],
2553}
2554
2555packet ConfigureDataPathComplete : CommandComplete (command_op_code = CONFIGURE_DATA_PATH) {
2556  status : ErrorCode,
2557}
2558
2559packet SetMinEncryptionKeySize : Command (op_code = SET_MIN_ENCRYPTION_KEY_SIZE) {
2560  min_encryption_key_size : 8,
2561}
2562
2563packet SetMinEncryptionKeySizeComplete : CommandComplete (command_op_code = SET_MIN_ENCRYPTION_KEY_SIZE) {
2564  status : ErrorCode,
2565}
2566
2567
2568  // INFORMATIONAL_PARAMETERS
2569packet ReadLocalVersionInformation : Command (op_code = READ_LOCAL_VERSION_INFORMATION) {
2570}
2571
2572test ReadLocalVersionInformation {
2573  "\x01\x10\x00",
2574}
2575
2576enum HciVersion : 8 {
2577  V_1_0B = 0x00,
2578  V_1_1 = 0x01,
2579  V_1_2 = 0x02,
2580  V_2_0 = 0x03, //  + EDR
2581  V_2_1 = 0x04, //  + EDR
2582  V_3_0 = 0x05, //  + HS
2583  V_4_0 = 0x06,
2584  V_4_1 = 0x07,
2585  V_4_2 = 0x08,
2586  V_5_0 = 0x09,
2587  V_5_1 = 0x0a,
2588  V_5_2 = 0x0b,
2589  V_5_3 = 0x0c,
2590  V_5_4 = 0x0d,
2591}
2592
2593enum LmpVersion : 8 {
2594  V_1_0B = 0x00, // withdrawn
2595  V_1_1 = 0x01, // withdrawn
2596  V_1_2 = 0x02, // withdrawn
2597  V_2_0 = 0x03, //  + EDR
2598  V_2_1 = 0x04, //  + EDR
2599  V_3_0 = 0x05, //  + HS
2600  V_4_0 = 0x06,
2601  V_4_1 = 0x07,
2602  V_4_2 = 0x08,
2603  V_5_0 = 0x09,
2604  V_5_1 = 0x0a,
2605  V_5_2 = 0x0b,
2606  V_5_3 = 0x0c,
2607  V_5_4 = 0x0d,
2608}
2609
2610struct LocalVersionInformation {
2611  hci_version : HciVersion,
2612  hci_revision : 16,
2613  lmp_version : LmpVersion,
2614  manufacturer_name : 16,
2615  lmp_subversion : 16,
2616}
2617
2618packet ReadLocalVersionInformationComplete : CommandComplete (command_op_code = READ_LOCAL_VERSION_INFORMATION) {
2619  status : ErrorCode,
2620  local_version_information : LocalVersionInformation,
2621}
2622
2623test ReadLocalVersionInformationComplete {
2624  "\x0e\x0c\x01\x01\x10\x00\x09\x00\x00\x09\x1d\x00\xbe\x02",
2625}
2626
2627packet ReadLocalSupportedCommands : Command (op_code = READ_LOCAL_SUPPORTED_COMMANDS) {
2628}
2629
2630test ReadLocalSupportedCommands {
2631  "\x02\x10\x00",
2632}
2633
2634packet ReadLocalSupportedCommandsComplete : CommandComplete (command_op_code = READ_LOCAL_SUPPORTED_COMMANDS) {
2635  status : ErrorCode,
2636  supported_commands : 8[64],
2637}
2638
2639test ReadLocalSupportedCommandsComplete {
2640  "\x0e\x44\x01\x02\x10\x00\xff\xff\xff\x03\xce\xff\xef\xff\xff\xff\xff\x7f\xf2\x0f\xe8\xfe\x3f\xf7\x83\xff\x1c\x00\x00\x00\x61\xff\xff\xff\x7f\xbe\x20\xf5\xff\xf0\xff\xff\xff\xff\xff\x07\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
2641}
2642
2643packet ReadLocalSupportedFeatures : Command (op_code = READ_LOCAL_SUPPORTED_FEATURES) {
2644}
2645
2646packet ReadLocalSupportedFeaturesComplete : CommandComplete (command_op_code = READ_LOCAL_SUPPORTED_FEATURES) {
2647  status : ErrorCode,
2648  lmp_features : 64,
2649}
2650
2651packet ReadLocalExtendedFeatures : Command (op_code = READ_LOCAL_EXTENDED_FEATURES) {
2652  page_number : 8,
2653}
2654
2655test ReadLocalExtendedFeatures {
2656  "\x04\x10\x01\x00",
2657  "\x04\x10\x01\x01",
2658  "\x04\x10\x01\x02",
2659}
2660
2661enum LMPFeaturesPage0Bits: 64 {
2662  // Byte 0
2663  LMP_3_SLOT_PACKETS = 0x01,
2664  LMP_5_SLOT_PACKETS = 0x02,
2665  ENCRYPTION         = 0x04,
2666  SLOT_OFFSET        = 0x08,
2667  TIMING_ACCURACY    = 0x10,
2668  ROLE_SWITCH        = 0x20,
2669  HOLD_MODE          = 0x40,
2670  SNIFF_MODE         = 0x80,
2671
2672  // Byte 1
2673  POWER_CONTROL_REQUESTS           = 0x0200,
2674  CHANNEL_QUALITY_DRIVEN_DATA_RATE = 0x0400,
2675  SCO_LINK                         = 0x0800,
2676  HV2_PACKETS                      = 0x1000,
2677  HV3_PACKETS                      = 0x2000,
2678  M_LAW_LOG_SYNCHRONOUS_DATA       = 0x4000,
2679  A_LAW_LOG_SYNCHRONOUS_DATA       = 0x8000,
2680
2681  // Byte 2
2682  CVSD_SYNCHRONOUS_DATA                  = 0x010000,
2683  PAGING_PARAMETER_NEGOTIATION           = 0x020000,
2684  POWER_CONTROL                          = 0x040000,
2685  TRANSPARENT_SYNCHRONOUS_DATA           = 0x080000,
2686  FLOW_CONTROL_LAG_LEAST_SIGNIFICANT_BIT = 0x100000,
2687  FLOW_CONTROL_LAG_MIDDLE_BIT            = 0x200000,
2688  FLOW_CONTROL_LAG_MOST_SIGNIFICANT_BIT  = 0x400000,
2689  BROADCAST_ENCRYPTION                   = 0x800000,
2690
2691  // Byte 3
2692  ENHANCED_DATA_RATE_ACL_2_MB_S_MODE = 0x02000000,
2693  ENHANCED_DATA_RATE_ACL_3_MB_S_MODE = 0x04000000,
2694  ENHANCED_INQUIRY_SCAN              = 0x08000000,
2695  INTERLACED_INQUIRY_SCAN            = 0x10000000,
2696  INTERLACED_PAGE_SCAN               = 0x20000000,
2697  RSSI_WITH_INQUIRY_RESULTS          = 0x40000000,
2698  EXTENDED_SCO_LINK                  = 0x80000000,
2699
2700  // Byte 4
2701  EV4_PACKETS                               = 0x0100000000,
2702  EV5_PACKETS                               = 0x0200000000,
2703  AFH_CAPABLE_PERIPHERAL                    = 0x0800000000,
2704  AFH_CLASSIFICATION_PERIPHERAL             = 0x1000000000,
2705  BR_EDR_NOT_SUPPORTED                      = 0x2000000000,
2706  LE_SUPPORTED_CONTROLLER                   = 0x4000000000,
2707  LMP_3_SLOT_ENHANCED_DATA_RATE_ACL_PACKETS = 0x8000000000,
2708
2709  // Byte 5
2710  LMP_5_SLOT_ENHANCED_DATA_RATE_ACL_PACKETS  = 0x010000000000,
2711  SNIFF_SUBRATING                            = 0x020000000000,
2712  PAUSE_ENCRYPTION                           = 0x040000000000,
2713  AFH_CAPABLE_CENTRAL                        = 0x080000000000,
2714  AFH_CLASSIFICATION_CENTRAL                 = 0x100000000000,
2715  ENHANCED_DATA_RATE_ESCO_2_MB_S_MODE        = 0x200000000000,
2716  ENHANCED_DATA_RATE_ESCO_3_MB_S_MODE        = 0x400000000000,
2717  LMP_3_SLOT_ENHANCED_DATA_RATE_ESCO_PACKETS = 0x800000000000,
2718
2719  // Byte 6
2720  EXTENDED_INQUIRY_RESPONSE          = 0x01000000000000,
2721  SIMULTANEOUS_LE_AND_BR_CONTROLLER  = 0x02000000000000,
2722  SECURE_SIMPLE_PAIRING_CONTROLLER   = 0x08000000000000,
2723  ENCAPSULATED_PDU                   = 0x10000000000000,
2724  ERRONEOUS_DATA_REPORTING           = 0x20000000000000,
2725  NON_FLUSHABLE_PACKET_BOUNDARY_FLAG = 0x40000000000000,
2726
2727  // Byte 7
2728  HCI_LINK_SUPERVISION_TIMEOUT_CHANGED_EVENT = 0x0100000000000000,
2729  VARIABLE_INQUIRY_TX_POWER_LEVEL            = 0x0200000000000000,
2730  ENHANCED_POWER_CONTROL                     = 0x0400000000000000,
2731  EXTENDED_FEATURES                          = 0x8000000000000000,
2732}
2733
2734enum LMPFeaturesPage1Bits: 64 {
2735  // Byte 0
2736  SECURE_SIMPLE_PAIRING_HOST_SUPPORT = 0x01,
2737  LE_SUPPORTED_HOST                  = 0x02,
2738  SIMULTANEOUS_LE_AND_BR_HOST        = 0x04,
2739  SECURE_CONNECTIONS_HOST_SUPPORT    = 0x08,
2740}
2741
2742enum LMPFeaturesPage2Bits: 64 {
2743  // Byte 0
2744  CONNECTIONLESS_PERIPHERAL_BROADCAST_TRANSMITTER_OPERATION = 0x01,
2745  CONNECTIONLESS_PERIPHERAL_BROADCAST_RECEIVER_OPERATION    = 0x02,
2746  SYNCHRONIZATION_TRAIN                                     = 0x04,
2747  SYNCHRONIZATION_SCAN                                      = 0x08,
2748  HCI_INQUIRY_RESPONSE_NOTIFICATION_EVENT                   = 0x10,
2749  GENERALIZED_INTERLACED_SCAN                               = 0x20,
2750  COARSE_CLOCK_ADJUSTMENT                                   = 0x40,
2751
2752  // Byte 1
2753  SECURE_CONNECTIONS_CONTROLLER_SUPPORT = 0x0100,
2754  PING                                  = 0x0200,
2755  SLOT_AVAILABILITY_MASK                = 0x0400,
2756  TRAIN_NUDGING                         = 0x0800,
2757}
2758
2759packet ReadLocalExtendedFeaturesComplete : CommandComplete (command_op_code = READ_LOCAL_EXTENDED_FEATURES) {
2760  status : ErrorCode,
2761  page_number : 8,
2762  maximum_page_number : 8,
2763  extended_lmp_features : 64,
2764}
2765
2766test ReadLocalExtendedFeaturesComplete {
2767  "\x0e\x0e\x01\x04\x10\x00\x00\x02\xff\xfe\x8f\xfe\xd8\x3f\x5b\x87",
2768  "\x0e\x0e\x01\x04\x10\x00\x01\x02\x07\x00\x00\x00\x00\x00\x00\x00",
2769  "\x0e\x0e\x01\x04\x10\x00\x02\x02\x45\x03\x00\x00\x00\x00\x00\x00",
2770}
2771
2772packet ReadBufferSize : Command (op_code = READ_BUFFER_SIZE) {
2773}
2774
2775test ReadBufferSize {
2776  "\x05\x10\x00",
2777}
2778
2779packet ReadBufferSizeComplete : CommandComplete (command_op_code = READ_BUFFER_SIZE) {
2780  status : ErrorCode,
2781  acl_data_packet_length : 16,
2782  synchronous_data_packet_length : 8,
2783  total_num_acl_data_packets : 16,
2784  total_num_synchronous_data_packets : 16,
2785}
2786
2787test ReadBufferSizeComplete {
2788  "\x0e\x0b\x01\x05\x10\x00\x00\x04\x3c\x07\x00\x08\x00",
2789}
2790
2791packet ReadBdAddr : Command (op_code = READ_BD_ADDR) {
2792}
2793
2794test ReadBdAddr {
2795  "\x09\x10\x00",
2796}
2797
2798packet ReadBdAddrComplete : CommandComplete (command_op_code = READ_BD_ADDR) {
2799  status : ErrorCode,
2800  bd_addr : Address,
2801}
2802
2803test ReadBdAddrComplete {
2804  "\x0e\x0a\x01\x09\x10\x00\x14\x8e\x61\x5f\x36\x88",
2805}
2806
2807packet ReadDataBlockSize : Command (op_code = READ_DATA_BLOCK_SIZE) {
2808}
2809
2810packet ReadDataBlockSizeComplete : CommandComplete (command_op_code = READ_DATA_BLOCK_SIZE) {
2811  status : ErrorCode,
2812  max_acl_data_packet_length : 16,
2813  data_block_length : 16,
2814  total_num_data_blocks : 16,
2815}
2816
2817packet ReadLocalSupportedCodecsV1 : Command (op_code = READ_LOCAL_SUPPORTED_CODECS_V1) {
2818}
2819
2820packet ReadLocalSupportedCodecsV1Complete : CommandComplete (command_op_code = READ_LOCAL_SUPPORTED_CODECS_V1) {
2821  status : ErrorCode,
2822  _count_(supported_codecs) : 8,
2823  supported_codecs : 8[],
2824  _count_(vendor_specific_codecs) : 8,
2825  vendor_specific_codecs : 32[],
2826}
2827
2828packet ReadLocalSupportedCodecsV2 : Command (op_code = READ_LOCAL_SUPPORTED_CODECS_V2) {
2829}
2830
2831group CodecTransport {
2832  br_edr : 1,
2833  br_edr_sco_and_esco : 1,
2834  le_cis : 1,
2835  le_bis : 1,
2836  _reserved_ : 4,
2837}
2838
2839struct CodecConfiguration {
2840  codec_id : 8,
2841  CodecTransport,
2842}
2843
2844struct VendorCodecConfiguration {
2845  company_id : 16,
2846  codec_vendor_id : 16,
2847  CodecTransport,
2848}
2849
2850packet ReadLocalSupportedCodecsV2Complete : CommandComplete (command_op_code = READ_LOCAL_SUPPORTED_CODECS_V2) {
2851  status : ErrorCode,
2852  _count_(supported_codecs) : 8,
2853  supported_codecs : CodecConfiguration[],
2854  _count_(vendor_specific_codecs) : 8,
2855  vendor_specific_codecs : VendorCodecConfiguration[],
2856}
2857
2858packet ReadLocalSupportedCodecCapabilities : Command (op_code = READ_LOCAL_SUPPORTED_CODEC_CAPABILITIES) {
2859  codec_id : 8,
2860  company_id : 16,
2861  codec_vendor_id : 16,
2862  CodecTransport,
2863  direction : DataPathDirection,
2864}
2865
2866struct CodecCapability {
2867  _size_(capability) : 8,
2868  capability : 8[],
2869}
2870
2871packet ReadLocalSupportedCodecCapabilitiesComplete : CommandComplete (command_op_code = READ_LOCAL_SUPPORTED_CODEC_CAPABILITIES) {
2872  status : ErrorCode,
2873  _count_(codec_capabilities) : 8,
2874  codec_capabilities : CodecCapability[],
2875}
2876
2877packet ReadLocalSupportedControllerDelay : Command (op_code = READ_LOCAL_SUPPORTED_CONTROLLER_DELAY) {
2878  codec_id : 8,
2879  company_id : 16,
2880  codec_vendor_id : 16,
2881  CodecTransport,
2882  direction : DataPathDirection,
2883  _size_(codec_configuration) : 8,
2884  codec_configuration : 8[],
2885}
2886
2887packet ReadLocalSupportedControllerDelayComplete : CommandComplete (command_op_code = READ_LOCAL_SUPPORTED_CONTROLLER_DELAY) {
2888  status : ErrorCode,
2889  min_controller_delay : 24,
2890  max_controller_delay : 24,
2891}
2892
2893
2894  // STATUS_PARAMETERS
2895packet ReadFailedContactCounter : Command (op_code = READ_FAILED_CONTACT_COUNTER) {
2896  connection_handle : 12,
2897  _reserved_ : 4,
2898}
2899
2900packet ReadFailedContactCounterComplete : CommandComplete (command_op_code = READ_FAILED_CONTACT_COUNTER) {
2901  status : ErrorCode,
2902  connection_handle : 12,
2903  _reserved_ : 4,
2904  failed_contact_counter : 16,
2905}
2906
2907packet ResetFailedContactCounter : Command (op_code = RESET_FAILED_CONTACT_COUNTER) {
2908  connection_handle : 12,
2909  _reserved_ : 4,
2910}
2911
2912packet ResetFailedContactCounterComplete : CommandComplete (command_op_code = RESET_FAILED_CONTACT_COUNTER) {
2913  status : ErrorCode,
2914  connection_handle : 12,
2915  _reserved_ : 4,
2916}
2917
2918packet ReadLinkQuality : Command (op_code = READ_LINK_QUALITY) {
2919  connection_handle : 12,
2920  _reserved_ : 4,
2921}
2922
2923packet ReadLinkQualityComplete : CommandComplete (command_op_code = READ_LINK_QUALITY) {
2924  status : ErrorCode,
2925  connection_handle : 12,
2926  _reserved_ : 4,
2927  link_quality : 8,
2928}
2929
2930packet ReadRssi : Command (op_code = READ_RSSI) {
2931  connection_handle : 12,
2932  _reserved_ : 4,
2933}
2934
2935packet ReadRssiComplete : CommandComplete (command_op_code = READ_RSSI) {
2936  status : ErrorCode,
2937  connection_handle : 12,
2938  _reserved_ : 4,
2939  rssi : 8,
2940}
2941
2942packet ReadAfhChannelMap : Command (op_code = READ_AFH_CHANNEL_MAP) {
2943  connection_handle : 12,
2944  _reserved_ : 4,
2945}
2946
2947enum AfhMode : 8 {
2948  AFH_DISABLED = 0x00,
2949  AFH_ENABLED = 0x01,
2950}
2951
2952packet ReadAfhChannelMapComplete : CommandComplete (command_op_code = READ_AFH_CHANNEL_MAP) {
2953  status : ErrorCode,
2954  connection_handle : 12,
2955  _reserved_ : 4,
2956  afh_mode : AfhMode,
2957  afh_channel_map : 8[10],
2958}
2959
2960
2961enum WhichClock : 8 {
2962  LOCAL = 0x00,
2963  PICONET = 0x01,
2964}
2965
2966packet ReadClock : Command (op_code = READ_CLOCK) {
2967  connection_handle : 12,
2968  _reserved_ : 4,
2969  which_clock : WhichClock,
2970}
2971
2972packet ReadClockComplete : CommandComplete (command_op_code = READ_CLOCK) {
2973  status : ErrorCode,
2974  connection_handle : 12,
2975  _reserved_ : 4,
2976  clock : 28,
2977  _reserved_ : 4,
2978  accuracy : 16,
2979}
2980
2981packet ReadEncryptionKeySize : Command (op_code = READ_ENCRYPTION_KEY_SIZE) {
2982  connection_handle : 12,
2983  _reserved_ : 4,
2984}
2985
2986packet ReadEncryptionKeySizeComplete : CommandComplete (command_op_code = READ_ENCRYPTION_KEY_SIZE) {
2987  status : ErrorCode,
2988  connection_handle : 12,
2989  _reserved_ : 4,
2990  key_size : 8,
2991}
2992
2993  // TESTING
2994enum LoopbackMode : 8 {
2995  NO_LOOPBACK = 0x00,
2996  ENABLE_LOCAL = 0x01,
2997  ENABLE_REMOTE = 0x02,
2998}
2999
3000packet ReadLoopbackMode : Command (op_code = READ_LOOPBACK_MODE) {
3001}
3002
3003packet ReadLoopbackModeComplete : CommandComplete (command_op_code = READ_LOOPBACK_MODE) {
3004  status : ErrorCode,
3005  loopback_mode : LoopbackMode,
3006}
3007
3008packet WriteLoopbackMode : Command (op_code = WRITE_LOOPBACK_MODE) {
3009  loopback_mode : LoopbackMode,
3010}
3011
3012packet WriteLoopbackModeComplete : CommandComplete (command_op_code = WRITE_LOOPBACK_MODE) {
3013  status : ErrorCode,
3014}
3015
3016packet EnableDeviceUnderTestMode : Command (op_code = ENABLE_DEVICE_UNDER_TEST_MODE) {
3017}
3018
3019packet EnableDeviceUnderTestModeComplete : CommandComplete (command_op_code = ENABLE_DEVICE_UNDER_TEST_MODE) {
3020  status : ErrorCode,
3021}
3022
3023packet WriteSimplePairingDebugMode : Command (op_code = WRITE_SIMPLE_PAIRING_DEBUG_MODE) {
3024  simple_pairing_debug_mode : Enable,
3025}
3026
3027packet WriteSimplePairingDebugModeComplete : CommandComplete (command_op_code = WRITE_SIMPLE_PAIRING_DEBUG_MODE) {
3028  status : ErrorCode,
3029}
3030
3031packet WriteSecureConnectionsTestMode : Command (op_code = WRITE_SECURE_CONNECTIONS_TEST_MODE) {
3032  connection_handle : 12,
3033  _reserved_ : 4,
3034  dm1_aclu_mode : Enable,
3035  esco_loopback_mode : Enable,
3036}
3037
3038packet WriteSecureConnectionsTestModeComplete : CommandComplete (command_op_code = WRITE_SECURE_CONNECTIONS_TEST_MODE) {
3039  status : ErrorCode,
3040}
3041
3042  // LE_CONTROLLER
3043packet LeSetEventMask : Command (op_code = LE_SET_EVENT_MASK) {
3044  le_event_mask : 64,
3045}
3046
3047packet LeSetEventMaskComplete : CommandComplete (command_op_code = LE_SET_EVENT_MASK) {
3048  status : ErrorCode,
3049}
3050
3051packet LeReadBufferSizeV1 : Command (op_code = LE_READ_BUFFER_SIZE_V1) {
3052}
3053
3054struct LeBufferSize {
3055  le_data_packet_length : 16,
3056  total_num_le_packets : 8,
3057}
3058
3059test LeReadBufferSizeV1 {
3060  "\x02\x20\x00",
3061}
3062
3063packet LeReadBufferSizeV1Complete : CommandComplete (command_op_code = LE_READ_BUFFER_SIZE_V1) {
3064  status : ErrorCode,
3065  le_buffer_size : LeBufferSize,
3066}
3067
3068test LeReadBufferSizeV1Complete {
3069  "\x0e\x07\x01\x02\x20\x00\xfb\x00\x10",
3070}
3071
3072enum LLFeaturesBits : 64 {
3073  // Byte 0
3074  LE_ENCRYPTION                                 = 0x0000000000000001,
3075  CONNECTION_PARAMETERS_REQUEST_PROCEDURE       = 0x0000000000000002,
3076  EXTENDED_REJECT_INDICATION                    = 0x0000000000000004,
3077  PERIPHERAL_INITIATED_FEATURES_EXCHANGE        = 0x0000000000000008,
3078  LE_PING                                       = 0x0000000000000010,
3079  LE_DATA_PACKET_LENGTH_EXTENSION               = 0x0000000000000020,
3080  LL_PRIVACY                                    = 0x0000000000000040,
3081  EXTENDED_SCANNER_FILTER_POLICIES              = 0x0000000000000080,
3082
3083  // Byte 1
3084  LE_2M_PHY                                     = 0x0000000000000100,
3085  STABLE_MODULATION_INDEX_TRANSMITTER           = 0x0000000000000200,
3086  STABLE_MODULATION_INDEX_RECEIVER              = 0x0000000000000400,
3087  LE_CODED_PHY                                  = 0x0000000000000800,
3088  LE_EXTENDED_ADVERTISING                       = 0x0000000000001000,
3089  LE_PERIODIC_ADVERTISING                       = 0x0000000000002000,
3090  CHANNEL_SELECTION_ALGORITHM_2                 = 0x0000000000004000,
3091  LE_POWER_CLASS_1                              = 0x0000000000008000,
3092
3093  // Byte 2
3094  MINIMUM_NUMBER_OF_USED_CHANNELS_PROCEDURE     = 0x0000000000010000,
3095  CONNECTION_CTE_REQUEST                        = 0x0000000000020000,
3096  CONNECTION_CTE_RESPONSE                       = 0x0000000000040000,
3097  CONNECTIONLESS_CTE_TRANSMITTER                = 0x0000000000080000,
3098  CONNECTIONLESS_CTE_RECEIVER                   = 0x0000000000100000,
3099  ANTENNA_SWITCHING_DURING_CTE_TRANSMISSION     = 0x0000000000200000,
3100  ANTENNA_SWITCHING_DURING_CTE_RECEPTION        = 0x0000000000400000,
3101  RECEIVING_CONSTANT_TONE_EXTENSIONS            = 0x0000000000800000,
3102
3103  // Byte 3
3104  PERIODIC_ADVERTISING_SYNC_TRANSFER_SENDER     = 0x0000000001000000,
3105  PERIODIC_ADVERTISING_SYNC_TRANSFER_RECIPIENT  = 0x0000000002000000,
3106  SLEEP_CLOCK_ACCURACY_UPDATES                  = 0x0000000004000000,
3107  REMOTE_PUBLIC_KEY_VALIDATION                  = 0x0000000008000000,
3108  CONNECTED_ISOCHRONOUS_STREAM_CENTRAL          = 0x0000000010000000,
3109  CONNECTED_ISOCHRONOUS_STREAM_PERIPHERAL       = 0x0000000020000000,
3110  ISOCHRONOUS_BROADCASTER                       = 0x0000000040000000,
3111  SYNCHRONIZED_RECEIVER                         = 0x0000000080000000,
3112
3113  // Byte 4
3114  CONNECTED_ISOCHRONOUS_STREAM_HOST_SUPPORT     = 0x0000000100000000,
3115  LE_POWER_CONTROL_REQUEST                      = 0x0000000200000000,
3116  LE_POWER_CONTROL_REQUEST_BIS                  = 0x0000000400000000,
3117  LE_PATH_LOSS_MONITORING                       = 0x0000000800000000,
3118  PERIODIC_ADVERTISING_ADI_SUPPORT              = 0x0000001000000000,
3119  CONNECTION_SUBRATING                          = 0x0000002000000000,
3120  CONNECTION_SUBRATING_HOST_SUPPORT             = 0x0000004000000000,
3121  CHANNEL_CLASSIFICATION                        = 0x0000008000000000,
3122}
3123
3124packet LeReadLocalSupportedFeatures : Command (op_code = LE_READ_LOCAL_SUPPORTED_FEATURES) {
3125}
3126
3127packet LeReadLocalSupportedFeaturesComplete : CommandComplete (command_op_code = LE_READ_LOCAL_SUPPORTED_FEATURES) {
3128  status : ErrorCode,
3129  le_features : 64,
3130}
3131
3132packet LeSetRandomAddress : Command (op_code = LE_SET_RANDOM_ADDRESS) {
3133  random_address : Address,
3134}
3135
3136packet LeSetRandomAddressComplete : CommandComplete (command_op_code = LE_SET_RANDOM_ADDRESS) {
3137  status : ErrorCode,
3138}
3139
3140enum AdvertisingFilterPolicy : 2 {
3141  ALL_DEVICES = 0, // Default
3142  LISTED_SCAN = 1,
3143  LISTED_CONNECT = 2,
3144  LISTED_SCAN_AND_CONNECT = 3,
3145}
3146
3147enum PeerAddressType : 8 {
3148  PUBLIC_DEVICE_OR_IDENTITY_ADDRESS = 0x00,
3149  RANDOM_DEVICE_OR_IDENTITY_ADDRESS = 0x01,
3150}
3151
3152enum AdvertisingType : 8 {
3153  ADV_IND = 0x00,
3154  ADV_DIRECT_IND_HIGH = 0x01,
3155  ADV_SCAN_IND = 0x02,
3156  ADV_NONCONN_IND = 0x03,
3157  ADV_DIRECT_IND_LOW = 0x04,
3158}
3159
3160enum AddressType : 8 {
3161  PUBLIC_DEVICE_ADDRESS = 0x00,
3162  RANDOM_DEVICE_ADDRESS = 0x01,
3163  PUBLIC_IDENTITY_ADDRESS = 0x02,
3164  RANDOM_IDENTITY_ADDRESS = 0x03,
3165}
3166
3167enum OwnAddressType : 8 {
3168  PUBLIC_DEVICE_ADDRESS = 0x00,
3169  RANDOM_DEVICE_ADDRESS = 0x01,
3170  RESOLVABLE_OR_PUBLIC_ADDRESS = 0x02,
3171  RESOLVABLE_OR_RANDOM_ADDRESS = 0x03,
3172}
3173
3174packet LeSetAdvertisingParameters : Command (op_code = LE_SET_ADVERTISING_PARAMETERS) {
3175  advertising_interval_min : 16,
3176  advertising_interval_max : 16,
3177  advertising_type : AdvertisingType,
3178  own_address_type : OwnAddressType,
3179  peer_address_type : PeerAddressType,
3180  peer_address : Address,
3181  advertising_channel_map : 8,
3182  advertising_filter_policy : AdvertisingFilterPolicy,
3183  _reserved_ : 6,
3184}
3185
3186packet LeSetAdvertisingParametersComplete : CommandComplete (command_op_code = LE_SET_ADVERTISING_PARAMETERS) {
3187  status : ErrorCode,
3188}
3189
3190packet LeReadAdvertisingPhysicalChannelTxPower : Command (op_code = LE_READ_ADVERTISING_PHYSICAL_CHANNEL_TX_POWER) {
3191}
3192
3193packet LeReadAdvertisingPhysicalChannelTxPowerComplete : CommandComplete (command_op_code = LE_READ_ADVERTISING_PHYSICAL_CHANNEL_TX_POWER) {
3194  status : ErrorCode,
3195  transmit_power_level : 8, // (-127dBm to 20dBm) Accuracy: +/-4dB
3196}
3197
3198packet LeSetAdvertisingData : Command (op_code = LE_SET_ADVERTISING_DATA) {
3199  _size_(advertising_data) : 8,
3200  advertising_data : 8[],
3201  _padding_[31], // Zero padding to 31 bytes of advertising_data
3202}
3203
3204packet LeSetAdvertisingDataComplete : CommandComplete (command_op_code = LE_SET_ADVERTISING_DATA) {
3205  status : ErrorCode,
3206}
3207
3208packet LeSetScanResponseData : Command (op_code = LE_SET_SCAN_RESPONSE_DATA) {
3209  _size_(advertising_data) : 8,
3210  advertising_data : 8[],
3211  _padding_[31], // Zero padding to 31 bytes of advertising_data
3212}
3213
3214packet LeSetScanResponseDataComplete : CommandComplete (command_op_code = LE_SET_SCAN_RESPONSE_DATA) {
3215  status : ErrorCode,
3216}
3217
3218packet LeSetAdvertisingEnable : Command (op_code = LE_SET_ADVERTISING_ENABLE) {
3219  advertising_enable : Enable, // Default DISABLED
3220}
3221
3222packet LeSetAdvertisingEnableComplete : CommandComplete (command_op_code = LE_SET_ADVERTISING_ENABLE) {
3223  status : ErrorCode,
3224}
3225
3226enum LeScanType : 8 {
3227  PASSIVE = 0x00, // Default
3228  ACTIVE = 0x01,
3229}
3230
3231enum LeScanningFilterPolicy : 8 {
3232  ACCEPT_ALL = 0x00, // Default
3233  FILTER_ACCEPT_LIST_ONLY = 0x01,
3234  CHECK_INITIATORS_IDENTITY = 0x02,
3235  FILTER_ACCEPT_LIST_AND_INITIATORS_IDENTITY = 0x03,
3236}
3237
3238packet LeSetScanParameters : Command (op_code = LE_SET_SCAN_PARAMETERS) {
3239  le_scan_type : LeScanType,
3240  le_scan_interval : 16, // 0x0004-0x4000 Default 0x10 (10ms)
3241  le_scan_window : 16, // Default 0x10 (10ms)
3242  own_address_type : OwnAddressType,
3243  scanning_filter_policy : LeScanningFilterPolicy,
3244}
3245
3246test LeSetScanParameters {
3247  "\x0b\x20\x07\x01\x12\x00\x12\x00\x01\x00",
3248}
3249
3250packet LeSetScanParametersComplete : CommandComplete (command_op_code = LE_SET_SCAN_PARAMETERS) {
3251  status : ErrorCode,
3252}
3253
3254packet LeSetScanEnable : Command (op_code = LE_SET_SCAN_ENABLE) {
3255  le_scan_enable : Enable,
3256  filter_duplicates : Enable,
3257}
3258
3259test LeSetScanEnable {
3260  "\x0c\x20\x02\x01\x00",
3261}
3262
3263packet LeSetScanEnableComplete : CommandComplete (command_op_code = LE_SET_SCAN_ENABLE) {
3264  status : ErrorCode,
3265}
3266
3267enum InitiatorFilterPolicy : 8 {
3268  USE_PEER_ADDRESS = 0x00,
3269  USE_FILTER_ACCEPT_LIST = 0x01,
3270}
3271
3272packet LeCreateConnection : Command (op_code = LE_CREATE_CONNECTION) {
3273  le_scan_interval : 16, // 0x0004-0x4000
3274  le_scan_window : 16, // < = LeScanInterval
3275  initiator_filter_policy : InitiatorFilterPolicy,
3276  peer_address_type : AddressType,
3277  peer_address : Address,
3278  own_address_type : OwnAddressType,
3279  connection_interval_min : 16, // 0x0006-0x0C80 (7.5ms to 4s)
3280  connection_interval_max : 16, // 0x0006-0x0C80 (7.5ms to 4s)
3281  max_latency : 16, // 0x0006-0x01F3
3282  supervision_timeout : 16, // 0x00A to 0x0C80 (100ms to 32s)
3283  min_ce_length : 16, // 0.625ms
3284  max_ce_length : 16, // 0.625ms
3285}
3286
3287packet LeCreateConnectionStatus : CommandStatus (command_op_code = LE_CREATE_CONNECTION) {
3288}
3289
3290packet LeCreateConnectionCancel : Command (op_code = LE_CREATE_CONNECTION_CANCEL) {
3291}
3292
3293packet LeCreateConnectionCancelComplete : CommandComplete (command_op_code = LE_CREATE_CONNECTION_CANCEL) {
3294  status : ErrorCode,
3295}
3296
3297packet LeReadFilterAcceptListSize : Command (op_code = LE_READ_FILTER_ACCEPT_LIST_SIZE) {
3298}
3299
3300test LeReadFilterAcceptListSize {
3301  "\x0f\x20\x00",
3302}
3303
3304packet LeReadFilterAcceptListSizeComplete : CommandComplete (command_op_code = LE_READ_FILTER_ACCEPT_LIST_SIZE) {
3305  status : ErrorCode,
3306  filter_accept_list_size : 8,
3307}
3308
3309test LeReadFilterAcceptListSizeComplete {
3310  "\x0e\x05\x01\x0f\x20\x00\x80",
3311}
3312
3313packet LeClearFilterAcceptList : Command (op_code = LE_CLEAR_FILTER_ACCEPT_LIST) {
3314}
3315
3316packet LeClearFilterAcceptListComplete : CommandComplete (command_op_code = LE_CLEAR_FILTER_ACCEPT_LIST) {
3317  status : ErrorCode,
3318}
3319
3320enum FilterAcceptListAddressType : 8 {
3321  PUBLIC = 0x00,
3322  RANDOM = 0x01,
3323  ANONYMOUS_ADVERTISERS = 0xFF,
3324}
3325
3326packet LeAddDeviceToFilterAcceptList : Command (op_code = LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST) {
3327  address_type : FilterAcceptListAddressType,
3328  address : Address,
3329}
3330
3331packet LeAddDeviceToFilterAcceptListComplete : CommandComplete (command_op_code = LE_ADD_DEVICE_TO_FILTER_ACCEPT_LIST) {
3332  status : ErrorCode,
3333}
3334
3335packet LeRemoveDeviceFromFilterAcceptList : Command (op_code = LE_REMOVE_DEVICE_FROM_FILTER_ACCEPT_LIST) {
3336  address_type : FilterAcceptListAddressType,
3337  address : Address,
3338}
3339
3340packet LeRemoveDeviceFromFilterAcceptListComplete : CommandComplete (command_op_code = LE_REMOVE_DEVICE_FROM_FILTER_ACCEPT_LIST) {
3341  status : ErrorCode,
3342}
3343
3344packet LeConnectionUpdate : Command (op_code = LE_CONNECTION_UPDATE) {
3345  connection_handle : 12,
3346  _reserved_ : 4,
3347  connection_interval_min : 16, // 0x0006-0x0C80 (7.5ms to 4s)
3348  connection_interval_max : 16, // 0x0006-0x0C80 (7.5ms to 4s)
3349  max_latency : 16, // 0x0006-0x01F3
3350  supervision_timeout : 16, // 0x00A to 0x0C80 (100ms to 32s)
3351  min_ce_length : 16, // 0.625ms
3352  max_ce_length : 16, // 0.625ms
3353}
3354
3355packet LeConnectionUpdateStatus : CommandStatus (command_op_code = LE_CONNECTION_UPDATE) {
3356}
3357
3358packet LeSetHostChannelClassification : Command (op_code = LE_SET_HOST_CHANNEL_CLASSIFICATION) {
3359  channel_map : 8[5],
3360}
3361
3362packet LeSetHostChannelClassificationComplete : CommandComplete (command_op_code = LE_SET_HOST_CHANNEL_CLASSIFICATION) {
3363  status : ErrorCode,
3364}
3365
3366packet LeReadChannelMap : Command (op_code = LE_READ_CHANNEL_MAP) {
3367}
3368
3369packet LeReadChannelMapComplete : CommandComplete (command_op_code = LE_READ_CHANNEL_MAP) {
3370  status : ErrorCode,
3371  connection_handle : 12,
3372  _reserved_ : 4,
3373  channel_map : 8[5],
3374}
3375
3376packet LeReadRemoteFeatures : Command (op_code = LE_READ_REMOTE_FEATURES) {
3377  connection_handle : 12,
3378  _reserved_ : 4,
3379}
3380
3381packet LeReadRemoteFeaturesStatus : CommandStatus (command_op_code = LE_READ_REMOTE_FEATURES) {
3382}
3383
3384packet LeEncrypt : Command (op_code = LE_ENCRYPT) {
3385  key : 8[16],
3386  plaintext_data : 8[16],
3387}
3388
3389packet LeEncryptComplete : CommandComplete (command_op_code = LE_ENCRYPT) {
3390  status : ErrorCode,
3391  encrypted_data : 8[16],
3392}
3393
3394packet LeRand : Command (op_code = LE_RAND) {
3395}
3396
3397packet LeRandComplete : CommandComplete (command_op_code = LE_RAND) {
3398  status : ErrorCode,
3399  random_number : 64,
3400}
3401
3402packet LeStartEncryption : Command (op_code = LE_START_ENCRYPTION) {
3403  connection_handle: 16,
3404  rand: 8[8],
3405  ediv: 16,
3406  ltk: 8[16],
3407}
3408
3409packet LeStartEncryptionStatus : CommandStatus (command_op_code = LE_START_ENCRYPTION) {
3410}
3411
3412packet LeLongTermKeyRequestReply : Command (op_code = LE_LONG_TERM_KEY_REQUEST_REPLY) {
3413  connection_handle: 16,
3414  long_term_key: 8[16],
3415}
3416
3417packet LeLongTermKeyRequestReplyComplete : CommandComplete (command_op_code = LE_LONG_TERM_KEY_REQUEST_REPLY) {
3418  status : ErrorCode,
3419  connection_handle : 12,
3420  _reserved_ : 4,
3421}
3422
3423packet LeLongTermKeyRequestNegativeReply : Command (op_code = LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY) {
3424  connection_handle : 12,
3425  _reserved_ : 4,
3426}
3427
3428packet LeLongTermKeyRequestNegativeReplyComplete : CommandComplete (command_op_code = LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY) {
3429  status : ErrorCode,
3430  connection_handle : 12,
3431  _reserved_ : 4,
3432}
3433
3434packet LeReadSupportedStates : Command (op_code = LE_READ_SUPPORTED_STATES) {
3435}
3436
3437packet LeReadSupportedStatesComplete : CommandComplete (command_op_code = LE_READ_SUPPORTED_STATES) {
3438  status : ErrorCode,
3439  le_states : 64,
3440}
3441
3442packet LeReceiverTest : Command (op_code = LE_RECEIVER_TEST_V1) {
3443  rx_channel : 8,
3444}
3445
3446packet LeReceiverTestComplete : CommandComplete (command_op_code = LE_RECEIVER_TEST_V1) {
3447  status : ErrorCode,
3448}
3449
3450enum LeTestPayload : 8 {
3451  PRBS9 = 0x00,
3452  REPEATED_F0 = 0x01,
3453  REPEATED_AA = 0x02,
3454  PRBS15 = 0x03,
3455  REPEATED_FF = 0x04,
3456  REPEATED_00 = 0x05,
3457  REPEATED_0F = 0x06,
3458  REPEATED_55 = 0x07,
3459}
3460
3461packet LeTransmitterTest : Command (op_code = LE_TRANSMITTER_TEST_V1) {
3462  tx_channel : 8,
3463  test_data_length : 8,
3464  packet_payload : LeTestPayload,
3465}
3466
3467packet LeTransmitterTestComplete : CommandComplete (command_op_code = LE_TRANSMITTER_TEST_V1) {
3468  status : ErrorCode,
3469}
3470
3471packet LeTestEnd : Command (op_code = LE_TEST_END) {
3472}
3473
3474packet LeTestEndComplete : CommandComplete (command_op_code = LE_TEST_END) {
3475  status : ErrorCode,
3476}
3477
3478packet LeRemoteConnectionParameterRequestReply : Command (op_code = LE_REMOTE_CONNECTION_PARAMETER_REQUEST_REPLY) {
3479  connection_handle : 12,
3480  _reserved_ : 4,
3481  interval_min : 16, // 0x0006-0x0C80 (7.5ms to 4s)
3482  interval_max : 16, // 0x0006-0x0C80 (7.5ms to 4s)
3483  latency : 16, // 0x0006-0x01F3
3484  timeout : 16, // 0x00A to 0x0C80 (100ms to 32s)
3485  minimum_ce_length : 16, // 0.625ms
3486  maximum_ce_length : 16, // 0.625ms
3487}
3488
3489packet LeRemoteConnectionParameterRequestReplyComplete : CommandComplete (command_op_code = LE_REMOTE_CONNECTION_PARAMETER_REQUEST_REPLY) {
3490  status : ErrorCode,
3491  connection_handle : 12,
3492  _reserved_ : 4,
3493}
3494
3495packet LeRemoteConnectionParameterRequestNegativeReply : Command (op_code = LE_REMOTE_CONNECTION_PARAMETER_REQUEST_NEGATIVE_REPLY) {
3496  connection_handle : 12,
3497  _reserved_ : 4,
3498  reason : ErrorCode,
3499}
3500
3501packet LeRemoteConnectionParameterRequestNegativeReplyComplete : CommandComplete (command_op_code = LE_REMOTE_CONNECTION_PARAMETER_REQUEST_NEGATIVE_REPLY) {
3502  status : ErrorCode,
3503  connection_handle : 12,
3504  _reserved_ : 4,
3505}
3506
3507packet LeSetDataLength : Command (op_code = LE_SET_DATA_LENGTH) {
3508  connection_handle : 12,
3509  _reserved_ : 4,
3510  tx_octets : 16, // payload octets per single PDU 0x1B to 0x00FB
3511  tx_time : 16, // microseconds used to transmit a single PDU 0x0148 to 0x4290
3512}
3513
3514packet LeSetDataLengthComplete : CommandComplete (command_op_code = LE_SET_DATA_LENGTH) {
3515  status : ErrorCode,
3516  connection_handle : 12,
3517  _reserved_ : 4,
3518}
3519
3520packet LeReadSuggestedDefaultDataLength : Command (op_code = LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH) {
3521}
3522
3523packet LeReadSuggestedDefaultDataLengthComplete : CommandComplete (command_op_code = LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH) {
3524  status : ErrorCode,
3525  tx_octets : 16, // payload octets per single PDU 0x1B to 0x00FB
3526  tx_time : 16, // microseconds used to transmit a single PDU 0x0148 to 0x4290
3527}
3528
3529packet LeWriteSuggestedDefaultDataLength : Command (op_code = LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH) {
3530  tx_octets : 16, // payload octets per single PDU 0x1B to 0x00FB
3531  tx_time : 16, // microseconds used to transmit a single PDU 0x0148 to 0x4290
3532}
3533
3534packet LeWriteSuggestedDefaultDataLengthComplete : CommandComplete (command_op_code = LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH) {
3535  status : ErrorCode,
3536}
3537
3538packet LeReadLocalP256PublicKeyCommand : Command (op_code = LE_READ_LOCAL_P_256_PUBLIC_KEY) {
3539}
3540
3541packet LeReadLocalP256PublicKeyCommandStatus : CommandStatus (command_op_code = LE_READ_LOCAL_P_256_PUBLIC_KEY) {
3542}
3543
3544packet LeGenerateDhkeyV1Command : Command (op_code = LE_GENERATE_DHKEY_V1) {
3545  remote_p_256_public_key : 8[64],
3546}
3547
3548packet LeGenerateDhkeyV1CommandStatus : CommandStatus (command_op_code = LE_GENERATE_DHKEY_V1) {
3549}
3550
3551packet LeAddDeviceToResolvingList : Command (op_code = LE_ADD_DEVICE_TO_RESOLVING_LIST) {
3552  peer_identity_address_type : PeerAddressType,
3553  peer_identity_address : Address,
3554  peer_irk : 8[16],
3555  local_irk : 8[16],
3556}
3557
3558packet LeAddDeviceToResolvingListComplete : CommandComplete (command_op_code = LE_ADD_DEVICE_TO_RESOLVING_LIST) {
3559  status : ErrorCode,
3560}
3561
3562packet LeRemoveDeviceFromResolvingList : Command (op_code = LE_REMOVE_DEVICE_FROM_RESOLVING_LIST) {
3563  peer_identity_address_type : PeerAddressType,
3564  peer_identity_address : Address,
3565}
3566
3567packet LeRemoveDeviceFromResolvingListComplete : CommandComplete (command_op_code = LE_REMOVE_DEVICE_FROM_RESOLVING_LIST) {
3568  status : ErrorCode,
3569}
3570
3571packet LeClearResolvingList : Command (op_code = LE_CLEAR_RESOLVING_LIST) {
3572}
3573
3574packet LeClearResolvingListComplete : CommandComplete (command_op_code = LE_CLEAR_RESOLVING_LIST) {
3575  status : ErrorCode,
3576}
3577
3578packet LeReadResolvingListSize : Command (op_code = LE_READ_RESOLVING_LIST_SIZE) {
3579}
3580
3581packet LeReadResolvingListSizeComplete : CommandComplete (command_op_code = LE_READ_RESOLVING_LIST_SIZE) {
3582  status : ErrorCode,
3583  resolving_list_size : 8,
3584}
3585
3586packet LeReadPeerResolvableAddress : Command (op_code = LE_READ_PEER_RESOLVABLE_ADDRESS) {
3587  peer_identity_address_type : PeerAddressType,
3588  peer_identity_address : Address,
3589}
3590
3591packet LeReadPeerResolvableAddressComplete : CommandComplete (command_op_code = LE_READ_PEER_RESOLVABLE_ADDRESS) {
3592  status : ErrorCode,
3593  peer_resolvable_address : Address,
3594}
3595
3596packet LeReadLocalResolvableAddress : Command (op_code = LE_READ_LOCAL_RESOLVABLE_ADDRESS) {
3597  peer_identity_address_type : PeerAddressType,
3598  peer_identity_address : Address,
3599}
3600
3601packet LeReadLocalResolvableAddressComplete : CommandComplete (command_op_code = LE_READ_LOCAL_RESOLVABLE_ADDRESS) {
3602  status : ErrorCode,
3603  local_resolvable_address : Address,
3604}
3605
3606packet LeSetAddressResolutionEnable : Command (op_code = LE_SET_ADDRESS_RESOLUTION_ENABLE) {
3607  address_resolution_enable : Enable,
3608}
3609
3610packet LeSetAddressResolutionEnableComplete : CommandComplete (command_op_code = LE_SET_ADDRESS_RESOLUTION_ENABLE) {
3611  status : ErrorCode,
3612}
3613
3614packet LeSetResolvablePrivateAddressTimeout : Command (op_code = LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT) {
3615  rpa_timeout : 16, // RPA_Timeout measured in seconds 0x0001 to 0xA1B8 1s to 11.5 hours
3616}
3617
3618packet LeSetResolvablePrivateAddressTimeoutComplete : CommandComplete (command_op_code = LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT) {
3619  status : ErrorCode,
3620}
3621
3622packet LeReadMaximumDataLength : Command (op_code = LE_READ_MAXIMUM_DATA_LENGTH) {
3623}
3624
3625struct LeMaximumDataLength {
3626  supported_max_tx_octets : 16,
3627  supported_max_tx_time: 16,
3628  supported_max_rx_octets : 16,
3629  supported_max_rx_time: 16,
3630}
3631
3632packet LeReadMaximumDataLengthComplete : CommandComplete (command_op_code = LE_READ_MAXIMUM_DATA_LENGTH) {
3633  status : ErrorCode,
3634  le_maximum_data_length : LeMaximumDataLength,
3635}
3636
3637packet LeReadPhy : Command (op_code = LE_READ_PHY) {
3638  connection_handle : 12,
3639  _reserved_ : 4,
3640}
3641
3642enum PhyType : 8 {
3643  LE_1M = 0x01,
3644  LE_2M = 0x02,
3645  LE_CODED = 0x03,
3646}
3647
3648packet LeReadPhyComplete : CommandComplete (command_op_code = LE_READ_PHY) {
3649  status : ErrorCode,
3650  connection_handle : 12,
3651  _reserved_ : 4,
3652  tx_phy : PhyType,
3653  rx_phy : PhyType,
3654}
3655
3656packet LeSetDefaultPhy : Command (op_code = LE_SET_DEFAULT_PHY) {
3657  all_phys_no_transmit_preference : 1,
3658  all_phys_no_receive_preference : 1,
3659  _reserved_ : 6,
3660  tx_phys : 3,
3661  _reserved_ : 5,
3662  rx_phys : 3,
3663  _reserved_ : 5,
3664}
3665
3666packet LeSetDefaultPhyComplete : CommandComplete (command_op_code = LE_SET_DEFAULT_PHY) {
3667  status : ErrorCode,
3668}
3669
3670enum PhyOptions : 8 {
3671  NO_PREFERENCE = 0x00,
3672  S_2 = 0x01,
3673  S_8 = 0x02,
3674}
3675
3676packet LeSetPhy : Command (op_code = LE_SET_PHY) {
3677  connection_handle : 12,
3678  _reserved_ : 4,
3679  all_phys_no_transmit_preference : 1,
3680  all_phys_no_receive_preference : 1,
3681  _reserved_ : 6,
3682  tx_phys : 3,
3683  _reserved_ : 5,
3684  rx_phys : 3,
3685  _reserved_ : 5,
3686  phy_options : PhyOptions,
3687}
3688
3689packet LeSetPhyStatus : CommandStatus (command_op_code = LE_SET_PHY) {
3690}
3691
3692enum ModulationIndex : 8 {
3693  STANDARD = 0x00,
3694  STABLE = 0x01,
3695}
3696
3697packet LeEnhancedReceiverTest : Command (op_code = LE_RECEIVER_TEST_V2) {
3698  rx_channel : 8,
3699  phy : PhyType,
3700  modulation_index : ModulationIndex,
3701}
3702
3703packet LeEnhancedReceiverTestComplete : CommandComplete (command_op_code = LE_RECEIVER_TEST_V2) {
3704  status : ErrorCode,
3705}
3706
3707packet LeEnhancedTransmitterTest : Command (op_code = LE_TRANSMITTER_TEST_V2) {
3708  tx_channel : 8,
3709  test_data_length : 8,
3710  packet_payload : LeTestPayload,
3711  phy : PhyType,
3712}
3713
3714packet LeEnhancedTransmitterTestComplete : CommandComplete (command_op_code = LE_TRANSMITTER_TEST_V2) {
3715  status : ErrorCode,
3716}
3717
3718packet LeSetAdvertisingSetRandomAddress : Command (op_code = LE_SET_ADVERTISING_SET_RANDOM_ADDRESS) {
3719  advertising_handle : 8,
3720  random_address : Address,
3721}
3722
3723test LeSetAdvertisingSetRandomAddress {
3724  "\x35\x20\x07\x00\x77\x58\xeb\xd3\x1c\x6e",
3725}
3726
3727packet LeSetAdvertisingSetRandomAddressComplete : CommandComplete (command_op_code = LE_SET_ADVERTISING_SET_RANDOM_ADDRESS) {
3728  status : ErrorCode,
3729}
3730
3731test LeSetAdvertisingSetRandomAddressComplete {
3732  "\x0e\x04\x01\x35\x20\x00",
3733}
3734
3735// The lower 4 bits of the advertising event properties
3736enum LegacyAdvertisingEventProperties : 4 {
3737  ADV_IND = 0x3,
3738  ADV_DIRECT_IND_LOW = 0x5,
3739  ADV_DIRECT_IND_HIGH = 0xD,
3740  ADV_SCAN_IND = 0x2,
3741  ADV_NONCONN_IND = 0,
3742}
3743
3744enum PrimaryPhyType : 8 {
3745  LE_1M = 0x01,
3746  LE_CODED = 0x03,
3747}
3748
3749enum SecondaryPhyType : 8 {
3750  NO_PACKETS = 0x00,
3751  LE_1M = 0x01,
3752  LE_2M = 0x02,
3753  LE_CODED = 0x03,
3754}
3755
3756packet LeSetExtendedAdvertisingParametersLegacy : Command (op_code = LE_SET_EXTENDED_ADVERTISING_PARAMETERS) {
3757  advertising_handle : 8,
3758  legacy_advertising_event_properties : LegacyAdvertisingEventProperties,
3759  _fixed_ = 0x1 : 1, // legacy bit set
3760  _reserved_ : 11, // advertising_event_properties reserved bits
3761  primary_advertising_interval_min : 24, // 0x20 - 0xFFFFFF N * 0.625 ms
3762  primary_advertising_interval_max : 24, // 0x20 - 0xFFFFFF N * 0.625 ms
3763  primary_advertising_channel_map : 3,  // bit 0 - Channel 37, bit 1 - 38, bit 2 - 39
3764  _reserved_ : 5,
3765  own_address_type : OwnAddressType,
3766  peer_address_type : PeerAddressType,
3767  peer_address : Address,
3768  advertising_filter_policy : AdvertisingFilterPolicy,
3769  _reserved_ : 6,
3770  advertising_tx_power : 8, // -127 to +20, 0x7F - no preference
3771  _fixed_ = 0x1 : 8, // PrimaryPhyType LE_1M
3772  _reserved_ : 8, // secondary_advertising_max_skip
3773  _fixed_ = 0x1 : 8, // secondary_advertising_phy LE_1M
3774  advertising_sid : 8, // SID subfield from the ADI field of the PDU
3775  scan_request_notification_enable : Enable,
3776}
3777
3778test LeSetExtendedAdvertisingParametersLegacy {
3779  "\x36\x20\x19\x00\x13\x00\x90\x01\x00\xc2\x01\x00\x07\x01\x00\x00\x00\x00\x00\x00\x00\x00\xf9\x01\x00\x01\x01\x00",
3780  "\x36\x20\x19\x01\x13\x00\x90\x01\x00\xc2\x01\x00\x07\x01\x00\x00\x00\x00\x00\x00\x00\x00\xf9\x01\x00\x01\x01\x00",
3781}
3782
3783struct AdvertisingEventProperties {
3784  connectable : 1,
3785  scannable : 1,
3786  directed : 1,
3787  high_duty_cycle : 1,
3788  legacy : 1,
3789  anonymous : 1,
3790  tx_power : 1,
3791  _reserved_ : 9,
3792}
3793
3794packet LeSetExtendedAdvertisingParameters : Command (op_code = LE_SET_EXTENDED_ADVERTISING_PARAMETERS) {
3795  advertising_handle : 8,
3796  advertising_event_properties : AdvertisingEventProperties,
3797  primary_advertising_interval_min : 24, // 0x20 - 0xFFFFFF N * 0.625 ms
3798  primary_advertising_interval_max : 24, // 0x20 - 0xFFFFFF N * 0.625 ms
3799  primary_advertising_channel_map : 3,  // bit 0 - Channel 37, bit 1 - 38, bit 2 - 39
3800  _reserved_ : 5,
3801  own_address_type : OwnAddressType,
3802  peer_address_type : PeerAddressType,
3803  peer_address : Address,
3804  advertising_filter_policy : AdvertisingFilterPolicy,
3805  _reserved_ : 6,
3806  advertising_tx_power : 8, // -127 to +20, 0x7F - no preference
3807  primary_advertising_phy : PrimaryPhyType,
3808  secondary_advertising_max_skip : 8, // 1 to 255, 0x00 - AUX_ADV_IND sent before next advertising event
3809  secondary_advertising_phy : SecondaryPhyType,
3810  advertising_sid : 8, // SID subfield from the ADI field of the PDU
3811  scan_request_notification_enable : Enable,
3812}
3813
3814packet LeSetExtendedAdvertisingParametersComplete : CommandComplete (command_op_code = LE_SET_EXTENDED_ADVERTISING_PARAMETERS) {
3815  status : ErrorCode,
3816  selected_tx_power : 8, // -127 to +20
3817}
3818
3819enum Operation : 3 {
3820  INTERMEDIATE_FRAGMENT = 0,
3821  FIRST_FRAGMENT = 1,
3822  LAST_FRAGMENT = 2,
3823  COMPLETE_ADVERTISEMENT = 3,
3824  UNCHANGED_DATA = 4,
3825}
3826
3827enum FragmentPreference : 1 {
3828  CONTROLLER_MAY_FRAGMENT = 0,
3829  CONTROLLER_SHOULD_NOT = 1,
3830}
3831
3832packet LeSetExtendedAdvertisingData : Command (op_code = LE_SET_EXTENDED_ADVERTISING_DATA) {
3833  advertising_handle : 8,
3834  operation : Operation,
3835  _reserved_ : 5,
3836  fragment_preference : FragmentPreference,
3837  _reserved_ : 7,
3838  _size_(advertising_data) : 8,
3839  advertising_data : 8[],
3840}
3841
3842test LeSetExtendedAdvertisingData {
3843  "\x37\x20\x12\x00\x03\x01\x0e\x02\x01\x02\x0a\x09\x50\x69\x78\x65\x6c\x20\x33\x20\x58",
3844}
3845
3846packet LeSetExtendedAdvertisingDataComplete : CommandComplete (command_op_code = LE_SET_EXTENDED_ADVERTISING_DATA) {
3847  status : ErrorCode,
3848}
3849
3850test LeSetExtendedAdvertisingDataComplete {
3851  "\x0e\x04\x01\x37\x20\x00",
3852}
3853
3854packet LeSetExtendedScanResponseData : Command (op_code = LE_SET_EXTENDED_SCAN_RESPONSE_DATA) {
3855  advertising_handle : 8,
3856  operation : Operation,
3857  _reserved_ : 5,
3858  fragment_preference : FragmentPreference,
3859  _reserved_ : 7,
3860  _size_(scan_response_data) : 8,
3861  scan_response_data : 8[],
3862}
3863
3864packet LeSetExtendedScanResponseDataComplete : CommandComplete (command_op_code = LE_SET_EXTENDED_SCAN_RESPONSE_DATA) {
3865  status : ErrorCode,
3866}
3867
3868packet LeSetExtendedAdvertisingEnableDisableAll : Command (op_code = LE_SET_EXTENDED_ADVERTISING_ENABLE) {
3869  _fixed_ = 0x00 : 8, // Enable::DISABLED
3870  _fixed_ = 0x00 : 8, // Disable all sets
3871}
3872
3873struct EnabledSet {
3874  advertising_handle : 8,
3875  duration : 16,
3876  max_extended_advertising_events : 8,
3877}
3878
3879struct DisabledSet {
3880  advertising_handle : 8,
3881  _fixed_ = 0x00 : 16, // duration
3882  _fixed_ = 0x00 : 8, // max_extended_advertising_events
3883}
3884
3885packet LeSetExtendedAdvertisingDisable : Command (op_code = LE_SET_EXTENDED_ADVERTISING_ENABLE) {
3886  _fixed_ = 0x00 : 8, // Enable::DISABLED
3887  _count_(disabled_sets) : 8,
3888  disabled_sets : DisabledSet[],
3889}
3890
3891packet LeSetExtendedAdvertisingEnable : Command (op_code = LE_SET_EXTENDED_ADVERTISING_ENABLE) {
3892  enable : Enable,
3893  _count_(enabled_sets) : 8,
3894  enabled_sets : EnabledSet[],
3895}
3896
3897test LeSetExtendedAdvertisingEnable {
3898  "\x39\x20\x06\x01\x01\x01\x00\x00\x00",
3899}
3900
3901test LeSetExtendedAdvertisingDisable {
3902  "\x39\x20\x06\x00\x01\x01\x00\x00\x00",
3903}
3904
3905packet LeSetExtendedAdvertisingEnableComplete : CommandComplete (command_op_code = LE_SET_EXTENDED_ADVERTISING_ENABLE) {
3906  status : ErrorCode,
3907}
3908
3909test LeSetExtendedAdvertisingEnableComplete {
3910  "\x0e\x04\x01\x39\x20\x00",
3911}
3912
3913packet LeReadMaximumAdvertisingDataLength : Command (op_code = LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH) {
3914}
3915
3916packet LeReadMaximumAdvertisingDataLengthComplete : CommandComplete (command_op_code = LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH) {
3917  status : ErrorCode,
3918  maximum_advertising_data_length : 16,
3919}
3920
3921packet LeReadNumberOfSupportedAdvertisingSets : Command (op_code = LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS) {
3922}
3923
3924packet LeReadNumberOfSupportedAdvertisingSetsComplete : CommandComplete (command_op_code = LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS) {
3925  status : ErrorCode,
3926  number_supported_advertising_sets : 8,
3927}
3928
3929packet LeRemoveAdvertisingSet : Command (op_code = LE_REMOVE_ADVERTISING_SET) {
3930  advertising_handle : 8,
3931}
3932
3933test LeRemoveAdvertisingSet {
3934  "\x3c\x20\x01\x01",
3935}
3936
3937packet LeRemoveAdvertisingSetComplete : CommandComplete (command_op_code = LE_REMOVE_ADVERTISING_SET) {
3938  status : ErrorCode,
3939}
3940
3941test LeRemoveAdvertisingSetComplete {
3942  "\x0e\x04\x01\x3c\x20\x00",
3943}
3944
3945packet LeClearAdvertisingSets : Command (op_code = LE_CLEAR_ADVERTISING_SETS) {
3946}
3947
3948packet LeClearAdvertisingSetsComplete : CommandComplete (command_op_code = LE_CLEAR_ADVERTISING_SETS) {
3949  status : ErrorCode,
3950}
3951
3952packet LeSetPeriodicAdvertisingParameters : Command (op_code = LE_SET_PERIODIC_ADVERTISING_PARAMETERS) {
3953  advertising_handle : 8,
3954  periodic_advertising_interval_min : 16, // 0x006 to 0xFFFF (7.5 ms to 82s)
3955  periodic_advertising_interval_max : 16, // 0x006 to 0xFFFF (7.5 ms to 82s)
3956  _reserved_ : 6,
3957  include_tx_power : 1,
3958  _reserved_ : 9,
3959}
3960
3961packet LeSetPeriodicAdvertisingParametersComplete : CommandComplete (command_op_code = LE_SET_PERIODIC_ADVERTISING_PARAMETERS) {
3962  status : ErrorCode,
3963}
3964
3965packet LeSetPeriodicAdvertisingData : Command (op_code = LE_SET_PERIODIC_ADVERTISING_DATA) {
3966  advertising_handle : 8,
3967  operation : Operation,
3968  _reserved_ : 5,
3969  _size_(advertising_data) : 8,
3970  advertising_data : 8[],
3971}
3972
3973packet LeSetPeriodicAdvertisingDataComplete : CommandComplete (command_op_code = LE_SET_PERIODIC_ADVERTISING_DATA) {
3974  status : ErrorCode,
3975}
3976
3977packet LeSetPeriodicAdvertisingEnable : Command (op_code = LE_SET_PERIODIC_ADVERTISING_ENABLE) {
3978  enable : 1,
3979  include_adi: 1,
3980  _reserved_: 6,
3981  advertising_handle : 8,
3982}
3983
3984packet LeSetPeriodicAdvertisingEnableComplete : CommandComplete (command_op_code = LE_SET_PERIODIC_ADVERTISING_ENABLE) {
3985  status : ErrorCode,
3986}
3987
3988struct ScanningPhyParameters {
3989  le_scan_type : LeScanType,
3990  le_scan_interval : 16, // 0x0004-0xFFFF Default 0x10 (10ms)
3991  le_scan_window : 16, // 0x004-0xFFFF Default 0x10 (10ms)
3992}
3993
3994packet LeSetExtendedScanParameters : Command (op_code = LE_SET_EXTENDED_SCAN_PARAMETERS) {
3995  own_address_type : OwnAddressType,
3996  scanning_filter_policy : LeScanningFilterPolicy,
3997  scanning_phys : 8,
3998  scanning_phy_parameters : ScanningPhyParameters[],
3999}
4000
4001test LeSetExtendedScanParameters {
4002  "\x41\x20\x08\x01\x00\x01\x01\x12\x00\x12\x00",
4003  "\x41\x20\x08\x01\x00\x01\x01\x99\x19\x99\x19",
4004}
4005
4006packet LeSetExtendedScanParametersComplete : CommandComplete (command_op_code = LE_SET_EXTENDED_SCAN_PARAMETERS) {
4007  status : ErrorCode,
4008}
4009
4010test LeSetExtendedScanParametersComplete {
4011  "\x0e\x04\x01\x41\x20\x00",
4012}
4013
4014enum FilterDuplicates : 8 {
4015  DISABLED = 0,
4016  ENABLED = 1,
4017  RESET_EACH_PERIOD = 2,
4018}
4019
4020packet LeSetExtendedScanEnable : Command (op_code = LE_SET_EXTENDED_SCAN_ENABLE) {
4021  enable : Enable,
4022  filter_duplicates : FilterDuplicates,
4023  duration : 16, // 0 - Scan continuously,  N * 10 ms
4024  period : 16, // 0 - Scan continuously,  N * 1.28 sec
4025}
4026
4027test LeSetExtendedScanEnable {
4028  "\x42\x20\x06\x01\x00\x00\x00\x00\x00",
4029  "\x42\x20\x06\x00\x01\x00\x00\x00\x00",
4030}
4031
4032packet LeSetExtendedScanEnableComplete : CommandComplete (command_op_code = LE_SET_EXTENDED_SCAN_ENABLE) {
4033  status : ErrorCode,
4034}
4035
4036test LeSetExtendedScanEnableComplete {
4037  "\x0e\x04\x01\x42\x20\x00",
4038}
4039
4040struct InitiatingPhyParameters {
4041  scan_interval : 16, // 0x0004-0xFFFF
4042  scan_window : 16, // < = LeScanInterval
4043  connection_interval_min : 16, // 0x0006-0x0C80 (7.5ms to 4s)
4044  connection_interval_max : 16, // 0x0006-0x0C80 (7.5ms to 4s)
4045  max_latency : 16, // 0x0006-0x01F3
4046  supervision_timeout : 16, // 0x00A to 0x0C80 (100ms to 32s)
4047  min_ce_length : 16, // 0.625ms
4048  max_ce_length : 16, // 0.625ms
4049}
4050
4051packet LeExtendedCreateConnection : Command (op_code = LE_EXTENDED_CREATE_CONNECTION) {
4052  initiator_filter_policy : InitiatorFilterPolicy,
4053  own_address_type : OwnAddressType,
4054  peer_address_type : PeerAddressType,
4055  peer_address : Address,
4056  initiating_phys : 8,
4057  initiating_phy_parameters : InitiatingPhyParameters[],
4058}
4059
4060test LeExtendedCreateConnection {
4061  "\x43\x20\x2a\x01\x01\x00\x00\x00\x00\x00\x00\x00\x03\x00\x08\x30\x00\x18\x00\x28\x00\x00\x00\xf4\x01\x00\x00\x00\x00\x00\x08\x30\x00\x18\x00\x28\x00\x00\x00\xf4\x01\x00\x00\x00\x00",
4062}
4063
4064packet LeExtendedCreateConnectionStatus : CommandStatus (command_op_code = LE_EXTENDED_CREATE_CONNECTION) {
4065}
4066
4067enum PeriodicSyncCteType : 8 {
4068  AVOID_AOA_CONSTANT_TONE_EXTENSION = 0x01,
4069  AVOID_AOD_CONSTANT_TONE_EXTENSION_WITH_ONE_US_SLOTS = 0x02,
4070  AVOID_AOD_CONSTANT_TONE_EXTENSION_WITH_TWO_US_SLOTS = 0x04,
4071  AVOID_TYPE_THREE_CONSTANT_TONE_EXTENSION = 0x08,
4072  AVOID_NO_CONSTANT_TONE_EXTENSION = 0x10,
4073}
4074
4075struct PeriodicAdvertisingOptions {
4076  use_periodic_advertiser_list: 1,
4077  disable_reporting: 1,
4078  enable_duplicate_filtering: 1,
4079  _reserved_: 5,
4080}
4081
4082enum AdvertiserAddressType : 8 {
4083  PUBLIC_DEVICE_OR_IDENTITY_ADDRESS = 0x00,
4084  RANDOM_DEVICE_OR_IDENTITY_ADDRESS = 0x01,
4085}
4086
4087packet LePeriodicAdvertisingCreateSync : Command (op_code = LE_PERIODIC_ADVERTISING_CREATE_SYNC) {
4088  options : PeriodicAdvertisingOptions,
4089  advertising_sid : 8,
4090  advertiser_address_type : AdvertiserAddressType,
4091  advertiser_address : Address,
4092  skip : 16,
4093  sync_timeout : 16,
4094  sync_cte_type : 8,
4095}
4096
4097packet LePeriodicAdvertisingCreateSyncStatus : CommandStatus (command_op_code = LE_PERIODIC_ADVERTISING_CREATE_SYNC) {
4098}
4099
4100packet LePeriodicAdvertisingCreateSyncCancel : Command (op_code = LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL) {
4101}
4102
4103packet LePeriodicAdvertisingCreateSyncCancelComplete : CommandComplete (command_op_code = LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL) {
4104  status : ErrorCode,
4105}
4106
4107packet LePeriodicAdvertisingTerminateSync : Command (op_code = LE_PERIODIC_ADVERTISING_TERMINATE_SYNC) {
4108  sync_handle : 12,
4109  _reserved_ : 4,
4110}
4111
4112packet LePeriodicAdvertisingTerminateSyncComplete : CommandComplete (command_op_code = LE_PERIODIC_ADVERTISING_TERMINATE_SYNC) {
4113  status : ErrorCode,
4114}
4115
4116packet LeAddDeviceToPeriodicAdvertiserList : Command (op_code = LE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST) {
4117  advertiser_address_type : AdvertiserAddressType,
4118  advertiser_address : Address,
4119  advertising_sid : 8,
4120}
4121
4122packet LeAddDeviceToPeriodicAdvertiserListComplete : CommandComplete (command_op_code = LE_ADD_DEVICE_TO_PERIODIC_ADVERTISER_LIST) {
4123  status : ErrorCode,
4124}
4125
4126packet LeRemoveDeviceFromPeriodicAdvertiserList : Command (op_code = LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST) {
4127  advertiser_address_type : AdvertiserAddressType,
4128  advertiser_address : Address,
4129  advertising_sid : 8,
4130}
4131
4132packet LeRemoveDeviceFromPeriodicAdvertiserListComplete : CommandComplete (command_op_code = LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISER_LIST) {
4133  status : ErrorCode,
4134}
4135
4136packet LeClearPeriodicAdvertiserList : Command (op_code = LE_CLEAR_PERIODIC_ADVERTISER_LIST) {
4137}
4138
4139packet LeClearPeriodicAdvertiserListComplete : CommandComplete (command_op_code = LE_CLEAR_PERIODIC_ADVERTISER_LIST) {
4140  status : ErrorCode,
4141}
4142
4143packet LeReadPeriodicAdvertiserListSize : Command (op_code = LE_READ_PERIODIC_ADVERTISER_LIST_SIZE) {
4144}
4145
4146packet LeReadPeriodicAdvertiserListSizeComplete : CommandComplete (command_op_code = LE_READ_PERIODIC_ADVERTISER_LIST_SIZE) {
4147  status : ErrorCode,
4148  periodic_advertiser_list_size : 8,
4149}
4150
4151packet LeReadTransmitPower : Command (op_code = LE_READ_TRANSMIT_POWER) {
4152}
4153
4154packet LeReadTransmitPowerComplete : CommandComplete (command_op_code = LE_READ_TRANSMIT_POWER) {
4155  status : ErrorCode,
4156  min_tx_power_dbm : 8,
4157  max_tx_power_dbm : 8,
4158}
4159
4160packet LeReadRfPathCompensationPower : Command (op_code = LE_READ_RF_PATH_COMPENSATION_POWER) {
4161}
4162
4163packet LeReadRfPathCompensationPowerComplete : CommandComplete (command_op_code = LE_READ_RF_PATH_COMPENSATION_POWER) {
4164  status : ErrorCode,
4165  rf_tx_path_compensation_tenths_db : 16,
4166  rf_rx_path_compensation_tenths_db : 16,
4167}
4168
4169packet LeWriteRfPathCompensationPower : Command (op_code = LE_WRITE_RF_PATH_COMPENSATION_POWER) {
4170  rf_tx_path_compensation_tenths_db : 16,
4171  rf_rx_path_compensation_tenths_db : 16,
4172}
4173
4174packet LeWriteRfPathCompensationPowerComplete : CommandComplete (command_op_code = LE_WRITE_RF_PATH_COMPENSATION_POWER) {
4175  status : ErrorCode,
4176}
4177
4178enum PrivacyMode : 8 {
4179  NETWORK = 0,
4180  DEVICE = 1,
4181}
4182
4183packet LeSetPrivacyMode : Command (op_code = LE_SET_PRIVACY_MODE) {
4184  peer_identity_address_type : PeerAddressType,
4185  peer_identity_address : Address,
4186  privacy_mode : PrivacyMode,
4187}
4188
4189packet LeSetPrivacyModeComplete : CommandComplete (command_op_code = LE_SET_PRIVACY_MODE) {
4190  status : ErrorCode,
4191}
4192
4193packet LeSetPeriodicAdvertisingReceiveEnable : Command (op_code = LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE) {
4194  sync_handle : 12,
4195  _reserved_ : 4,
4196  enable : 8,
4197}
4198
4199packet LeSetPeriodicAdvertisingReceiveEnableComplete : CommandComplete (command_op_code = LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE) {
4200  status : ErrorCode,
4201}
4202
4203packet LePeriodicAdvertisingSyncTransfer : Command (op_code = LE_PERIODIC_ADVERTISING_SYNC_TRANSFER) {
4204  connection_handle : 12,
4205  _reserved_ : 4,
4206  service_data : 16,
4207  sync_handle: 12,
4208  _reserved_ : 4,
4209}
4210
4211packet LePeriodicAdvertisingSyncTransferComplete : CommandComplete (command_op_code = LE_PERIODIC_ADVERTISING_SYNC_TRANSFER) {
4212  status : ErrorCode,
4213  connection_handle : 12,
4214  _reserved_ : 4,
4215}
4216
4217packet LePeriodicAdvertisingSetInfoTransfer : Command (op_code = LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER) {
4218  connection_handle : 12,
4219  _reserved_ : 4,
4220  service_data : 16,
4221  advertising_handle: 8,
4222}
4223
4224packet LePeriodicAdvertisingSetInfoTransferComplete : CommandComplete (command_op_code = LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER) {
4225  status : ErrorCode,
4226  connection_handle : 12,
4227  _reserved_ : 4,
4228}
4229
4230enum SyncTransferMode : 8 {
4231  NO_SYNC = 0,
4232  SEND_SYNC_RECEIVED_DISABLE_REPORTS = 1,
4233  SEND_SYNC_RECEIVED_SEND_REPORTS = 2,
4234}
4235
4236enum CteType : 8 {
4237  AOA_CONSTANT_TONE_EXTENSION = 0x00,
4238  AOD_CONSTANT_TONE_EXTENSION_ONE_US_SLOTS = 0x01,
4239  AOD_CONSTANT_TONE_EXTENSION_TWO_US_SLOTS = 0x02,
4240  NO_CONSTANT_TONE_EXTENSION = 0xFF,
4241}
4242
4243packet LeSetPeriodicAdvertisingSyncTransferParameters : Command (op_code = LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS) {
4244  connection_handle : 12,
4245  _reserved_ : 4,
4246  mode : SyncTransferMode,
4247  skip: 16,
4248  sync_timeout : 16,
4249  cte_type : CteType,
4250}
4251
4252packet LeSetPeriodicAdvertisingSyncTransferParametersComplete : CommandComplete (command_op_code = LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS) {
4253  status : ErrorCode,
4254  connection_handle : 12,
4255  _reserved_ : 4,
4256}
4257
4258packet LeSetDefaultPeriodicAdvertisingSyncTransferParameters : Command (op_code = LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS) {
4259  mode : SyncTransferMode,
4260  skip: 16,
4261  sync_timeout : 16,
4262  cte_type : CteType,
4263}
4264
4265packet LeSetDefaultPeriodicAdvertisingSyncTransferParametersComplete : CommandComplete (command_op_code = LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS) {
4266  status : ErrorCode,
4267}
4268
4269enum UseDebugKey : 8 {
4270  USE_GENERATED_KEY = 0,
4271  USE_DEBUG_KEY = 1,
4272}
4273
4274packet LeGenerateDhkeyCommand : Command (op_code = LE_GENERATE_DHKEY_V2) {
4275  remote_p_256_public_key : 8[64],
4276  key_type : UseDebugKey,
4277}
4278
4279packet LeGenerateDhkeyCommandStatus : CommandStatus (command_op_code = LE_GENERATE_DHKEY_V2) {
4280}
4281
4282enum ScaAction : 8 {
4283  MORE_ACCURATE_CLOCK = 0,
4284  LESS_ACCURATE_CLOCK = 1,
4285}
4286
4287packet LeModifySleepClockAccuracy : Command (op_code = LE_MODIFY_SLEEP_CLOCK_ACCURACY) {
4288  action : ScaAction,
4289}
4290
4291packet LeModifySleepClockAccuracyComplete : CommandComplete (command_op_code = LE_MODIFY_SLEEP_CLOCK_ACCURACY) {
4292  status : ErrorCode,
4293}
4294
4295packet LeReadBufferSizeV2 : Command (op_code = LE_READ_BUFFER_SIZE_V2) {
4296}
4297
4298packet LeReadBufferSizeV2Complete : CommandComplete (command_op_code = LE_READ_BUFFER_SIZE_V2) {
4299  status : ErrorCode,
4300  le_buffer_size : LeBufferSize,
4301  iso_buffer_size : LeBufferSize,
4302}
4303
4304packet LeReadIsoTxSync : Command (op_code = LE_READ_ISO_TX_SYNC) {
4305  connection_handle : 12,
4306  _reserved_ : 4,
4307}
4308
4309packet LeReadIsoTxSyncComplete : CommandComplete (command_op_code = LE_READ_ISO_TX_SYNC) {
4310  connection_handle : 12,
4311  _reserved_ : 4,
4312  packet_sequence_number : 16,
4313  timestamp : 32,
4314  time_offset : 24,
4315}
4316
4317struct CisParametersConfig {
4318  cis_id : 8,
4319  max_sdu_c_to_p : 12,
4320  _reserved_ : 4,
4321  max_sdu_p_to_c : 12,
4322  _reserved_ : 4,
4323  phy_c_to_p : 3,
4324  _reserved_ : 5,
4325  phy_p_to_c : 3,
4326  _reserved_ : 5,
4327  rtn_c_to_p : 4,
4328  _reserved_ : 4,
4329  rtn_p_to_c : 4,
4330  _reserved_ : 4,
4331}
4332
4333enum Packing : 8 {
4334  SEQUENTIAL = 0,
4335  INTERLEAVED = 1,
4336}
4337
4338enum ClockAccuracy : 8 {
4339  PPM_500 = 0x00,
4340  PPM_250 = 0x01,
4341  PPM_150 = 0x02,
4342  PPM_100 = 0x03,
4343  PPM_75 = 0x04,
4344  PPM_50 = 0x05,
4345  PPM_30 = 0x06,
4346  PPM_20 = 0x07,
4347}
4348
4349packet LeSetCigParameters : Command (op_code = LE_SET_CIG_PARAMETERS) {
4350  cig_id : 8,
4351  sdu_interval_c_to_p : 24,
4352  sdu_interval_p_to_c : 24,
4353  worst_case_sca: ClockAccuracy,
4354  packing : Packing,
4355  framing : Enable,
4356  max_transport_latency_c_to_p : 16,
4357  max_transport_latency_p_to_c : 16,
4358  _count_(cis_config) : 8,
4359  cis_config : CisParametersConfig[],
4360}
4361
4362packet LeSetCigParametersComplete : CommandComplete (command_op_code = LE_SET_CIG_PARAMETERS) {
4363  status : ErrorCode,
4364  cig_id : 8,
4365  _count_(connection_handle) : 8,
4366  connection_handle : 16[],
4367}
4368
4369struct LeCisParametersTestConfig {
4370  cis_id : 8,
4371  nse : 8,
4372  max_sdu_c_to_p : 16,
4373  max_sdu_p_to_c : 16,
4374  max_pdu_c_to_p : 16,
4375  max_pdu_p_to_c : 16,
4376  phy_c_to_p : 8,
4377  phy_p_to_c : 8,
4378  bn_c_to_p : 8,
4379  bn_p_to_c : 8,
4380}
4381
4382packet LeSetCigParametersTest : Command (op_code = LE_SET_CIG_PARAMETERS_TEST) {
4383  cig_id : 8,
4384  sdu_interval_c_to_p : 24,
4385  sdu_interval_p_to_c : 24,
4386  ft_c_to_p : 8,
4387  ft_p_to_c : 8,
4388  iso_interval : 16,
4389  worst_case_sca: ClockAccuracy,
4390  packing : Packing,
4391  framing : Enable,
4392  _count_(cis_config) : 8,
4393  cis_config : LeCisParametersTestConfig[],
4394}
4395
4396packet LeSetCigParametersTestComplete : CommandComplete (command_op_code = LE_SET_CIG_PARAMETERS_TEST) {
4397  status : ErrorCode,
4398  cig_id : 8,
4399  _count_(connection_handle) : 8,
4400  connection_handle : 16[],
4401}
4402
4403struct LeCreateCisConfig {
4404  cis_connection_handle : 12,
4405  _reserved_ : 4,
4406  acl_connection_handle : 12,
4407  _reserved_ : 4,
4408}
4409
4410packet LeCreateCis : Command (op_code = LE_CREATE_CIS) {
4411  _count_(cis_config) : 8,
4412  cis_config : LeCreateCisConfig[],
4413}
4414
4415packet LeCreateCisStatus : CommandStatus (command_op_code = LE_CREATE_CIS) {
4416}
4417
4418packet LeRemoveCig : Command (op_code = LE_REMOVE_CIG) {
4419  cig_id : 8,
4420}
4421
4422packet LeRemoveCigComplete : CommandComplete (command_op_code = LE_REMOVE_CIG) {
4423  status : ErrorCode,
4424  cig_id : 8,
4425}
4426
4427packet LeAcceptCisRequest : Command (op_code = LE_ACCEPT_CIS_REQUEST) {
4428  connection_handle : 12,
4429  _reserved_ : 4,
4430}
4431
4432packet LeAcceptCisRequestStatus : CommandStatus (command_op_code = LE_ACCEPT_CIS_REQUEST) {
4433}
4434
4435packet LeRejectCisRequest : Command (op_code = LE_REJECT_CIS_REQUEST) {
4436  connection_handle : 12,
4437  _reserved_ : 4,
4438  reason : ErrorCode,
4439}
4440
4441packet LeRejectCisRequestComplete : CommandComplete (command_op_code = LE_REJECT_CIS_REQUEST) {
4442  status : ErrorCode,
4443  connection_handle : 12,
4444  _reserved_ : 4,
4445}
4446
4447packet LeCreateBig : Command (op_code = LE_CREATE_BIG) {
4448  big_handle : 8,
4449  advertising_handle : 8,
4450  num_bis : 8,
4451  sdu_interval : 24,
4452  max_sdu : 16,
4453  max_transport_latency : 16,
4454  rtn : 4,
4455  _reserved_ : 4,
4456  phy : SecondaryPhyType,
4457  packing : Packing,
4458  framing : Enable,
4459  encryption : Enable,
4460  broadcast_code: 8[16],
4461}
4462
4463packet LeCreateBigStatus : CommandStatus (command_op_code = LE_CREATE_BIG) {
4464}
4465
4466packet LeTerminateBig : Command (op_code = LE_TERMINATE_BIG) {
4467  big_handle : 8,
4468  reason : ErrorCode,
4469}
4470
4471packet LeTerminateBigStatus : CommandStatus (command_op_code = LE_TERMINATE_BIG) {
4472}
4473
4474packet LeBigCreateSync : Command (op_code = LE_BIG_CREATE_SYNC) {
4475  big_handle : 8,
4476  sync_handle : 12,
4477  _reserved_ : 4,
4478  encryption : Enable,
4479  broadcast_code : 8[16],
4480  mse : 5,
4481  _reserved_ : 3,
4482  big_sync_timeout : 16,
4483  _count_(bis) : 8,
4484  bis : 8[],
4485}
4486
4487packet LeBigCreateSyncStatus : CommandStatus (command_op_code = LE_BIG_CREATE_SYNC) {
4488}
4489
4490packet LeBigTerminateSync : Command (op_code = LE_BIG_TERMINATE_SYNC) {
4491  big_handle : 8,
4492}
4493
4494packet LeBigTerminateSyncComplete : CommandComplete (command_op_code = LE_BIG_TERMINATE_SYNC) {
4495  status : ErrorCode,
4496  big_handle : 8,
4497}
4498
4499packet LeRequestPeerSca : Command (op_code = LE_REQUEST_PEER_SCA) {
4500  connection_handle : 12,
4501  _reserved_ : 4,
4502}
4503
4504packet LeRequestPeerScaStatus : CommandStatus (command_op_code = LE_REQUEST_PEER_SCA) {
4505}
4506
4507packet LeSetupIsoDataPath : Command (op_code = LE_SETUP_ISO_DATA_PATH) {
4508  connection_handle : 12,
4509  _reserved_ : 4,
4510  data_path_direction : DataPathDirection,
4511  data_path_id : 8,
4512  codec_id : 40,
4513  controller_delay : 24,
4514  _count_(codec_configuration) : 8,
4515  codec_configuration : 8[],
4516}
4517
4518packet LeSetupIsoDataPathComplete : CommandComplete (command_op_code = LE_SETUP_ISO_DATA_PATH) {
4519  status : ErrorCode,
4520  connection_handle : 12,
4521  _reserved_ : 4,
4522}
4523
4524enum RemoveDataPathDirection : 8 {
4525  INPUT = 1,
4526  OUTPUT = 2,
4527  INPUT_AND_OUTPUT = 3,
4528}
4529
4530packet LeRemoveIsoDataPath : Command (op_code = LE_REMOVE_ISO_DATA_PATH) {
4531  connection_handle : 12,
4532  _reserved_ : 4,
4533  remove_data_path_direction : RemoveDataPathDirection,
4534}
4535
4536packet LeRemoveIsoDataPathComplete : CommandComplete (command_op_code = LE_REMOVE_ISO_DATA_PATH) {
4537  status : ErrorCode,
4538  connection_handle : 12,
4539  _reserved_ : 4,
4540}
4541
4542enum LeHostFeatureBits : 8 {
4543  CONNECTED_ISO_STREAM_HOST_SUPPORT = 32,
4544  CONNECTION_SUBRATING_HOST_SUPPORT = 38,
4545}
4546
4547packet LeSetHostFeature : Command (op_code = LE_SET_HOST_FEATURE) {
4548  bit_number : LeHostFeatureBits,
4549  bit_value:  Enable,
4550}
4551
4552packet LeSetHostFeatureComplete : CommandComplete (command_op_code = LE_SET_HOST_FEATURE) {
4553  status : ErrorCode,
4554}
4555
4556packet LeReadIsoLinkQuality : Command (op_code = LE_READ_ISO_LINK_QUALITY) {
4557  connection_handle : 12,
4558  _reserved_ : 4,
4559}
4560
4561packet LeReadIsoLinkQualityComplete : CommandComplete (command_op_code = LE_READ_ISO_LINK_QUALITY) {
4562  status : ErrorCode,
4563  connection_handle : 12,
4564  _reserved_ : 4,
4565  tx_unacked_packets : 32,
4566  tx_flushed_packets : 32,
4567  tx_last_subevent_packets : 32,
4568  retransmitted_packets : 32,
4569  crc_error_packets : 32,
4570  rx_unreceived_packets : 32,
4571  duplicate_packets : 32,
4572}
4573
4574packet LeEnhancedReadTransmitPowerLevel : Command (op_code = LE_ENHANCED_READ_TRANSMIT_POWER_LEVEL) {
4575  connection_handle : 12,
4576  _reserved_ : 4,
4577  phy : 8,
4578}
4579
4580enum PhyWithCodedSpecified : 8 {
4581  LE_1M = 1,
4582  LE_2M = 2,
4583  LE_CODED_S_8 = 3,
4584  LE_CODED_S_2 = 4,
4585}
4586
4587packet LeEnhancedReadTransmitPowerLevelComplete : CommandComplete (command_op_code = LE_ENHANCED_READ_TRANSMIT_POWER_LEVEL) {
4588  status : ErrorCode,
4589  connection_handle : 12,
4590  _reserved_ : 4,
4591  phy : PhyWithCodedSpecified,
4592  current_transmit_power_level : 8,
4593  max_transmit_power_level : 8,
4594}
4595
4596packet LeReadRemoteTransmitPowerLevel : Command (op_code = LE_READ_REMOTE_TRANSMIT_POWER_LEVEL) {
4597  connection_handle : 12,
4598  _reserved_ : 4,
4599  phy : 8,
4600}
4601
4602packet LeReadRemoteTransmitPowerLevelStatus : CommandStatus (command_op_code = LE_READ_REMOTE_TRANSMIT_POWER_LEVEL) {
4603}
4604
4605packet LeSetPathLossReportingParameters : Command (op_code = LE_SET_PATH_LOSS_REPORTING_PARAMETERS) {
4606  connection_handle : 12,
4607  _reserved_ : 4,
4608  high_threshold : 8,
4609  high_hysteresis : 8,
4610  low_threshold : 8,
4611  low_hysteresis : 8,
4612  min_time_spent : 16,
4613}
4614
4615packet LeSetPathLossReportingParametersComplete : CommandComplete (command_op_code = LE_SET_PATH_LOSS_REPORTING_PARAMETERS) {
4616  status : ErrorCode,
4617  connection_handle : 12,
4618  _reserved_ : 4,
4619}
4620
4621packet LeSetPathLossReportingEnable : Command (op_code = LE_SET_PATH_LOSS_REPORTING_ENABLE) {
4622  connection_handle : 12,
4623  _reserved_ : 4,
4624  enable : 8,
4625}
4626
4627packet LeSetPathLossReportingEnableComplete : CommandComplete (command_op_code = LE_SET_PATH_LOSS_REPORTING_ENABLE) {
4628  status : ErrorCode,
4629  connection_handle : 12,
4630  _reserved_ : 4,
4631}
4632
4633packet LeSetTransmitPowerReportingEnable : Command (op_code = LE_SET_TRANSMIT_POWER_REPORTING_ENABLE) {
4634  connection_handle : 12,
4635  _reserved_ : 4,
4636  local_enable : 8,
4637  remote_enable : 8,
4638}
4639
4640packet LeSetTransmitPowerReportingEnableComplete : CommandComplete (command_op_code = LE_SET_TRANSMIT_POWER_REPORTING_ENABLE) {
4641  status : ErrorCode,
4642  connection_handle : 12,
4643  _reserved_ : 4,
4644}
4645
4646packet LeSetDataRelatedAddressChanges : Command (op_code = LE_SET_DATA_RELATED_ADDRESS_CHANGES) {
4647  advertising_handle : 8,
4648  change_reasons : 8,
4649}
4650
4651packet LeSetDataRelatedAddressChangesComplete : CommandComplete (command_op_code = LE_SET_DATA_RELATED_ADDRESS_CHANGES) {
4652  status : ErrorCode,
4653}
4654
4655packet LeSetDefaultSubrate : Command (op_code = LE_SET_DEFAULT_SUBRATE) {
4656  subrate_min : 9,
4657  _reserved_ : 7,
4658  subrate_max : 9,
4659  _reserved_ : 7,
4660  max_latency : 9,
4661  _reserved_ : 7,
4662  continuation_number : 9,
4663  _reserved_ : 7,
4664  supervision_timeout: 12,
4665  _reserved_ : 4,
4666}
4667
4668packet LeSetDefaultSubrateComplete : CommandComplete (command_op_code = LE_SET_DEFAULT_SUBRATE) {
4669  status : ErrorCode,
4670}
4671
4672packet LeSubrateRequest : Command (op_code = LE_SUBRATE_REQUEST) {
4673  connection_handle : 12,
4674  _reserved_ : 4,
4675  subrate_min : 9,
4676  _reserved_ : 7,
4677  subrate_max : 9,
4678  _reserved_ : 7,
4679  max_latency : 9,
4680  _reserved_ : 7,
4681  continuation_number : 9,
4682  _reserved_ : 7,
4683  supervision_timeout: 12,
4684  _reserved_ : 4,
4685}
4686
4687packet LeSubrateRequestStatus : CommandStatus (command_op_code = LE_SUBRATE_REQUEST) {
4688}
4689
4690// HCI Event Packets
4691
4692packet InquiryComplete : Event (event_code = INQUIRY_COMPLETE) {
4693  status : ErrorCode,
4694}
4695
4696struct InquiryResponse {
4697  bd_addr : Address,
4698  page_scan_repetition_mode : PageScanRepetitionMode,
4699  _reserved_ : 8,
4700  _reserved_ : 8,
4701  class_of_device : 24,
4702  clock_offset : 15,
4703  _reserved_ : 1,
4704}
4705
4706packet InquiryResult : Event (event_code = INQUIRY_RESULT) {
4707  _count_(responses) : 8,
4708  responses : InquiryResponse[],
4709}
4710
4711enum LinkType : 8 {
4712  SCO = 0x00,
4713  ACL = 0x01,
4714}
4715
4716packet ConnectionComplete : Event (event_code = CONNECTION_COMPLETE) {
4717  status : ErrorCode,
4718  connection_handle : 12,
4719  _reserved_ : 4,
4720  bd_addr : Address,
4721  link_type : LinkType,
4722  encryption_enabled : Enable,
4723}
4724
4725enum ConnectionRequestLinkType : 8 {
4726  UNKNOWN = 0xFF,
4727  SCO = 0x00,
4728  ACL = 0x01,
4729  ESCO = 0x02,
4730}
4731
4732packet ConnectionRequest : Event (event_code = CONNECTION_REQUEST) {
4733  bd_addr : Address,
4734  class_of_device : 24,
4735  link_type : ConnectionRequestLinkType,
4736}
4737
4738packet DisconnectionComplete : Event (event_code = DISCONNECTION_COMPLETE) {
4739  status : ErrorCode,
4740  connection_handle : 12,
4741  _reserved_ : 4,
4742  reason : ErrorCode,
4743}
4744
4745packet AuthenticationComplete : Event (event_code = AUTHENTICATION_COMPLETE) {
4746  status : ErrorCode,
4747  connection_handle : 12,
4748  _reserved_ : 4,
4749}
4750
4751packet RemoteNameRequestComplete : Event (event_code = REMOTE_NAME_REQUEST_COMPLETE) {
4752  status : ErrorCode,
4753  bd_addr : Address,
4754  remote_name : 8[248], // UTF-8 encoded user-friendly descriptive name
4755}
4756
4757enum EncryptionEnabled : 8 {
4758  OFF = 0x00,
4759  ON = 0x01, // E0 for BR/EDR and AES-CCM for LE
4760  BR_EDR_AES_CCM = 0x02,
4761}
4762
4763packet EncryptionChange : Event (event_code = ENCRYPTION_CHANGE) {
4764  status : ErrorCode,
4765  connection_handle : 12,
4766  _reserved_ : 4,
4767  encryption_enabled : EncryptionEnabled,
4768}
4769
4770packet ChangeConnectionLinkKeyComplete : Event (event_code = CHANGE_CONNECTION_LINK_KEY_COMPLETE) {
4771  status : ErrorCode,
4772  connection_handle : 12,
4773  _reserved_ : 4,
4774}
4775
4776packet CentralLinkKeyComplete : Event (event_code = CENTRAL_LINK_KEY_COMPLETE) {
4777  status : ErrorCode,
4778  connection_handle : 12,
4779  _reserved_ : 4,
4780  key_flag : KeyFlag,
4781}
4782
4783packet ReadRemoteSupportedFeaturesComplete : Event (event_code = READ_REMOTE_SUPPORTED_FEATURES_COMPLETE) {
4784  status : ErrorCode,
4785  connection_handle : 12,
4786  _reserved_ : 4,
4787  lmp_features : 64,
4788}
4789
4790packet ReadRemoteVersionInformationComplete : Event (event_code = READ_REMOTE_VERSION_INFORMATION_COMPLETE) {
4791  status : ErrorCode,
4792  connection_handle : 12,
4793  _reserved_ : 4,
4794  version : 8,
4795  manufacturer_name : 16,
4796  sub_version : 16,
4797}
4798
4799packet QosSetupComplete : Event (event_code = QOS_SETUP_COMPLETE) {
4800  status : ErrorCode,
4801  connection_handle : 12,
4802  _reserved_ : 4,
4803  _reserved_ : 8,
4804  service_type : ServiceType,
4805  token_rate : 32, // Octets/s
4806  peak_bandwidth : 32, // Octets/s
4807  latency : 32, // Octets/s
4808  delay_variation : 32, // microseconds
4809}
4810
4811// Command Complete and Command Status Events are implemented above Commands.
4812
4813packet HardwareError : Event (event_code = HARDWARE_ERROR) {
4814  hardware_code : 8,
4815}
4816
4817packet FlushOccurred : Event (event_code = FLUSH_OCCURRED) {
4818  connection_handle : 12,
4819  _reserved_ : 4,
4820}
4821
4822packet RoleChange : Event (event_code = ROLE_CHANGE) {
4823  status : ErrorCode,
4824  bd_addr : Address,
4825  new_role : Role,
4826}
4827
4828packet NumberOfCompletedPackets : Event (event_code = NUMBER_OF_COMPLETED_PACKETS) {
4829  _count_(completed_packets) : 8,
4830  completed_packets : CompletedPackets[],
4831}
4832
4833enum Mode : 8 {
4834  ACTIVE = 0x00,
4835  HOLD = 0x01,
4836  SNIFF = 0x02,
4837}
4838
4839packet ModeChange : Event (event_code = MODE_CHANGE) {
4840  status : ErrorCode,
4841  connection_handle : 12,
4842  _reserved_ : 4,
4843  current_mode : Mode,
4844  interval : 16, // 0x002 - 0xFFFE (1.25ms - 40.9s)
4845}
4846
4847struct ZeroKeyAndAddress {
4848  address : Address,
4849  _fixed_ = 0 : 64,
4850  _fixed_ = 0 : 64,
4851}
4852
4853packet ReturnLinkKeys : Event (event_code = RETURN_LINK_KEYS) {
4854  _count_(keys) : 8,
4855  keys : ZeroKeyAndAddress[],
4856}
4857
4858packet PinCodeRequest : Event (event_code = PIN_CODE_REQUEST) {
4859  bd_addr : Address,
4860}
4861
4862packet LinkKeyRequest : Event (event_code = LINK_KEY_REQUEST) {
4863  bd_addr : Address,
4864}
4865
4866enum KeyType : 8 {
4867  COMBINATION = 0x00,
4868  DEBUG_COMBINATION = 0x03,
4869  UNAUTHENTICATED_P192 = 0x04,
4870  AUTHENTICATED_P192 = 0x05,
4871  CHANGED = 0x06,
4872  UNAUTHENTICATED_P256 = 0x07,
4873  AUTHENTICATED_P256 = 0x08,
4874}
4875
4876packet LinkKeyNotification : Event (event_code = LINK_KEY_NOTIFICATION) {
4877  bd_addr : Address,
4878  link_key : 8[16],
4879  key_type : KeyType,
4880}
4881
4882packet LoopbackCommand : Event (event_code = LOOPBACK_COMMAND) {
4883  _payload_, // Command packet, truncated if it was longer than 252 bytes
4884}
4885
4886packet DataBufferOverflow : Event (event_code = DATA_BUFFER_OVERFLOW) {
4887  link_type : LinkType,
4888}
4889
4890packet MaxSlotsChange : Event (event_code = MAX_SLOTS_CHANGE) {
4891  connection_handle : 12,
4892  _reserved_ : 4,
4893  lmp_max_slots : 8,
4894}
4895
4896packet ReadClockOffsetComplete : Event (event_code = READ_CLOCK_OFFSET_COMPLETE) {
4897  status : ErrorCode,
4898  connection_handle : 12,
4899  _reserved_ : 4,
4900  clock_offset : 15,
4901  _reserved_ : 1,
4902}
4903
4904packet ConnectionPacketTypeChanged : Event (event_code = CONNECTION_PACKET_TYPE_CHANGED) {
4905  status : ErrorCode,
4906  connection_handle : 12,
4907  _reserved_ : 4,
4908  packet_type : 16,
4909}
4910
4911packet QosViolation : Event (event_code = QOS_VIOLATION) {
4912  connection_handle : 12,
4913  _reserved_ : 4,
4914}
4915
4916packet PageScanRepetitionModeChange : Event (event_code = PAGE_SCAN_REPETITION_MODE_CHANGE) {
4917  bd_addr : Address,
4918  page_scan_repetition_mode : PageScanRepetitionMode,
4919}
4920
4921packet FlowSpecificationComplete : Event (event_code = FLOW_SPECIFICATION_COMPLETE) {
4922  status : ErrorCode,
4923  connection_handle : 12,
4924  _reserved_ : 4,
4925  _reserved_ : 8,
4926  flow_direction : FlowDirection,
4927  service_type : ServiceType,
4928  token_rate : 32, // Octets/s
4929  token_bucket_size : 32,
4930  peak_bandwidth : 32, // Octets/s
4931  access_latency : 32, // Octets/s
4932}
4933
4934struct InquiryResponseWithRssi {
4935  address : Address,
4936  page_scan_repetition_mode : PageScanRepetitionMode,
4937  _reserved_ : 8,
4938  class_of_device : 24,
4939  clock_offset : 15,
4940  _reserved_ : 1,
4941  rssi : 8,
4942}
4943
4944packet InquiryResultWithRssi : Event (event_code = INQUIRY_RESULT_WITH_RSSI) {
4945  _count_(responses) : 8,
4946  responses : InquiryResponseWithRssi[],
4947}
4948
4949packet ReadRemoteExtendedFeaturesComplete : Event (event_code = READ_REMOTE_EXTENDED_FEATURES_COMPLETE) {
4950  status : ErrorCode,
4951  connection_handle : 12,
4952  _reserved_ : 4,
4953  page_number : 8,
4954  maximum_page_number : 8,
4955  extended_lmp_features : 64,
4956}
4957
4958enum ScoLinkType : 8 {
4959  SCO = 0x00,
4960  ESCO = 0x02,
4961}
4962
4963enum ScoAirMode : 8 {
4964  ULAW_LOG = 0x00,
4965  ALAW_LOG = 0x01,
4966  CVSD = 0x02,
4967  TRANSPARENT = 0x03,
4968}
4969
4970packet SynchronousConnectionComplete : Event (event_code = SYNCHRONOUS_CONNECTION_COMPLETE) {
4971  status : ErrorCode,
4972  connection_handle : 12,
4973   _reserved_ : 4,
4974  bd_addr : Address,
4975  link_type : ScoLinkType,
4976  // Time between two consecutive eSCO instants measured in slots.
4977  // eSCO only, Shall be zero for SCO links.
4978  transmission_interval_slots : 8,
4979  // The size of the retransmission window measured in slots.
4980  // eSCO only. Shall be zero for SCO links.
4981  retransmission_window_slots : 8,
4982  // Length in bytes of the eSCO payload in the receive direction.
4983  // eSCO only. Shall be zero for SCO links.
4984  rx_packet_length : 16,
4985  // Length in bytes of the eSCO payload in the transmit direction.
4986  // eSCO only. Shall be zero for SCO links.
4987  tx_packet_length : 16,
4988  air_mode : ScoAirMode,
4989}
4990
4991test SynchronousConnectionComplete {
4992  "\x2c\x11\x00\x03\x00\x1d\xdf\xed\x2b\x1a\xf8\x02\x0c\x04\x3c\x00\x3c\x00\x03",
4993}
4994
4995packet SynchronousConnectionChanged : Event (event_code = SYNCHRONOUS_CONNECTION_CHANGED) {
4996  status : ErrorCode,
4997  connection_handle : 12,
4998   _reserved_ : 4,
4999  // Time between two consecutive eSCO instants measured in slots.
5000  // eSCO only, Shall be zero for SCO links.
5001  transmission_interval_slots : 8,
5002  // Time between two consecutive SCO/eSCO instants measured in slots.
5003  retransmission_window_slots : 8,
5004  // Length in bytes of the SCO/eSCO payload in the receive direction.
5005  rx_packet_length : 16,
5006  // Length in bytes of the SCO/eSCO payload in the transmit direction.
5007  tx_packet_length : 16,
5008}
5009
5010packet SniffSubratingEvent : Event (event_code = SNIFF_SUBRATING) {
5011  status : ErrorCode,
5012  connection_handle : 12,
5013  _reserved_ : 4,
5014  maximum_transmit_latency : 16, // 0x000 - 0xFFFE (0s - 40.9s)
5015  maximum_receive_latency : 16, // 0x000 - 0xFFFE (0s - 40.9s)
5016  minimum_remote_timeout : 16, // 0x000 - 0xFFFE (0s - 40.9s)
5017  minimum_local_timeout : 16, // 0x000 - 0xFFFE (0s - 40.9s)
5018}
5019
5020packet ExtendedInquiryResult : Event (event_code = EXTENDED_INQUIRY_RESULT) {
5021  _fixed_ = 0x01 : 8,
5022  address : Address,
5023  page_scan_repetition_mode : PageScanRepetitionMode,
5024  _reserved_ : 8,
5025  class_of_device : 24,
5026  clock_offset : 15,
5027  _reserved_ : 1,
5028  rssi : 8,
5029  // Extended inquiry Result is always 255 bytes long;
5030  // the gap data is padded with zeros as necessary.
5031  // Refer to BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 3, Part C Section 8 on page 1340
5032  extended_inquiry_response : 8[240],
5033}
5034
5035packet EncryptionKeyRefreshComplete : Event (event_code = ENCRYPTION_KEY_REFRESH_COMPLETE) {
5036  status : ErrorCode,
5037  connection_handle : 12,
5038  _reserved_ : 4,
5039}
5040
5041packet IoCapabilityRequest : Event (event_code = IO_CAPABILITY_REQUEST) {
5042  bd_addr : Address,
5043}
5044
5045packet IoCapabilityResponse : Event (event_code = IO_CAPABILITY_RESPONSE) {
5046  bd_addr : Address,
5047  io_capability : IoCapability,
5048  oob_data_present : OobDataPresent,
5049  authentication_requirements : AuthenticationRequirements,
5050}
5051
5052packet UserConfirmationRequest : Event (event_code = USER_CONFIRMATION_REQUEST) {
5053  bd_addr : Address,
5054  numeric_value : 20, // 0x00000-0xF423F (000000 - 999999)
5055  _reserved_ : 12,
5056}
5057
5058packet UserPasskeyRequest : Event (event_code = USER_PASSKEY_REQUEST) {
5059  bd_addr : Address,
5060}
5061
5062packet RemoteOobDataRequest : Event (event_code = REMOTE_OOB_DATA_REQUEST) {
5063  bd_addr : Address,
5064}
5065
5066packet SimplePairingComplete : Event (event_code = SIMPLE_PAIRING_COMPLETE) {
5067  status : ErrorCode,
5068  bd_addr : Address,
5069}
5070
5071packet LinkSupervisionTimeoutChanged : Event (event_code = LINK_SUPERVISION_TIMEOUT_CHANGED) {
5072  connection_handle : 12,
5073  _reserved_ : 4,
5074  link_supervision_timeout : 16, // 0x001-0xFFFF (0.625ms-40.9s)
5075}
5076
5077enum FlushablePacketType : 8 {
5078  AUTOMATICALLY_FLUSHABLE_ONLY = 0,
5079}
5080
5081packet EnhancedFlush : Command (op_code = ENHANCED_FLUSH) {
5082  connection_handle : 12,
5083  _reserved_ : 4,
5084  packet_type : FlushablePacketType,
5085}
5086
5087test EnhancedFlush {
5088  "\x5f\x0c\x03\x02\x00\x00",
5089}
5090
5091packet EnhancedFlushStatus : CommandStatus (command_op_code = ENHANCED_FLUSH) {
5092}
5093
5094packet EnhancedFlushComplete : Event (event_code = ENHANCED_FLUSH_COMPLETE) {
5095  connection_handle : 12,
5096  _reserved_ : 4,
5097}
5098
5099test EnhancedFlushComplete {
5100  "\x39\x02\x02\x00",
5101}
5102
5103packet UserPasskeyNotification : Event (event_code = USER_PASSKEY_NOTIFICATION) {
5104  bd_addr : Address,
5105  passkey : 20, // 0x00000-0xF423F (000000 - 999999)
5106  _reserved_ : 12,
5107}
5108
5109packet KeypressNotification : Event (event_code = KEYPRESS_NOTIFICATION) {
5110  bd_addr : Address,
5111  notification_type : KeypressNotificationType,
5112}
5113
5114packet RemoteHostSupportedFeaturesNotification : Event (event_code = REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION) {
5115  bd_addr : Address,
5116  host_supported_features : 64,
5117}
5118
5119packet LeMetaEvent : Event (event_code = LE_META_EVENT) {
5120  subevent_code : SubeventCode,
5121  _body_,
5122}
5123
5124packet NumberOfCompletedDataBlocks : Event (event_code = NUMBER_OF_COMPLETED_DATA_BLOCKS) {
5125  total_num_data_blocks : 16,
5126  _payload_, // placeholder (unimplemented)
5127}
5128
5129// LE Events
5130packet LeConnectionComplete : LeMetaEvent (subevent_code = CONNECTION_COMPLETE) {
5131  status : ErrorCode,
5132  connection_handle : 12,
5133  _reserved_ : 4,
5134  role : Role,
5135  peer_address_type : AddressType,
5136  peer_address : Address,
5137  connection_interval : 16, // 0x006 - 0x0C80 (7.5ms - 4000ms)
5138  peripheral_latency : 16,
5139  supervision_timeout : 16,  // 0x000A to 0x0C80 (100ms to 32s)
5140  central_clock_accuracy : ClockAccuracy,
5141}
5142
5143enum AdvertisingEventType : 8 {
5144  ADV_IND = 0x00,
5145  ADV_DIRECT_IND = 0x01,
5146  ADV_SCAN_IND = 0x02,
5147  ADV_NONCONN_IND = 0x03,
5148  SCAN_RESPONSE = 0x04,
5149}
5150
5151struct LeAdvertisingResponse {
5152  event_type : AdvertisingEventType,
5153  address_type : AddressType,
5154  address : Address,
5155  _size_(advertising_data) : 8,
5156  advertising_data : 8[],
5157  rssi : 8,
5158}
5159
5160packet LeAdvertisingReport : LeMetaEvent (subevent_code = ADVERTISING_REPORT) {
5161  _count_(responses) : 8,
5162  responses : LeAdvertisingResponse[],
5163}
5164
5165packet LeConnectionUpdateComplete : LeMetaEvent (subevent_code = CONNECTION_UPDATE_COMPLETE) {
5166  status : ErrorCode,
5167  connection_handle : 12,
5168  _reserved_ : 4,
5169  connection_interval : 16, // 0x006 - 0x0C80 (7.5ms - 4000ms)
5170  peripheral_latency : 16,  // Number of connection events
5171  supervision_timeout : 16,  // 0x000A to 0x0C80 (100ms to 32s)
5172}
5173
5174packet LeReadRemoteFeaturesComplete : LeMetaEvent (subevent_code = READ_REMOTE_FEATURES_COMPLETE) {
5175  status : ErrorCode,
5176  connection_handle : 12,
5177  _reserved_ : 4,
5178  le_features : 64,
5179}
5180
5181packet LeLongTermKeyRequest : LeMetaEvent (subevent_code = LONG_TERM_KEY_REQUEST) {
5182  connection_handle : 12,
5183  _reserved_ : 4,
5184  random_number : 8[8],
5185  encrypted_diversifier : 16,
5186}
5187
5188packet LeRemoteConnectionParameterRequest : LeMetaEvent (subevent_code = REMOTE_CONNECTION_PARAMETER_REQUEST) {
5189  connection_handle : 12,
5190  _reserved_ : 4,
5191  interval_min : 16, // 0x006 - 0x0C80 (7.5ms - 4s)
5192  interval_max : 16, // 0x006 - 0x0C80 (7.5ms - 4s)
5193  latency : 16,  // Number of connection events (0x0000 to 0x01f3 (499)
5194  timeout : 16,  // 0x000A to 0x0C80 (100ms to 32s)
5195}
5196
5197packet LeDataLengthChange : LeMetaEvent (subevent_code = DATA_LENGTH_CHANGE) {
5198  connection_handle : 12,
5199  _reserved_ : 4,
5200  max_tx_octets : 16, // 0x001B - 0x00FB
5201  max_tx_time : 16, // 0x0148 - 0x4290
5202  max_rx_octets : 16, // 0x001B - 0x00FB
5203  max_rx_time : 16, // 0x0148 - 0x4290
5204}
5205
5206packet ReadLocalP256PublicKeyComplete : LeMetaEvent (subevent_code = READ_LOCAL_P256_PUBLIC_KEY_COMPLETE) {
5207  status : ErrorCode,
5208  local_p_256_public_key : 8[64],
5209}
5210
5211packet GenerateDhKeyComplete : LeMetaEvent (subevent_code = GENERATE_DHKEY_COMPLETE) {
5212  status : ErrorCode,
5213  dh_key : 8[32],
5214}
5215
5216packet LeEnhancedConnectionComplete : LeMetaEvent (subevent_code = ENHANCED_CONNECTION_COMPLETE) {
5217  status : ErrorCode,
5218  connection_handle : 12,
5219  _reserved_ : 4,
5220  role : Role,
5221  peer_address_type : AddressType,
5222  peer_address : Address,
5223  local_resolvable_private_address : Address,
5224  peer_resolvable_private_address : Address,
5225  connection_interval : 16, // 0x006 - 0x0C80 (7.5ms - 4000ms)
5226  peripheral_latency : 16,
5227  supervision_timeout : 16,  // 0x000A to 0x0C80 (100ms to 32s)
5228  central_clock_accuracy : ClockAccuracy,
5229}
5230
5231enum DirectAdvertisingAddressType : 8 {
5232  PUBLIC_DEVICE_ADDRESS = 0x00,
5233  RANDOM_DEVICE_ADDRESS = 0x01,
5234  PUBLIC_IDENTITY_ADDRESS = 0x02,
5235  RANDOM_IDENTITY_ADDRESS = 0x03,
5236  CONTROLLER_UNABLE_TO_RESOLVE = 0xFE,
5237  NO_ADDRESS_PROVIDED = 0xFF,
5238}
5239
5240enum DirectAdvertisingEventType : 8 {
5241  ADV_DIRECT_IND = 0x01,
5242}
5243
5244enum DirectAddressType : 8 {
5245  RANDOM_DEVICE_ADDRESS = 0x01,
5246}
5247
5248struct LeDirectedAdvertisingResponse {
5249  event_type : DirectAdvertisingEventType,
5250  address_type : DirectAdvertisingAddressType,
5251  address : Address,
5252  direct_address_type : DirectAddressType,
5253  direct_address : Address,
5254  rssi : 8,
5255}
5256
5257packet LeDirectedAdvertisingReport : LeMetaEvent (subevent_code = DIRECTED_ADVERTISING_REPORT) {
5258  _count_(responses) : 8,
5259  responses : LeDirectedAdvertisingResponse[],
5260}
5261
5262packet LePhyUpdateComplete : LeMetaEvent (subevent_code = PHY_UPDATE_COMPLETE) {
5263    status : ErrorCode,
5264    connection_handle : 12,
5265    _reserved_ : 4,
5266    tx_phy : PhyType,
5267    rx_phy : PhyType,
5268}
5269
5270enum DataStatus : 2 {
5271  COMPLETE = 0x0,
5272  CONTINUING = 0x1,
5273  TRUNCATED = 0x2,
5274  RESERVED = 0x3,
5275}
5276
5277struct LeExtendedAdvertisingResponse {
5278  connectable : 1,
5279  scannable : 1,
5280  directed : 1,
5281  scan_response : 1,
5282  legacy : 1,
5283  data_status : DataStatus,
5284  _reserved_ : 9,
5285  address_type : DirectAdvertisingAddressType,
5286  address : Address,
5287  primary_phy : PrimaryPhyType,
5288  secondary_phy : SecondaryPhyType,
5289  advertising_sid : 8, // SID subfield in the ADI field
5290  tx_power : 8,
5291  rssi : 8, // -127 to +20 (0x7F means not available)
5292  periodic_advertising_interval : 16, // 0x006 to 0xFFFF (7.5 ms to 82s)
5293  direct_address_type : DirectAdvertisingAddressType,
5294  direct_address : Address,
5295  _size_(advertising_data) : 8,
5296  advertising_data: 8[],
5297}
5298
5299packet LeExtendedAdvertisingReport : LeMetaEvent (subevent_code = EXTENDED_ADVERTISING_REPORT) {
5300  _count_(responses) : 8,
5301  responses : LeExtendedAdvertisingResponse[],
5302}
5303
5304packet LePeriodicAdvertisingSyncEstablished : LeMetaEvent (subevent_code = PERIODIC_ADVERTISING_SYNC_ESTABLISHED) {
5305  status : ErrorCode,
5306  sync_handle : 12,
5307  _reserved_ : 4,
5308  advertising_sid : 8,
5309  advertiser_address_type : AddressType,
5310  advertiser_address : Address,
5311  advertiser_phy : SecondaryPhyType,
5312  periodic_advertising_interval : 16,
5313  advertiser_clock_accuracy : ClockAccuracy,
5314}
5315
5316packet LePeriodicAdvertisingReport : LeMetaEvent (subevent_code = PERIODIC_ADVERTISING_REPORT) {
5317  sync_handle : 12,
5318  _reserved_ : 4,
5319  tx_power : 8,
5320  rssi : 8,
5321  cte_type : CteType,
5322  data_status : DataStatus,
5323  _reserved_: 6,
5324  _size_(data) : 8,
5325  data : 8[],
5326}
5327
5328packet LePeriodicAdvertisingSyncLost : LeMetaEvent (subevent_code = PERIODIC_ADVERTISING_SYNC_LOST) {
5329  sync_handle : 12,
5330  _reserved_ : 4,
5331}
5332
5333packet LeScanTimeout : LeMetaEvent (subevent_code = SCAN_TIMEOUT) {
5334}
5335
5336packet LeAdvertisingSetTerminated : LeMetaEvent (subevent_code = ADVERTISING_SET_TERMINATED) {
5337  status : ErrorCode,
5338  advertising_handle : 8,
5339  connection_handle : 12,
5340  _reserved_ : 4,
5341  num_completed_extended_advertising_events : 8,
5342}
5343
5344packet LeScanRequestReceived : LeMetaEvent (subevent_code = SCAN_REQUEST_RECEIVED) {
5345  advertising_handle : 8,
5346  scanner_address_type : AddressType,
5347  scanner_address : Address,
5348}
5349
5350enum ChannelSelectionAlgorithm : 8 {
5351  ALGORITHM_1 = 0,
5352  ALGORITHM_2 = 1,
5353}
5354
5355packet LeChannelSelectionAlgorithm : LeMetaEvent (subevent_code = CHANNEL_SELECTION_ALGORITHM) {
5356  connection_handle : 12,
5357  _reserved_ : 4,
5358  channel_selection_algorithm : ChannelSelectionAlgorithm,
5359}
5360
5361packet LeConnectionlessIqReport : LeMetaEvent (subevent_code = CONNECTIONLESS_IQ_REPORT) {
5362  _payload_, // placeholder (unimplemented)
5363}
5364
5365packet LeConnectionIqReport : LeMetaEvent (subevent_code = CONNECTION_IQ_REPORT) {
5366  _payload_, // placeholder (unimplemented)
5367}
5368
5369packet LeCteRequestFailed : LeMetaEvent (subevent_code = CTE_REQUEST_FAILED) {
5370  _payload_, // placeholder (unimplemented)
5371}
5372
5373packet LePeriodicAdvertisingSyncTransferReceived : LeMetaEvent (subevent_code = PERIODIC_ADVERTISING_SYNC_TRANSFER_RECEIVED) {
5374  status : ErrorCode,
5375  connection_handle : 12,
5376  _reserved_ : 4,
5377  service_data : 16,
5378  sync_handle : 12,
5379  _reserved_ : 4,
5380  advertising_sid : 4,
5381  _reserved_ : 4,
5382  advertiser_address_type : AddressType,
5383  advertiser_address : Address,
5384  advertiser_phy : SecondaryPhyType,
5385  periodic_advertising_interval : 16,
5386  advertiser_clock_accuracy : ClockAccuracy,
5387}
5388
5389packet LeCisEstablished : LeMetaEvent (subevent_code = CIS_ESTABLISHED) {
5390  status : ErrorCode,
5391  connection_handle : 12,
5392  _reserved_ : 4,
5393  cig_sync_delay : 24,
5394  cis_sync_delay : 24,
5395  transport_latency_c_to_p : 24,
5396  transport_latency_p_to_c : 24,
5397  phy_c_to_p : SecondaryPhyType,
5398  phy_p_to_c : SecondaryPhyType,
5399  nse : 8,
5400  bn_c_to_p : 4,
5401  _reserved_ : 4,
5402  bn_p_to_c : 4,
5403  _reserved_ : 4,
5404  ft_c_to_p : 8,
5405  ft_p_to_c : 8,
5406  max_pdu_c_to_p : 8,
5407  _reserved_ : 8,
5408  max_pdu_p_to_c : 8,
5409  _reserved_ : 8,
5410  iso_interval : 16,
5411}
5412
5413packet LeCisRequest : LeMetaEvent (subevent_code = CIS_REQUEST) {
5414  acl_connection_handle : 12,
5415  _reserved_ : 4,
5416  cis_connection_handle : 12,
5417  _reserved_ : 4,
5418  cig_id : 8,
5419  cis_id : 8,
5420}
5421
5422packet LeCreateBigComplete : LeMetaEvent (subevent_code = CREATE_BIG_COMPLETE) {
5423  status : ErrorCode,
5424  big_handle : 8,
5425  big_sync_delay : 24,
5426  transport_latency_big: 24,
5427  phy : SecondaryPhyType,
5428  nse : 8,
5429  bn : 8,
5430  pto : 8,
5431  irc : 8,
5432  max_pdu : 16,
5433  iso_interval : 16,
5434  _size_(connection_handle) : 8,
5435  connection_handle : 16[],
5436}
5437
5438packet LeTerminateBigComplete : LeMetaEvent (subevent_code = TERMINATE_BIG_COMPLETE) {
5439  big_handle : 8,
5440  reason : ErrorCode,
5441}
5442
5443packet LeBigSyncEstablished : LeMetaEvent (subevent_code = BIG_SYNC_ESTABLISHED) {
5444  status : ErrorCode,
5445  big_handle : 8,
5446  transport_latency_big : 24,
5447  nse : 8,
5448  bn : 8,
5449  pto : 8,
5450  irc : 8,
5451  max_pdu : 16,
5452  iso_interval : 16,
5453  _size_(connection_handle) : 8,
5454  connection_handle : 16[],
5455}
5456
5457packet LeBigSyncLost : LeMetaEvent (subevent_code = BIG_SYNC_LOST) {
5458  big_handle : 8,
5459  reason : ErrorCode,
5460}
5461
5462packet LeRequestPeerScaComplete : LeMetaEvent (subevent_code = REQUEST_PEER_SCA_COMPLETE) {
5463  status : ErrorCode,
5464  connection_handle : 12,
5465  _reserved_ : 4,
5466  peer_clock_accuracy : ClockAccuracy,
5467}
5468
5469enum PathLossZone : 8 {
5470  LOW = 0,
5471  MID = 1,
5472  HIGH = 2,
5473}
5474
5475packet LePathLossThreshold : LeMetaEvent (subevent_code = PATH_LOSS_THRESHOLD) {
5476  connection_handle : 12,
5477  _reserved_ : 4,
5478  current_path_loss : 8,
5479  zone_entered : PathLossZone,
5480}
5481
5482enum ReportingReason : 8 {
5483  LOCAL_TRANSMIT_POWER_CHANGED = 0x00,
5484  REMOTE_TRANSMIT_POWER_CHANGED = 0x01,
5485  READ_COMMAND_COMPLETE = 0x02,
5486}
5487
5488packet LeTransmitPowerReporting : LeMetaEvent (subevent_code = TRANSMIT_POWER_REPORTING) {
5489  status : ErrorCode,
5490  connection_handle : 12,
5491  _reserved_ : 4,
5492  reason : ReportingReason,
5493  phy : 8,
5494  transmit_power_level : 8,
5495  transmit_power_level_flag : 8,
5496  delta : 8,
5497}
5498
5499packet LeBigInfoAdvertisingReport : LeMetaEvent (subevent_code = BIG_INFO_ADVERTISING_REPORT) {
5500  sync_handle : 12,
5501  _reserved_ : 4,
5502  num_bis : 8,
5503  nse : 8,
5504  iso_interval : 16,
5505  bn : 8,
5506  pto : 8,
5507  irc : 8,
5508  max_pdu : 16,
5509  sdu_interval : 24,
5510  max_sdu : 16,
5511  phy : SecondaryPhyType,
5512  framing : Enable,
5513  encryption : Enable,
5514}
5515
5516packet LeSubrateChange : LeMetaEvent (subevent_code = LE_SUBRATE_CHANGE) {
5517  status : ErrorCode,
5518  connection_handle : 12,
5519  _reserved_ : 4,
5520  subrate_factor : 9,
5521  _reserved_ : 7,
5522  peripheral_latency : 9,
5523  _reserved_ : 7,
5524  continuation_number : 9,
5525  _reserved_ : 7,
5526  supervision_timeout: 12,
5527  _reserved_ : 4,
5528}
5529
5530enum IsoPacketBoundaryFlag : 2 {
5531  FIRST_FRAGMENT = 0,
5532  CONTINUATION_FRAGMENT = 1,
5533  COMPLETE_SDU = 2,
5534  LAST_FRAGMENT = 3,
5535}
5536
5537enum TimeStampFlag : 1 {
5538  NOT_PRESENT = 0,
5539  PRESENT = 1,
5540}
5541
5542packet Iso {
5543  connection_handle : 12,
5544  pb_flag : IsoPacketBoundaryFlag,
5545  ts_flag : TimeStampFlag,
5546  _reserved_ : 1,
5547  _size_(_payload_) : 14,
5548  _reserved_ : 2,
5549  _payload_,
5550}
5551
5552enum IsoPacketStatusFlag : 2 {
5553  VALID = 0,
5554  POSSIBLY_INVALID = 1,
5555  LOST_DATA = 2,
5556}
5557
5558packet IsoWithTimestamp : Iso (ts_flag = PRESENT) {
5559  time_stamp : 32,
5560  packet_sequence_number : 16,
5561  iso_sdu_length : 12,
5562  _reserved_ : 2,
5563  packet_status_flag : IsoPacketStatusFlag,
5564  _payload_,
5565}
5566
5567packet IsoWithoutTimestamp : Iso (ts_flag = NOT_PRESENT) {
5568  packet_sequence_number : 16,
5569  iso_sdu_length : 12,
5570  _reserved_ : 2,
5571  packet_status_flag : IsoPacketStatusFlag,
5572  _payload_,
5573}
5574
5575// https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile
5576enum GapDataType : 8 {
5577  INVALID = 0x00,
5578  FLAGS = 0x01,
5579  INCOMPLETE_LIST_16_BIT_UUIDS = 0x02,
5580  COMPLETE_LIST_16_BIT_UUIDS = 0x03,
5581  INCOMPLETE_LIST_32_BIT_UUIDS = 0x04,
5582  COMPLETE_LIST_32_BIT_UUIDS = 0x05,
5583  INCOMPLETE_LIST_128_BIT_UUIDS = 0x06,
5584  COMPLETE_LIST_128_BIT_UUIDS = 0x07,
5585  SHORTENED_LOCAL_NAME = 0x08,
5586  COMPLETE_LOCAL_NAME = 0x09,
5587  TX_POWER_LEVEL = 0x0A,
5588  CLASS_OF_DEVICE = 0x0D,
5589  SIMPLE_PAIRING_HASH_C = 0x0E,
5590  SIMPLE_PAIRING_RANDOMIZER_R = 0x0F,
5591  DEVICE_ID = 0x10,
5592  SECURITY_MANAGER_OOB_FLAGS = 0x11,
5593  SLAVE_CONNECTION_INTERVAL_RANGE = 0x12,
5594  LIST_16BIT_SERVICE_SOLICITATION_UUIDS = 0x14,
5595  LIST_128BIT_SERVICE_SOLICITATION_UUIDS = 0x15,
5596  SERVICE_DATA_16_BIT_UUIDS = 0x16,
5597  PUBLIC_TARGET_ADDRESS = 0x17,
5598  RANDOM_TARGET_ADDRESS = 0x18,
5599  APPEARANCE = 0x19,
5600  ADVERTISING_INTERVAL = 0x1A,
5601  LE_BLUETOOTH_DEVICE_ADDRESS = 0x1B,
5602  LE_ROLE = 0x1C,
5603  SIMPLE_PAIRING_HASH_C_256 = 0x1D,
5604  SIMPLE_PAIRING_RANDOMIZER_R_256 = 0x1E,
5605  LIST_32BIT_SERVICE_SOLICITATION_UUIDS = 0x1F,
5606  SERVICE_DATA_32_BIT_UUIDS = 0x20,
5607  SERVICE_DATA_128_BIT_UUIDS = 0x21,
5608  LE_SECURE_CONNECTIONS_CONFIRMATION_VALUE = 0x22,
5609  LE_SECURE_CONNECTIONS_RANDOM_VALUE = 0x23,
5610  URI = 0x24,
5611  INDOOR_POSITIONING = 0x25,
5612  TRANSPORT_DISCOVERY_DATA = 0x26,
5613  LE_SUPPORTED_FEATURES = 0x27,
5614  CHANNEL_MAP_UPDATE_INDICATION = 0x28,
5615  MESH_PB_ADV = 0x29,
5616  MESH_MESSAGE = 0x2A,
5617  MESH_BEACON = 0x2B,
5618  BIG_INFO = 0x2C,
5619  BROADCAST_CODE = 0x2D,
5620  THREE_D_INFORMATION_DATA = 0x3D,
5621  MANUFACTURER_SPECIFIC_DATA = 0xFF,
5622}
5623
5624// -----------------------------------------------------------------------------
5625//  LE Get Vendor Capabilities Command
5626//  https://source.android.com/docs/core/connect/bluetooth/hci_requirements#vendor-specific-capabilities
5627// -----------------------------------------------------------------------------
5628
5629packet LeGetVendorCapabilities : Command (op_code = LE_GET_VENDOR_CAPABILITIES) {
5630}
5631
5632test LeGetVendorCapabilities {
5633  "\x53\xfd\x00",
5634}
5635
5636packet LeGetVendorCapabilitiesComplete : CommandComplete (command_op_code = LE_GET_VENDOR_CAPABILITIES) {
5637  status : ErrorCode,
5638  vendor_capabilities : 8[],
5639}
5640
5641struct VendorCapabilities_V_0_96 {
5642  max_advt_instances: 8,
5643  offloaded_resolution_of_private_address: 8,
5644  total_scan_results_storage: 16,
5645  max_irk_list_sz: 8,
5646  filtering_support: 8,
5647  max_filter: 8,
5648  activity_energy_info_support: 8,
5649  _fixed_ = 0x0060 : 16, // v0.96
5650  total_num_of_advt_tracked: 16,
5651  extended_scan_support: 8,
5652  debug_logging_supported: 8,
5653  le_address_generation_offloading_support: 8,
5654}
5655
5656struct VendorCapabilities_V_0_98 {
5657  _reserved_ : 8,
5658  _reserved_ : 8,
5659  total_scan_results_storage: 16,
5660  max_irk_list_sz: 8,
5661  filtering_support: 8,
5662  max_filter: 8,
5663  activity_energy_info_support: 8,
5664  _fixed_ = 0x0062 : 16, // v0.98
5665  total_num_of_advt_tracked: 16,
5666  extended_scan_support: 8,
5667  debug_logging_supported: 8,
5668  _reserved_ : 8,
5669  a2dp_source_offload_capability_mask: 32,
5670  bluetooth_quality_report_support: 8,
5671}
5672
5673struct VendorCapabilities_V_1_03 {
5674  _reserved_ : 8,
5675  _reserved_ : 8,
5676  total_scan_results_storage: 16,
5677  max_irk_list_sz: 8,
5678  filtering_support: 8,
5679  max_filter: 8,
5680  activity_energy_info_support: 8,
5681  _fixed_ = 0x0103 : 16, // v1.03
5682  total_num_of_advt_tracked: 16,
5683  extended_scan_support: 8,
5684  debug_logging_supported: 8,
5685  _reserved_ : 8,
5686  a2dp_source_offload_capability_mask: 32,
5687  bluetooth_quality_report_support: 8,
5688  dynamic_audio_buffer_support: 32,
5689}
5690
5691// -----------------------------------------------------------------------------
5692//  LE Batch Scan Command
5693//  https://source.android.com/docs/core/connect/bluetooth/hci_requirements#le_batch_scan_command
5694//  https://source.android.com/docs/core/connect/bluetooth/hci_requirements#storage-threshold-breach-subevent
5695// -----------------------------------------------------------------------------
5696
5697enum BatchScanOpcode : 8 {
5698  ENABLE = 0x01,
5699  SET_STORAGE_PARAMETERS = 0x02,
5700  SET_SCAN_PARAMETERS = 0x03,
5701  READ_RESULT_PARAMETERS = 0x04,
5702}
5703
5704packet LeBatchScan : Command (op_code = LE_BATCH_SCAN) {
5705  batch_scan_opcode : BatchScanOpcode,
5706  _body_,
5707}
5708
5709packet LeBatchScanComplete : CommandComplete (command_op_code = LE_BATCH_SCAN) {
5710  status : ErrorCode,
5711  batch_scan_opcode : BatchScanOpcode,
5712  _body_,
5713}
5714
5715packet LeBatchScanEnable : LeBatchScan (batch_scan_opcode = ENABLE) {
5716  enable : Enable,
5717}
5718
5719packet LeBatchScanEnableComplete : LeBatchScanComplete (batch_scan_opcode = ENABLE) {
5720}
5721
5722packet LeBatchScanSetStorageParameters : LeBatchScan (batch_scan_opcode = SET_STORAGE_PARAMETERS) {
5723  batch_scan_full_max_percentage : 8,
5724  batch_scan_truncated_max_percentage : 8,
5725  batch_scan_notify_threshold_percentage : 8,
5726}
5727
5728packet LeBatchScanSetStorageParametersComplete : LeBatchScanComplete (batch_scan_opcode = SET_STORAGE_PARAMETERS) {
5729}
5730
5731enum BatchScanDiscardRule : 8 {
5732  OLDEST = 0x00,
5733  WEAKEST_RSSI = 0x01,
5734}
5735
5736packet LeBatchScanSetScanParameters : LeBatchScan (batch_scan_opcode = SET_SCAN_PARAMETERS) {
5737  truncated_mode_enabled : 1,
5738  full_mode_enabled : 1,
5739  _reserved_ : 6,
5740  duty_cycle_scan_window_slots : 32,
5741  duty_cycle_scan_interval_slots : 32,
5742  own_address_type : PeerAddressType,
5743  batch_scan_discard_rule : BatchScanDiscardRule,
5744}
5745
5746packet LeBatchScanSetScanParametersComplete : LeBatchScanComplete (batch_scan_opcode = SET_SCAN_PARAMETERS) {
5747}
5748
5749enum BatchScanDataRead : 8 {
5750  TRUNCATED_MODE_DATA = 0x01,
5751  FULL_MODE_DATA = 0x02,
5752}
5753
5754packet LeBatchScanReadResultParameters : LeBatchScan (batch_scan_opcode = READ_RESULT_PARAMETERS) {
5755  batch_scan_data_read : BatchScanDataRead,
5756}
5757
5758packet LeBatchScanReadResultParametersCompleteRaw : LeBatchScanComplete (batch_scan_opcode = READ_RESULT_PARAMETERS) {
5759  batch_scan_data_read : BatchScanDataRead,
5760  num_of_records : 8,
5761  raw_data : 8[],
5762}
5763
5764packet LeBatchScanReadResultParametersComplete : LeBatchScanComplete (batch_scan_opcode = READ_RESULT_PARAMETERS) {
5765  batch_scan_data_read : BatchScanDataRead,
5766  _body_,
5767}
5768
5769struct TruncatedResult {
5770  bd_addr : Address,
5771  address_type : AddressType,
5772  tx_power : 8,
5773  rssi : 8,
5774  timestamp : 16,
5775}
5776
5777packet LeBatchScanReadTruncatedResultParametersComplete : LeBatchScanReadResultParametersComplete (batch_scan_data_read = TRUNCATED_MODE_DATA) {
5778  _count_(results) : 8,
5779  results : TruncatedResult[],
5780}
5781
5782struct FullResult {
5783  bd_addr : Address,
5784  address_type : AddressType,
5785  tx_power : 8,
5786  rssi : 8,
5787  timestamp : 16,
5788  _size_(adv_packet) : 8,
5789  adv_packet : 8[],
5790  _size_(scan_response) : 8,
5791  scan_response : 8[],
5792}
5793
5794packet LeBatchScanReadFullResultParametersComplete : LeBatchScanReadResultParametersComplete (batch_scan_data_read = FULL_MODE_DATA) {
5795  _count_(results) : 8,
5796  results : FullResult[],
5797}
5798
5799packet StorageThresholdBreachEvent : VendorSpecificEvent (subevent_code = STORAGE_THRESHOLD_BREACH) {
5800}
5801
5802// -----------------------------------------------------------------------------
5803//  Advertising Packet Content Filter (APCF) Command.
5804//  https://source.android.com/docs/core/connect/bluetooth/hci_requirements#advertising-packet-content-filter
5805//  https://source.android.com/docs/core/connect/bluetooth/hci_requirements#le-advertisement-tracking-sub-event
5806// -----------------------------------------------------------------------------
5807
5808enum ApcfOpcode : 8 {
5809  ENABLE = 0x00,
5810  SET_FILTERING_PARAMETERS = 0x01,
5811  BROADCASTER_ADDRESS = 0x02,
5812  SERVICE_UUID = 0x03,
5813  SERVICE_SOLICITATION_UUID = 0x04,
5814  LOCAL_NAME = 0x05,
5815  MANUFACTURER_DATA = 0x06,
5816  SERVICE_DATA = 0x07,
5817  TRANSPORT_DISCOVERY_SERVICE = 0x08,
5818  AD_TYPE_FILTER = 0x09,
5819  READ_EXTENDED_FEATURES = 0xFF,
5820}
5821
5822packet LeApcf : Command (op_code = LE_APCF) {
5823  apcf_opcode : ApcfOpcode,
5824  _payload_,
5825}
5826
5827packet LeApcfComplete : CommandComplete (command_op_code = LE_APCF) {
5828  status : ErrorCode,
5829  apcf_opcode : ApcfOpcode,
5830  _payload_
5831}
5832
5833packet LeApcfEnable : LeApcf (apcf_opcode = ENABLE) {
5834  apcf_enable : Enable,
5835}
5836
5837packet LeApcfEnableComplete : LeApcfComplete (apcf_opcode = ENABLE) {
5838  apcf_enable : Enable,
5839}
5840
5841enum ApcfAction : 8 {
5842  ADD = 0x00,
5843  DELETE = 0x01,
5844  CLEAR = 0x02,
5845}
5846
5847enum DeliveryMode : 8 {
5848  IMMEDIATE = 0x00,
5849  ONFOUND = 0x01,
5850  BATCHED = 0x02,
5851}
5852
5853// Bit mask for the APCF Feature Selection field.
5854enum ApcfFeatureSelection : 8 {
5855  BROADCASTER_ADDRESS = 0x00,
5856  SERVICE_DATA_CHANGE = 0x01,
5857  SERVICE_UUID = 0x02,
5858  SERVICE_SOLICITATION_UUID = 0x03,
5859  LOCAL_NAME = 0x04,
5860  MANUFACTURER_DATA = 0x05,
5861  SERVICE_DATA = 0x06,
5862  TRANSPORT_DISCOVERY_DATA = 0x07,
5863  AD_TYPE = 0x08,
5864}
5865
5866packet LeApcfSetFilteringParameters : LeApcf (apcf_opcode = SET_FILTERING_PARAMETERS) {
5867  apcf_action : ApcfAction,
5868  _payload_,
5869}
5870
5871packet LeApcfAddFilteringParameters : LeApcfSetFilteringParameters (apcf_action = ADD) {
5872  apcf_filter_index : 8,
5873  apcf_feature_selection : 16,
5874  apcf_list_logic_type : 16,
5875  apcf_filter_logic_type : 8,
5876  rssi_high_thresh : 8,
5877  delivery_mode : DeliveryMode,
5878  onfound_timeout : 16,
5879  onfound_timeout_cnt : 8,
5880  rssi_low_thresh : 8,
5881  onlost_timeout : 16,
5882  num_of_tracking_entries : 16,
5883}
5884
5885packet LeApcfDeleteFilteringParameters : LeApcfSetFilteringParameters (apcf_action = DELETE) {
5886  apcf_filter_index : 8,
5887}
5888
5889packet LeApcfClearFilteringParameters : LeApcfSetFilteringParameters (apcf_action = CLEAR) {
5890}
5891
5892packet LeApcfSetFilteringParametersComplete : LeApcfComplete (apcf_opcode = SET_FILTERING_PARAMETERS) {
5893  apcf_action : ApcfAction,
5894  apcf_available_spaces : 8,
5895}
5896
5897enum ApcfApplicationAddressType : 8 {
5898  PUBLIC = 0x00,
5899  RANDOM = 0x01,
5900  NOT_APPLICABLE = 0x02,
5901}
5902
5903packet LeApcfBroadcasterAddress : LeApcf (apcf_opcode = BROADCASTER_ADDRESS) {
5904  apcf_action : ApcfAction,
5905  _payload_,
5906}
5907
5908packet LeApcfAddBroadcasterAddress : LeApcfBroadcasterAddress (apcf_action = ADD) {
5909  apcf_filter_index : 8,
5910  apcf_broadcaster_address : Address,
5911  apcf_application_address_type : ApcfApplicationAddressType,
5912}
5913
5914packet LeApcfDeleteBroadcasterAddress : LeApcfBroadcasterAddress (apcf_action = DELETE) {
5915  apcf_filter_index : 8,
5916  apcf_broadcaster_address : Address,
5917  apcf_application_address_type : ApcfApplicationAddressType,
5918}
5919
5920packet LeApcfClearBroadcasterAddress : LeApcfBroadcasterAddress (apcf_action = CLEAR) {
5921  apcf_filter_index : 8,
5922}
5923
5924packet LeApcfBroadcasterAddressComplete : LeApcfComplete (apcf_opcode = BROADCASTER_ADDRESS) {
5925  apcf_action : ApcfAction,
5926  apcf_available_spaces : 8,
5927}
5928
5929packet LeApcfServiceUuid : LeApcf (apcf_opcode = SERVICE_UUID) {
5930  apcf_action : ApcfAction,
5931  apcf_filter_index : 8,
5932  acpf_uuid_data : 8[],
5933}
5934
5935packet LeApcfServiceUuidComplete : LeApcfComplete (apcf_opcode = SERVICE_UUID) {
5936  apcf_action : ApcfAction,
5937  apcf_available_spaces : 8,
5938}
5939
5940packet LeApcfServiceSolicitationUuid : LeApcf (apcf_opcode = SERVICE_SOLICITATION_UUID) {
5941  apcf_action : ApcfAction,
5942  apcf_filter_index : 8,
5943  acpf_uuid_data : 8[],
5944}
5945
5946packet LeApcfServiceSolicitationUuidComplete : LeApcfComplete (apcf_opcode = SERVICE_SOLICITATION_UUID) {
5947  apcf_action : ApcfAction,
5948  apcf_available_spaces : 8,
5949}
5950
5951packet LeApcfLocalName : LeApcf (apcf_opcode = LOCAL_NAME) {
5952  apcf_action : ApcfAction,
5953  apcf_filter_index : 8,
5954  apcf_local_name : 8[],
5955}
5956
5957packet LeApcfLocalNameComplete : LeApcfComplete (apcf_opcode = LOCAL_NAME) {
5958  apcf_action : ApcfAction,
5959  apcf_available_spaces : 8,
5960}
5961
5962packet LeApcfManufacturerData : LeApcf (apcf_opcode = MANUFACTURER_DATA) {
5963  apcf_action : ApcfAction,
5964  apcf_filter_index : 8,
5965  apcf_manufacturer_data : 8[],
5966}
5967
5968packet LeApcfManufacturerDataComplete : LeApcfComplete (apcf_opcode = MANUFACTURER_DATA) {
5969  apcf_action : ApcfAction,
5970  apcf_available_spaces : 8,
5971}
5972
5973packet LeApcfServiceData : LeApcf (apcf_opcode = SERVICE_DATA) {
5974  apcf_action : ApcfAction,
5975  apcf_filter_index : 8,
5976  apcf_service_data : 8[],
5977}
5978
5979packet LeApcfServiceDataComplete : LeApcfComplete (apcf_opcode = SERVICE_DATA) {
5980  apcf_action : ApcfAction,
5981  apcf_available_spaces : 8,
5982}
5983
5984packet LeApcfAdTypeFilter : LeApcf (apcf_opcode = AD_TYPE_FILTER) {
5985  apcf_action : ApcfAction,
5986  apcf_filter_index : 8,
5987  apcf_ad_type : 8,
5988  _size_(apcf_ad_data) : 8,
5989  apcf_ad_data : 8[],
5990  apcf_ad_data_mask : 8[],
5991}
5992
5993packet LeApcfAdTypeFilterComplete : LeApcfComplete (apcf_opcode = AD_TYPE_FILTER) {
5994  apcf_action : ApcfAction,
5995  apcf_available_spaces : 8,
5996}
5997
5998packet LeApcfTransportDiscoveryService : LeApcf (apcf_opcode = TRANSPORT_DISCOVERY_SERVICE) {
5999  apcf_action : ApcfAction,
6000  apcf_filter_index : 8,
6001  apcf_transport_discovery_data : 8[],
6002}
6003
6004packet LeApcfTransportDiscoveryServiceComplete : LeApcfComplete (apcf_opcode = TRANSPORT_DISCOVERY_SERVICE) {
6005  apcf_action : ApcfAction,
6006  apcf_available_spaces : 8,
6007}
6008
6009packet LeApcfReadExtendedFeatures : LeApcf (apcf_opcode = READ_EXTENDED_FEATURES) {
6010}
6011
6012test LeApcfReadExtendedFeatures {
6013  "\x57\xfd\x01\xff",
6014}
6015
6016packet LeApcfReadExtendedFeaturesComplete : LeApcfComplete (apcf_opcode = READ_EXTENDED_FEATURES) {
6017  transport_discovery_data_filter : 1,
6018  ad_type_filter : 1,
6019  _reserved_ : 14,
6020}
6021
6022test LeApcfReadExtendedFeaturesComplete {
6023  "\x0e\x07\x01\x57\xfd\x00\xff\x03\x00",
6024}
6025
6026enum AdvertiserState : 8 {
6027  ADVERTISER_FOUND = 0x0,
6028  ADVERTISER_LOST = 0x1,
6029}
6030
6031enum AdvtInfoPresent : 8 {
6032  ADVT_INFO_PRESENT = 0x0,
6033  ADVT_INFO_NOT_PRESENT = 0x1,
6034}
6035
6036struct AdvtInfo {
6037  tx_power : 8,
6038  rssi : 8,
6039  timestamp : 16,
6040  _size_(adv_packet) : 8,
6041  adv_packet : 8[],
6042  _size_(scan_data_resp) : 8,
6043  scan_data_resp : 8[],
6044}
6045
6046packet LeAdvertisementTrackingEvent : VendorSpecificEvent (subevent_code = LE_ADVERTISEMENT_TRACKING) {
6047  apcf_filter_index : 8,
6048  advertiser_state : AdvertiserState,
6049  advt_info_present : AdvtInfoPresent,
6050  advertiser_address : Address,
6051  advertiser_address_type : PeerAddressType,
6052  advt_info : AdvtInfo[],
6053}
6054
6055// -----------------------------------------------------------------------------
6056//  LE Get Controller Activity Energy Info Command
6057//  https://source.android.com/docs/core/connect/bluetooth/hci_requirements#le_get_controller_activity_energy_info
6058// -----------------------------------------------------------------------------
6059
6060packet LeGetControllerActivityEnergyInfo : Command (op_code = LE_GET_CONTROLLER_ACTIVITY_ENERGY_INFO) {
6061}
6062
6063packet LeGetControllerActivityEnergyInfoComplete : CommandComplete (command_op_code = LE_GET_CONTROLLER_ACTIVITY_ENERGY_INFO) {
6064  status : ErrorCode,
6065  total_tx_time_ms : 32,
6066  total_rx_time_ms : 32,
6067  total_idle_time_ms : 32,
6068  total_energy_used : 32,
6069}
6070
6071// -----------------------------------------------------------------------------
6072//  LE Extended Set Scan Parameters Command
6073//  https://source.android.com/docs/core/connect/bluetooth/hci_requirements#le-extended-set-scan-parameters-command
6074// -----------------------------------------------------------------------------
6075
6076enum LeExScanType : 8 {
6077  PASSIVE = 0x0,
6078  ACTIVE = 0x1,
6079}
6080
6081enum LeExScanFilterPolicy : 8 {
6082  ACCEPT_ALL = 0x0,
6083  FILTER_ACCEPT_LIST_ONLY = 0x01,
6084}
6085
6086packet LeExSetScanParameters : Command (op_code = LE_EX_SET_SCAN_PARAMETERS) {
6087  le_ex_scan_type : LeExScanType,
6088  le_ex_scan_interval : 32,
6089  le_ex_scan_window : 32,
6090  own_address_type : OwnAddressType,
6091  le_ex_scan_filter_policy : LeExScanFilterPolicy,
6092}
6093
6094packet LeExSetScanParametersComplete : CommandComplete (command_op_code = LE_EX_SET_SCAN_PARAMETERS) {
6095  status : ErrorCode,
6096}
6097
6098// -----------------------------------------------------------------------------
6099//  Get Controller Debug Info Command
6100//  https://source.android.com/docs/core/connect/bluetooth/hci_requirements#get-controller-debug-info-command
6101// -----------------------------------------------------------------------------
6102
6103packet GetControllerDebugInfo : Command (op_code = GET_CONTROLLER_DEBUG_INFO) {
6104}
6105
6106packet GetControllerDebugInfoComplete : CommandComplete (command_op_code = GET_CONTROLLER_DEBUG_INFO) {
6107  status : ErrorCode,
6108}
6109
6110packet ControllerDebugInfoEvent : VendorSpecificEvent (subevent_code = CONTROLLER_DEBUG_INFO) {
6111  debug_block_byte_offset_start : 16,
6112  last_block : 8,
6113  _size_(debug_data) : 16,
6114  debug_data : 8[],
6115}
6116
6117// -----------------------------------------------------------------------------
6118//  Microsoft Commands
6119//  https://learn.microsoft.com/en-us/windows-hardware/drivers/bluetooth/microsoft-defined-bluetooth-hci-commands-and-events
6120// -----------------------------------------------------------------------------
6121
6122enum MsftSubcommandOpcode : 8 {
6123  MSFT_READ_SUPPORTED_FEATURES = 0x00,
6124  MSFT_MONITOR_RSSI = 0x01,
6125  MSFT_CANCEL_MONITOR_RSSI = 0x02,
6126  MSFT_LE_MONITOR_ADV = 0x03,
6127  MSFT_LE_CANCEL_MONITOR_ADV = 0x04,
6128  MSFT_LE_SET_ADV_FILTER_ENABLE = 0x05,
6129  MSFT_READ_ABSOLUTE_RSSI = 0x06,
6130}
6131
6132// MSFT Commands do not have a constant opcode, so leave `op_code` undefined.
6133packet MsftCommand : Command {
6134  subcommand_opcode: MsftSubcommandOpcode,
6135  _payload_,
6136}
6137
6138packet MsftReadSupportedFeatures : MsftCommand (subcommand_opcode = MSFT_READ_SUPPORTED_FEATURES) {}
6139
6140enum MsftLeMonitorAdvConditionType : 8 {
6141  MSFT_CONDITION_TYPE_PATTERNS = 0x01,
6142  MSFT_CONDITION_TYPE_UUID = 0x02,
6143  MSFT_CONDITION_TYPE_IRK_RESOLUTION = 0x03,
6144  MSFT_CONDITION_TYPE_ADDRESS = 0x04,
6145}
6146
6147enum MsftLeMonitorAdvConditionUuidType : 8 {
6148  MSFT_CONDITION_UUID_TYPE_16_BIT = 0x01,
6149  MSFT_CONDITION_UUID_TYPE_32_BIT = 0x02,
6150  MSFT_CONDITION_UUID_TYPE_128_BIT = 0x03,
6151}
6152
6153packet MsftLeMonitorAdv : MsftCommand (subcommand_opcode = MSFT_LE_MONITOR_ADV) {
6154  rssi_threshold_high : 8,
6155  rssi_threshold_low : 8,
6156  rssi_threshold_low_time_interval : 8,
6157  rssi_sampling_period : 8,
6158  condition_type: MsftLeMonitorAdvConditionType,
6159  _payload_,
6160}
6161
6162struct MsftLeMonitorAdvConditionPattern {
6163  _size_(pattern) : 8, // including one byte for ad_type and one byte for start_of_pattern
6164  ad_type: 8,
6165  start_of_pattern: 8,
6166  pattern: 8[+2],
6167}
6168
6169packet MsftLeMonitorAdvConditionPatterns : MsftLeMonitorAdv (condition_type = MSFT_CONDITION_TYPE_PATTERNS) {
6170  _count_(patterns): 8,
6171  patterns: MsftLeMonitorAdvConditionPattern[],
6172}
6173
6174test MsftLeMonitorAdvConditionPatterns {
6175  "\x1e\xfc\x0e\x03\x10\x05\x04\xaa\x01\x01\x06\x03\x00\x80\x81\x82\x83", // 1 pattern
6176  "\x70\xfd\x13\x03\x15\x04\x02\xbb\x01\x02\x04\x03\x00\x80\x81\x06\x0f\x00\x90\x91\x92\x93", // 2 patterns
6177}
6178
6179packet MsftLeMonitorAdvConditionUuid : MsftLeMonitorAdv (condition_type = MSFT_CONDITION_TYPE_UUID) {
6180  uuid_type: MsftLeMonitorAdvConditionUuidType,
6181  _payload_,
6182}
6183
6184packet MsftLeMonitorAdvConditionUuid2 : MsftLeMonitorAdvConditionUuid (uuid_type = MSFT_CONDITION_UUID_TYPE_16_BIT) {
6185  uuid2: 8[2],
6186}
6187
6188test MsftLeMonitorAdvConditionUuid2 {
6189  "\x1e\xfc\x09\x03\x10\x11\x12\x13\x02\x01\x70\x71", // opcode = fc1e for Intel
6190  "\x70\xfd\x09\x03\x10\x11\x12\x13\x02\x01\x70\x71", // opcode = fd70 for Qualcomm
6191}
6192
6193packet MsftLeMonitorAdvConditionUuid4 : MsftLeMonitorAdvConditionUuid (uuid_type = MSFT_CONDITION_UUID_TYPE_32_BIT) {
6194  uuid4: 8[4],
6195}
6196
6197test MsftLeMonitorAdvConditionUuid4 {
6198  "\x1e\xfc\x0b\x03\x10\x11\x12\x13\x02\x02\x70\x71\x72\x73",
6199  "\x70\xfd\x0b\x03\x10\x11\x12\x13\x02\x02\x70\x71\x72\x73",
6200}
6201
6202packet MsftLeMonitorAdvConditionUuid16 : MsftLeMonitorAdvConditionUuid (uuid_type = MSFT_CONDITION_UUID_TYPE_128_BIT) {
6203  uuid16: 8[16],
6204}
6205
6206test MsftLeMonitorAdvConditionUuid16 {
6207  "\x1e\xfc\x17\x03\x10\x11\x12\x13\x02\x03\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f",
6208  "\x70\xfd\x17\x03\x10\x11\x12\x13\x02\x03\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7a\x7b\x7c\x7d\x7e\x7f",
6209}
6210
6211packet MsftLeCancelMonitorAdv: MsftCommand (subcommand_opcode = MSFT_LE_CANCEL_MONITOR_ADV) {
6212  monitor_handle: 8,
6213}
6214
6215test MsftLeCancelMonitorAdv {
6216  "\x1e\xfc\x02\x04\x01", // cancel handle 0x01
6217}
6218
6219packet MsftLeSetAdvFilterEnable : MsftCommand (subcommand_opcode = MSFT_LE_SET_ADV_FILTER_ENABLE) {
6220  enable: 8,
6221}
6222
6223test MsftLeSetAdvFilterEnable {
6224  "\x1e\xfc\x02\x05\x01", // disable
6225  "\x70\xfd\x02\x05\x01", // enable
6226}
6227
6228packet MsftCommandComplete : CommandComplete {
6229  status: ErrorCode,
6230  subcommand_opcode: MsftSubcommandOpcode,
6231  _payload_,
6232}
6233
6234packet MsftReadSupportedFeaturesCommandComplete : MsftCommandComplete (subcommand_opcode = MSFT_READ_SUPPORTED_FEATURES) {
6235  supported_features: 64,
6236  _size_(prefix) : 8,
6237  prefix: 8[],
6238}
6239
6240test MsftReadSupportedFeaturesCommandComplete {
6241  "\x0e\x10\x01\x1e\xfc\x00\x00\x7f\x00\x00\x00\x00\x00\x00\x00\x02\x87\x80", // Msft opcode by Intel
6242  "\x0e\x12\x01\x70\xfd\x00\x00\x1f\x00\x00\x00\x00\x00\x00\x00\x04\x4d\x53\x46\x54", // Msft opcode by Qualcomm
6243}
6244
6245packet MsftLeMonitorAdvCommandComplete : MsftCommandComplete (subcommand_opcode = MSFT_LE_MONITOR_ADV) {
6246  monitor_handle: 8,
6247}
6248
6249test MsftLeMonitorAdvCommandComplete {
6250  "\x0e\x06\x01\x1e\xfc\x00\x03\x05", // succeeded
6251  "\x0e\x06\x01\x70\xfd\x01\x03\x06", // failed
6252}
6253
6254packet MsftLeCancelMonitorAdvCommandComplete : MsftCommandComplete (subcommand_opcode = MSFT_LE_CANCEL_MONITOR_ADV) {}
6255
6256packet MsftLeSetAdvFilterEnableCommandComplete : MsftCommandComplete (subcommand_opcode = MSFT_LE_SET_ADV_FILTER_ENABLE) {}
6257
6258enum MsftEventCode : 8 {
6259  MSFT_RSSI_EVENT = 0x01,
6260  MSFT_LE_MONITOR_DEVICE_EVENT = 0x02,
6261}
6262
6263enum MsftEventStatus : 8 {
6264  MSFT_EVENT_STATUS_SUCCESS = 0x00,
6265  MSFT_EVENT_STATUS_FAILURE = 0x01,
6266}
6267
6268// It is not possible to define MSFT Event packet by deriving `Event` packet
6269// because it starts with variable-length event prefix which can only be determined
6270// at run-time (after receiving return of MSFT Read Supported Features).
6271// Therefore we only define the payload which is located after the event prefix.
6272packet MsftEventPayload {
6273  msft_event_code : MsftEventCode,
6274  _payload_,
6275}
6276
6277packet MsftRssiEventPayload : MsftEventPayload (msft_event_code = MSFT_RSSI_EVENT) {
6278  status: MsftEventStatus,
6279  connection_handle: 16,
6280  rssi: 8,
6281}
6282
6283test MsftRssiEventPayload {
6284  "\x01\x00\x01\x10\xf0", // MSFT_RSSI_EVENT succeeded
6285  "\x01\x01\x02\x02\x08", // MSFT_RSSI_EVENT failed
6286}
6287
6288packet MsftLeMonitorDeviceEventPayload : MsftEventPayload (msft_event_code = MSFT_LE_MONITOR_DEVICE_EVENT) {
6289  address_type: 8,
6290  bd_addr: Address,
6291  monitor_handle: 8,
6292  monitor_state: 8,
6293}
6294
6295test MsftLeMonitorDeviceEventPayload {
6296  "\x02\x01\x00\x01\x02\x03\x04\x05\x10\x00",
6297  "\x02\x02\xf0\xf1\xf2\xf3\xf4\xf5\xaa\x02",
6298}
6299