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