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