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