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