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