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  SERVICE_DATA_16_BIT_UUIDS = 0x16,
26  APPEARANCE = 0x19,
27  SERVICE_DATA_32_BIT_UUIDS = 0x20,
28  SERVICE_DATA_128_BIT_UUIDS = 0x21,
29  MANUFACTURER_SPECIFIC_DATA = 0xFF,
30}
31
32struct GapData {
33  _size_(data) : 8, // Including one byte for data_type
34  data_type : GapDataType,
35  data : 8[+1*8],
36}
37
38// HCI ACL Packets
39
40enum PacketBoundaryFlag : 2 {
41  FIRST_NON_AUTOMATICALLY_FLUSHABLE = 0,
42  CONTINUING_FRAGMENT = 1,
43  FIRST_AUTOMATICALLY_FLUSHABLE = 2,
44}
45
46enum BroadcastFlag : 2 {
47  POINT_TO_POINT = 0,
48  ACTIVE_SLAVE_BROADCAST = 1,
49}
50
51packet AclPacket {
52  handle : 12,
53  packet_boundary_flag : PacketBoundaryFlag,
54  broadcast_flag : BroadcastFlag,
55  _size_(_payload_) : 16,
56  _payload_,
57}
58
59// HCI SCO Packets
60
61enum PacketStatusFlag : 2 {
62  CORRECTLY_RECEIVED = 0,
63  POSSIBLY_INCOMPLETE = 1,
64  NO_DATA = 2,
65  PARTIALLY_LOST = 3,
66}
67
68packet ScoPacket {
69  handle : 12,
70  packet_status_flag : PacketStatusFlag,
71  _reserved_ : 2, // BroadcastFlag
72  _size_(data) : 8,
73  data : 8[],
74}
75
76// HCI Command Packets
77
78enum OpCode : 16 {
79  NONE = 0x0000,
80
81  // LINK_CONTROL
82  INQUIRY = 0x0401,
83  INQUIRY_CANCEL = 0x0402,
84  PERIODIC_INQUIRY_MODE = 0x0403,
85  EXIT_PERIODIC_INQUIRY_MODE = 0x0404,
86  CREATE_CONNECTION = 0x0405,
87  DISCONNECT = 0x0406,
88  CREATE_CONNECTION_CANCEL = 0x0408,
89  ACCEPT_CONNECTION_REQUEST = 0x0409,
90  REJECT_CONNECTION_REQUEST = 0x040A,
91  LINK_KEY_REQUEST_REPLY = 0x040B,
92  LINK_KEY_REQUEST_NEGATIVE_REPLY = 0x040C,
93  PIN_CODE_REQUEST_REPLY = 0x040D,
94  PIN_CODE_REQUEST_NEGATIVE_REPLY = 0x040E,
95  CHANGE_CONNECTION_PACKET_TYPE = 0x040F,
96  AUTHENTICATION_REQUESTED = 0x0411,
97  SET_CONNECTION_ENCRYPTION = 0x0413,
98  CHANGE_CONNECTION_LINK_KEY = 0x0415,
99  MASTER_LINK_KEY = 0x0417,
100  REMOTE_NAME_REQUEST = 0x0419,
101  REMOTE_NAME_REQUEST_CANCEL = 0x041A,
102  READ_REMOTE_SUPPORTED_FEATURES = 0x041B,
103  READ_REMOTE_EXTENDED_FEATURES = 0x041C,
104  READ_REMOTE_VERSION_INFORMATION = 0x041D,
105  READ_CLOCK_OFFSET = 0x041F,
106  READ_LMP_HANDLE = 0x0420,
107  SETUP_SYNCHRONOUS_CONNECTION = 0x0428,
108  ACCEPT_SYNCHRONOUS_CONNECTION = 0x0429,
109  REJECT_SYNCHRONOUS_CONNECTION = 0x042A,
110  IO_CAPABILITY_REQUEST_REPLY = 0x042B,
111  USER_CONFIRMATION_REQUEST_REPLY = 0x042C,
112  USER_CONFIRMATION_REQUEST_NEGATIVE_REPLY = 0x042D,
113  USER_PASSKEY_REQUEST_REPLY = 0x042E,
114  USER_PASSKEY_REQUEST_NEGATIVE_REPLY = 0x042F,
115  REMOTE_OOB_DATA_REQUEST_REPLY = 0x0430,
116  REMOTE_OOB_DATA_REQUEST_NEGATIVE_REPLY = 0x0433,
117  IO_CAPABILITY_REQUEST_NEGATIVE_REPLY = 0x0434,
118  ENHANCED_SETUP_SYNCHRONOUS_CONNECTION = 0x043D,
119  ENHANCED_ACCEPT_SYNCHRONOUS_CONNECTION = 0x043E,
120
121  // LINK_POLICY
122  HOLD_MODE = 0x0801,
123  SNIFF_MODE = 0x0803,
124  EXIT_SNIFF_MODE = 0x0804,
125  QOS_SETUP = 0x0807,
126  ROLE_DISCOVERY = 0x0809,
127  SWITCH_ROLE = 0x080B,
128  READ_LINK_POLICY_SETTINGS = 0x080C,
129  WRITE_LINK_POLICY_SETTINGS = 0x080D,
130  READ_DEFAULT_LINK_POLICY_SETTINGS = 0x080E,
131  WRITE_DEFAULT_LINK_POLICY_SETTINGS = 0x080F,
132  FLOW_SPECIFICATION = 0x0810,
133  SNIFF_SUBRATING = 0x0811,
134
135  // CONTROLLER_AND_BASEBAND
136  SET_EVENT_MASK = 0x0C01,
137  RESET = 0x0C03,
138  SET_EVENT_FILTER = 0x0C05,
139  FLUSH = 0x0C08,
140  READ_PIN_TYPE = 0x0C09,
141  WRITE_PIN_TYPE = 0x0C0A,
142  CREATE_NEW_UNIT_KEY = 0x0C0B,
143  READ_STORED_LINK_KEY = 0x0C0D,
144  WRITE_STORED_LINK_KEY = 0x0C11,
145  DELETE_STORED_LINK_KEY = 0x0C12,
146  WRITE_LOCAL_NAME = 0x0C13,
147  READ_LOCAL_NAME = 0x0C14,
148  READ_CONNECTION_ACCEPT_TIMEOUT = 0x0C15,
149  WRITE_CONNECTION_ACCEPT_TIMEOUT = 0x0C16,
150  READ_PAGE_TIMEOUT = 0x0C17,
151  WRITE_PAGE_TIMEOUT = 0x0C18,
152  READ_SCAN_ENABLE = 0x0C19,
153  WRITE_SCAN_ENABLE = 0x0C1A,
154  READ_PAGE_SCAN_ACTIVITY = 0x0C1B,
155  WRITE_PAGE_SCAN_ACTIVITY = 0x0C1C,
156  READ_INQUIRY_SCAN_ACTIVITY = 0x0C1D,
157  WRITE_INQUIRY_SCAN_ACTIVITY = 0x0C1E,
158  READ_AUTHENTICATION_ENABLE = 0x0C1F,
159  WRITE_AUTHENTICATION_ENABLE = 0x0C20,
160  READ_CLASS_OF_DEVICE = 0x0C23,
161  WRITE_CLASS_OF_DEVICE = 0x0C24,
162  READ_VOICE_SETTING = 0x0C25,
163  WRITE_VOICE_SETTING = 0x0C26,
164  READ_AUTOMATIC_FLUSH_TIMEOUT = 0x0C27,
165  WRITE_AUTOMATIC_FLUSH_TIMEOUT = 0x0C28,
166  READ_NUM_BROADCAST_RETRANSMITS = 0x0C29,
167  WRITE_NUM_BROADCAST_RETRANSMITS = 0x0C2A,
168  READ_HOLD_MODE_ACTIVITY = 0x0C2B,
169  WRITE_HOLD_MODE_ACTIVITY = 0x0C2C,
170  READ_TRANSMIT_POWER_LEVEL = 0x0C2D,
171  READ_SYNCHRONOUS_FLOW_CONTROL_ENABLE = 0x0C2E,
172  WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE = 0x0C2F,
173  SET_CONTROLLER_TO_HOST_FLOW_CONTROL = 0x0C31,
174  HOST_BUFFER_SIZE = 0x0C33,
175  HOST_NUM_COMPLETED_PACKETS = 0x0C35,
176  READ_LINK_SUPERVISION_TIMEOUT = 0x0C36,
177  WRITE_LINK_SUPERVISION_TIMEOUT = 0x0C37,
178  READ_NUMBER_OF_SUPPORTED_IAC = 0x0C38,
179  READ_CURRENT_IAC_LAP = 0x0C39,
180  WRITE_CURRENT_IAC_LAP = 0x0C3A,
181  SET_AFH_HOST_CHANNEL_CLASSIFICATION = 0x0C3F,
182  READ_INQUIRY_SCAN_TYPE = 0x0C42,
183  WRITE_INQUIRY_SCAN_TYPE = 0x0C43,
184  READ_INQUIRY_MODE = 0x0C44,
185  WRITE_INQUIRY_MODE = 0x0C45,
186  READ_PAGE_SCAN_TYPE = 0x0C46,
187  WRITE_PAGE_SCAN_TYPE = 0x0C47,
188  READ_AFH_CHANNEL_ASSESSMENT_MODE = 0x0C48,
189  WRITE_AFH_CHANNEL_ASSESSMENT_MODE = 0x0C49,
190  READ_EXTENDED_INQUIRY_RESPONSE = 0x0C51,
191  WRITE_EXTENDED_INQUIRY_RESPONSE = 0x0C52,
192  REFRESH_ENCRYPTION_KEY = 0x0C53,
193  READ_SIMPLE_PAIRING_MODE = 0x0C55,
194  WRITE_SIMPLE_PAIRING_MODE = 0x0C56,
195  READ_LOCAL_OOB_DATA = 0x0C57,
196  READ_INQUIRY_RESPONSE_TRANSMIT_POWER_LEVEL = 0x0C58,
197  WRITE_INQUIRY_TRANSMIT_POWER_LEVEL = 0x0C59,
198  SEND_KEYPRESS_NOTIFICATION = 0x0C60,
199
200  READ_LE_HOST_SUPPORT = 0x0C6C,
201  WRITE_LE_HOST_SUPPORT = 0x0C6D,
202
203  READ_SECURE_CONNECTIONS_HOST_SUPPORT = 0x0C79,
204  WRITE_SECURE_CONNECTIONS_HOST_SUPPORT = 0x0C7A,
205  READ_LOCAL_OOB_EXTENDED_DATA = 0x0C7D,
206  SET_ECOSYSTEM_BASE_INTERVAL = 0x0C82,
207  CONFIGURE_DATA_PATH = 0x0C83,
208
209  // INFORMATIONAL_PARAMETERS
210  READ_LOCAL_VERSION_INFORMATION = 0x1001,
211  READ_LOCAL_SUPPORTED_COMMANDS = 0x1002,
212  READ_LOCAL_SUPPORTED_FEATURES = 0x1003,
213  READ_LOCAL_EXTENDED_FEATURES = 0x1004,
214  READ_BUFFER_SIZE = 0x1005,
215  READ_BD_ADDR = 0x1009,
216  READ_DATA_BLOCK_SIZE = 0x100A,
217  READ_LOCAL_SUPPORTED_CODECS_V1 = 0x100B,
218  READ_LOCAL_SUPPORTED_CODECS_V2 = 0x100D,
219  READ_LOCAL_SUPPORTED_CODEC_CAPABILITIES = 0x100E,
220  READ_LOCAL_SUPPORTED_CONTROLLER_DELAY = 0X100F,
221
222  // STATUS_PARAMETERS
223  READ_FAILED_CONTACT_COUNTER = 0x1401,
224  RESET_FAILED_CONTACT_COUNTER = 0x1402,
225  READ_LINK_QUALITY = 0x1403,
226  READ_RSSI = 0x1405,
227  READ_AFH_CHANNEL_MAP = 0x1406,
228  READ_CLOCK = 0x1407,
229  READ_ENCRYPTION_KEY_SIZE = 0x1408,
230
231  // TESTING
232  READ_LOOPBACK_MODE = 0x1801,
233  WRITE_LOOPBACK_MODE = 0x1802,
234  ENABLE_DEVICE_UNDER_TEST_MODE = 0x1803,
235  WRITE_SIMPLE_PAIRING_DEBUG_MODE = 0x1804,
236  WRITE_SECURE_CONNECTIONS_TEST_MODE = 0x180A,
237
238  // LE_CONTROLLER
239  LE_SET_EVENT_MASK = 0x2001,
240  LE_READ_BUFFER_SIZE_V1 = 0x2002,
241  LE_READ_LOCAL_SUPPORTED_FEATURES = 0x2003,
242  LE_SET_RANDOM_ADDRESS = 0x2005,
243  LE_SET_ADVERTISING_PARAMETERS = 0x2006,
244  LE_READ_ADVERTISING_CHANNEL_TX_POWER = 0x2007,
245  LE_SET_ADVERTISING_DATA = 0x2008,
246  LE_SET_SCAN_RESPONSE_DATA = 0x2009,
247  LE_SET_ADVERTISING_ENABLE = 0x200A,
248  LE_SET_SCAN_PARAMETERS = 0x200B,
249  LE_SET_SCAN_ENABLE = 0x200C,
250  LE_CREATE_CONNECTION = 0x200D,
251  LE_CREATE_CONNECTION_CANCEL = 0x200E,
252  LE_READ_CONNECT_LIST_SIZE = 0x200F,
253  LE_CLEAR_CONNECT_LIST = 0x2010,
254  LE_ADD_DEVICE_TO_CONNECT_LIST = 0x2011,
255  LE_REMOVE_DEVICE_FROM_CONNECT_LIST = 0x2012,
256  LE_CONNECTION_UPDATE = 0x2013,
257  LE_SET_HOST_CHANNEL_CLASSIFICATION = 0x2014,
258  LE_READ_CHANNEL_MAP = 0x2015,
259  LE_READ_REMOTE_FEATURES = 0x2016,
260  LE_ENCRYPT = 0x2017,
261  LE_RAND = 0x2018,
262  LE_START_ENCRYPTION = 0x2019,
263  LE_LONG_TERM_KEY_REQUEST_REPLY = 0x201A,
264  LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY = 0x201B,
265  LE_READ_SUPPORTED_STATES = 0x201C,
266  LE_RECEIVER_TEST = 0x201D,
267  LE_TRANSMITTER_TEST = 0x201E,
268  LE_TEST_END = 0x201F,
269  LE_REMOTE_CONNECTION_PARAMETER_REQUEST_REPLY = 0x2020,
270  LE_REMOTE_CONNECTION_PARAMETER_REQUEST_NEGATIVE_REPLY = 0x2021,
271
272  LE_SET_DATA_LENGTH = 0x2022,
273  LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH = 0x2023,
274  LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH = 0x2024,
275  LE_READ_LOCAL_P_256_PUBLIC_KEY_COMMAND = 0x2025,
276  LE_GENERATE_DHKEY_COMMAND_V1 = 0x2026,
277  LE_ADD_DEVICE_TO_RESOLVING_LIST = 0x2027,
278  LE_REMOVE_DEVICE_FROM_RESOLVING_LIST = 0x2028,
279  LE_CLEAR_RESOLVING_LIST = 0x2029,
280  LE_READ_RESOLVING_LIST_SIZE = 0x202A,
281  LE_READ_PEER_RESOLVABLE_ADDRESS = 0x202B,
282  LE_READ_LOCAL_RESOLVABLE_ADDRESS = 0x202C,
283  LE_SET_ADDRESS_RESOLUTION_ENABLE = 0x202D,
284  LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT = 0x202E,
285  LE_READ_MAXIMUM_DATA_LENGTH = 0x202F,
286  LE_READ_PHY = 0x2030,
287  LE_SET_DEFAULT_PHY = 0x2031,
288  LE_SET_PHY = 0x2032,
289  LE_ENHANCED_RECEIVER_TEST = 0x2033,
290  LE_ENHANCED_TRANSMITTER_TEST = 0x2034,
291  LE_SET_EXTENDED_ADVERTISING_RANDOM_ADDRESS = 0x2035,
292  LE_SET_EXTENDED_ADVERTISING_PARAMETERS = 0x2036,
293  LE_SET_EXTENDED_ADVERTISING_DATA = 0x2037,
294  LE_SET_EXTENDED_ADVERTISING_SCAN_RESPONSE = 0x2038,
295  LE_SET_EXTENDED_ADVERTISING_ENABLE = 0x2039,
296  LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH = 0x203A,
297  LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS = 0x203B,
298  LE_REMOVE_ADVERTISING_SET = 0x203C,
299  LE_CLEAR_ADVERTISING_SETS = 0x203D,
300  LE_SET_PERIODIC_ADVERTISING_PARAM = 0x203E,
301  LE_SET_PERIODIC_ADVERTISING_DATA = 0x203F,
302  LE_SET_PERIODIC_ADVERTISING_ENABLE = 0x2040,
303  LE_SET_EXTENDED_SCAN_PARAMETERS = 0x2041,
304  LE_SET_EXTENDED_SCAN_ENABLE = 0x2042,
305  LE_EXTENDED_CREATE_CONNECTION = 0x2043,
306  LE_PERIODIC_ADVERTISING_CREATE_SYNC = 0x2044,
307  LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL = 0x2045,
308  LE_PERIODIC_ADVERTISING_TERMINATE_SYNC = 0x2046,
309  LE_ADD_DEVICE_TO_PERIODIC_ADVERTISING_LIST = 0x2047,
310  LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISING_LIST = 0x2048,
311  LE_CLEAR_PERIODIC_ADVERTISING_LIST = 0x2049,
312  LE_READ_PERIODIC_ADVERTISING_LIST_SIZE = 0x204A,
313  LE_READ_TRANSMIT_POWER = 0x204B,
314  LE_READ_RF_PATH_COMPENSATION_POWER = 0x204C,
315  LE_WRITE_RF_PATH_COMPENSATION_POWER = 0x204D,
316  LE_SET_PRIVACY_MODE = 0x204E,
317  LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE = 0X2059,
318  LE_PERIODIC_ADVERTISING_SYNC_TRANSFER = 0X205A,
319  LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER = 0X205B,
320  LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS = 0X205C,
321  LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS = 0X205D,
322  LE_GENERATE_DHKEY_COMMAND = 0x205E,
323  LE_MODIFY_SLEEP_CLOCK_ACCURACY = 0X205F,
324  LE_READ_BUFFER_SIZE_V2 = 0x2060,
325  LE_READ_ISO_TX_SYNC = 0X2061,
326  LE_SET_CIG_PARAMETERS = 0X2062,
327  LE_CREATE_CIS = 0X2064,
328  LE_REMOVE_CIG = 0X2065,
329  LE_ACCEPT_CIS_REQUEST = 0X2066,
330  LE_REJECT_CIS_REQUEST = 0X2067,
331  LE_CREATE_BIG = 0X2068,
332  LE_TERMINATE_BIG = 0X206A,
333  LE_BIG_CREATE_SYNC = 0X206B,
334  LE_BIG_TERMINATE_SYNC = 0X206C,
335  LE_REQUEST_PEER_SCA = 0X206D,
336  LE_SETUP_ISO_DATA_PATH = 0X206E,
337  LE_REMOVE_ISO_DATA_PATH = 0X206F,
338  LE_SET_HOST_FEATURE = 0X2074,
339  LE_READ_ISO_LINK_QUALITY = 0X2075,
340  LE_ENHANCED_READ_TRANSMIT_POWER_LEVEL = 0X2076,
341  LE_READ_REMOTE_TRANSMIT_POWER_LEVEL = 0X2077,
342  LE_SET_PATH_LOSS_REPORTING_PARAMETERS = 0X2078,
343  LE_SET_PATH_LOSS_REPORTING_ENABLE = 0X2079,
344  LE_SET_TRANSMIT_POWER_REPORTING_ENABLE = 0X207A,
345
346  // VENDOR_SPECIFIC
347  LE_GET_VENDOR_CAPABILITIES = 0xFD53,
348  LE_MULTI_ADVT = 0xFD54,
349  LE_BATCH_SCAN = 0xFD56,
350  LE_ADV_FILTER = 0xFD57,
351  LE_TRACK_ADV = 0xFD58,
352  LE_ENERGY_INFO = 0xFD59,
353  LE_EXTENDED_SCAN_PARAMS = 0xFD5A,
354  CONTROLLER_DEBUG_INFO = 0xFD5B,
355  CONTROLLER_A2DP_OPCODE = 0xFD5D,
356  CONTROLLER_BQR = 0xFD5E,
357}
358
359// For mapping Local Supported Commands command
360// Value = Octet * 10 + bit
361enum OpCodeIndex : 16 {
362  INQUIRY = 0,
363  INQUIRY_CANCEL = 1,
364  PERIODIC_INQUIRY_MODE = 2,
365  EXIT_PERIODIC_INQUIRY_MODE = 3,
366  CREATE_CONNECTION = 4,
367  DISCONNECT = 5,
368  CREATE_CONNECTION_CANCEL = 7,
369  ACCEPT_CONNECTION_REQUEST = 10,
370  REJECT_CONNECTION_REQUEST = 11,
371  LINK_KEY_REQUEST_REPLY = 12,
372  LINK_KEY_REQUEST_NEGATIVE_REPLY = 13,
373  PIN_CODE_REQUEST_REPLY = 14,
374  PIN_CODE_REQUEST_NEGATIVE_REPLY = 15,
375  CHANGE_CONNECTION_PACKET_TYPE = 16,
376  AUTHENTICATION_REQUESTED = 17,
377  SET_CONNECTION_ENCRYPTION = 20,
378  CHANGE_CONNECTION_LINK_KEY = 21,
379  MASTER_LINK_KEY = 22,
380  REMOTE_NAME_REQUEST = 23,
381  REMOTE_NAME_REQUEST_CANCEL = 24,
382  READ_REMOTE_SUPPORTED_FEATURES = 25,
383  READ_REMOTE_EXTENDED_FEATURES = 26,
384  READ_REMOTE_VERSION_INFORMATION = 27,
385  READ_CLOCK_OFFSET = 30,
386  READ_LMP_HANDLE = 31,
387  HOLD_MODE = 41,
388  SNIFF_MODE = 42,
389  EXIT_SNIFF_MODE = 43,
390  QOS_SETUP = 46,
391  ROLE_DISCOVERY = 47,
392  SWITCH_ROLE = 50,
393  READ_LINK_POLICY_SETTINGS = 51,
394  WRITE_LINK_POLICY_SETTINGS = 52,
395  READ_DEFAULT_LINK_POLICY_SETTINGS = 53,
396  WRITE_DEFAULT_LINK_POLICY_SETTINGS = 54,
397  FLOW_SPECIFICATION = 55,
398  SET_EVENT_MASK = 56,
399  RESET = 57,
400  SET_EVENT_FILTER = 60,
401  FLUSH = 61,
402  READ_PIN_TYPE = 62,
403  WRITE_PIN_TYPE = 63,
404  READ_STORED_LINK_KEY = 65,
405  WRITE_STORED_LINK_KEY = 66,
406  DELETE_STORED_LINK_KEY = 67,
407  WRITE_LOCAL_NAME = 70,
408  READ_LOCAL_NAME = 71,
409  READ_CONNECTION_ACCEPT_TIMEOUT = 72,
410  WRITE_CONNECTION_ACCEPT_TIMEOUT = 73,
411  READ_PAGE_TIMEOUT = 74,
412  WRITE_PAGE_TIMEOUT = 75,
413  READ_SCAN_ENABLE = 76,
414  WRITE_SCAN_ENABLE = 77,
415  READ_PAGE_SCAN_ACTIVITY = 80,
416  WRITE_PAGE_SCAN_ACTIVITY = 81,
417  READ_INQUIRY_SCAN_ACTIVITY = 82,
418  WRITE_INQUIRY_SCAN_ACTIVITY = 83,
419  READ_AUTHENTICATION_ENABLE = 84,
420  WRITE_AUTHENTICATION_ENABLE = 85,
421  READ_CLASS_OF_DEVICE = 90,
422  WRITE_CLASS_OF_DEVICE = 91,
423  READ_VOICE_SETTING = 92,
424  WRITE_VOICE_SETTING = 93,
425  READ_AUTOMATIC_FLUSH_TIMEOUT = 94,
426  WRITE_AUTOMATIC_FLUSH_TIMEOUT = 95,
427  READ_NUM_BROADCAST_RETRANSMITS = 96,
428  WRITE_NUM_BROADCAST_RETRANSMITS = 97,
429  READ_HOLD_MODE_ACTIVITY = 100,
430  WRITE_HOLD_MODE_ACTIVITY = 101,
431  READ_TRANSMIT_POWER_LEVEL = 102,
432  READ_SYNCHRONOUS_FLOW_CONTROL_ENABLE = 103,
433  WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE = 104,
434  SET_CONTROLLER_TO_HOST_FLOW_CONTROL = 105,
435  HOST_BUFFER_SIZE = 106,
436  HOST_NUM_COMPLETED_PACKETS = 107,
437  READ_LINK_SUPERVISION_TIMEOUT = 110,
438  WRITE_LINK_SUPERVISION_TIMEOUT = 111,
439  READ_NUMBER_OF_SUPPORTED_IAC = 112,
440  READ_CURRENT_IAC_LAP = 113,
441  WRITE_CURRENT_IAC_LAP = 114,
442  SET_AFH_HOST_CHANNEL_CLASSIFICATION = 121,
443  READ_INQUIRY_SCAN_TYPE = 124,
444  WRITE_INQUIRY_SCAN_TYPE = 125,
445  READ_INQUIRY_MODE = 126,
446  WRITE_INQUIRY_MODE = 127,
447  READ_PAGE_SCAN_TYPE = 130,
448  WRITE_PAGE_SCAN_TYPE = 131,
449  READ_AFH_CHANNEL_ASSESSMENT_MODE = 132,
450  WRITE_AFH_CHANNEL_ASSESSMENT_MODE = 133,
451  READ_LOCAL_VERSION_INFORMATION = 143,
452  READ_LOCAL_SUPPORTED_FEATURES = 145,
453  READ_LOCAL_EXTENDED_FEATURES = 146,
454  READ_BUFFER_SIZE = 147,
455  READ_BD_ADDR = 151,
456  READ_FAILED_CONTACT_COUNTER = 152,
457  RESET_FAILED_CONTACT_COUNTER = 153,
458  READ_LINK_QUALITY = 154,
459  READ_RSSI = 155,
460  READ_AFH_CHANNEL_MAP = 156,
461  READ_CLOCK = 157,
462  READ_LOOPBACK_MODE = 160,
463  WRITE_LOOPBACK_MODE = 161,
464  ENABLE_DEVICE_UNDER_TEST_MODE = 162,
465  SETUP_SYNCHRONOUS_CONNECTION = 163,
466  ACCEPT_SYNCHRONOUS_CONNECTION = 164,
467  REJECT_SYNCHRONOUS_CONNECTION = 165,
468  READ_EXTENDED_INQUIRY_RESPONSE = 170,
469  WRITE_EXTENDED_INQUIRY_RESPONSE = 171,
470  REFRESH_ENCRYPTION_KEY = 172,
471  SNIFF_SUBRATING = 174,
472  READ_SIMPLE_PAIRING_MODE = 175,
473  WRITE_SIMPLE_PAIRING_MODE = 176,
474  READ_LOCAL_OOB_DATA = 177,
475  READ_INQUIRY_RESPONSE_TRANSMIT_POWER_LEVEL = 180,
476  WRITE_INQUIRY_TRANSMIT_POWER_LEVEL = 181,
477  IO_CAPABILITY_REQUEST_REPLY = 187,
478  USER_CONFIRMATION_REQUEST_REPLY = 190,
479  USER_CONFIRMATION_REQUEST_NEGATIVE_REPLY = 191,
480  USER_PASSKEY_REQUEST_REPLY = 192,
481  USER_PASSKEY_REQUEST_NEGATIVE_REPLY = 193,
482  REMOTE_OOB_DATA_REQUEST_REPLY = 194,
483  WRITE_SIMPLE_PAIRING_DEBUG_MODE = 195,
484  REMOTE_OOB_DATA_REQUEST_NEGATIVE_REPLY = 197,
485  SEND_KEYPRESS_NOTIFICATION = 202,
486  IO_CAPABILITY_REQUEST_NEGATIVE_REPLY = 203,
487  READ_ENCRYPTION_KEY_SIZE = 204,
488  READ_DATA_BLOCK_SIZE = 232,
489  READ_LE_HOST_SUPPORT = 245,
490  WRITE_LE_HOST_SUPPORT = 246,
491  LE_SET_EVENT_MASK = 250,
492  LE_READ_BUFFER_SIZE_V1 = 251,
493  LE_READ_LOCAL_SUPPORTED_FEATURES = 252,
494  LE_SET_RANDOM_ADDRESS = 254,
495  LE_SET_ADVERTISING_PARAMETERS = 255,
496  LE_READ_ADVERTISING_CHANNEL_TX_POWER = 256,
497  LE_SET_ADVERTISING_DATA = 257,
498  LE_SET_SCAN_RESPONSE_DATA = 260,
499  LE_SET_ADVERTISING_ENABLE = 261,
500  LE_SET_SCAN_PARAMETERS = 262,
501  LE_SET_SCAN_ENABLE = 263,
502  LE_CREATE_CONNECTION = 264,
503  LE_CREATE_CONNECTION_CANCEL = 265,
504  LE_READ_CONNECT_LIST_SIZE = 266,
505  LE_CLEAR_CONNECT_LIST = 267,
506  LE_ADD_DEVICE_TO_CONNECT_LIST = 270,
507  LE_REMOVE_DEVICE_FROM_CONNECT_LIST = 271,
508  LE_CONNECTION_UPDATE = 272,
509  LE_SET_HOST_CHANNEL_CLASSIFICATION = 273,
510  LE_READ_CHANNEL_MAP = 274,
511  LE_READ_REMOTE_FEATURES = 275,
512  LE_ENCRYPT = 276,
513  LE_RAND = 277,
514  LE_START_ENCRYPTION = 280,
515  LE_LONG_TERM_KEY_REQUEST_REPLY = 281,
516  LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY = 282,
517  LE_READ_SUPPORTED_STATES = 283,
518  LE_RECEIVER_TEST = 284,
519  LE_TRANSMITTER_TEST = 285,
520  LE_TEST_END = 286,
521  ENHANCED_SETUP_SYNCHRONOUS_CONNECTION = 293,
522  ENHANCED_ACCEPT_SYNCHRONOUS_CONNECTION = 294,
523  READ_LOCAL_SUPPORTED_CODECS_V1 = 295,
524  READ_SECURE_CONNECTIONS_HOST_SUPPORT = 322,
525  WRITE_SECURE_CONNECTIONS_HOST_SUPPORT = 323,
526  READ_LOCAL_OOB_EXTENDED_DATA = 326,
527  WRITE_SECURE_CONNECTIONS_TEST_MODE = 327,
528  LE_REMOTE_CONNECTION_PARAMETER_REQUEST_REPLY = 334,
529  LE_REMOTE_CONNECTION_PARAMETER_REQUEST_NEGATIVE_REPLY = 335,
530  LE_SET_DATA_LENGTH = 336,
531  LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH = 337,
532  LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH = 340,
533  LE_READ_LOCAL_P_256_PUBLIC_KEY_COMMAND = 341,
534  LE_GENERATE_DHKEY_COMMAND_V1 = 342,
535  LE_ADD_DEVICE_TO_RESOLVING_LIST = 343,
536  LE_REMOVE_DEVICE_FROM_RESOLVING_LIST = 344,
537  LE_CLEAR_RESOLVING_LIST = 345,
538  LE_READ_RESOLVING_LIST_SIZE = 346,
539  LE_READ_PEER_RESOLVABLE_ADDRESS = 347,
540  LE_READ_LOCAL_RESOLVABLE_ADDRESS = 350,
541  LE_SET_ADDRESS_RESOLUTION_ENABLE = 351,
542  LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT = 352,
543  LE_READ_MAXIMUM_DATA_LENGTH = 353,
544  LE_READ_PHY = 354,
545  LE_SET_DEFAULT_PHY = 355,
546  LE_SET_PHY = 356,
547  LE_ENHANCED_RECEIVER_TEST = 357,
548  LE_ENHANCED_TRANSMITTER_TEST = 360,
549  LE_SET_EXTENDED_ADVERTISING_RANDOM_ADDRESS = 361,
550  LE_SET_EXTENDED_ADVERTISING_PARAMETERS = 362,
551  LE_SET_EXTENDED_ADVERTISING_DATA = 363,
552  LE_SET_EXTENDED_ADVERTISING_SCAN_RESPONSE = 364,
553  LE_SET_EXTENDED_ADVERTISING_ENABLE = 365,
554  LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH = 366,
555  LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS = 367,
556  LE_REMOVE_ADVERTISING_SET = 370,
557  LE_CLEAR_ADVERTISING_SETS = 371,
558  LE_SET_PERIODIC_ADVERTISING_PARAM = 372,
559  LE_SET_PERIODIC_ADVERTISING_DATA = 373,
560  LE_SET_PERIODIC_ADVERTISING_ENABLE = 374,
561  LE_SET_EXTENDED_SCAN_PARAMETERS = 375,
562  LE_SET_EXTENDED_SCAN_ENABLE = 376,
563  LE_EXTENDED_CREATE_CONNECTION = 377,
564  LE_PERIODIC_ADVERTISING_CREATE_SYNC = 380,
565  LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL = 381,
566  LE_PERIODIC_ADVERTISING_TERMINATE_SYNC = 382,
567  LE_ADD_DEVICE_TO_PERIODIC_ADVERTISING_LIST = 383,
568  LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISING_LIST = 384,
569  LE_CLEAR_PERIODIC_ADVERTISING_LIST = 385,
570  LE_READ_PERIODIC_ADVERTISING_LIST_SIZE = 386,
571  LE_READ_TRANSMIT_POWER = 387,
572  LE_READ_RF_PATH_COMPENSATION_POWER = 390,
573  LE_WRITE_RF_PATH_COMPENSATION_POWER = 391,
574  LE_SET_PRIVACY_MODE = 392,
575
576  LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE = 405,
577  LE_PERIODIC_ADVERTISING_SYNC_TRANSFER = 406,
578  LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER = 407,
579  LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS = 410,
580  LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS = 411,
581  LE_GENERATE_DHKEY_COMMAND = 412,
582  LE_MODIFY_SLEEP_CLOCK_ACCURACY = 414,
583  LE_READ_BUFFER_SIZE_V2 = 415,
584  LE_READ_ISO_TX_SYNC = 416,
585  LE_SET_CIG_PARAMETERS = 417,
586  LE_CREATE_CIS = 421,
587  LE_REMOVE_CIG = 422,
588  LE_ACCEPT_CIS_REQUEST = 423,
589  LE_REJECT_CIS_REQUEST = 424,
590  LE_CREATE_BIG = 425,
591  LE_TERMINATE_BIG = 427,
592  LE_BIG_CREATE_SYNC = 430,
593  LE_BIG_TERMINATE_SYNC = 431,
594  LE_REQUEST_PEER_SCA = 432,
595  LE_SETUP_ISO_DATA_PATH = 433,
596  LE_REMOVE_ISO_DATA_PATH = 434,
597  LE_SET_HOST_FEATURE = 441,
598  LE_READ_ISO_LINK_QUALITY = 442,
599  LE_ENHANCED_READ_TRANSMIT_POWER_LEVEL = 443,
600  LE_READ_REMOTE_TRANSMIT_POWER_LEVEL = 444,
601  LE_SET_PATH_LOSS_REPORTING_PARAMETERS = 445,
602  LE_SET_PATH_LOSS_REPORTING_ENABLE = 446,
603  LE_SET_TRANSMIT_POWER_REPORTING_ENABLE = 447,
604  SET_ECOSYSTEM_BASE_INTERVAL = 451,
605  READ_LOCAL_SUPPORTED_CODECS_V2 = 452,
606  READ_LOCAL_SUPPORTED_CODEC_CAPABILITIES = 453,
607  READ_LOCAL_SUPPORTED_CONTROLLER_DELAY = 454,
608  CONFIGURE_DATA_PATH = 455,
609}
610
611packet CommandPacket {
612  op_code : OpCode,
613  _size_(_payload_) : 8,
614  _payload_,
615}
616
617// Packets for interfaces
618
619packet DiscoveryCommand : CommandPacket { _payload_, }
620packet ConnectionManagementCommand : CommandPacket { _payload_, }
621packet SecurityCommand : CommandPacket { _payload_, }
622packet ScoConnectionCommand : CommandPacket { _payload_, }
623packet LeAdvertisingCommand : CommandPacket { _payload_, }
624packet LeScanningCommand : CommandPacket { _payload_, }
625packet LeConnectionManagementCommand : CommandPacket { _payload_, }
626packet LeSecurityCommand : CommandPacket { _payload_, }
627packet VendorCommand : CommandPacket { _payload_, }
628
629// HCI Event Packets
630
631enum EventCode : 8 {
632  INQUIRY_COMPLETE = 0x01,
633  INQUIRY_RESULT = 0x02,
634  CONNECTION_COMPLETE = 0x03,
635  CONNECTION_REQUEST = 0x04,
636  DISCONNECTION_COMPLETE = 0x05,
637  AUTHENTICATION_COMPLETE = 0x06,
638  REMOTE_NAME_REQUEST_COMPLETE = 0x07,
639  ENCRYPTION_CHANGE = 0x08,
640  CHANGE_CONNECTION_LINK_KEY_COMPLETE = 0x09,
641  MASTER_LINK_KEY_COMPLETE = 0x0A,
642  READ_REMOTE_SUPPORTED_FEATURES_COMPLETE = 0x0B,
643  READ_REMOTE_VERSION_INFORMATION_COMPLETE = 0x0C,
644  QOS_SETUP_COMPLETE = 0x0D,
645  COMMAND_COMPLETE = 0x0E,
646  COMMAND_STATUS = 0x0F,
647  HARDWARE_ERROR = 0x10,
648  FLUSH_OCCURRED = 0x11,
649  ROLE_CHANGE = 0x12,
650  NUMBER_OF_COMPLETED_PACKETS = 0x13,
651  MODE_CHANGE = 0x14,
652  RETURN_LINK_KEYS = 0x15,
653  PIN_CODE_REQUEST = 0x16,
654  LINK_KEY_REQUEST = 0x17,
655  LINK_KEY_NOTIFICATION = 0x18,
656  LOOPBACK_COMMAND = 0x19,
657  DATA_BUFFER_OVERFLOW = 0x1A,
658  MAX_SLOTS_CHANGE = 0x1B,
659  READ_CLOCK_OFFSET_COMPLETE = 0x1C,
660  CONNECTION_PACKET_TYPE_CHANGED = 0x1D,
661  QOS_VIOLATION = 0x1E,
662  PAGE_SCAN_REPETITION_MODE_CHANGE = 0x20,
663  FLOW_SPECIFICATION_COMPLETE = 0x21,
664  INQUIRY_RESULT_WITH_RSSI = 0x22,
665  READ_REMOTE_EXTENDED_FEATURES_COMPLETE = 0x23,
666  SYNCHRONOUS_CONNECTION_COMPLETE = 0x2C,
667  SYNCHRONOUS_CONNECTION_CHANGED = 0x2D,
668  SNIFF_SUBRATING = 0x2E,
669  EXTENDED_INQUIRY_RESULT = 0x2F,
670  ENCRYPTION_KEY_REFRESH_COMPLETE = 0x30,
671  IO_CAPABILITY_REQUEST = 0x31,
672  IO_CAPABILITY_RESPONSE = 0x32,
673  USER_CONFIRMATION_REQUEST = 0x33,
674  USER_PASSKEY_REQUEST = 0x34,
675  REMOTE_OOB_DATA_REQUEST = 0x35,
676  SIMPLE_PAIRING_COMPLETE = 0x36,
677  LINK_SUPERVISION_TIMEOUT_CHANGED = 0x38,
678  ENHANCED_FLUSH_COMPLETE = 0x39,
679  USER_PASSKEY_NOTIFICATION = 0x3B,
680  KEYPRESS_NOTIFICATION = 0x3C,
681  REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION = 0x3D,
682  LE_META_EVENT = 0x3e,
683  NUMBER_OF_COMPLETED_DATA_BLOCKS = 0x48,
684  VENDOR_SPECIFIC = 0xFF,
685}
686
687packet EventPacket {
688  event_code : EventCode,
689  _size_(_payload_) : 8,
690  _payload_,
691}
692
693// LE Events
694
695enum SubeventCode : 8 {
696  CONNECTION_COMPLETE = 0x01,
697  ADVERTISING_REPORT = 0x02,
698  CONNECTION_UPDATE_COMPLETE = 0x03,
699  READ_REMOTE_FEATURES_COMPLETE = 0x04,
700  LONG_TERM_KEY_REQUEST = 0x05,
701  REMOTE_CONNECTION_PARAMETER_REQUEST = 0x06,
702  DATA_LENGTH_CHANGE = 0x07,
703  READ_LOCAL_P256_PUBLIC_KEY_COMPLETE = 0x08,
704  GENERATE_DHKEY_COMPLETE = 0x09,
705  ENHANCED_CONNECTION_COMPLETE = 0x0a,
706  DIRECTED_ADVERTISING_REPORT = 0x0b,
707  PHY_UPDATE_COMPLETE = 0x0c,
708  EXTENDED_ADVERTISING_REPORT = 0x0D,
709  PERIODIC_ADVERTISING_SYNC_ESTABLISHED = 0x0E,
710  PERIODIC_ADVERTISING_REPORT = 0x0F,
711  PERIODIC_ADVERTISING_SYNC_LOST = 0x10,
712  SCAN_TIMEOUT = 0x11,
713  ADVERTISING_SET_TERMINATED = 0x12,
714  SCAN_REQUEST_RECEIVED = 0x13,
715  CHANNEL_SELECTION_ALGORITHM = 0X14,
716  CONNECTIONLESS_IQ_REPORT = 0X15,
717  CONNECTION_IQ_REPORT = 0X16,
718  CTE_REQUEST_FAILED = 0X17,
719  PERIODIC_ADVERTISING_SYNC_TRANSFER_RECEIVED = 0X18,
720  CIS_ESTABLISHED = 0X19,
721  CIS_REQUEST = 0X1A,
722  CREATE_BIG_COMPLETE = 0X1B,
723  TERMINATE_BIG_COMPLETE = 0X1C,
724  BIG_SYNC_ESTABLISHED = 0X1D,
725  BIG_SYNC_LOST = 0X1E,
726  REQUEST_PEER_SCA_COMPLETE = 0X1F,
727  PATH_LOSS_THRESHOLD = 0X20,
728  TRANSMIT_POWER_REPORTING = 0X21,
729  BIG_INFO_ADVERTISING_REPORT = 0X22,
730}
731
732// Vendor specific events
733enum VseSubeventCode : 8 {
734  BLE_THRESHOLD = 0x54,
735  BLE_TRACKING = 0x56,
736  DEBUG_INFO = 0x57,
737  BQR_EVENT = 0x58,
738}
739
740// Common definitions for commands and events
741
742enum FeatureFlag : 1 {
743  UNSUPPORTED = 0,
744  SUPPORTED = 1,
745}
746
747enum ErrorCode: 8 {
748  SUCCESS = 0x00,
749  UNKNOWN_HCI_COMMAND = 0x01,
750  UNKNOWN_CONNECTION = 0x02,
751  HARDWARE_FAILURE = 0x03,
752  PAGE_TIMEOUT = 0x04,
753  AUTHENTICATION_FAILURE = 0x05,
754  PIN_OR_KEY_MISSING = 0x06,
755  MEMORY_CAPACITY_EXCEEDED = 0x07,
756  CONNECTION_TIMEOUT = 0x08,
757  CONNECTION_LIMIT_EXCEEDED = 0x09,
758  SYNCHRONOUS_CONNECTION_LIMIT_EXCEEDED = 0x0A,
759  CONNECTION_ALREADY_EXISTS = 0x0B,
760  COMMAND_DISALLOWED = 0x0C,
761  CONNECTION_REJECTED_LIMITED_RESOURCES = 0x0D,
762  CONNECTION_REJECTED_SECURITY_REASONS = 0x0E,
763  CONNECTION_REJECTED_UNACCEPTABLE_BD_ADDR = 0x0F,
764  CONNECTION_ACCEPT_TIMEOUT = 0x10,
765  UNSUPORTED_FEATURE_OR_PARAMETER_VALUE = 0x11,
766  INVALID_HCI_COMMAND_PARAMETERS = 0x12,
767  REMOTE_USER_TERMINATED_CONNECTION = 0x13,
768  REMOTE_DEVICE_TERMINATED_CONNECTION_LOW_RESOURCES = 0x14,
769  REMOTE_DEVICE_TERMINATED_CONNECTION_POWER_OFF = 0x15,
770  CONNECTION_TERMINATED_BY_LOCAL_HOST = 0x16,
771  REPEATED_ATTEMPTS = 0x17,
772  PAIRING_NOT_ALLOWED = 0x18,
773  UNKNOWN_LMP_PDU = 0x19,
774  UNSUPPORTED_REMOTE_OR_LMP_FEATURE = 0x1A,
775  SCO_OFFSET_REJECTED = 0x1B,
776  SCO_INTERVAL_REJECTED = 0x1C,
777  SCO_AIR_MODE_REJECTED = 0x1D,
778  INVALID_LMP_OR_LL_PARAMETERS = 0x1E,
779  UNSPECIFIED_ERROR = 0x1F,
780  UNSUPPORTED_LMP_OR_LL_PARAMETER = 0x20,
781  ROLE_CHANGE_NOT_ALLOWED = 0x21,
782  LINK_LAYER_COLLISION = 0x23,
783  ENCRYPTION_MODE_NOT_ACCEPTABLE = 0x25,
784  CONTROLLER_BUSY = 0x3A,
785}
786
787// Events that are defined with their respective commands
788
789packet CommandComplete : EventPacket (event_code = COMMAND_COMPLETE){
790  num_hci_command_packets : 8,
791  command_op_code : OpCode,
792  _payload_,
793}
794
795packet CommandStatus : EventPacket (event_code = COMMAND_STATUS){
796  status : ErrorCode, // SUCCESS means PENDING
797  num_hci_command_packets : 8,
798  command_op_code : OpCode,
799  _payload_,
800}
801
802  // Credits
803packet NoCommandComplete : CommandComplete (command_op_code = NONE){
804}
805
806struct Lap { // Lower Address Part
807  lap : 6,
808  _reserved_ : 2,
809  _fixed_ = 0x9e8b : 16,
810}
811
812  // LINK_CONTROL
813packet Inquiry : DiscoveryCommand (op_code = INQUIRY) {
814  lap : Lap,
815  inquiry_length : 8, // 0x1 - 0x30 (times 1.28s)
816  num_responses : 8, // 0x00 unlimited
817}
818
819packet InquiryStatus : CommandStatus (command_op_code = INQUIRY) {
820}
821
822packet InquiryCancel : DiscoveryCommand (op_code = INQUIRY_CANCEL) {
823}
824
825packet InquiryCancelComplete : CommandComplete (command_op_code = INQUIRY_CANCEL) {
826  status : ErrorCode,
827}
828
829packet PeriodicInquiryMode : DiscoveryCommand (op_code = PERIODIC_INQUIRY_MODE) {
830  max_period_length : 16, // Range 0x0003 to 0xffff (times 1.28s)
831  min_period_length : 16, // Range 0x0002 to 0xfffe (times 1.28s)
832  lap : Lap,
833  inquiry_length : 8, // 0x1 - 0x30 (times 1.28s)
834  num_responses : 8, // 0x00 unlimited
835}
836
837packet PeriodicInquiryModeComplete : CommandComplete (command_op_code = PERIODIC_INQUIRY_MODE) {
838  status : ErrorCode,
839}
840
841packet ExitPeriodicInquiryMode : DiscoveryCommand (op_code = EXIT_PERIODIC_INQUIRY_MODE) {
842}
843
844packet ExitPeriodicInquiryModeComplete : CommandComplete (command_op_code = EXIT_PERIODIC_INQUIRY_MODE) {
845  status : ErrorCode,
846}
847
848enum PageScanRepetitionMode : 8 {
849  R0 = 0x00,
850  R1 = 0x01,
851  R2 = 0x02,
852}
853
854enum ClockOffsetValid : 1 {
855  INVALID = 0,
856  VALID = 1,
857}
858
859enum CreateConnectionRoleSwitch : 8 {
860  REMAIN_MASTER = 0x00,
861  ALLOW_ROLE_SWITCH = 0x01,
862}
863
864packet CreateConnection : ConnectionManagementCommand (op_code = CREATE_CONNECTION) {
865  bd_addr : Address,
866  packet_type : 16,
867  page_scan_repetition_mode : PageScanRepetitionMode,
868  _reserved_ : 8,
869  clock_offset : 15,
870  clock_offset_valid : ClockOffsetValid,
871  allow_role_switch : CreateConnectionRoleSwitch,
872}
873
874packet CreateConnectionStatus : CommandStatus (command_op_code = CREATE_CONNECTION) {
875}
876
877enum DisconnectReason : 8 {
878  AUTHENTICATION_FAILURE = 0x05,
879  REMOTE_USER_TERMINATED_CONNECTION = 0x13,
880  REMOTE_DEVICE_TERMINATED_CONNECTION_LOW_RESOURCES = 0x14,
881  REMOTE_DEVICE_TERMINATED_CONNECTION_POWER_OFF = 0x15,
882  UNSUPPORTED_REMOTE_FEATURE = 0x1A,
883  PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED = 0x29,
884  UNACCEPTABLE_CONNECTION_PARAMETERS = 0x3B,
885}
886
887packet Disconnect : ConnectionManagementCommand (op_code = DISCONNECT) {
888  connection_handle : 12,
889  _reserved_ : 4,
890  reason : DisconnectReason,
891}
892
893packet DisconnectStatus : CommandStatus (command_op_code = DISCONNECT) {
894}
895
896packet CreateConnectionCancel : ConnectionManagementCommand (op_code = CREATE_CONNECTION_CANCEL) {
897  bd_addr : Address,
898}
899
900packet CreateConnectionCancelComplete : CommandComplete (command_op_code = CREATE_CONNECTION_CANCEL) {
901  status : ErrorCode,
902  bd_addr : Address,
903}
904
905enum AcceptConnectionRequestRole : 8 {
906  BECOME_MASTER = 0x00,
907  REMAIN_SLAVE = 0x01,
908}
909
910packet AcceptConnectionRequest : ConnectionManagementCommand (op_code = ACCEPT_CONNECTION_REQUEST) {
911  bd_addr : Address,
912  role : AcceptConnectionRequestRole,
913}
914
915packet AcceptConnectionRequestStatus : CommandStatus (command_op_code = ACCEPT_CONNECTION_REQUEST) {
916}
917
918enum RejectConnectionReason : 8 {
919  LIMITED_RESOURCES = 0x0D,
920  SECURITY_REASONS = 0x0E,
921  UNACCEPTABLE_BD_ADDR = 0x0F,
922}
923
924packet RejectConnectionRequest : ConnectionManagementCommand (op_code = REJECT_CONNECTION_REQUEST) {
925  bd_addr : Address,
926  reason : RejectConnectionReason,
927}
928
929packet RejectConnectionRequestStatus : CommandStatus (command_op_code = REJECT_CONNECTION_REQUEST) {
930}
931
932packet LinkKeyRequestReply : SecurityCommand (op_code = LINK_KEY_REQUEST_REPLY) {
933  bd_addr : Address,
934  link_key : 8[16],
935}
936
937packet LinkKeyRequestReplyComplete : CommandComplete (command_op_code = LINK_KEY_REQUEST_REPLY) {
938  status : ErrorCode,
939}
940
941packet LinkKeyRequestNegativeReply : SecurityCommand (op_code = LINK_KEY_REQUEST_NEGATIVE_REPLY) {
942  bd_addr : Address,
943}
944
945packet LinkKeyRequestNegativeReplyComplete : CommandComplete (command_op_code = LINK_KEY_REQUEST_NEGATIVE_REPLY) {
946  status : ErrorCode,
947  bd_addr : Address,
948}
949
950packet PinCodeRequestReply : SecurityCommand (op_code = PIN_CODE_REQUEST_REPLY) {
951  bd_addr : Address,
952  pin_code_length : 5, // 0x01 - 0x10
953  _reserved_ : 3,
954  pin_code : 8[16], // string parameter, first octet first
955}
956
957packet PinCodeRequestReplyComplete : CommandComplete (command_op_code = PIN_CODE_REQUEST_REPLY) {
958  status : ErrorCode,
959  bd_addr : Address,
960}
961
962packet PinCodeRequestNegativeReply : SecurityCommand (op_code = PIN_CODE_REQUEST_NEGATIVE_REPLY) {
963  bd_addr : Address,
964}
965
966packet PinCodeRequestNegativeReplyComplete : CommandComplete (command_op_code = PIN_CODE_REQUEST_NEGATIVE_REPLY) {
967  status : ErrorCode,
968  bd_addr : Address,
969}
970
971packet ChangeConnectionPacketType : ConnectionManagementCommand (op_code = CHANGE_CONNECTION_PACKET_TYPE) {
972  connection_handle : 12,
973  _reserved_ : 4,
974  packet_type : 16,
975}
976
977packet ChangeConnectionPacketTypeStatus : CommandStatus (command_op_code = CHANGE_CONNECTION_PACKET_TYPE) {
978}
979
980packet AuthenticationRequested : ConnectionManagementCommand (op_code = AUTHENTICATION_REQUESTED) {
981  connection_handle : 12,
982  _reserved_ : 4,
983}
984
985packet AuthenticationRequestedStatus : CommandStatus (command_op_code = AUTHENTICATION_REQUESTED) {
986}
987
988packet SetConnectionEncryption : ConnectionManagementCommand (op_code = SET_CONNECTION_ENCRYPTION) {
989  connection_handle : 12,
990  _reserved_ : 4,
991  encryption_enable : Enable,
992}
993
994packet SetConnectionEncryptionStatus : CommandStatus (command_op_code = SET_CONNECTION_ENCRYPTION) {
995}
996
997packet ChangeConnectionLinkKey : ConnectionManagementCommand (op_code = CHANGE_CONNECTION_LINK_KEY) {
998  connection_handle : 12,
999  _reserved_ : 4,
1000}
1001
1002packet ChangeConnectionLinkKeyStatus : CommandStatus (command_op_code = CHANGE_CONNECTION_LINK_KEY) {
1003}
1004
1005enum KeyFlag : 8 {
1006  SEMI_PERMANENT = 0x00,
1007  TEMPORARY = 0x01,
1008}
1009
1010packet MasterLinkKey : ConnectionManagementCommand (op_code = MASTER_LINK_KEY) {
1011  key_flag : KeyFlag,
1012}
1013
1014packet MasterLinkKeyStatus : CommandStatus (command_op_code = MASTER_LINK_KEY) {
1015}
1016
1017packet RemoteNameRequest : DiscoveryCommand (op_code = REMOTE_NAME_REQUEST) {
1018  bd_addr : Address,
1019  page_scan_repetition_mode : PageScanRepetitionMode,
1020  _reserved_ : 8,
1021  clock_offset : 15,
1022  clock_offset_valid : ClockOffsetValid,
1023}
1024
1025packet RemoteNameRequestStatus : CommandStatus (command_op_code = REMOTE_NAME_REQUEST) {
1026}
1027
1028packet RemoteNameRequestCancel : DiscoveryCommand (op_code = REMOTE_NAME_REQUEST_CANCEL) {
1029  bd_addr : Address,
1030}
1031
1032packet RemoteNameRequestCancelComplete : CommandComplete (command_op_code = REMOTE_NAME_REQUEST_CANCEL) {
1033  status : ErrorCode,
1034  bd_addr : Address,
1035}
1036
1037packet ReadRemoteSupportedFeatures : ConnectionManagementCommand (op_code = READ_REMOTE_SUPPORTED_FEATURES) {
1038  connection_handle : 12,
1039  _reserved_ : 4,
1040}
1041
1042packet ReadRemoteSupportedFeaturesStatus : CommandStatus (command_op_code = READ_REMOTE_SUPPORTED_FEATURES) {
1043}
1044
1045packet ReadRemoteExtendedFeatures : ConnectionManagementCommand (op_code = READ_REMOTE_EXTENDED_FEATURES) {
1046  connection_handle : 12,
1047  _reserved_ : 4,
1048  page_number : 8,
1049}
1050
1051packet ReadRemoteExtendedFeaturesStatus : CommandStatus (command_op_code = READ_REMOTE_EXTENDED_FEATURES) {
1052}
1053
1054packet ReadRemoteVersionInformation : ConnectionManagementCommand (op_code = READ_REMOTE_VERSION_INFORMATION) {
1055  connection_handle : 12,
1056  _reserved_ : 4,
1057}
1058
1059packet ReadRemoteVersionInformationStatus : CommandStatus (command_op_code = READ_REMOTE_VERSION_INFORMATION) {
1060}
1061
1062packet ReadClockOffset : ConnectionManagementCommand (op_code = READ_CLOCK_OFFSET) {
1063  connection_handle : 12,
1064  _reserved_ : 4,
1065}
1066
1067packet ReadClockOffsetStatus : CommandStatus (command_op_code = READ_CLOCK_OFFSET) {
1068}
1069
1070packet ReadLmpHandle : ConnectionManagementCommand (op_code = READ_LMP_HANDLE) {
1071  connection_handle : 12,
1072  _reserved_ : 4,
1073}
1074
1075packet ReadLmpHandleComplete : CommandComplete (command_op_code = READ_LMP_HANDLE) {
1076  status : ErrorCode,
1077  connection_handle : 12,
1078  _reserved_ : 4,
1079  lmp_handle : 8,
1080  _reserved_ : 32,
1081}
1082
1083packet SetupSynchronousConnection : ScoConnectionCommand (op_code = SETUP_SYNCHRONOUS_CONNECTION) {
1084  _payload_,  // placeholder (unimplemented)
1085}
1086
1087packet AcceptSynchronousConnection : ScoConnectionCommand (op_code = ACCEPT_SYNCHRONOUS_CONNECTION) {
1088  _payload_,  // placeholder (unimplemented)
1089}
1090
1091packet RejectSynchronousConnection : ScoConnectionCommand (op_code = REJECT_SYNCHRONOUS_CONNECTION) {
1092  _payload_,  // placeholder (unimplemented)
1093}
1094
1095enum IoCapability : 8 {
1096  DISPLAY_ONLY = 0x00,
1097  DISPLAY_YES_NO = 0x01,
1098  KEYBOARD_ONLY = 0x02,
1099  NO_INPUT_NO_OUTPUT = 0x03,
1100}
1101
1102enum OobDataPresent : 8 {
1103  NOT_PRESENT = 0x00,
1104  P_192_PRESENT = 0x01,
1105  P_256_PRESENT = 0x02,
1106  P_192_AND_256_PRESENT = 0x03,
1107}
1108
1109enum AuthenticationRequirements : 8 {
1110  NO_BONDING = 0x00,
1111  NO_BONDING_MITM_PROTECTION = 0x01,
1112  DEDICATED_BONDING = 0x02,
1113  DEDICATED_BONDING_MITM_PROTECTION = 0x03,
1114  GENERAL_BONDING = 0x04,
1115  GENERAL_BONDING_MITM_PROTECTION = 0x05,
1116}
1117
1118packet IoCapabilityRequestReply : SecurityCommand (op_code = IO_CAPABILITY_REQUEST_REPLY) {
1119  bd_addr : Address,
1120  io_capability : IoCapability,
1121  oob_present : OobDataPresent,
1122  authentication_requirements : AuthenticationRequirements,
1123}
1124
1125packet IoCapabilityRequestReplyComplete : CommandComplete (command_op_code = IO_CAPABILITY_REQUEST_REPLY) {
1126  status : ErrorCode,
1127  bd_addr : Address,
1128}
1129
1130packet UserConfirmationRequestReply : SecurityCommand (op_code = USER_CONFIRMATION_REQUEST_REPLY) {
1131  bd_addr : Address,
1132}
1133
1134packet UserConfirmationRequestReplyComplete : CommandComplete (command_op_code = USER_CONFIRMATION_REQUEST_REPLY) {
1135  status : ErrorCode,
1136  bd_addr : Address,
1137}
1138
1139packet UserConfirmationRequestNegativeReply : SecurityCommand (op_code = USER_CONFIRMATION_REQUEST_NEGATIVE_REPLY) {
1140  bd_addr : Address,
1141}
1142
1143packet UserConfirmationRequestNegativeReplyComplete : CommandComplete (command_op_code = USER_CONFIRMATION_REQUEST_NEGATIVE_REPLY) {
1144  status : ErrorCode,
1145  bd_addr : Address,
1146}
1147
1148packet UserPasskeyRequestReply : SecurityCommand (op_code = USER_PASSKEY_REQUEST_REPLY) {
1149  bd_addr : Address,
1150  numeric_value : 32, // 000000-999999 decimal or 0x0-0xF423F
1151}
1152
1153packet UserPasskeyRequestReplyComplete : CommandComplete (command_op_code = USER_PASSKEY_REQUEST_REPLY) {
1154  status : ErrorCode,
1155  bd_addr : Address,
1156}
1157
1158packet UserPasskeyRequestNegativeReply : SecurityCommand (op_code = USER_PASSKEY_REQUEST_NEGATIVE_REPLY) {
1159  bd_addr : Address,
1160}
1161
1162packet UserPasskeyRequestNegativeReplyComplete : CommandComplete (command_op_code = USER_PASSKEY_REQUEST_NEGATIVE_REPLY) {
1163  status : ErrorCode,
1164  bd_addr : Address,
1165}
1166
1167packet RemoteOobDataRequestReply : SecurityCommand (op_code = REMOTE_OOB_DATA_REQUEST_REPLY) {
1168  bd_addr : Address,
1169  c : 8[16],
1170  r : 8[16],
1171}
1172
1173packet RemoteOobDataRequestReplyComplete : CommandComplete (command_op_code = REMOTE_OOB_DATA_REQUEST_REPLY) {
1174  status : ErrorCode,
1175  bd_addr : Address,
1176}
1177
1178packet RemoteOobDataRequestNegativeReply : SecurityCommand (op_code = REMOTE_OOB_DATA_REQUEST_NEGATIVE_REPLY) {
1179  bd_addr : Address,
1180}
1181
1182packet RemoteOobDataRequestNegativeReplyComplete : CommandComplete (command_op_code = REMOTE_OOB_DATA_REQUEST_NEGATIVE_REPLY) {
1183  status : ErrorCode,
1184  bd_addr : Address,
1185}
1186
1187packet IoCapabilityRequestNegativeReply : SecurityCommand (op_code = IO_CAPABILITY_REQUEST_NEGATIVE_REPLY) {
1188  bd_addr : Address,
1189  reason : ErrorCode,
1190}
1191
1192packet IoCapabilityRequestNegativeReplyComplete : CommandComplete (command_op_code = IO_CAPABILITY_REQUEST_NEGATIVE_REPLY) {
1193  status : ErrorCode,
1194  bd_addr : Address,
1195}
1196
1197packet EnhancedSetupSynchronousConnection : ScoConnectionCommand (op_code = ENHANCED_SETUP_SYNCHRONOUS_CONNECTION) {
1198  _payload_,  // placeholder (unimplemented)
1199}
1200
1201packet EnhancedAcceptSynchronousConnection : ScoConnectionCommand (op_code = ENHANCED_ACCEPT_SYNCHRONOUS_CONNECTION) {
1202  _payload_,  // placeholder (unimplemented)
1203}
1204
1205
1206  // LINK_POLICY
1207packet HoldMode : ConnectionManagementCommand (op_code = HOLD_MODE) {
1208  connection_handle : 12,
1209  _reserved_ : 4,
1210  hold_mode_max_interval: 16, // 0x0002-0xFFFE (1.25ms-40.9s)
1211  hold_mode_min_interval: 16, // 0x0002-0xFFFE (1.25ms-40.9s)
1212}
1213
1214packet HoldModeStatus : CommandStatus (command_op_code = HOLD_MODE) {
1215}
1216
1217
1218packet SniffMode : ConnectionManagementCommand (op_code = SNIFF_MODE) {
1219  connection_handle : 12,
1220  _reserved_ : 4,
1221  sniff_max_interval: 16, // 0x0002-0xFFFE (1.25ms-40.9s)
1222  sniff_min_interval: 16, // 0x0002-0xFFFE (1.25ms-40.9s)
1223  sniff_attempt: 16, // 0x0001-0x7FFF (1.25ms-40.9s)
1224  sniff_timeout: 16, // 0x0000-0x7FFF (0ms-40.9s)
1225}
1226
1227packet SniffModeStatus : CommandStatus (command_op_code = SNIFF_MODE) {
1228}
1229
1230
1231packet ExitSniffMode : ConnectionManagementCommand (op_code = EXIT_SNIFF_MODE) {
1232  connection_handle : 12,
1233  _reserved_ : 4,
1234}
1235
1236packet ExitSniffModeStatus : CommandStatus (command_op_code = EXIT_SNIFF_MODE) {
1237}
1238
1239enum ServiceType : 8 {
1240  NO_TRAFFIC = 0x00,
1241  BEST_EFFORT = 0x01,
1242  GUARANTEED = 0x02,
1243}
1244
1245packet QosSetup : ConnectionManagementCommand (op_code = QOS_SETUP) {
1246  connection_handle : 12,
1247  _reserved_ : 4,
1248  _reserved_ : 8,
1249  service_type : ServiceType,
1250  token_rate : 32, // Octets/s
1251  peak_bandwidth : 32, // Octets/s
1252  latency : 32, // Octets/s
1253  delay_variation : 32, // microseconds
1254}
1255
1256packet QosSetupStatus : CommandStatus (command_op_code = QOS_SETUP) {
1257}
1258
1259packet RoleDiscovery : ConnectionManagementCommand (op_code = ROLE_DISCOVERY) {
1260  connection_handle : 12,
1261  _reserved_ : 4,
1262}
1263
1264enum Role : 8 {
1265  MASTER = 0x00,
1266  SLAVE = 0x01,
1267}
1268
1269packet RoleDiscoveryComplete : CommandComplete (command_op_code = ROLE_DISCOVERY) {
1270  status : ErrorCode,
1271  connection_handle : 12,
1272  _reserved_ : 4,
1273  current_role : Role,
1274}
1275
1276packet SwitchRole : ConnectionManagementCommand (op_code = SWITCH_ROLE) {
1277  bd_addr : Address,
1278  role : Role,
1279}
1280
1281packet SwitchRoleStatus : CommandStatus (command_op_code = SWITCH_ROLE) {
1282}
1283
1284
1285packet ReadLinkPolicySettings : ConnectionManagementCommand (op_code = READ_LINK_POLICY_SETTINGS) {
1286  connection_handle : 12,
1287  _reserved_ : 4,
1288}
1289
1290enum LinkPolicy : 16 {
1291  ENABLE_ROLE_SWITCH = 0x01,
1292  ENABLE_HOLD_MODE = 0x02,
1293  ENABLE_SNIFF_MODE = 0x04,
1294  ENABLE_PARK_MODE = 0x08, // deprecated after 5.0
1295}
1296
1297packet ReadLinkPolicySettingsComplete : CommandComplete (command_op_code = READ_LINK_POLICY_SETTINGS) {
1298  status : ErrorCode,
1299  connection_handle : 12,
1300  _reserved_ : 4,
1301  link_policy_settings : 16,
1302}
1303
1304packet WriteLinkPolicySettings : ConnectionManagementCommand (op_code = WRITE_LINK_POLICY_SETTINGS) {
1305  connection_handle : 12,
1306  _reserved_ : 4,
1307  link_policy_settings : 16,
1308}
1309
1310packet WriteLinkPolicySettingsComplete : CommandComplete (command_op_code = WRITE_LINK_POLICY_SETTINGS) {
1311  status : ErrorCode,
1312  connection_handle : 12,
1313  _reserved_ : 4,
1314}
1315
1316packet ReadDefaultLinkPolicySettings : ConnectionManagementCommand (op_code = READ_DEFAULT_LINK_POLICY_SETTINGS) {
1317}
1318
1319packet ReadDefaultLinkPolicySettingsComplete : CommandComplete (command_op_code = READ_DEFAULT_LINK_POLICY_SETTINGS) {
1320  status : ErrorCode,
1321  default_link_policy_settings : 16,
1322}
1323
1324packet WriteDefaultLinkPolicySettings : ConnectionManagementCommand (op_code = WRITE_DEFAULT_LINK_POLICY_SETTINGS) {
1325  default_link_policy_settings : 16,
1326}
1327
1328packet WriteDefaultLinkPolicySettingsComplete : CommandComplete (command_op_code = WRITE_DEFAULT_LINK_POLICY_SETTINGS) {
1329  status : ErrorCode,
1330}
1331
1332enum FlowDirection : 8 {
1333  OUTGOING_FLOW = 0x00,
1334  INCOMING_FLOW = 0x01,
1335}
1336
1337packet FlowSpecification : ConnectionManagementCommand (op_code = FLOW_SPECIFICATION) {
1338  connection_handle : 12,
1339  _reserved_ : 4,
1340  _reserved_ : 8,
1341  flow_direction : FlowDirection,
1342  service_type : ServiceType,
1343  token_rate : 32, // Octets/s
1344  token_bucket_size : 32,
1345  peak_bandwidth : 32, // Octets/s
1346  access_latency : 32, // Octets/s
1347}
1348
1349packet FlowSpecificationStatus : CommandStatus (command_op_code = FLOW_SPECIFICATION) {
1350}
1351
1352packet SniffSubrating : ConnectionManagementCommand (op_code = SNIFF_SUBRATING) {
1353  connection_handle : 12,
1354  _reserved_ : 4,
1355  maximum_latency : 16,  // 0x0002-0xFFFE (1.25ms-40.9s)
1356  minimum_remote_timeout : 16, // 0x0000-0xFFFE (0-40.9s)
1357  minimum_local_timeout: 16, // 0x0000-0xFFFE (0-40.9s)
1358}
1359
1360packet SniffSubratingComplete : CommandComplete (command_op_code = SNIFF_SUBRATING) {
1361  status : ErrorCode,
1362  connection_handle : 12,
1363  _reserved_ : 4,
1364}
1365
1366  // CONTROLLER_AND_BASEBAND
1367packet SetEventMask : CommandPacket (op_code = SET_EVENT_MASK) {
1368  event_mask : 64,
1369}
1370
1371packet SetEventMaskComplete : CommandComplete (command_op_code = SET_EVENT_MASK) {
1372  status : ErrorCode,
1373}
1374
1375packet Reset : CommandPacket (op_code = RESET) {
1376}
1377
1378packet ResetComplete : CommandComplete (command_op_code = RESET) {
1379  status : ErrorCode,
1380}
1381
1382enum FilterType : 8 {
1383  CLEAR_ALL_FILTERS = 0x00,
1384  INQUIRY_RESULT = 0x01,
1385  CONNECTION_SETUP = 0x02,
1386}
1387
1388packet SetEventFilter : CommandPacket (op_code = SET_EVENT_FILTER) {
1389  filter_type : FilterType,
1390  _body_,
1391}
1392
1393packet SetEventFilterComplete : CommandComplete (command_op_code = SET_EVENT_FILTER) {
1394  status : ErrorCode,
1395}
1396
1397packet SetEventFilterClearAll : SetEventFilter (filter_type = CLEAR_ALL_FILTERS) {
1398}
1399
1400enum FilterConditionType : 8 {
1401  ALL_DEVICES = 0x00,
1402  CLASS_OF_DEVICE = 0x01,
1403  ADDRESS = 0x02,
1404}
1405
1406packet SetEventFilterInquiryResult : SetEventFilter (filter_type = INQUIRY_RESULT) {
1407  filter_condition_type : FilterConditionType,
1408  _body_,
1409}
1410
1411packet SetEventFilterInquiryResultAllDevices : SetEventFilterInquiryResult (filter_condition_type = ALL_DEVICES) {
1412}
1413
1414packet SetEventFilterInquiryResultClassOfDevice : SetEventFilterInquiryResult (filter_condition_type = CLASS_OF_DEVICE) {
1415  class_of_device : ClassOfDevice,
1416  class_of_device_mask : ClassOfDevice,
1417}
1418
1419packet SetEventFilterInquiryResultAddress : SetEventFilterInquiryResult (filter_condition_type = ADDRESS) {
1420  address : Address,
1421}
1422
1423packet SetEventFilterConnectionSetup : SetEventFilter (filter_type = CONNECTION_SETUP) {
1424  filter_condition_type : FilterConditionType,
1425  _body_,
1426}
1427
1428enum AutoAcceptFlag : 8 {
1429  AUTO_ACCEPT_OFF = 0x01,
1430  AUTO_ACCEPT_ON_ROLE_SWITCH_DISABLED = 0x02,
1431  AUTO_ACCEPT_ON_ROLE_SWITCH_ENABLED = 0x03,
1432}
1433
1434packet SetEventFilterConnectionSetupAllDevices : SetEventFilterConnectionSetup (filter_condition_type = ALL_DEVICES) {
1435  auto_accept_flag : AutoAcceptFlag,
1436}
1437
1438packet SetEventFilterConnectionSetupClassOfDevice : SetEventFilterConnectionSetup (filter_condition_type = CLASS_OF_DEVICE) {
1439  class_of_device : ClassOfDevice,
1440  class_of_device_mask : ClassOfDevice,
1441  auto_accept_flag : AutoAcceptFlag,
1442}
1443
1444packet SetEventFilterConnectionSetupAddress : SetEventFilterConnectionSetup (filter_condition_type = ADDRESS) {
1445  address : Address,
1446  auto_accept_flag : AutoAcceptFlag,
1447}
1448
1449packet Flush : ConnectionManagementCommand (op_code = FLUSH) {
1450  connection_handle : 12,
1451  _reserved_ : 4,
1452}
1453
1454packet FlushComplete : CommandComplete (command_op_code = FLUSH) {
1455  status : ErrorCode,
1456  connection_handle : 12,
1457  _reserved_ : 4,
1458}
1459
1460enum PinType : 8 {
1461  VARIABLE = 0,
1462  FIXED = 1,
1463}
1464
1465packet ReadPinType : CommandPacket (op_code = READ_PIN_TYPE) {
1466}
1467
1468packet ReadPinTypeComplete : CommandComplete (command_op_code = READ_PIN_TYPE) {
1469  status : ErrorCode,
1470  pin_type : PinType,
1471}
1472
1473packet WritePinType : CommandPacket (op_code = WRITE_PIN_TYPE) {
1474  pin_type : PinType,
1475}
1476
1477packet WritePinTypeComplete : CommandComplete (command_op_code = WRITE_PIN_TYPE) {
1478  status : ErrorCode,
1479}
1480
1481packet CreateNewUnitKey : CommandPacket (op_code = CREATE_NEW_UNIT_KEY) {
1482  _payload_,  // placeholder (unimplemented)
1483}
1484
1485enum ReadStoredLinkKeyReadAllFlag : 8 {
1486  SPECIFIED_BD_ADDR = 0x00,
1487  ALL = 0x01,
1488}
1489
1490packet ReadStoredLinkKey : SecurityCommand (op_code = READ_STORED_LINK_KEY) {
1491  bd_addr : Address,
1492  read_all_flag : ReadStoredLinkKeyReadAllFlag,
1493}
1494
1495packet ReadStoredLinkKeyComplete : CommandComplete (command_op_code = READ_STORED_LINK_KEY) {
1496  status : ErrorCode,
1497  max_num_keys : 16,
1498  num_keys_read : 16,
1499}
1500
1501struct KeyAndAddress {
1502  address : Address,
1503  link_key : 8[16],
1504}
1505
1506packet WriteStoredLinkKey : SecurityCommand (op_code = WRITE_STORED_LINK_KEY) {
1507  _count_(keys_to_write) : 8, // 0x01-0x0B
1508  keys_to_write : KeyAndAddress[],
1509}
1510
1511packet WriteStoredLinkKeyComplete : CommandComplete (command_op_code = WRITE_STORED_LINK_KEY) {
1512  status : ErrorCode,
1513  num_keys_written : 8,
1514}
1515
1516enum DeleteStoredLinkKeyDeleteAllFlag : 8 {
1517  SPECIFIED_BD_ADDR = 0x00,
1518  ALL = 0x01,
1519}
1520
1521packet DeleteStoredLinkKey : SecurityCommand (op_code = DELETE_STORED_LINK_KEY) {
1522  bd_addr : Address,
1523  delete_all_flag : DeleteStoredLinkKeyDeleteAllFlag,
1524}
1525
1526packet DeleteStoredLinkKeyComplete : CommandComplete (command_op_code = DELETE_STORED_LINK_KEY) {
1527  status : ErrorCode,
1528  num_keys_deleted : 16,
1529}
1530
1531packet WriteLocalName : CommandPacket (op_code = WRITE_LOCAL_NAME) {
1532  local_name : 8[248], // Null-terminated UTF-8 encoded name
1533}
1534
1535packet WriteLocalNameComplete : CommandComplete (command_op_code = WRITE_LOCAL_NAME) {
1536  status : ErrorCode,
1537}
1538
1539packet ReadLocalName : CommandPacket (op_code = READ_LOCAL_NAME) {
1540}
1541
1542packet ReadLocalNameComplete : CommandComplete (command_op_code = READ_LOCAL_NAME) {
1543  status : ErrorCode,
1544  local_name : 8[248], // Null-terminated UTF-8 encoded name
1545}
1546
1547packet ReadConnectionAcceptTimeout : ConnectionManagementCommand (op_code = READ_CONNECTION_ACCEPT_TIMEOUT) {
1548}
1549
1550packet ReadConnectionAcceptTimeoutComplete : CommandComplete (command_op_code = READ_CONNECTION_ACCEPT_TIMEOUT) {
1551  status : ErrorCode,
1552  conn_accept_timeout : 16, // 0x0001 to 0xB540 (N * 0.625 ms) 0.625 ms to 29 s
1553}
1554
1555packet WriteConnectionAcceptTimeout : ConnectionManagementCommand (op_code = WRITE_CONNECTION_ACCEPT_TIMEOUT) {
1556  conn_accept_timeout : 16, // 0x0001 to 0xB540 (N * 0.625 ms) 0.625 ms to 29 s, Default 0x1FA0, 5.06s
1557}
1558
1559packet WriteConnectionAcceptTimeoutComplete : CommandComplete (command_op_code = WRITE_CONNECTION_ACCEPT_TIMEOUT) {
1560  status : ErrorCode,
1561}
1562
1563packet ReadPageTimeout : DiscoveryCommand (op_code = READ_PAGE_TIMEOUT) {
1564}
1565
1566packet ReadPageTimeoutComplete : CommandComplete (command_op_code = READ_PAGE_TIMEOUT) {
1567  status : ErrorCode,
1568  page_timeout : 16,
1569}
1570
1571packet WritePageTimeout : DiscoveryCommand (op_code = WRITE_PAGE_TIMEOUT) {
1572  page_timeout : 16,
1573}
1574
1575packet WritePageTimeoutComplete : CommandComplete (command_op_code = WRITE_PAGE_TIMEOUT) {
1576  status : ErrorCode,
1577}
1578
1579enum ScanEnable : 8 {
1580  NO_SCANS = 0x00,
1581  INQUIRY_SCAN_ONLY = 0x01,
1582  PAGE_SCAN_ONLY = 0x02,
1583  INQUIRY_AND_PAGE_SCAN = 0x03,
1584}
1585
1586packet ReadScanEnable : DiscoveryCommand (op_code = READ_SCAN_ENABLE) {
1587}
1588
1589packet ReadScanEnableComplete : CommandComplete (command_op_code = READ_SCAN_ENABLE) {
1590  status : ErrorCode,
1591  scan_enable : ScanEnable,
1592}
1593
1594packet WriteScanEnable : DiscoveryCommand (op_code = WRITE_SCAN_ENABLE) {
1595  scan_enable : ScanEnable,
1596}
1597
1598packet WriteScanEnableComplete : CommandComplete (command_op_code = WRITE_SCAN_ENABLE) {
1599  status : ErrorCode,
1600}
1601
1602packet ReadPageScanActivity : DiscoveryCommand (op_code = READ_PAGE_SCAN_ACTIVITY) {
1603}
1604
1605packet ReadPageScanActivityComplete : CommandComplete (command_op_code = READ_PAGE_SCAN_ACTIVITY) {
1606  status : ErrorCode,
1607  page_scan_interval : 16, // Range: 0x0012 to 0x1000; only even values are valid * 0x625 ms
1608  page_scan_window : 16, // 0x0011 to PageScanInterval
1609}
1610
1611packet WritePageScanActivity : DiscoveryCommand (op_code = WRITE_PAGE_SCAN_ACTIVITY) {
1612  page_scan_interval : 16, // Range: 0x0012 to 0x1000; only even values are valid * 0x625 ms
1613  page_scan_window : 16, // 0x0011 to PageScanInterval
1614}
1615
1616packet WritePageScanActivityComplete : CommandComplete (command_op_code = WRITE_PAGE_SCAN_ACTIVITY) {
1617  status : ErrorCode,
1618}
1619
1620packet ReadInquiryScanActivity : DiscoveryCommand (op_code = READ_INQUIRY_SCAN_ACTIVITY) {
1621}
1622
1623packet ReadInquiryScanActivityComplete : CommandComplete (command_op_code = READ_INQUIRY_SCAN_ACTIVITY) {
1624  status : ErrorCode,
1625  inquiry_scan_interval : 16, // Range: 0x0012 to 0x1000; only even values are valid * 0x625 ms
1626  inquiry_scan_window : 16, // Range: 0x0011 to 0x1000
1627}
1628
1629packet WriteInquiryScanActivity : DiscoveryCommand (op_code = WRITE_INQUIRY_SCAN_ACTIVITY) {
1630  inquiry_scan_interval : 16, // Range: 0x0012 to 0x1000; only even values are valid * 0x625 ms
1631  inquiry_scan_window : 16, // Range: 0x0011 to 0x1000
1632}
1633
1634packet WriteInquiryScanActivityComplete : CommandComplete (command_op_code = WRITE_INQUIRY_SCAN_ACTIVITY) {
1635  status : ErrorCode,
1636}
1637
1638enum AuthenticationEnable : 8 {
1639  NOT_REQUIRED = 0x00,
1640  REQUIRED = 0x01,
1641}
1642
1643packet ReadAuthenticationEnable : CommandPacket (op_code = READ_AUTHENTICATION_ENABLE) {
1644}
1645
1646packet ReadAuthenticationEnableComplete : CommandComplete (command_op_code = READ_AUTHENTICATION_ENABLE) {
1647  status : ErrorCode,
1648  authentication_enable : AuthenticationEnable,
1649}
1650
1651packet WriteAuthenticationEnable : SecurityCommand (op_code = WRITE_AUTHENTICATION_ENABLE) {
1652  authentication_enable : AuthenticationEnable,
1653}
1654
1655packet WriteAuthenticationEnableComplete : CommandComplete (command_op_code = WRITE_AUTHENTICATION_ENABLE) {
1656  status : ErrorCode,
1657}
1658
1659packet ReadClassOfDevice : DiscoveryCommand (op_code = READ_CLASS_OF_DEVICE) {
1660}
1661
1662packet ReadClassOfDeviceComplete : CommandComplete (command_op_code = READ_CLASS_OF_DEVICE) {
1663  status : ErrorCode,
1664  class_of_device : ClassOfDevice,
1665}
1666
1667packet WriteClassOfDevice : DiscoveryCommand (op_code = WRITE_CLASS_OF_DEVICE) {
1668  class_of_device : ClassOfDevice,
1669}
1670
1671packet WriteClassOfDeviceComplete : CommandComplete (command_op_code = WRITE_CLASS_OF_DEVICE) {
1672  status : ErrorCode,
1673}
1674
1675packet ReadVoiceSetting : CommandPacket (op_code = READ_VOICE_SETTING) {
1676  _payload_,  // placeholder (unimplemented)
1677}
1678
1679packet WriteVoiceSetting : CommandPacket (op_code = WRITE_VOICE_SETTING) {
1680  _payload_,  // placeholder (unimplemented)
1681}
1682
1683packet WriteVoiceSettingComplete : CommandComplete (command_op_code = WRITE_VOICE_SETTING) {
1684  status : ErrorCode,
1685}
1686
1687packet ReadAutomaticFlushTimeout : ConnectionManagementCommand (op_code = READ_AUTOMATIC_FLUSH_TIMEOUT) {
1688  connection_handle : 12,
1689  _reserved_ : 4,
1690}
1691
1692packet ReadAutomaticFlushTimeoutComplete : CommandComplete (command_op_code = READ_AUTOMATIC_FLUSH_TIMEOUT) {
1693  status : ErrorCode,
1694  connection_handle : 12,
1695  _reserved_ : 4,
1696  flush_timeout : 16,
1697}
1698
1699packet WriteAutomaticFlushTimeout : ConnectionManagementCommand (op_code = WRITE_AUTOMATIC_FLUSH_TIMEOUT) {
1700  connection_handle : 12,
1701  _reserved_ : 4,
1702  flush_timeout : 16, // 0x0000-0x07FF Default 0x0000 (No Automatic Flush)
1703}
1704
1705packet WriteAutomaticFlushTimeoutComplete : CommandComplete (command_op_code = WRITE_AUTOMATIC_FLUSH_TIMEOUT) {
1706  status : ErrorCode,
1707  connection_handle : 12,
1708  _reserved_ : 4,
1709}
1710
1711packet ReadNumBroadcastRetransmits : CommandPacket (op_code = READ_NUM_BROADCAST_RETRANSMITS) {
1712  _payload_,  // placeholder (unimplemented)
1713}
1714
1715packet WriteNumBroadcastRetransmits : CommandPacket (op_code = WRITE_NUM_BROADCAST_RETRANSMITS) {
1716  _payload_,  // placeholder (unimplemented)
1717}
1718
1719packet ReadHoldModeActivity : CommandPacket (op_code = READ_HOLD_MODE_ACTIVITY) {
1720  _payload_,  // placeholder (unimplemented)
1721}
1722
1723packet WriteHoldModeActivity : CommandPacket (op_code = WRITE_HOLD_MODE_ACTIVITY) {
1724  _payload_,  // placeholder (unimplemented)
1725}
1726
1727
1728enum TransmitPowerLevelType : 8 {
1729  CURRENT = 0x00,
1730  MAXIMUM = 0x01,
1731}
1732
1733packet ReadTransmitPowerLevel : ConnectionManagementCommand (op_code = READ_TRANSMIT_POWER_LEVEL) {
1734  connection_handle : 12,
1735  _reserved_ : 4,
1736  type : TransmitPowerLevelType,
1737
1738}
1739
1740packet ReadTransmitPowerLevelComplete : CommandComplete (command_op_code = READ_TRANSMIT_POWER_LEVEL) {
1741  status : ErrorCode,
1742  connection_handle : 12,
1743  _reserved_ : 4,
1744  transmit_power_level : 8,
1745}
1746
1747packet ReadSynchronousFlowControlEnable : CommandPacket (op_code = READ_SYNCHRONOUS_FLOW_CONTROL_ENABLE) {
1748  _payload_,  // placeholder (unimplemented)
1749}
1750
1751packet WriteSynchronousFlowControlEnable : CommandPacket (op_code = WRITE_SYNCHRONOUS_FLOW_CONTROL_ENABLE) {
1752  _payload_,  // placeholder (unimplemented)
1753}
1754
1755packet SetControllerToHostFlowControl : CommandPacket (op_code = SET_CONTROLLER_TO_HOST_FLOW_CONTROL) {
1756  _payload_,  // placeholder (unimplemented)
1757}
1758
1759packet HostBufferSize : CommandPacket (op_code = HOST_BUFFER_SIZE) {
1760  host_acl_data_packet_length : 16,
1761  host_synchronous_data_packet_length : 8,
1762  host_total_num_acl_data_packets : 16,
1763  host_total_num_synchronous_data_packets : 16,
1764}
1765
1766packet HostBufferSizeComplete : CommandComplete (command_op_code = HOST_BUFFER_SIZE) {
1767  status : ErrorCode,
1768}
1769
1770struct CompletedPackets {
1771  connection_handle : 12,
1772  _reserved_ : 4,
1773  host_num_of_completed_packets : 16,
1774}
1775
1776packet HostNumCompletedPackets : CommandPacket (op_code = HOST_NUM_COMPLETED_PACKETS) {
1777  _count_(completed_packets) : 8,
1778  completed_packets : CompletedPackets[],
1779}
1780
1781packet HostNumCompletedPacketsError : CommandComplete (command_op_code = HOST_NUM_COMPLETED_PACKETS) {
1782  error_code : ErrorCode,
1783}
1784
1785packet ReadLinkSupervisionTimeout : ConnectionManagementCommand (op_code = READ_LINK_SUPERVISION_TIMEOUT) {
1786  connection_handle : 12,
1787  _reserved_ : 4,
1788}
1789
1790packet ReadLinkSupervisionTimeoutComplete : CommandComplete (command_op_code = READ_LINK_SUPERVISION_TIMEOUT) {
1791  status : ErrorCode,
1792  connection_handle : 12,
1793  _reserved_ : 4,
1794  link_supervision_timeout : 16, // 0x001-0xFFFF (0.625ms-40.9s)
1795}
1796
1797packet WriteLinkSupervisionTimeout : ConnectionManagementCommand (op_code = WRITE_LINK_SUPERVISION_TIMEOUT) {
1798  connection_handle : 12,
1799  _reserved_ : 4,
1800  link_supervision_timeout : 16, // 0x001-0xFFFF (0.625ms-40.9s)
1801}
1802
1803packet WriteLinkSupervisionTimeoutComplete : CommandComplete (command_op_code = WRITE_LINK_SUPERVISION_TIMEOUT) {
1804  status : ErrorCode,
1805  connection_handle : 12,
1806  _reserved_ : 4,
1807}
1808
1809packet ReadNumberOfSupportedIac : DiscoveryCommand (op_code = READ_NUMBER_OF_SUPPORTED_IAC) {
1810}
1811
1812packet ReadNumberOfSupportedIacComplete : CommandComplete (command_op_code = READ_NUMBER_OF_SUPPORTED_IAC) {
1813  status : ErrorCode,
1814  num_support_iac : 8,
1815}
1816
1817packet ReadCurrentIacLap : DiscoveryCommand (op_code = READ_CURRENT_IAC_LAP) {
1818}
1819
1820packet ReadCurrentIacLapComplete : CommandComplete (command_op_code = READ_CURRENT_IAC_LAP) {
1821  status : ErrorCode,
1822  _count_(laps_to_read) : 8,
1823  laps_to_read : Lap[],
1824}
1825
1826packet WriteCurrentIacLap : DiscoveryCommand (op_code = WRITE_CURRENT_IAC_LAP) {
1827  _count_(laps_to_write) : 8,
1828  laps_to_write : Lap[],
1829}
1830
1831packet WriteCurrentIacLapComplete : CommandComplete (command_op_code = WRITE_CURRENT_IAC_LAP) {
1832  status : ErrorCode,
1833}
1834
1835packet SetAfhHostChannelClassification : CommandPacket (op_code = SET_AFH_HOST_CHANNEL_CLASSIFICATION) {
1836  afh_host_channel_classification : 8[10],
1837}
1838
1839packet SetAfhHostChannelClassificationComplete : CommandComplete (command_op_code = SET_AFH_HOST_CHANNEL_CLASSIFICATION) {
1840  status : ErrorCode,
1841}
1842
1843enum InquiryScanType : 8 {
1844  STANDARD = 0x00,
1845  INTERLACED = 0x01,
1846}
1847
1848packet ReadInquiryScanType : DiscoveryCommand (op_code = READ_INQUIRY_SCAN_TYPE) {
1849}
1850
1851packet ReadInquiryScanTypeComplete : CommandComplete (command_op_code = READ_INQUIRY_SCAN_TYPE) {
1852  status : ErrorCode,
1853  inquiry_scan_type : InquiryScanType,
1854}
1855
1856packet WriteInquiryScanType : DiscoveryCommand (op_code = WRITE_INQUIRY_SCAN_TYPE) {
1857  inquiry_scan_type : InquiryScanType,
1858}
1859
1860packet WriteInquiryScanTypeComplete : CommandComplete (command_op_code = WRITE_INQUIRY_SCAN_TYPE) {
1861  status : ErrorCode,
1862}
1863
1864enum InquiryMode : 8 {
1865  STANDARD = 0x00,
1866  RSSI = 0x01,
1867  RSSI_OR_EXTENDED = 0x02,
1868}
1869
1870packet ReadInquiryMode : DiscoveryCommand (op_code = READ_INQUIRY_MODE) {
1871}
1872
1873packet ReadInquiryModeComplete : CommandComplete (command_op_code = READ_INQUIRY_MODE) {
1874  status : ErrorCode,
1875  inquiry_mode : InquiryMode,
1876}
1877
1878packet WriteInquiryMode : DiscoveryCommand (op_code = WRITE_INQUIRY_MODE) {
1879  inquiry_mode : InquiryMode,
1880}
1881
1882packet WriteInquiryModeComplete : CommandComplete (command_op_code = WRITE_INQUIRY_MODE) {
1883  status : ErrorCode,
1884}
1885
1886enum PageScanType : 8 {
1887  STANDARD = 0x00,
1888  INTERLACED = 0x01,
1889}
1890
1891packet ReadPageScanType : DiscoveryCommand (op_code = READ_PAGE_SCAN_TYPE) {
1892}
1893
1894packet ReadPageScanTypeComplete : CommandComplete (command_op_code = READ_PAGE_SCAN_TYPE) {
1895  status : ErrorCode,
1896  page_scan_type : PageScanType,
1897}
1898
1899packet WritePageScanType : DiscoveryCommand (op_code = WRITE_PAGE_SCAN_TYPE) {
1900  page_scan_type : PageScanType,
1901}
1902
1903packet WritePageScanTypeComplete : CommandComplete (command_op_code = WRITE_PAGE_SCAN_TYPE) {
1904  status : ErrorCode,
1905}
1906
1907packet ReadAfhChannelAssessmentMode : CommandPacket (op_code = READ_AFH_CHANNEL_ASSESSMENT_MODE) {
1908  _payload_,  // placeholder (unimplemented)
1909}
1910
1911packet WriteAfhChannelAssessmentMode : CommandPacket (op_code = WRITE_AFH_CHANNEL_ASSESSMENT_MODE) {
1912  _payload_,  // placeholder (unimplemented)
1913}
1914
1915enum FecRequired : 8 {
1916  NOT_REQUIRED = 0x00,
1917  REQUIRED = 0x01,
1918}
1919
1920packet ReadExtendedInquiryResponse : CommandPacket (op_code = READ_EXTENDED_INQUIRY_RESPONSE) {
1921}
1922
1923packet ReadExtendedInquiryResponseComplete : CommandComplete (command_op_code = READ_EXTENDED_INQUIRY_RESPONSE) {
1924  status : ErrorCode,
1925  fec_required : FecRequired,
1926  extended_inquiry_response : GapData[],
1927}
1928
1929packet WriteExtendedInquiryResponse : CommandPacket (op_code = WRITE_EXTENDED_INQUIRY_RESPONSE) {
1930  fec_required : FecRequired,
1931  extended_inquiry_response : GapData[],
1932  _padding_[244], // Zero padding to be 240 octets (GapData[]) + 2 (opcode) + 1 (size) + 1 (FecRequired)
1933}
1934
1935packet WriteExtendedInquiryResponseComplete : CommandComplete (command_op_code = WRITE_EXTENDED_INQUIRY_RESPONSE) {
1936  status : ErrorCode,
1937}
1938
1939packet RefreshEncryptionKey : SecurityCommand (op_code = REFRESH_ENCRYPTION_KEY) {
1940  connection_handle : 12,
1941  _reserved_ : 4,
1942}
1943
1944packet RefreshEncryptionKeyStatus : CommandStatus (command_op_code = REFRESH_ENCRYPTION_KEY) {
1945}
1946
1947packet ReadSimplePairingMode : SecurityCommand (op_code = READ_SIMPLE_PAIRING_MODE) {
1948}
1949
1950packet ReadSimplePairingModeComplete : CommandComplete (command_op_code = READ_SIMPLE_PAIRING_MODE) {
1951  status : ErrorCode,
1952  simple_pairing_mode : Enable,
1953}
1954
1955packet WriteSimplePairingMode : SecurityCommand (op_code = WRITE_SIMPLE_PAIRING_MODE) {
1956  simple_pairing_mode : Enable,
1957}
1958
1959packet WriteSimplePairingModeComplete : CommandComplete (command_op_code = WRITE_SIMPLE_PAIRING_MODE) {
1960  status : ErrorCode,
1961}
1962
1963packet ReadLocalOobData : SecurityCommand (op_code = READ_LOCAL_OOB_DATA) {
1964}
1965
1966packet ReadLocalOobDataComplete : CommandComplete (command_op_code = READ_LOCAL_OOB_DATA) {
1967  status : ErrorCode,
1968  c : 8[16],
1969  r : 8[16],
1970}
1971
1972packet ReadInquiryResponseTransmitPowerLevel : DiscoveryCommand (op_code = READ_INQUIRY_RESPONSE_TRANSMIT_POWER_LEVEL) {
1973}
1974
1975packet ReadInquiryResponseTransmitPowerLevelComplete : CommandComplete (command_op_code = READ_INQUIRY_RESPONSE_TRANSMIT_POWER_LEVEL) {
1976  status : ErrorCode,
1977  tx_power : 8, // (-70dBm to 20dBm)
1978}
1979
1980packet WriteInquiryTransmitPowerLevel : DiscoveryCommand (op_code = WRITE_INQUIRY_TRANSMIT_POWER_LEVEL) {
1981  tx_power : 8,
1982}
1983
1984packet WriteInquiryResponseTransmitPowerLevelComplete : CommandComplete (command_op_code = WRITE_INQUIRY_TRANSMIT_POWER_LEVEL) {
1985  status : ErrorCode,
1986}
1987
1988enum KeypressNotificationType : 8 {
1989  ENTRY_STARTED = 0,
1990  DIGIT_ENTERED = 1,
1991  DIGIT_ERASED = 2,
1992  CLEARED = 3,
1993  ENTRY_COMPLETED = 4,
1994}
1995
1996packet SendKeypressNotification : SecurityCommand (op_code = SEND_KEYPRESS_NOTIFICATION) {
1997  bd_addr : Address,
1998  notification_type : KeypressNotificationType,
1999}
2000
2001packet SendKeypressNotificationComplete : CommandComplete (command_op_code = SEND_KEYPRESS_NOTIFICATION) {
2002  status : ErrorCode,
2003  bd_addr : Address,
2004}
2005
2006enum SimultaneousLeHost : 8 {
2007  DISABLED = 0x00,
2008}
2009
2010packet ReadLeHostSupport : CommandPacket (op_code = READ_LE_HOST_SUPPORT) {
2011}
2012
2013packet ReadLeHostSupportComplete : CommandComplete (command_op_code = READ_LE_HOST_SUPPORT) {
2014  status : ErrorCode,
2015  le_supported_host : Enable,
2016  simultaneous_le_host : SimultaneousLeHost,
2017}
2018
2019packet WriteLeHostSupport : CommandPacket (op_code = WRITE_LE_HOST_SUPPORT) {
2020  le_supported_host : Enable,
2021  simultaneous_le_host : SimultaneousLeHost,
2022}
2023
2024packet WriteLeHostSupportComplete : CommandComplete (command_op_code = WRITE_LE_HOST_SUPPORT) {
2025  status : ErrorCode,
2026}
2027
2028packet ReadSecureConnectionsHostSupport : CommandPacket (op_code = READ_SECURE_CONNECTIONS_HOST_SUPPORT) {
2029}
2030
2031packet ReadSecureConnectionsHostSupportComplete : CommandComplete (command_op_code = READ_SECURE_CONNECTIONS_HOST_SUPPORT) {
2032  status : ErrorCode,
2033  secure_connections_host_support : Enable,
2034}
2035
2036packet WriteSecureConnectionsHostSupport : SecurityCommand (op_code = WRITE_SECURE_CONNECTIONS_HOST_SUPPORT) {
2037  secure_connections_host_support : Enable,
2038}
2039
2040packet WriteSecureConnectionsHostSupportComplete : CommandComplete (command_op_code = WRITE_SECURE_CONNECTIONS_HOST_SUPPORT) {
2041  status : ErrorCode,
2042}
2043
2044packet ReadLocalOobExtendedData : SecurityCommand (op_code = READ_LOCAL_OOB_EXTENDED_DATA) {
2045}
2046
2047packet ReadLocalOobExtendedDataComplete : CommandComplete (command_op_code = READ_LOCAL_OOB_EXTENDED_DATA) {
2048  status : ErrorCode,
2049  c_192 : 8[16],
2050  r_192 : 8[16],
2051  c_256 : 8[16],
2052  r_256 : 8[16],
2053}
2054
2055packet SetEcosystemBaseInterval : CommandPacket (op_code = SET_ECOSYSTEM_BASE_INTERVAL) {
2056  interval : 16,
2057}
2058
2059packet SetEcosystemBaseIntervalComplete : CommandComplete (command_op_code = SET_ECOSYSTEM_BASE_INTERVAL) {
2060  status : ErrorCode,
2061}
2062
2063enum DataPathDirection : 8 {
2064  INPUT = 0,
2065  OUTPUT = 1,
2066}
2067
2068packet ConfigureDataPath : CommandPacket (op_code = CONFIGURE_DATA_PATH) {
2069  data_path_direction : DataPathDirection,
2070  data_path_id : 8,
2071  _size_(vendor_specific_config) : 8,
2072  vendor_specific_config : 8[],
2073}
2074
2075packet ConfigureDataPathComplete : CommandComplete (command_op_code = CONFIGURE_DATA_PATH) {
2076  status : ErrorCode,
2077}
2078
2079
2080  // INFORMATIONAL_PARAMETERS
2081packet ReadLocalVersionInformation : CommandPacket (op_code = READ_LOCAL_VERSION_INFORMATION) {
2082}
2083
2084enum HciVersion : 8 {
2085  V_1_0B = 0x00,
2086  V_1_1 = 0x01,
2087  V_1_2 = 0x02,
2088  V_2_0 = 0x03, //  + EDR
2089  V_2_1 = 0x04, //  + EDR
2090  V_3_0 = 0x05, //  + HS
2091  V_4_0 = 0x06,
2092  V_4_1 = 0x07,
2093  V_4_2 = 0x08,
2094  V_5_0 = 0x09,
2095  V_5_1 = 0x0a,
2096}
2097
2098enum LmpVersion : 8 {
2099  V_1_0B = 0x00, // withdrawn
2100  V_1_1 = 0x01, // withdrawn
2101  V_1_2 = 0x02, // withdrawn
2102  V_2_0 = 0x03, //  + EDR
2103  V_2_1 = 0x04, //  + EDR
2104  V_3_0 = 0x05, //  + HS
2105  V_4_0 = 0x06,
2106  V_4_1 = 0x07,
2107  V_4_2 = 0x08,
2108  V_5_0 = 0x09,
2109  V_5_1 = 0x0a,
2110}
2111
2112struct LocalVersionInformation {
2113  hci_version : HciVersion,
2114  hci_revision : 16,
2115  lmp_version : LmpVersion,
2116  manufacturer_name : 16,
2117  lmp_subversion : 16,
2118}
2119
2120packet ReadLocalVersionInformationComplete : CommandComplete (command_op_code = READ_LOCAL_VERSION_INFORMATION) {
2121  status : ErrorCode,
2122  local_version_information : LocalVersionInformation,
2123}
2124
2125packet ReadLocalSupportedCommands : CommandPacket (op_code = READ_LOCAL_SUPPORTED_COMMANDS) {
2126}
2127
2128packet ReadLocalSupportedCommandsComplete : CommandComplete (command_op_code = READ_LOCAL_SUPPORTED_COMMANDS) {
2129  status : ErrorCode,
2130  supported_commands : 8[64],
2131}
2132
2133packet ReadLocalSupportedFeatures : CommandPacket (op_code = READ_LOCAL_SUPPORTED_FEATURES) {
2134}
2135
2136packet ReadLocalSupportedFeaturesComplete : CommandComplete (command_op_code = READ_LOCAL_SUPPORTED_FEATURES) {
2137  status : ErrorCode,
2138  lmp_features : 64,
2139}
2140
2141packet ReadLocalExtendedFeatures : CommandPacket (op_code = READ_LOCAL_EXTENDED_FEATURES) {
2142  page_number : 8,
2143}
2144
2145packet ReadLocalExtendedFeaturesComplete : CommandComplete (command_op_code = READ_LOCAL_EXTENDED_FEATURES) {
2146  status : ErrorCode,
2147  page_number : 8,
2148  maximum_page_number : 8,
2149  extended_lmp_features : 64,
2150}
2151
2152packet ReadBufferSize : CommandPacket (op_code = READ_BUFFER_SIZE) {
2153}
2154
2155packet ReadBufferSizeComplete : CommandComplete (command_op_code = READ_BUFFER_SIZE) {
2156  status : ErrorCode,
2157  acl_data_packet_length : 16,
2158  synchronous_data_packet_length : 8,
2159  total_num_acl_data_packets : 16,
2160  total_num_synchronous_data_packets : 16,
2161}
2162
2163packet ReadBdAddr : CommandPacket (op_code = READ_BD_ADDR) {
2164}
2165
2166packet ReadBdAddrComplete : CommandComplete (command_op_code = READ_BD_ADDR) {
2167  status : ErrorCode,
2168  bd_addr : Address,
2169}
2170
2171packet ReadDataBlockSize : CommandPacket (op_code = READ_DATA_BLOCK_SIZE) {
2172}
2173
2174packet ReadLocalSupportedCodecsV1 : CommandPacket (op_code = READ_LOCAL_SUPPORTED_CODECS_V1) {
2175}
2176
2177packet ReadLocalSupportedCodecsV1Complete : CommandComplete (command_op_code = READ_LOCAL_SUPPORTED_CODECS_V1) {
2178  status : ErrorCode,
2179  _size_(supported_codecs) : 8,
2180  supported_codecs : 8[],
2181  _size_(vendor_specific_codecs) : 8,
2182  vendor_specific_codecs : 32[],
2183}
2184
2185packet ReadLocalSupportedCodecsV2 : CommandPacket (op_code = READ_LOCAL_SUPPORTED_CODECS_V2) {
2186}
2187
2188group CodecTransport {
2189  br_edr : 1,
2190  br_edr_sco_and_esco : 1,
2191  le_cis : 1,
2192  le_bis : 1,
2193  _reserved_ : 4,
2194}
2195
2196struct CodecConfiguration {
2197  codec_id : 8,
2198  CodecTransport,
2199}
2200
2201struct VendorCodecConfiguration {
2202  company_id : 16,
2203  codec_vendor_id : 16,
2204  CodecTransport,
2205}
2206
2207packet ReadLocalSupportedCodecsV2Complete : CommandComplete (command_op_code = READ_LOCAL_SUPPORTED_CODECS_V2) {
2208  status : ErrorCode,
2209  _size_(supported_codecs) : 8,
2210  supported_codecs : CodecConfiguration[],
2211  _size_(vendor_specific_codecs) : 8,
2212  vendor_specific_codecs : VendorCodecConfiguration[],
2213}
2214
2215packet ReadLocalSupportedCodecCapabilities : CommandPacket (op_code = READ_LOCAL_SUPPORTED_CODEC_CAPABILITIES) {
2216  codec_id : 8,
2217  company_id : 16,
2218  codec_vendor_id : 16,
2219  CodecTransport,
2220  direction : DataPathDirection,
2221}
2222
2223struct CodecCapability {
2224  _size_(capability) : 8,
2225  capability : 8[],
2226}
2227
2228packet ReadLocalSupportedCodecCapabilitiesComplete : CommandComplete (command_op_code = READ_LOCAL_SUPPORTED_CODEC_CAPABILITIES) {
2229  status : ErrorCode,
2230  _count_(codec_capabilities) : 8,
2231  codec_capabilities : CodecCapability[],
2232}
2233
2234packet ReadLocalSupportedControllerDelay : CommandPacket (op_code = READ_LOCAL_SUPPORTED_CONTROLLER_DELAY) {
2235  codec_id : 8,
2236  company_id : 16,
2237  codec_vendor_id : 16,
2238  CodecTransport,
2239  direction : DataPathDirection,
2240  _size_(codec_configuration) : 8,
2241  codec_configuration : 8[],
2242}
2243
2244packet ReadLocalSupportedControllerDelayComplete : CommandComplete (command_op_code = READ_LOCAL_SUPPORTED_CONTROLLER_DELAY) {
2245  status : ErrorCode,
2246  min_controller_delay : 24,
2247  max_controller_delay : 24,
2248}
2249
2250
2251  // STATUS_PARAMETERS
2252packet ReadFailedContactCounter : ConnectionManagementCommand (op_code = READ_FAILED_CONTACT_COUNTER) {
2253  connection_handle : 12,
2254  _reserved_ : 4,
2255}
2256
2257packet ReadFailedContactCounterComplete : CommandComplete (command_op_code = READ_FAILED_CONTACT_COUNTER) {
2258  status : ErrorCode,
2259  connection_handle : 12,
2260  _reserved_ : 4,
2261  failed_contact_counter : 16,
2262}
2263
2264packet ResetFailedContactCounter : ConnectionManagementCommand (op_code = RESET_FAILED_CONTACT_COUNTER) {
2265  connection_handle : 12,
2266  _reserved_ : 4,
2267}
2268
2269packet ResetFailedContactCounterComplete : CommandComplete (command_op_code = RESET_FAILED_CONTACT_COUNTER) {
2270  status : ErrorCode,
2271  connection_handle : 12,
2272  _reserved_ : 4,
2273}
2274
2275packet ReadLinkQuality : ConnectionManagementCommand (op_code = READ_LINK_QUALITY) {
2276  connection_handle : 12,
2277  _reserved_ : 4,
2278}
2279
2280packet ReadLinkQualityComplete : CommandComplete (command_op_code = READ_LINK_QUALITY) {
2281  status : ErrorCode,
2282  connection_handle : 12,
2283  _reserved_ : 4,
2284  link_quality : 8,
2285}
2286
2287packet ReadRssi : ConnectionManagementCommand (op_code = READ_RSSI) {
2288  connection_handle : 12,
2289  _reserved_ : 4,
2290}
2291
2292packet ReadRssiComplete : CommandComplete (command_op_code = READ_RSSI) {
2293  status : ErrorCode,
2294  connection_handle : 12,
2295  _reserved_ : 4,
2296  rssi : 8,
2297}
2298
2299packet ReadAfhChannelMap : ConnectionManagementCommand (op_code = READ_AFH_CHANNEL_MAP) {
2300  connection_handle : 12,
2301  _reserved_ : 4,
2302}
2303
2304enum AfhMode : 8 {
2305  AFH_DISABLED = 0x00,
2306  AFH_ENABLED = 0x01,
2307}
2308
2309packet ReadAfhChannelMapComplete : CommandComplete (command_op_code = READ_AFH_CHANNEL_MAP) {
2310  status : ErrorCode,
2311  connection_handle : 12,
2312  _reserved_ : 4,
2313  afh_mode : AfhMode,
2314  afh_channel_map : 8[10],
2315}
2316
2317
2318enum WhichClock : 8 {
2319  LOCAL = 0x00,
2320  PICONET = 0x01,
2321}
2322
2323packet ReadClock : ConnectionManagementCommand (op_code = READ_CLOCK) {
2324  connection_handle : 12,
2325  _reserved_ : 4,
2326  which_clock : WhichClock,
2327}
2328
2329packet ReadClockComplete : CommandComplete (command_op_code = READ_CLOCK) {
2330  status : ErrorCode,
2331  connection_handle : 12,
2332  _reserved_ : 4,
2333  clock : 28,
2334  _reserved_ : 4,
2335  accuracy : 16,
2336}
2337
2338packet ReadEncryptionKeySize : SecurityCommand (op_code = READ_ENCRYPTION_KEY_SIZE) {
2339  connection_handle : 12,
2340  _reserved_ : 4,
2341}
2342
2343packet ReadEncryptionKeySizeComplete : CommandComplete (command_op_code = READ_ENCRYPTION_KEY_SIZE) {
2344  status : ErrorCode,
2345  connection_handle : 12,
2346  _reserved_ : 4,
2347  key_size : 8,
2348}
2349
2350  // TESTING
2351enum LoopbackMode : 8 {
2352  NO_LOOPBACK = 0x00,
2353  ENABLE_LOCAL = 0x01,
2354  ENABLE_REMOTE = 0x02,
2355}
2356
2357packet ReadLoopbackMode : CommandPacket (op_code = READ_LOOPBACK_MODE) {
2358}
2359
2360packet ReadLoopbackModeComplete : CommandComplete (command_op_code = READ_LOOPBACK_MODE) {
2361  status : ErrorCode,
2362  loopback_mode : LoopbackMode,
2363}
2364
2365packet WriteLoopbackMode : CommandPacket (op_code = WRITE_LOOPBACK_MODE) {
2366  loopback_mode : LoopbackMode,
2367}
2368
2369packet WriteLoopbackModeComplete : CommandComplete (command_op_code = WRITE_LOOPBACK_MODE) {
2370  status : ErrorCode,
2371}
2372
2373packet EnableDeviceUnderTestMode : CommandPacket (op_code = ENABLE_DEVICE_UNDER_TEST_MODE) {
2374}
2375
2376packet EnableDeviceUnderTestModeComplete : CommandComplete (command_op_code = ENABLE_DEVICE_UNDER_TEST_MODE) {
2377  status : ErrorCode,
2378}
2379
2380packet WriteSimplePairingDebugMode : SecurityCommand (op_code = WRITE_SIMPLE_PAIRING_DEBUG_MODE) {
2381  simple_pairing_debug_mode : Enable,
2382}
2383
2384packet WriteSimplePairingDebugModeComplete : CommandComplete (command_op_code = WRITE_SIMPLE_PAIRING_DEBUG_MODE) {
2385  status : ErrorCode,
2386}
2387
2388packet WriteSecureConnectionsTestMode : CommandPacket (op_code = WRITE_SECURE_CONNECTIONS_TEST_MODE) {
2389  connection_handle : 12,
2390  _reserved_ : 4,
2391  dm1_aclu_mode : Enable,
2392  esco_loopback_mode : Enable,
2393}
2394
2395packet WriteSecureConnectionsTestModeComplete : CommandComplete (command_op_code = WRITE_SECURE_CONNECTIONS_TEST_MODE) {
2396  status : ErrorCode,
2397}
2398
2399  // LE_CONTROLLER
2400packet LeSetEventMask : CommandPacket (op_code = LE_SET_EVENT_MASK) {
2401  le_event_mask : 64,
2402}
2403
2404packet LeSetEventMaskComplete : CommandComplete (command_op_code = LE_SET_EVENT_MASK) {
2405  status : ErrorCode,
2406}
2407
2408packet LeReadBufferSizeV1 : CommandPacket (op_code = LE_READ_BUFFER_SIZE_V1) {
2409}
2410
2411struct LeBufferSize {
2412  le_data_packet_length : 16,
2413  total_num_le_packets : 8,
2414}
2415
2416packet LeReadBufferSizeV1Complete : CommandComplete (command_op_code = LE_READ_BUFFER_SIZE_V1) {
2417  status : ErrorCode,
2418  le_buffer_size : LeBufferSize,
2419}
2420
2421packet LeReadLocalSupportedFeatures : CommandPacket (op_code = LE_READ_LOCAL_SUPPORTED_FEATURES) {
2422}
2423
2424packet LeReadLocalSupportedFeaturesComplete : CommandComplete (command_op_code = LE_READ_LOCAL_SUPPORTED_FEATURES) {
2425  status : ErrorCode,
2426  le_features : 64,
2427}
2428
2429packet LeSetRandomAddress : LeAdvertisingCommand (op_code = LE_SET_RANDOM_ADDRESS) {
2430  random_address : Address,
2431}
2432
2433packet LeSetRandomAddressComplete : CommandComplete (command_op_code = LE_SET_RANDOM_ADDRESS) {
2434  status : ErrorCode,
2435}
2436
2437enum AdvertisingFilterPolicy : 2 {
2438  ALL_DEVICES = 0, // Default
2439  LISTED_SCAN = 1,
2440  LISTED_CONNECT = 2,
2441  LISTED_SCAN_AND_CONNECT = 3,
2442}
2443
2444enum PeerAddressType : 8 {
2445  PUBLIC_DEVICE_OR_IDENTITY_ADDRESS = 0x00,
2446  RANDOM_DEVICE_OR_IDENTITY_ADDRESS = 0x01,
2447}
2448
2449enum AdvertisingType : 8 {
2450  ADV_IND = 0x00,
2451  ADV_DIRECT_IND = 0x01,
2452  ADV_SCAN_IND = 0x02,
2453  ADV_NONCONN_IND = 0x03,
2454  ADV_DIRECT_IND_LOW = 0x04,
2455}
2456
2457enum AddressType : 8 {
2458  PUBLIC_DEVICE_ADDRESS = 0x00,
2459  RANDOM_DEVICE_ADDRESS = 0x01,
2460  PUBLIC_IDENTITY_ADDRESS = 0x02,
2461  RANDOM_IDENTITY_ADDRESS = 0x03,
2462}
2463
2464packet LeSetAdvertisingParameters : LeAdvertisingCommand (op_code = LE_SET_ADVERTISING_PARAMETERS) {
2465  interval_min : 16,
2466  interval_max : 16,
2467  type : AdvertisingType,
2468  own_address_type : AddressType,
2469  peer_address_type : PeerAddressType,
2470  peer_address : Address,
2471  channel_map : 8,
2472  filter_policy : AdvertisingFilterPolicy,
2473  _reserved_ : 6,
2474}
2475
2476packet LeSetAdvertisingParametersComplete : CommandComplete (command_op_code = LE_SET_ADVERTISING_PARAMETERS) {
2477  status : ErrorCode,
2478}
2479
2480packet LeReadAdvertisingChannelTxPower : LeAdvertisingCommand (op_code = LE_READ_ADVERTISING_CHANNEL_TX_POWER) {
2481}
2482
2483packet LeReadAdvertisingChannelTxPowerComplete : CommandComplete (command_op_code = LE_READ_ADVERTISING_CHANNEL_TX_POWER) {
2484  status : ErrorCode,
2485  transmit_power_level : 8, // (-20dBm to 10dBm) Accuracy: +/-4dB
2486}
2487
2488packet LeSetAdvertisingData : LeAdvertisingCommand (op_code = LE_SET_ADVERTISING_DATA) {
2489  _size_(advertising_data) : 8,
2490  advertising_data : GapData[],
2491  _padding_[35], // Zero padding to 31 bytes of advertising_data + 1 size + 2 opcode + 1 total_size
2492}
2493
2494packet LeSetAdvertisingDataComplete : CommandComplete (command_op_code = LE_SET_ADVERTISING_DATA) {
2495  status : ErrorCode,
2496}
2497
2498packet LeSetScanResponseData : LeAdvertisingCommand (op_code = LE_SET_SCAN_RESPONSE_DATA) {
2499  _size_(advertising_data) : 8,
2500  advertising_data : GapData[],
2501  _padding_[35], // Zero padding to 31 bytes of advertising_data + 1 size + 2 opcode + 1 total_size
2502}
2503
2504packet LeSetScanResponseDataComplete : CommandComplete (command_op_code = LE_SET_SCAN_RESPONSE_DATA) {
2505  status : ErrorCode,
2506}
2507
2508packet LeSetAdvertisingEnable : LeAdvertisingCommand (op_code = LE_SET_ADVERTISING_ENABLE) {
2509  advertising_enable : Enable, // Default DISABLED
2510}
2511
2512packet LeSetAdvertisingEnableComplete : CommandComplete (command_op_code = LE_SET_ADVERTISING_ENABLE) {
2513  status : ErrorCode,
2514}
2515
2516enum LeScanType : 8 {
2517  PASSIVE = 0x00, // Default
2518  ACTIVE = 0x01,
2519}
2520
2521enum LeScanningFilterPolicy : 8 {
2522  ACCEPT_ALL = 0x00, // Default
2523  CONNECT_LIST_ONLY = 0x01,
2524  CHECK_INITIATORS_IDENTITY = 0x02,
2525  CONNECT_LIST_AND_INITIATORS_IDENTITY = 0x03,
2526}
2527
2528packet LeSetScanParameters : LeScanningCommand (op_code = LE_SET_SCAN_PARAMETERS) {
2529  le_scan_type : LeScanType,
2530  le_scan_interval : 16, // 0x0004-0x4000 Default 0x10 (10ms)
2531  le_scan_window : 16, // Default 0x10 (10ms)
2532  own_address_type : AddressType,
2533  scanning_filter_policy : LeScanningFilterPolicy,
2534}
2535
2536packet LeSetScanParametersComplete : CommandComplete (command_op_code = LE_SET_SCAN_PARAMETERS) {
2537  status : ErrorCode,
2538}
2539
2540packet LeSetScanEnable : LeScanningCommand (op_code = LE_SET_SCAN_ENABLE) {
2541  le_scan_enable : Enable,
2542  filter_duplicates : Enable,
2543}
2544
2545packet LeSetScanEnableComplete : CommandComplete (command_op_code = LE_SET_SCAN_ENABLE) {
2546  status : ErrorCode,
2547}
2548
2549enum InitiatorFilterPolicy : 8 {
2550  USE_PEER_ADDRESS = 0x00,
2551  USE_CONNECT_LIST = 0x01,
2552}
2553
2554enum OwnAddressType : 8 {
2555  PUBLIC_DEVICE_ADDRESS = 0x00,
2556  RANDOM_DEVICE_ADDRESS = 0x01,
2557  RESOLVABLE_OR_PUBLIC_ADDRESS = 0x02,
2558  RESOLVABLE_OR_RANDOM_ADDRESS = 0x03,
2559}
2560
2561packet LeCreateConnection : LeConnectionManagementCommand (op_code = LE_CREATE_CONNECTION) {
2562  le_scan_interval : 16, // 0x0004-0x4000
2563  le_scan_window : 16, // < = LeScanInterval
2564  initiator_filter_policy : InitiatorFilterPolicy,
2565  peer_address_type : AddressType,
2566  peer_address : Address,
2567  own_address_type : OwnAddressType,
2568  conn_interval_min : 16, // 0x0006-0x0C80 (7.5ms to 4s)
2569  conn_interval_max : 16, // 0x0006-0x0C80 (7.5ms to 4s)
2570  conn_latency : 16, // 0x0006-0x01F3
2571  supervision_timeout : 16, // 0x00A to 0x0C80 (100ms to 32s)
2572  minimum_ce_length : 16, // 0.625ms
2573  maximum_ce_length : 16, // 0.625ms
2574}
2575
2576packet LeCreateConnectionStatus : CommandStatus (command_op_code = LE_CREATE_CONNECTION) {
2577}
2578
2579packet LeCreateConnectionCancel : LeConnectionManagementCommand (op_code = LE_CREATE_CONNECTION_CANCEL) {
2580}
2581
2582packet LeCreateConnectionCancelComplete : CommandComplete (command_op_code = LE_CREATE_CONNECTION_CANCEL) {
2583  status : ErrorCode,
2584}
2585
2586packet LeReadConnectListSize : CommandPacket (op_code = LE_READ_CONNECT_LIST_SIZE) {
2587}
2588
2589packet LeReadConnectListSizeComplete : CommandComplete (command_op_code = LE_READ_CONNECT_LIST_SIZE) {
2590  status : ErrorCode,
2591  connect_list_size : 8,
2592}
2593
2594packet LeClearConnectList : LeConnectionManagementCommand (op_code = LE_CLEAR_CONNECT_LIST) {
2595}
2596
2597packet LeClearConnectListComplete : CommandComplete (command_op_code = LE_CLEAR_CONNECT_LIST) {
2598  status : ErrorCode,
2599}
2600
2601enum ConnectListAddressType : 8 {
2602  PUBLIC = 0x00,
2603  RANDOM = 0x01,
2604  ANONYMOUS_ADVERTISERS = 0xFF,
2605}
2606
2607packet LeAddDeviceToConnectList : LeConnectionManagementCommand (op_code = LE_ADD_DEVICE_TO_CONNECT_LIST) {
2608  address_type : ConnectListAddressType,
2609  address : Address,
2610}
2611
2612packet LeAddDeviceToConnectListComplete : CommandComplete (command_op_code = LE_ADD_DEVICE_TO_CONNECT_LIST) {
2613  status : ErrorCode,
2614}
2615
2616packet LeRemoveDeviceFromConnectList : LeConnectionManagementCommand (op_code = LE_REMOVE_DEVICE_FROM_CONNECT_LIST) {
2617  address_type : ConnectListAddressType,
2618  address : Address,
2619}
2620
2621packet LeRemoveDeviceFromConnectListComplete : CommandComplete (command_op_code = LE_REMOVE_DEVICE_FROM_CONNECT_LIST) {
2622  status : ErrorCode,
2623}
2624
2625packet LeConnectionUpdate : LeConnectionManagementCommand (op_code = LE_CONNECTION_UPDATE) {
2626  connection_handle : 12,
2627  _reserved_ : 4,
2628  conn_interval_min : 16, // 0x0006-0x0C80 (7.5ms to 4s)
2629  conn_interval_max : 16, // 0x0006-0x0C80 (7.5ms to 4s)
2630  conn_latency : 16, // 0x0006-0x01F3
2631  supervision_timeout : 16, // 0x00A to 0x0C80 (100ms to 32s)
2632  minimum_ce_length : 16, // 0.625ms
2633  maximum_ce_length : 16, // 0.625ms
2634}
2635
2636packet LeConnectionUpdateStatus : CommandStatus (command_op_code = LE_CONNECTION_UPDATE) {
2637}
2638
2639packet LeSetHostChannelClassification : LeConnectionManagementCommand (op_code = LE_SET_HOST_CHANNEL_CLASSIFICATION) {
2640  channel_map : 8[5],
2641}
2642
2643packet LeSetHostChannelClassificationComplete : CommandComplete (command_op_code = LE_SET_HOST_CHANNEL_CLASSIFICATION) {
2644  status : ErrorCode,
2645}
2646
2647packet LeReadChannelMap : LeConnectionManagementCommand (op_code = LE_READ_CHANNEL_MAP) {
2648}
2649
2650packet LeReadChannelMapComplete : CommandComplete (command_op_code = LE_SET_HOST_CHANNEL_CLASSIFICATION) {
2651  status : ErrorCode,
2652  connection_handle : 12,
2653  _reserved_ : 4,
2654  channel_map : 8[5],
2655}
2656
2657packet LeReadRemoteFeatures : LeConnectionManagementCommand (op_code = LE_READ_REMOTE_FEATURES) {
2658  connection_handle : 12,
2659  _reserved_ : 4,
2660}
2661
2662packet LeEncrypt : LeSecurityCommand (op_code = LE_ENCRYPT) {
2663  key : 8[16],
2664  plaintext_data : 8[16],
2665}
2666
2667packet LeEncryptComplete : CommandComplete (command_op_code = LE_ENCRYPT) {
2668  status : ErrorCode,
2669  encrypted_data : 8[16],
2670}
2671
2672packet LeRand : LeSecurityCommand (op_code = LE_RAND) {
2673}
2674
2675packet LeRandComplete : CommandComplete (command_op_code = LE_RAND) {
2676  status : ErrorCode,
2677  random_number : 64,
2678}
2679
2680packet LeStartEncryption : LeSecurityCommand (op_code = LE_START_ENCRYPTION) {
2681  connection_handle: 16,
2682  rand: 8[8],
2683  ediv: 16,
2684  ltk: 8[16],
2685}
2686
2687packet LeStartEncryptionStatus : CommandStatus (command_op_code = LE_START_ENCRYPTION) {
2688}
2689
2690packet LeLongTermKeyRequestReply : LeSecurityCommand (op_code = LE_LONG_TERM_KEY_REQUEST_REPLY) {
2691  connection_handle: 16,
2692  long_term_key: 8[16],
2693}
2694
2695packet LeLongTermKeyRequestReplyComplete : CommandComplete (command_op_code = LE_LONG_TERM_KEY_REQUEST_REPLY) {
2696  status : ErrorCode,
2697  connection_handle : 12,
2698  _reserved_ : 4,
2699}
2700
2701packet LeLongTermKeyRequestNegativeReply : LeSecurityCommand (op_code = LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY) {
2702  connection_handle : 12,
2703  _reserved_ : 4,
2704}
2705
2706packet LeLongTermKeyRequestNegativeReplyComplete : CommandComplete (command_op_code = LE_LONG_TERM_KEY_REQUEST_NEGATIVE_REPLY) {
2707  status : ErrorCode,
2708  connection_handle : 12,
2709  _reserved_ : 4,
2710}
2711
2712packet LeReadSupportedStates : CommandPacket (op_code = LE_READ_SUPPORTED_STATES) {
2713}
2714
2715packet LeReadSupportedStatesComplete : CommandComplete (command_op_code = LE_READ_SUPPORTED_STATES) {
2716  status : ErrorCode,
2717  le_states : 64,
2718}
2719
2720packet LeReceiverTest : CommandPacket (op_code = LE_RECEIVER_TEST) {
2721  _payload_,  // placeholder (unimplemented)
2722}
2723
2724packet LeTransmitterTest : CommandPacket (op_code = LE_TRANSMITTER_TEST) {
2725  _payload_,  // placeholder (unimplemented)
2726}
2727
2728packet LeTestEnd : CommandPacket (op_code = LE_TEST_END) {
2729  _payload_,  // placeholder (unimplemented)
2730}
2731
2732packet LeRemoteConnectionParameterRequestReply : LeConnectionManagementCommand (op_code = LE_REMOTE_CONNECTION_PARAMETER_REQUEST_REPLY) {
2733  connection_handle : 12,
2734  _reserved_ : 4,
2735  interval_min : 16, // 0x0006-0x0C80 (7.5ms to 4s)
2736  interval_max : 16, // 0x0006-0x0C80 (7.5ms to 4s)
2737  latency : 16, // 0x0006-0x01F3
2738  timeout : 16, // 0x00A to 0x0C80 (100ms to 32s)
2739  minimum_ce_length : 16, // 0.625ms
2740  maximum_ce_length : 16, // 0.625ms
2741}
2742
2743packet LeRemoteConnectionParameterRequestReplyComplete : CommandComplete (command_op_code = LE_REMOTE_CONNECTION_PARAMETER_REQUEST_REPLY) {
2744  status : ErrorCode,
2745  connection_handle : 12,
2746  _reserved_ : 4,
2747}
2748
2749packet LeRemoteConnectionParameterRequestNegativeReply : LeConnectionManagementCommand (op_code = LE_REMOTE_CONNECTION_PARAMETER_REQUEST_NEGATIVE_REPLY) {
2750  connection_handle : 12,
2751  _reserved_ : 4,
2752  reason : ErrorCode,
2753}
2754
2755packet LeRemoteConnectionParameterRequestNegativeReplyComplete : CommandComplete (command_op_code = LE_REMOTE_CONNECTION_PARAMETER_REQUEST_NEGATIVE_REPLY) {
2756  status : ErrorCode,
2757  connection_handle : 12,
2758  _reserved_ : 4,
2759}
2760
2761packet LeSetDataLength : LeConnectionManagementCommand (op_code = LE_SET_DATA_LENGTH) {
2762  connection_handle : 12,
2763  _reserved_ : 4,
2764  tx_octets : 16, // payload octets per single PDU 0x1B to 0x00FB
2765  tx_time : 16, // microseconds used to transmit a single PDU 0x0148 to 0x4290
2766}
2767
2768packet LeSetDataLengthComplete : CommandComplete (command_op_code = LE_SET_DATA_LENGTH) {
2769  status : ErrorCode,
2770  connection_handle : 12,
2771  _reserved_ : 4,
2772}
2773
2774packet LeReadSuggestedDefaultDataLength : LeConnectionManagementCommand (op_code = LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH) {
2775}
2776
2777packet LeReadSuggestedDefaultDataLengthComplete : CommandComplete (command_op_code = LE_READ_SUGGESTED_DEFAULT_DATA_LENGTH) {
2778  status : ErrorCode,
2779  tx_octets : 16, // payload octets per single PDU 0x1B to 0x00FB
2780  tx_time : 16, // microseconds used to transmit a single PDU 0x0148 to 0x4290
2781}
2782
2783packet LeWriteSuggestedDefaultDataLength : LeConnectionManagementCommand (op_code = LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH) {
2784  tx_octets : 16, // payload octets per single PDU 0x1B to 0x00FB
2785  tx_time : 16, // microseconds used to transmit a single PDU 0x0148 to 0x4290
2786}
2787
2788packet LeWriteSuggestedDefaultDataLengthComplete : CommandComplete (command_op_code = LE_WRITE_SUGGESTED_DEFAULT_DATA_LENGTH) {
2789  status : ErrorCode,
2790}
2791
2792packet LeReadLocalP256PublicKeyCommand : LeSecurityCommand (op_code = LE_READ_LOCAL_P_256_PUBLIC_KEY_COMMAND) {
2793}
2794
2795packet LeGenerateDhkeyV1Command : LeSecurityCommand (op_code = LE_GENERATE_DHKEY_COMMAND_V1) {
2796  remote_p_256_public_key : 8[64],
2797}
2798
2799packet LeGenerateDhkeyV1CommandStatus : CommandStatus (command_op_code = LE_GENERATE_DHKEY_COMMAND_V1) {
2800}
2801
2802packet LeAddDeviceToResolvingList : LeSecurityCommand (op_code = LE_ADD_DEVICE_TO_RESOLVING_LIST) {
2803  peer_identity_address_type : PeerAddressType,
2804  peer_identity_address : Address,
2805  peer_irk : 8[16],
2806  local_irk : 8[16],
2807}
2808
2809packet LeAddDeviceToResolvingListComplete : CommandComplete (command_op_code = LE_ADD_DEVICE_TO_RESOLVING_LIST) {
2810  status : ErrorCode,
2811}
2812
2813packet LeRemoveDeviceFromResolvingList : LeSecurityCommand (op_code = LE_REMOVE_DEVICE_FROM_RESOLVING_LIST) {
2814  peer_identity_address_type : PeerAddressType,
2815  peer_identity_address : Address,
2816}
2817
2818packet LeRemoveDeviceFromResolvingListComplete : CommandComplete (command_op_code = LE_REMOVE_DEVICE_FROM_RESOLVING_LIST) {
2819  status : ErrorCode,
2820}
2821
2822packet LeClearResolvingList : LeSecurityCommand (op_code = LE_CLEAR_RESOLVING_LIST) {
2823}
2824
2825packet LeClearResolvingListComplete : CommandComplete (command_op_code = LE_CLEAR_RESOLVING_LIST) {
2826  status : ErrorCode,
2827}
2828
2829packet LeReadResolvingListSize : CommandPacket (op_code = LE_READ_RESOLVING_LIST_SIZE) {
2830}
2831
2832packet LeReadResolvingListSizeComplete : CommandComplete (command_op_code = LE_READ_RESOLVING_LIST_SIZE) {
2833  status : ErrorCode,
2834  resolving_list_size : 8,
2835}
2836
2837packet LeReadPeerResolvableAddress : LeSecurityCommand (op_code = LE_READ_PEER_RESOLVABLE_ADDRESS) {
2838  peer_identity_address_type : PeerAddressType,
2839  peer_identity_address : Address,
2840}
2841
2842packet LeReadPeerResolvableAddressComplete : CommandComplete (command_op_code = LE_READ_PEER_RESOLVABLE_ADDRESS) {
2843  status : ErrorCode,
2844  peer_resolvable_address : Address,
2845}
2846
2847packet LeReadLocalResolvableAddress : LeSecurityCommand (op_code = LE_READ_LOCAL_RESOLVABLE_ADDRESS) {
2848  peer_identity_address_type : PeerAddressType,
2849  peer_identity_address : Address,
2850}
2851
2852packet LeReadLocalResolvableAddressComplete : CommandComplete (command_op_code = LE_READ_LOCAL_RESOLVABLE_ADDRESS) {
2853  status : ErrorCode,
2854  local_resolvable_address : Address,
2855}
2856
2857packet LeSetAddressResolutionEnable : LeSecurityCommand (op_code = LE_SET_ADDRESS_RESOLUTION_ENABLE) {
2858  address_resolution_enable : Enable,
2859}
2860
2861packet LeSetAddressResolutionEnableComplete : CommandComplete (command_op_code = LE_SET_ADDRESS_RESOLUTION_ENABLE) {
2862  status : ErrorCode,
2863}
2864
2865packet LeSetResolvablePrivateAddressTimeout : LeSecurityCommand (op_code = LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT) {
2866  rpa_timeout : 16, // RPA_Timeout measured in seconds 0x0001 to 0xA1B8 1s to 11.5 hours
2867}
2868
2869packet LeSetResolvablePrivateAddressTimeoutComplete : CommandComplete (command_op_code = LE_SET_RESOLVABLE_PRIVATE_ADDRESS_TIMEOUT) {
2870  status : ErrorCode,
2871}
2872
2873packet LeReadMaximumDataLength : CommandPacket (op_code = LE_READ_MAXIMUM_DATA_LENGTH) {
2874}
2875
2876struct LeMaximumDataLength {
2877  supported_max_tx_octets : 16,
2878  supported_max_tx_time: 16,
2879  supported_max_rx_octets : 16,
2880  supported_max_rx_time: 16,
2881}
2882
2883packet LeReadMaximumDataLengthComplete : CommandComplete (command_op_code = LE_READ_MAXIMUM_DATA_LENGTH) {
2884  status : ErrorCode,
2885  le_maximum_data_length : LeMaximumDataLength,
2886}
2887
2888packet LeReadPhy : LeConnectionManagementCommand (op_code = LE_READ_PHY) {
2889  _payload_,  // placeholder (unimplemented)
2890}
2891
2892packet LeSetDefaultPhy : LeConnectionManagementCommand (op_code = LE_SET_DEFAULT_PHY) {
2893  _payload_,  // placeholder (unimplemented)
2894}
2895
2896packet LeSetPhy : LeConnectionManagementCommand (op_code = LE_SET_PHY) {
2897  _payload_,  // placeholder (unimplemented)
2898}
2899
2900packet LeEnhancedReceiverTest : CommandPacket (op_code = LE_ENHANCED_RECEIVER_TEST) {
2901  _payload_,  // placeholder (unimplemented)
2902}
2903
2904packet LeEnhancedTransmitterTest : CommandPacket (op_code = LE_ENHANCED_TRANSMITTER_TEST) {
2905  _payload_,  // placeholder (unimplemented)
2906}
2907
2908packet LeSetExtendedAdvertisingRandomAddress : LeAdvertisingCommand (op_code = LE_SET_EXTENDED_ADVERTISING_RANDOM_ADDRESS) {
2909  advertising_handle : 8,
2910  advertising_random_address : Address,
2911}
2912
2913packet LeSetExtendedAdvertisingRandomAddressComplete : CommandComplete (command_op_code = LE_SET_EXTENDED_ADVERTISING_RANDOM_ADDRESS) {
2914  status : ErrorCode,
2915}
2916
2917// The lower 4 bits of the advertising event properties
2918enum LegacyAdvertisingProperties : 4 {
2919  ADV_IND = 0x3,
2920  ADV_DIRECT_IND_LOW = 0x5,
2921  ADV_DIRECT_IND_HIGH = 0xD,
2922  ADV_SCAN_IND = 0x2,
2923  ADV_NONCONN_IND = 0,
2924}
2925
2926enum PrimaryPhyType : 8 {
2927  LE_1M = 0x01,
2928  LE_CODED = 0x03,
2929}
2930
2931enum SecondaryPhyType : 8 {
2932  NO_PACKETS = 0x00,
2933  LE_1M = 0x01,
2934  LE_2M = 0x02,
2935  LE_CODED = 0x03,
2936}
2937
2938packet LeSetExtendedAdvertisingLegacyParameters : LeAdvertisingCommand (op_code = LE_SET_EXTENDED_ADVERTISING_PARAMETERS) {
2939  advertising_handle : 8,
2940  advertising_event_legacy_properties : LegacyAdvertisingProperties,
2941  _fixed_ = 0x1 : 1, // legacy bit set
2942  _reserved_ : 11, // advertising_event_properties
2943  primary_advertising_interval_min : 24, // 0x20 - 0xFFFFFF N * 0.625 ms
2944  primary_advertising_interval_max : 24, // 0x20 - 0xFFFFFF N * 0.625 ms
2945  primary_advertising_channel_map : 3,  // bit 0 - Channel 37, bit 1 - 38, bit 2 - 39
2946  _reserved_ : 5,
2947  own_address_type : OwnAddressType,
2948  peer_address_type : PeerAddressType,
2949  peer_address : Address,
2950  advertising_filter_policy : AdvertisingFilterPolicy,
2951  _reserved_ : 6,
2952  advertising_tx_power : 8, // -127 to +20, 0x7F - no preference
2953  _fixed_ = 0x1 : 8, // PrimaryPhyType LE_1M
2954  _reserved_ : 8, // secondary_advertising_max_skip
2955  _fixed_ = 0x1 : 8, // secondary_advertising_phy LE_1M
2956  advertising_sid : 8, // SID subfield from the ADI field of the PDU
2957  scan_request_notification_enable : Enable,
2958}
2959
2960packet LeSetExtendedAdvertisingParameters : LeAdvertisingCommand (op_code = LE_SET_EXTENDED_ADVERTISING_PARAMETERS) {
2961  advertising_handle : 8,
2962  advertising_event_legacy_properties : 4,
2963  _fixed_ = 0 : 1, // legacy bit cleared
2964  advertising_event_properties : 3,
2965  _reserved_ : 8,
2966  primary_advertising_interval_min : 24, // 0x20 - 0xFFFFFF N * 0.625 ms
2967  primary_advertising_interval_max : 24, // 0x20 - 0xFFFFFF N * 0.625 ms
2968  primary_advertising_channel_map : 3,  // bit 0 - Channel 37, bit 1 - 38, bit 2 - 39
2969  _reserved_ : 5,
2970  own_address_type : OwnAddressType,
2971  peer_address_type : PeerAddressType,
2972  peer_address : Address,
2973  advertising_filter_policy : AdvertisingFilterPolicy,
2974  _reserved_ : 6,
2975  advertising_tx_power : 8, // -127 to +20, 0x7F - no preference
2976  primary_advertising_phy : PrimaryPhyType,
2977  secondary_advertising_max_skip : 8, // 1 to 255, 0x00 - AUX_ADV_IND sent before next advertising event
2978  secondary_advertising_phy : SecondaryPhyType,
2979  advertising_sid : 8, // SID subfield from the ADI field of the PDU
2980  scan_request_notification_enable : Enable,
2981}
2982
2983packet LeSetExtendedAdvertisingParametersComplete : CommandComplete (command_op_code = LE_SET_EXTENDED_ADVERTISING_PARAMETERS) {
2984  status : ErrorCode,
2985  selected_tx_power : 8, // -127 to +20
2986}
2987
2988enum Operation : 3 {
2989  INTERMEDIATE_FRAGMENT = 0,
2990  FIRST_FRAGMENT = 1,
2991  LAST_FRAGMENT = 2,
2992  COMPLETE_ADVERTISEMENT = 3,
2993  UNCHANGED_DATA = 4,
2994}
2995
2996enum FragmentPreference : 1 {
2997  CONTROLLER_MAY_FRAGMENT = 0,
2998  CONTROLLER_SHOULD_NOT = 1,
2999}
3000
3001packet LeSetExtendedAdvertisingData : LeAdvertisingCommand (op_code = LE_SET_EXTENDED_ADVERTISING_DATA) {
3002  advertising_handle : 8,
3003  operation : Operation,
3004  _reserved_ : 5,
3005  fragment_preference : FragmentPreference,
3006  _reserved_ : 7,
3007  _size_(advertising_data) : 8,
3008  advertising_data : GapData[],
3009}
3010
3011packet LeSetExtendedAdvertisingDataRaw : LeAdvertisingCommand (op_code = LE_SET_EXTENDED_ADVERTISING_DATA) {
3012  advertising_handle : 8,
3013  operation : Operation,
3014  _reserved_ : 5,
3015  fragment_preference : FragmentPreference,
3016  _reserved_ : 7,
3017  _size_(advertising_data) : 8,
3018  advertising_data : 8[],
3019}
3020
3021packet LeSetExtendedAdvertisingDataComplete : CommandComplete (command_op_code = LE_SET_EXTENDED_ADVERTISING_DATA) {
3022  status : ErrorCode,
3023}
3024
3025packet LeSetExtendedAdvertisingScanResponse : LeAdvertisingCommand (op_code = LE_SET_EXTENDED_ADVERTISING_SCAN_RESPONSE) {
3026  advertising_handle : 8,
3027  operation : Operation,
3028  _reserved_ : 5,
3029  fragment_preference : FragmentPreference,
3030  _reserved_ : 7,
3031  _size_(scan_response_data) : 8,
3032  scan_response_data : GapData[],
3033}
3034
3035packet LeSetExtendedAdvertisingScanResponseRaw : LeAdvertisingCommand (op_code = LE_SET_EXTENDED_ADVERTISING_SCAN_RESPONSE) {
3036  advertising_handle : 8,
3037  operation : Operation,
3038  _reserved_ : 5,
3039  fragment_preference : FragmentPreference,
3040  _reserved_ : 7,
3041  _size_(scan_response_data) : 8,
3042  scan_response_data : 8[],
3043}
3044
3045packet LeSetExtendedAdvertisingScanResponseComplete : CommandComplete (command_op_code = LE_SET_EXTENDED_ADVERTISING_SCAN_RESPONSE) {
3046  status : ErrorCode,
3047}
3048
3049packet LeSetExtendedAdvertisingEnableDisableAll : LeAdvertisingCommand (op_code = LE_SET_EXTENDED_ADVERTISING_ENABLE) {
3050  _fixed_ = 0x00 : 8, // Enable::DISABLED
3051  _fixed_ = 0x00 : 8, // Disable all sets
3052}
3053
3054struct EnabledSet {
3055  advertising_handle : 8,
3056  duration : 16,
3057  max_extended_advertising_events : 8,
3058}
3059
3060struct DisabledSet {
3061  advertising_handle : 8,
3062  _fixed_ = 0x00 : 16, // duration
3063  _fixed_ = 0x00 : 8, // max_extended_advertising_events
3064}
3065
3066packet LeSetExtendedAdvertisingDisable : LeAdvertisingCommand (op_code = LE_SET_EXTENDED_ADVERTISING_ENABLE) {
3067  _fixed_ = 0x00 : 8, // Enable::DISABLED
3068  _count_(disabled_sets) : 8,
3069  disabled_sets : DisabledSet[],
3070}
3071
3072packet LeSetExtendedAdvertisingEnable : LeAdvertisingCommand (op_code = LE_SET_EXTENDED_ADVERTISING_ENABLE) {
3073  enable : Enable,
3074  _count_(enabled_sets) : 8,
3075  enabled_sets : EnabledSet[],
3076}
3077
3078packet LeSetExtendedAdvertisingEnableComplete : CommandComplete (command_op_code = LE_SET_EXTENDED_ADVERTISING_ENABLE) {
3079  status : ErrorCode,
3080}
3081
3082packet LeReadMaximumAdvertisingDataLength : CommandPacket (op_code = LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH) {
3083}
3084
3085packet LeReadMaximumAdvertisingDataLengthComplete : CommandComplete (command_op_code = LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH) {
3086  status : ErrorCode,
3087  maximum_advertising_data_length : 16,
3088}
3089
3090packet LeReadNumberOfSupportedAdvertisingSets : CommandPacket (op_code = LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS) {
3091}
3092
3093packet LeReadNumberOfSupportedAdvertisingSetsComplete : CommandComplete (command_op_code = LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS) {
3094  status : ErrorCode,
3095  number_supported_advertising_sets : 8,
3096}
3097
3098packet LeRemoveAdvertisingSet : LeAdvertisingCommand (op_code = LE_REMOVE_ADVERTISING_SET) {
3099  advertising_handle : 8,
3100}
3101
3102packet LeRemoveAdvertisingSetComplete : CommandComplete (command_op_code = LE_REMOVE_ADVERTISING_SET) {
3103  status : ErrorCode,
3104}
3105
3106packet LeClearAdvertisingSets : LeAdvertisingCommand (op_code = LE_CLEAR_ADVERTISING_SETS) {
3107}
3108
3109packet LeClearAdvertisingSetsComplete : CommandComplete (command_op_code = LE_CLEAR_ADVERTISING_SETS) {
3110  status : ErrorCode,
3111}
3112
3113packet LeSetPeriodicAdvertisingParam : LeAdvertisingCommand (op_code = LE_SET_PERIODIC_ADVERTISING_PARAM) {
3114  advertising_handle : 8,
3115  periodic_advertising_interval_min : 16, // 0x006 to 0xFFFF (7.5 ms to 82s)
3116  periodic_advertising_interval_max : 16, // 0x006 to 0xFFFF (7.5 ms to 82s)
3117  _reserved_ : 6,
3118  include_tx_power : 1,
3119  _reserved_ : 9,
3120}
3121
3122packet LeSetPeriodicAdvertisingParamComplete : CommandComplete (command_op_code = LE_SET_PERIODIC_ADVERTISING_PARAM) {
3123  status : ErrorCode,
3124}
3125
3126packet LeSetPeriodicAdvertisingData : LeAdvertisingCommand (op_code = LE_SET_PERIODIC_ADVERTISING_DATA) {
3127  advertising_handle : 8,
3128  operation : Operation,
3129  _reserved_ : 5,
3130  _size_(scan_response_data) : 8,
3131  scan_response_data : 8[],
3132}
3133
3134packet LeSetPeriodicAdvertisingDataComplete : CommandComplete (command_op_code = LE_SET_PERIODIC_ADVERTISING_DATA) {
3135  status : ErrorCode,
3136}
3137
3138packet LeSetPeriodicAdvertisingEnable : LeAdvertisingCommand (op_code = LE_SET_PERIODIC_ADVERTISING_ENABLE) {
3139  advertising_handle : 8,
3140  enable : Enable,
3141}
3142
3143packet LeSetPeriodicAdvertisingEnableComplete : CommandComplete (command_op_code = LE_SET_PERIODIC_ADVERTISING_ENABLE) {
3144  status : ErrorCode,
3145}
3146
3147struct PhyScanParameters {
3148  le_scan_type : LeScanType,
3149  le_scan_interval : 16, // 0x0004-0xFFFF Default 0x10 (10ms)
3150  le_scan_window : 16, // 0x004-0xFFFF Default 0x10 (10ms)
3151}
3152
3153packet LeSetExtendedScanParameters : LeScanningCommand (op_code = LE_SET_EXTENDED_SCAN_PARAMETERS) {
3154  own_address_type : AddressType,
3155  scanning_filter_policy : LeScanningFilterPolicy,
3156  scanning_phys : 8,
3157  parameters : PhyScanParameters[],
3158}
3159
3160packet LeSetExtendedScanParametersComplete : CommandComplete (command_op_code = LE_SET_EXTENDED_SCAN_PARAMETERS) {
3161  status : ErrorCode,
3162}
3163
3164enum FilterDuplicates : 8 {
3165  DISABLED = 0,
3166  ENABLED = 1,
3167  RESET_EACH_PERIOD = 2,
3168}
3169
3170packet LeSetExtendedScanEnable : LeScanningCommand (op_code = LE_SET_EXTENDED_SCAN_ENABLE) {
3171  enable : Enable,
3172  filter_duplicates : FilterDuplicates,
3173  duration : 16, // 0 - Scan continuously,  N * 10 ms
3174  period : 16, // 0 - Scan continuously,  N * 1.28 sec
3175}
3176
3177packet LeSetExtendedScanEnableComplete : CommandComplete (command_op_code = LE_SET_EXTENDED_SCAN_ENABLE) {
3178  status : ErrorCode,
3179}
3180
3181struct LeCreateConnPhyScanParameters {
3182  scan_interval : 16, // 0x0004-0xFFFF
3183  scan_window : 16, // < = LeScanInterval
3184  conn_interval_min : 16, // 0x0006-0x0C80 (7.5ms to 4s)
3185  conn_interval_max : 16, // 0x0006-0x0C80 (7.5ms to 4s)
3186  conn_latency : 16, // 0x0006-0x01F3
3187  supervision_timeout : 16, // 0x00A to 0x0C80 (100ms to 32s)
3188  min_ce_length : 16, // 0.625ms
3189  max_ce_length : 16, // 0.625ms
3190}
3191
3192packet LeExtendedCreateConnection : LeConnectionManagementCommand (op_code = LE_EXTENDED_CREATE_CONNECTION) {
3193  initiator_filter_policy : InitiatorFilterPolicy,
3194  own_address_type : OwnAddressType,
3195  peer_address_type : AddressType,
3196  peer_address : Address,
3197  initiating_phys : 8,
3198  phy_scan_parameters : LeCreateConnPhyScanParameters[],
3199}
3200
3201packet LeExtendedCreateConnectionStatus : CommandStatus (command_op_code = LE_EXTENDED_CREATE_CONNECTION) {
3202}
3203
3204packet LePeriodicAdvertisingCreateSync : LeAdvertisingCommand (op_code = LE_PERIODIC_ADVERTISING_CREATE_SYNC) {
3205  _payload_,  // placeholder (unimplemented)
3206}
3207
3208packet LePeriodicAdvertisingCreateSyncCancel : LeAdvertisingCommand (op_code = LE_PERIODIC_ADVERTISING_CREATE_SYNC_CANCEL) {
3209  _payload_,  // placeholder (unimplemented)
3210}
3211
3212packet LePeriodicAdvertisingTerminateSync : LeAdvertisingCommand (op_code = LE_PERIODIC_ADVERTISING_TERMINATE_SYNC) {
3213  _payload_,  // placeholder (unimplemented)
3214}
3215
3216packet LeAddDeviceToPeriodicAdvertisingList : LeAdvertisingCommand (op_code = LE_ADD_DEVICE_TO_PERIODIC_ADVERTISING_LIST) {
3217  _payload_,  // placeholder (unimplemented)
3218}
3219
3220packet LeRemoveDeviceFromPeriodicAdvertisingList : LeAdvertisingCommand (op_code = LE_REMOVE_DEVICE_FROM_PERIODIC_ADVERTISING_LIST) {
3221  _payload_,  // placeholder (unimplemented)
3222}
3223
3224packet LeClearPeriodicAdvertisingList : LeAdvertisingCommand (op_code = LE_CLEAR_PERIODIC_ADVERTISING_LIST) {
3225  _payload_,  // placeholder (unimplemented)
3226}
3227
3228packet LeReadPeriodicAdvertisingListSize : LeAdvertisingCommand (op_code = LE_READ_PERIODIC_ADVERTISING_LIST_SIZE) {
3229  _payload_,  // placeholder (unimplemented)
3230}
3231
3232packet LeReadTransmitPower : LeAdvertisingCommand (op_code = LE_READ_TRANSMIT_POWER) {
3233  _payload_,  // placeholder (unimplemented)
3234}
3235
3236packet LeReadRfPathCompensationPower : LeAdvertisingCommand (op_code = LE_READ_RF_PATH_COMPENSATION_POWER) {
3237  _payload_,  // placeholder (unimplemented)
3238}
3239
3240packet LeWriteRfPathCompensationPower : LeAdvertisingCommand (op_code = LE_WRITE_RF_PATH_COMPENSATION_POWER) {
3241  _payload_,  // placeholder (unimplemented)
3242}
3243
3244enum PrivacyMode : 8 {
3245  NETWORK = 0,
3246  DEVICE = 1,
3247}
3248
3249packet LeSetPrivacyMode : LeSecurityCommand (op_code = LE_SET_PRIVACY_MODE) {
3250  peer_identity_address_type : PeerAddressType,
3251  peer_identity_address : Address,
3252  privacy_mode : PrivacyMode,
3253}
3254
3255packet LeSetPrivacyModeComplete : CommandComplete (command_op_code = LE_SET_PRIVACY_MODE) {
3256  status : ErrorCode,
3257}
3258
3259packet LeSetPeriodicAdvertisingReceiveEnable : CommandPacket (op_code = LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE) {
3260  sync_handle : 12,
3261  _reserved_ : 4,
3262  enable : 8,
3263}
3264
3265packet LeSetPeriodicAdvertisingReceiveEnableComplete : CommandComplete (command_op_code = LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE) {
3266  status : ErrorCode,
3267}
3268
3269packet LePeriodicAdvertisingSyncTransfer : CommandPacket (op_code = LE_PERIODIC_ADVERTISING_SYNC_TRANSFER) {
3270  connection_handle : 12,
3271  _reserved_ : 4,
3272  service_data : 16,
3273  sync_handle: 12,
3274  _reserved_ : 4,
3275}
3276
3277packet LePeriodicAdvertisingSyncTransferComplete : CommandComplete (command_op_code = LE_PERIODIC_ADVERTISING_SYNC_TRANSFER) {
3278  status : ErrorCode,
3279  connection_handle : 12,
3280  _reserved_ : 4,
3281}
3282
3283packet LePeriodicAdvertisingSetInfoTransfer : CommandPacket (op_code = LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER) {
3284  connection_handle : 12,
3285  _reserved_ : 4,
3286  service_data : 16,
3287  advertising_handle: 8,
3288}
3289
3290packet LePeriodicAdvertisingSetInfoTransferComplete : CommandComplete (command_op_code = LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER) {
3291  status : ErrorCode,
3292  connection_handle : 12,
3293  _reserved_ : 4,
3294}
3295
3296enum SyncTransferMode : 8 {
3297  NO_SYNC = 0,
3298  SEND_SYNC_RECEIVED_DISABLE_REPORTS = 1,
3299  SEND_SYNC_RECEIVED_SEND_REPORTS = 2,
3300}
3301
3302packet LeSetPeriodicAdvertisingSyncTransferParameters : CommandPacket (op_code = LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS) {
3303  connection_handle : 12,
3304  _reserved_ : 4,
3305  mode : SyncTransferMode,
3306  skip: 16,
3307  sync_timeout : 16,
3308  cte_type : 8,
3309}
3310
3311packet LeSetPeriodicAdvertisingSyncTransferParametersComplete : CommandComplete (command_op_code = LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS) {
3312  status : ErrorCode,
3313  connection_handle : 12,
3314  _reserved_ : 4,
3315}
3316
3317packet LeSetDefaultPeriodicAdvertisingSyncTransferParameters : CommandPacket (op_code = LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS) {
3318  mode : SyncTransferMode,
3319  skip: 16,
3320  sync_timeout : 16,
3321  cte_type : 8,
3322}
3323
3324enum UseDebugKey : 8 {
3325  USE_GENERATED_KEY = 0,
3326  USE_DEBUG_KEY = 1,
3327}
3328
3329packet LeGenerateDhkeyCommand : LeSecurityCommand (op_code = LE_GENERATE_DHKEY_COMMAND) {
3330  remote_p_256_public_key : 8[64],
3331  key_type : UseDebugKey,
3332}
3333
3334packet LeGenerateDhkeyCommandStatus : CommandStatus (command_op_code = LE_GENERATE_DHKEY_COMMAND) {
3335}
3336
3337enum ScaAction : 8 {
3338  MORE_ACCURATE_CLOCK = 0,
3339  LESS_ACCURATE_CLOCK = 1,
3340}
3341
3342packet LeModifySleepClockAccuracy : CommandPacket (op_code = LE_MODIFY_SLEEP_CLOCK_ACCURACY) {
3343  action : ScaAction,
3344}
3345
3346packet LeModifySleepClockAccuracyComplete : CommandComplete (command_op_code = LE_MODIFY_SLEEP_CLOCK_ACCURACY) {
3347  status : ErrorCode,
3348}
3349
3350packet LeReadBufferSizeV2 : CommandPacket (op_code = LE_READ_BUFFER_SIZE_V2) {
3351}
3352
3353packet LeReadBufferSizeV2Complete : CommandComplete (command_op_code = LE_READ_BUFFER_SIZE_V2) {
3354  status : ErrorCode,
3355  le_buffer_size : LeBufferSize,
3356  iso_buffer_size : LeBufferSize,
3357}
3358
3359packet LeReadIsoTxSync : CommandPacket (op_code = LE_READ_ISO_TX_SYNC) {
3360  connection_handle : 12,
3361  _reserved_ : 4,
3362}
3363
3364packet LeReadIsoTxSyncComplete : CommandComplete (command_op_code = LE_READ_ISO_TX_SYNC) {
3365  connection_handle : 12,
3366  _reserved_ : 4,
3367  packet_sequence_number : 16,
3368  timestamp : 32,
3369  time_offset : 24,
3370}
3371
3372struct CisParametersConfig {
3373  cis_id : 8,
3374  max_sdu_m_to_s : 12,
3375  _reserved_ : 4,
3376  max_sdu_s_to_m : 12,
3377  _reserved_ : 4,
3378  phy_m_to_s : SecondaryPhyType,
3379  phy_s_to_m : SecondaryPhyType,
3380  rtn_m_to_s : 4,
3381  _reserved_ : 4,
3382  rtn_s_to_m : 4,
3383  _reserved_ : 4,
3384}
3385
3386enum Packing : 8 {
3387  SEQUENTIAL = 0,
3388  INTERLEAVED = 1,
3389}
3390
3391enum ClockAccuracy : 8 {
3392  PPM_500 = 0x00,
3393  PPM_250 = 0x01,
3394  PPM_150 = 0x02,
3395  PPM_100 = 0x03,
3396  PPM_75 = 0x04,
3397  PPM_50 = 0x05,
3398  PPM_30 = 0x06,
3399  PPM_20 = 0x07,
3400}
3401
3402packet LeSetCigParameters : CommandPacket (op_code = LE_SET_CIG_PARAMETERS) {
3403  cig_id : 8,
3404  sdu_interval_m_to_s : 24,
3405  sdu_interval_s_to_m : 24,
3406  slaves_clock_accuracy : ClockAccuracy,
3407  packing : Packing,
3408  framing : Enable,
3409  max_transport_latency_m_to_s : 16,
3410  max_transport_latency_s_to_m : 16,
3411  _count_(cis_config) : 8,
3412  cis_config : CisParametersConfig[],
3413}
3414
3415packet LeSetCigParametersComplete : CommandComplete (command_op_code = LE_SET_CIG_PARAMETERS) {
3416  status : ErrorCode,
3417  cig_id : 8,
3418  _count_(connection_handle) : 8,
3419  connection_handle : 16[],
3420}
3421
3422struct CreateCisConfig {
3423  cis_connection_handle : 12,
3424  _reserved_ : 4,
3425  acl_connection_handle : 12,
3426  _reserved_ : 4,
3427}
3428
3429packet LeCreateCis : CommandPacket (op_code = LE_CREATE_CIS) {
3430  _count_(cis_config) : 8,
3431  cis_config : CreateCisConfig[],
3432}
3433
3434packet LeCreateCisStatus : CommandStatus (command_op_code = LE_CREATE_CIS) {
3435}
3436
3437packet LeRemoveCig : CommandPacket (op_code = LE_REMOVE_CIG) {
3438  cig_id : 8,
3439}
3440
3441packet LeRemoveCigComplete : CommandComplete (command_op_code = LE_REMOVE_CIG) {
3442  status : ErrorCode,
3443  cig_id : 8,
3444}
3445
3446packet LeAcceptCisRequest : CommandPacket (op_code = LE_ACCEPT_CIS_REQUEST) {
3447  connection_handle : 12,
3448  _reserved_ : 4,
3449}
3450
3451packet LeAcceptCisRequestStatus : CommandStatus (command_op_code = LE_ACCEPT_CIS_REQUEST) {
3452}
3453
3454packet LeRejectCisRequest : CommandPacket (op_code = LE_REJECT_CIS_REQUEST) {
3455  connection_handle : 12,
3456  _reserved_ : 4,
3457  reason : ErrorCode,
3458}
3459
3460packet LeRejectCisRequestComplete : CommandComplete (command_op_code = LE_REJECT_CIS_REQUEST) {
3461  status : ErrorCode,
3462  connection_handle : 12,
3463  _reserved_ : 4,
3464}
3465
3466packet LeCreateBig : CommandPacket (op_code = LE_CREATE_BIG) {
3467  big_handle : 8,
3468  advertising_handle : 8,
3469  num_bis : 8,
3470  sdu_interval : 24,
3471  max_sdu : 16,
3472  max_transport_latency : 16,
3473  rtn : 4,
3474  _reserved_ : 4,
3475  phy : SecondaryPhyType,
3476  packing : Packing,
3477  framing : Enable,
3478  encryption : Enable,
3479  broadcast_code: 16[],
3480}
3481
3482packet LeCreateBigStatus : CommandStatus (command_op_code = LE_CREATE_BIG) {
3483}
3484
3485packet LeTerminateBig : CommandPacket (op_code = LE_TERMINATE_BIG) {
3486  big_handle : 8,
3487  reason : ErrorCode,
3488}
3489
3490packet LeTerminateBigStatus : CommandStatus (command_op_code = LE_TERMINATE_BIG) {
3491}
3492
3493packet LeBigCreateSync : CommandPacket (op_code = LE_BIG_CREATE_SYNC) {
3494  big_handle : 8,
3495  sync_handle : 12,
3496  _reserved_ : 4,
3497  encryption : Enable,
3498  broadcast_code : 16[],
3499  mse : 5,
3500  _reserved_ : 3,
3501  big_sync_timeout : 16,
3502  _count_(bis) : 8,
3503  bis : 8[],
3504}
3505
3506packet LeBigCreateSyncStatus : CommandStatus (command_op_code = LE_BIG_CREATE_SYNC) {
3507}
3508
3509packet LeBigTerminateSync : CommandPacket (op_code = LE_BIG_TERMINATE_SYNC) {
3510  big_handle : 8,
3511}
3512
3513packet LeBigTerminateSyncComplete : CommandComplete (command_op_code = LE_BIG_TERMINATE_SYNC) {
3514  status : ErrorCode,
3515  big_handle : 8,
3516}
3517
3518packet LeRequestPeerSca : CommandPacket (op_code = LE_REQUEST_PEER_SCA) {
3519  connection_handle : 12,
3520  _reserved_ : 4,
3521}
3522
3523packet LeRequestPeerScaStatus : CommandStatus (command_op_code = LE_REQUEST_PEER_SCA) {
3524}
3525
3526packet LeSetupIsoDataPath : CommandPacket (op_code = LE_SETUP_ISO_DATA_PATH) {
3527  connection_handle : 12,
3528  _reserved_ : 4,
3529  data_path_direction : DataPathDirection,
3530  data_path_id : 8,
3531  codec_id : 40,
3532  controller_delay : 24,
3533  _count_(codec_configuration) : 8,
3534  codec_configuration : 8[],
3535}
3536
3537packet LeSetupIsoDataPathComplete : CommandComplete (command_op_code = LE_SETUP_ISO_DATA_PATH) {
3538  status : ErrorCode,
3539  connection_handle : 12,
3540  _reserved_ : 4,
3541}
3542
3543packet LeRemoveIsoDataPath : CommandPacket (op_code = LE_REMOVE_ISO_DATA_PATH) {
3544  connection_handle : 12,
3545  _reserved_ : 4,
3546  data_path_direction : DataPathDirection,
3547}
3548
3549packet LeRemoveIsoDataPathComplete : CommandComplete (command_op_code = LE_REMOVE_ISO_DATA_PATH) {
3550  status : ErrorCode,
3551  connection_handle : 12,
3552  _reserved_ : 4,
3553}
3554
3555packet LeSetHostFeature : CommandPacket (op_code = LE_SET_HOST_FEATURE) {
3556  bit_number : 8,
3557  bit_value:  Enable,
3558}
3559
3560packet LeSetHostFeatureComplete : CommandComplete (command_op_code = LE_SET_HOST_FEATURE) {
3561  status : ErrorCode,
3562}
3563
3564packet LeReadIsoLinkQuality : CommandPacket (op_code = LE_READ_ISO_LINK_QUALITY) {
3565  connection_handle : 12,
3566  _reserved_ : 4,
3567}
3568
3569packet LeReadIsoLinkQualityComplete : CommandComplete (command_op_code = LE_READ_ISO_LINK_QUALITY) {
3570  status : ErrorCode,
3571  connection_handle : 12,
3572  _reserved_ : 4,
3573  tx_unacked_packets : 32,
3574  tx_flushed_packets : 32,
3575  tx_last_subevent_packets : 32,
3576  retransmitted_packets : 32,
3577  crc_error_packets : 32,
3578  rx_unreceived_packets : 32,
3579  duplicate_packets : 32,
3580}
3581
3582packet LeEnhancedReadTransmitPowerLevel : CommandPacket (op_code = LE_ENHANCED_READ_TRANSMIT_POWER_LEVEL) {
3583  connection_handle : 12,
3584  _reserved_ : 4,
3585  phy : 8,
3586}
3587
3588enum PhyWithCodedSpecified : 8 {
3589  LE_1M = 1,
3590  LE_2M = 2,
3591  LE_CODED_S_8 = 3,
3592  LE_CODED_S_2 = 4,
3593}
3594
3595packet LeEnhancedReadTransmitPowerLevelComplete : CommandComplete (command_op_code = LE_ENHANCED_READ_TRANSMIT_POWER_LEVEL) {
3596  status : ErrorCode,
3597  connection_handle : 12,
3598  _reserved_ : 4,
3599  phy : PhyWithCodedSpecified,
3600  current_transmit_power_level : 8,
3601  max_transmit_power_level : 8,
3602}
3603
3604packet LeReadRemoteTransmitPowerLevel : CommandPacket (op_code = LE_READ_REMOTE_TRANSMIT_POWER_LEVEL) {
3605  connection_handle : 12,
3606  _reserved_ : 4,
3607  phy : 8,
3608}
3609
3610packet LeReadRemoteTransmitPowerLevelStatus : CommandStatus (command_op_code = LE_READ_REMOTE_TRANSMIT_POWER_LEVEL) {
3611}
3612
3613packet LeSetPathLossReportingParameters : CommandPacket (op_code = LE_SET_PATH_LOSS_REPORTING_PARAMETERS) {
3614  connection_handle : 12,
3615  _reserved_ : 4,
3616  high_threshold : 8,
3617  high_hysteresis : 8,
3618  low_threshold : 8,
3619  low_hysteresis : 8,
3620  min_time_spent : 16,
3621}
3622
3623packet LeSetPathLossReportingParametersComplete : CommandComplete (command_op_code = LE_SET_PATH_LOSS_REPORTING_PARAMETERS) {
3624  status : ErrorCode,
3625  connection_handle : 12,
3626  _reserved_ : 4,
3627}
3628
3629packet LeSetPathLossReportingEnable : CommandPacket (op_code = LE_SET_PATH_LOSS_REPORTING_ENABLE) {
3630  connection_handle : 12,
3631  _reserved_ : 4,
3632  enable : 8,
3633}
3634
3635packet LeSetPathLossReportingEnableComplete : CommandComplete (command_op_code = LE_SET_PATH_LOSS_REPORTING_ENABLE) {
3636  status : ErrorCode,
3637  connection_handle : 12,
3638  _reserved_ : 4,
3639}
3640
3641packet LeSetTransmitPowerReportingEnable : CommandPacket (op_code = LE_SET_TRANSMIT_POWER_REPORTING_ENABLE) {
3642  connection_handle : 12,
3643  _reserved_ : 4,
3644  local_enable : 8,
3645  remote_enable : 8,
3646}
3647
3648packet LeSetTransmitPowerReportingEnableComplete : CommandComplete (command_op_code = LE_SET_TRANSMIT_POWER_REPORTING_ENABLE) {
3649  status : ErrorCode,
3650  connection_handle : 12,
3651  _reserved_ : 4,
3652}
3653
3654  // VENDOR_SPECIFIC
3655packet LeGetVendorCapabilities : VendorCommand (op_code = LE_GET_VENDOR_CAPABILITIES) {
3656}
3657
3658struct VendorCapabilities {
3659  is_supported : 8,
3660  max_advt_instances: 8,
3661  offloaded_resolution_of_private_address : 8,
3662  total_scan_results_storage: 16,
3663  max_irk_list_sz: 8,
3664  filtering_support: 8,
3665  max_filter: 8,
3666  activity_energy_info_support: 8,
3667  version_supported: 16,
3668  total_num_of_advt_tracked: 16,
3669  extended_scan_support: 8,
3670  debug_logging_supported: 8,
3671  le_address_generation_offloading_support: 8,
3672  a2dp_source_offload_capability_mask: 32,
3673  bluetooth_quality_report_support: 8
3674}
3675
3676struct BaseVendorCapabilities {
3677  max_advt_instances: 8,
3678  offloaded_resolution_of_private_address : 8,
3679  total_scan_results_storage: 16,
3680  max_irk_list_sz: 8,
3681  filtering_support: 8,
3682  max_filter: 8,
3683  activity_energy_info_support: 8,
3684}
3685
3686packet LeGetVendorCapabilitiesComplete : CommandComplete (command_op_code = LE_GET_VENDOR_CAPABILITIES) {
3687  status : ErrorCode,
3688  base_vendor_capabilities : BaseVendorCapabilities,
3689  _payload_,
3690}
3691packet LeGetVendorCapabilitiesComplete095 : LeGetVendorCapabilitiesComplete {
3692  version_supported: 16,
3693  total_num_of_advt_tracked: 16,
3694  extended_scan_support: 8,
3695  debug_logging_supported: 8,
3696  _payload_,
3697}
3698packet LeGetVendorCapabilitiesComplete096 : LeGetVendorCapabilitiesComplete095 {
3699  le_address_generation_offloading_support: 8,
3700  _payload_,
3701}
3702
3703packet LeGetVendorCapabilitiesComplete098 : LeGetVendorCapabilitiesComplete096 {
3704  a2dp_source_offload_capability_mask: 32,
3705  bluetooth_quality_report_support: 8
3706}
3707
3708enum SubOcf : 8 {
3709  SET_PARAM = 0x01,
3710  SET_DATA = 0x02,
3711  SET_SCAN_RESP = 0x03,
3712  SET_RANDOM_ADDR = 0x04,
3713  SET_ENABLE = 0x05,
3714}
3715
3716packet LeMultiAdvt : LeAdvertisingCommand (op_code = LE_MULTI_ADVT) {
3717  sub_cmd : SubOcf,
3718  _body_,
3719}
3720
3721packet LeMultiAdvtComplete : CommandComplete (command_op_code = LE_MULTI_ADVT) {
3722  status : ErrorCode,
3723  sub_cmd : SubOcf,
3724}
3725
3726packet LeMultiAdvtParam : LeMultiAdvt (sub_cmd = SET_PARAM) {
3727  interval_min : 16,
3728  interval_max : 16,
3729  type : AdvertisingType,
3730  own_address_type : AddressType,
3731  peer_address_type : PeerAddressType,
3732  peer_address : Address,
3733  channel_map : 8,
3734  filter_policy : AdvertisingFilterPolicy,
3735  _reserved_ : 6,
3736  instance : 8,
3737  tx_power : 8,
3738}
3739
3740packet LeMultiAdvtParamComplete : LeMultiAdvtComplete (sub_cmd = SET_PARAM) {
3741}
3742
3743packet LeMultiAdvtSetData : LeMultiAdvt (sub_cmd = SET_DATA) {
3744  _size_(advertising_data) : 8,
3745  advertising_data : GapData[],
3746  _padding_[36], // Zero padding to 31 bytes of advertising_data + 1 size + 2 opcode + 1 total_size + 1 set
3747  advertising_instance : 8,
3748}
3749
3750packet LeMultiAdvtSetDataComplete : LeMultiAdvtComplete (sub_cmd = SET_DATA) {
3751}
3752
3753packet LeMultiAdvtSetScanResp : LeMultiAdvt (sub_cmd = SET_SCAN_RESP) {
3754  _size_(advertising_data) : 8,
3755  advertising_data : GapData[],
3756  _padding_[36], // Zero padding to 31 bytes of advertising_data + 1 size + 2 opcode + 1 total_size + 1 set
3757  advertising_instance : 8,
3758}
3759
3760packet LeMultiAdvtSetScanRespComplete : LeMultiAdvtComplete (sub_cmd = SET_SCAN_RESP) {
3761}
3762
3763packet LeMultiAdvtSetRandomAddr : LeMultiAdvt (sub_cmd = SET_RANDOM_ADDR) {
3764  random_address : Address,
3765  advertising_instance : 8,
3766}
3767
3768packet LeMultiAdvtSetRandomAddrComplete : LeMultiAdvtComplete (sub_cmd = SET_RANDOM_ADDR) {
3769}
3770
3771packet LeMultiAdvtSetEnable : LeMultiAdvt (sub_cmd = SET_ENABLE) {
3772  advertising_enable : Enable, // Default DISABLED
3773  advertising_instance : 8,
3774}
3775
3776packet LeMultiAdvtSetEnableComplete : LeMultiAdvtComplete (sub_cmd = SET_ENABLE) {
3777}
3778
3779packet LeBatchScan : VendorCommand (op_code = LE_BATCH_SCAN) {
3780  _payload_,  // placeholder (unimplemented)
3781}
3782
3783enum ApcfOpcode : 8 {
3784  ENABLE = 0x00,
3785  SET_FILTERING_PARAMETERS = 0x01,
3786  BROADCASTER_ADDRESS = 0x02,
3787  SERVICE_UUID = 0x03,
3788  SERVICE_SOLICITATION_UUID = 0x04,
3789  LOCAL_NAME = 0x05,
3790  MANUFACTURER_DATA = 0x06,
3791  SERVICE_DATA = 0x07,
3792}
3793
3794packet LeAdvFilter : LeScanningCommand (op_code = LE_ADV_FILTER) {
3795  apcf_opcode : ApcfOpcode,
3796  _body_,
3797}
3798
3799packet LeAdvFilterComplete : CommandComplete (command_op_code = LE_ADV_FILTER) {
3800  status : ErrorCode,
3801  apcf_opcode : ApcfOpcode,
3802}
3803
3804packet LeTrackAdv : VendorCommand (op_code = LE_TRACK_ADV) {
3805  _payload_,  // placeholder (unimplemented)
3806}
3807
3808packet LeEnergyInfo : VendorCommand (op_code = LE_ENERGY_INFO) {
3809  _payload_,  // placeholder (unimplemented)
3810}
3811
3812packet LeExtendedScanParams : LeScanningCommand (op_code = LE_EXTENDED_SCAN_PARAMS) {
3813  le_scan_type : LeScanType,
3814  le_scan_interval : 32, // 0x0004-0x4000 Default 0x10 (10ms)
3815  le_scan_window : 32, // Default 0x10 (10ms)
3816  own_address_type : AddressType,
3817  scanning_filter_policy : LeScanningFilterPolicy,
3818}
3819
3820packet LeExtendedScanParamsComplete : CommandComplete (command_op_code = LE_EXTENDED_SCAN_PARAMS) {
3821  status : ErrorCode,
3822}
3823
3824packet ControllerDebugInfo : VendorCommand (op_code = CONTROLLER_DEBUG_INFO) {
3825  _payload_,  // placeholder (unimplemented)
3826}
3827
3828packet ControllerA2DPOpcode : VendorCommand (op_code = CONTROLLER_A2DP_OPCODE) {
3829  _payload_,  // placeholder (unimplemented)
3830}
3831
3832enum BqrReportAction : 8 {
3833  ADD = 0x00,
3834  DELETE = 0x01,
3835  CLEAR = 0x02,
3836}
3837
3838packet ControllerBqr : VendorCommand(op_code = CONTROLLER_BQR) {
3839  bqr_report_action : BqrReportAction,
3840  bqr_quality_event_mask : 32,
3841  bqr_minimum_report_interval : 16,
3842}
3843
3844packet ControllerBqrComplete : CommandComplete (command_op_code = CONTROLLER_BQR) {
3845  status : ErrorCode,
3846  current_quality_event_mask : 32
3847}
3848
3849// HCI Event Packets
3850
3851packet InquiryComplete : EventPacket (event_code = INQUIRY_COMPLETE){
3852  status : ErrorCode,
3853}
3854
3855struct InquiryResult {
3856  bd_addr : Address,
3857  page_scan_repetition_mode : PageScanRepetitionMode,
3858  _reserved_ : 8,
3859  _reserved_ : 8,
3860  class_of_device : ClassOfDevice,
3861  clock_offset : 15,
3862  _reserved_ : 1,
3863}
3864
3865packet InquiryResult : EventPacket (event_code = INQUIRY_RESULT){
3866  _count_(inquiry_results) : 8,
3867  inquiry_results : InquiryResult[],
3868}
3869
3870enum LinkType : 8 {
3871  SCO = 0x00,
3872  ACL = 0x01,
3873}
3874
3875packet ConnectionComplete : EventPacket (event_code = CONNECTION_COMPLETE){
3876  status : ErrorCode,
3877  connection_handle : 12,
3878  _reserved_ : 4,
3879  bd_addr : Address,
3880  link_type : LinkType,
3881  encryption_enabled : Enable,
3882}
3883
3884enum ConnectionRequestLinkType : 8 {
3885  SCO = 0x00,
3886  ACL = 0x01,
3887  ESCO = 0x02,
3888}
3889
3890packet ConnectionRequest : EventPacket (event_code = CONNECTION_REQUEST){
3891  bd_addr : Address,
3892  class_of_device : ClassOfDevice,
3893  link_type : ConnectionRequestLinkType,
3894}
3895
3896packet DisconnectionComplete : EventPacket (event_code = DISCONNECTION_COMPLETE){
3897  status : ErrorCode,
3898  connection_handle : 12,
3899  _reserved_ : 4,
3900  reason : ErrorCode,
3901}
3902
3903packet AuthenticationComplete : EventPacket (event_code = AUTHENTICATION_COMPLETE){
3904  status : ErrorCode,
3905  connection_handle : 12,
3906  _reserved_ : 4,
3907}
3908
3909packet RemoteNameRequestComplete : EventPacket (event_code = REMOTE_NAME_REQUEST_COMPLETE){
3910  status : ErrorCode,
3911  bd_addr : Address,
3912  remote_name : 8[248], // UTF-8 encoded user-friendly descriptive name
3913}
3914
3915enum EncryptionEnabled : 8 {
3916  OFF = 0x00,
3917  ON = 0x01, // E0 for BR/EDR and AES-CCM for LE
3918  BR_EDR_AES_CCM = 0x02,
3919}
3920
3921packet EncryptionChange : EventPacket (event_code = ENCRYPTION_CHANGE){
3922  status : ErrorCode,
3923  connection_handle : 12,
3924  _reserved_ : 4,
3925  encryption_enabled : EncryptionEnabled,
3926}
3927
3928packet ChangeConnectionLinkKeyComplete : EventPacket (event_code = CHANGE_CONNECTION_LINK_KEY_COMPLETE){
3929  status : ErrorCode,
3930  connection_handle : 12,
3931  _reserved_ : 4,
3932}
3933
3934packet MasterLinkKeyComplete : EventPacket (event_code = MASTER_LINK_KEY_COMPLETE){
3935  status : ErrorCode,
3936  connection_handle : 12,
3937  _reserved_ : 4,
3938  key_flag : KeyFlag,
3939}
3940
3941packet ReadRemoteSupportedFeaturesComplete : EventPacket (event_code = READ_REMOTE_SUPPORTED_FEATURES_COMPLETE){
3942  status : ErrorCode,
3943  connection_handle : 12,
3944  _reserved_ : 4,
3945  lmp_features : 64,
3946}
3947
3948packet ReadRemoteVersionInformationComplete : EventPacket (event_code = READ_REMOTE_VERSION_INFORMATION_COMPLETE){
3949  status : ErrorCode,
3950  connection_handle : 12,
3951  _reserved_ : 4,
3952  version : 8,
3953  manufacturer_name : 16,
3954  sub_version : 16,
3955}
3956
3957packet QosSetupComplete : EventPacket (event_code = QOS_SETUP_COMPLETE){
3958  status : ErrorCode,
3959  connection_handle : 12,
3960  _reserved_ : 4,
3961  _reserved_ : 8,
3962  service_type : ServiceType,
3963  token_rate : 32, // Octets/s
3964  peak_bandwidth : 32, // Octets/s
3965  latency : 32, // Octets/s
3966  delay_variation : 32, // microseconds
3967}
3968
3969// Command Complete and Command Status Events are implemented above Commands.
3970
3971packet HardwareError : EventPacket (event_code = HARDWARE_ERROR){
3972  hardware_code : 8,
3973}
3974
3975packet FlushOccurred : EventPacket (event_code = FLUSH_OCCURRED){
3976  connection_handle : 12,
3977  _reserved_ : 4,
3978}
3979
3980packet RoleChange : EventPacket (event_code = ROLE_CHANGE){
3981  status : ErrorCode,
3982  bd_addr : Address,
3983  new_role : Role,
3984}
3985
3986packet NumberOfCompletedPackets : EventPacket (event_code = NUMBER_OF_COMPLETED_PACKETS){
3987  _count_(completed_packets) : 8,
3988  completed_packets : CompletedPackets[],
3989}
3990
3991enum Mode : 8 {
3992  ACTIVE = 0x00,
3993  HOLD = 0x01,
3994  SNIFF = 0x02,
3995}
3996
3997packet ModeChange : EventPacket (event_code = MODE_CHANGE){
3998  status : ErrorCode,
3999  connection_handle : 12,
4000  _reserved_ : 4,
4001  current_mode : Mode,
4002  interval : 16, // 0x002 - 0xFFFE (1.25ms - 40.9s)
4003}
4004
4005struct ZeroKeyAndAddress {
4006  address : Address,
4007  _fixed_ = 0 : 64,
4008  _fixed_ = 0 : 64,
4009}
4010
4011packet ReturnLinkKeys : EventPacket (event_code = RETURN_LINK_KEYS){
4012  _count_(keys) : 8,
4013  keys : ZeroKeyAndAddress[],
4014}
4015
4016packet PinCodeRequest : EventPacket (event_code = PIN_CODE_REQUEST){
4017  bd_addr : Address,
4018}
4019
4020packet LinkKeyRequest : EventPacket (event_code = LINK_KEY_REQUEST){
4021  bd_addr : Address,
4022}
4023
4024enum KeyType : 8 {
4025  COMBINATION = 0x00,
4026  DEBUG_COMBINATION = 0x03,
4027  UNAUTHENTICATED_P192 = 0x04,
4028  AUTHENTICATED_P192 = 0x05,
4029  CHANGED = 0x06,
4030  UNAUTHENTICATED_P256 = 0x07,
4031  AUTHENTICATED_P256 = 0x08,
4032}
4033
4034packet LinkKeyNotification : EventPacket (event_code = LINK_KEY_NOTIFICATION){
4035  bd_addr : Address,
4036  link_key : 8[16],
4037  key_type : KeyType,
4038}
4039
4040packet LoopbackCommand : EventPacket (event_code = LOOPBACK_COMMAND){
4041  _payload_, // Command packet, truncated if it was longer than 252 bytes
4042}
4043
4044packet DataBufferOverflow : EventPacket (event_code = DATA_BUFFER_OVERFLOW){
4045  link_type : LinkType,
4046}
4047
4048packet MaxSlotsChange : EventPacket (event_code = MAX_SLOTS_CHANGE){
4049  connection_handle : 12,
4050  _reserved_ : 4,
4051  lmp_max_slots : 8,
4052}
4053
4054packet ReadClockOffsetComplete : EventPacket (event_code = READ_CLOCK_OFFSET_COMPLETE){
4055  status : ErrorCode,
4056  connection_handle : 12,
4057  _reserved_ : 4,
4058  clock_offset : 15,
4059  _reserved_ : 1,
4060}
4061
4062packet ConnectionPacketTypeChanged : EventPacket (event_code = CONNECTION_PACKET_TYPE_CHANGED){
4063  status : ErrorCode,
4064  connection_handle : 12,
4065  _reserved_ : 4,
4066  packet_type : 16,
4067}
4068
4069packet QosViolation : EventPacket (event_code = QOS_VIOLATION){
4070  _payload_, // placeholder (unimplemented)
4071}
4072
4073packet PageScanRepetitionModeChange : EventPacket (event_code = PAGE_SCAN_REPETITION_MODE_CHANGE){
4074  _payload_, // placeholder (unimplemented)
4075}
4076
4077packet FlowSpecificationComplete : EventPacket (event_code = FLOW_SPECIFICATION_COMPLETE){
4078  status : ErrorCode,
4079  connection_handle : 12,
4080  _reserved_ : 4,
4081  _reserved_ : 8,
4082  flow_direction : FlowDirection,
4083  service_type : ServiceType,
4084  token_rate : 32, // Octets/s
4085  token_bucket_size : 32,
4086  peak_bandwidth : 32, // Octets/s
4087  access_latency : 32, // Octets/s
4088}
4089
4090struct InquiryResultWithRssi {
4091  address : Address,
4092  page_scan_repetition_mode : PageScanRepetitionMode,
4093  _reserved_ : 8,
4094  class_of_device : ClassOfDevice,
4095  clock_offset : 15,
4096  _reserved_ : 1,
4097  rssi : 8,
4098}
4099
4100packet InquiryResultWithRssi : EventPacket (event_code = INQUIRY_RESULT_WITH_RSSI){
4101  _count_(inquiry_results) : 8,
4102  inquiry_results : InquiryResultWithRssi[],
4103}
4104
4105packet ReadRemoteExtendedFeaturesComplete : EventPacket (event_code = READ_REMOTE_EXTENDED_FEATURES_COMPLETE){
4106  status : ErrorCode,
4107  connection_handle : 12,
4108  _reserved_ : 4,
4109  page_number : 8,
4110  maximum_page_number : 8,
4111  extended_lmp_features : 64,
4112}
4113
4114packet SynchronousConnectionComplete : EventPacket (event_code = SYNCHRONOUS_CONNECTION_COMPLETE){
4115  _payload_, // placeholder (unimplemented)
4116}
4117
4118packet SynchronousConnectionChanged : EventPacket (event_code = SYNCHRONOUS_CONNECTION_CHANGED){
4119  _payload_, // placeholder (unimplemented)
4120}
4121
4122packet SniffSubratingEvent : EventPacket (event_code = SNIFF_SUBRATING){
4123  status : ErrorCode,
4124  connection_handle : 12,
4125  _reserved_ : 4,
4126  maximum_transmit_latency : 16, // 0x000 - 0xFFFE (0s - 40.9s)
4127  maximum_receive_latency : 16, // 0x000 - 0xFFFE (0s - 40.9s)
4128  minimum_remote_timeout : 16, // 0x000 - 0xFFFE (0s - 40.9s)
4129  minimum_local_timeout : 16, // 0x000 - 0xFFFE (0s - 40.9s)
4130}
4131
4132packet ExtendedInquiryResult : EventPacket (event_code = EXTENDED_INQUIRY_RESULT) {
4133  _fixed_ = 0x01 : 8,
4134  address : Address,
4135  page_scan_repetition_mode : PageScanRepetitionMode,
4136  _reserved_ : 8,
4137  class_of_device : ClassOfDevice,
4138  clock_offset : 15,
4139  _reserved_ : 1,
4140  rssi : 8,
4141  extended_inquiry_response : GapData[],
4142}
4143
4144packet EncryptionKeyRefreshComplete : EventPacket (event_code = ENCRYPTION_KEY_REFRESH_COMPLETE){
4145  status : ErrorCode,
4146  connection_handle : 12,
4147  _reserved_ : 4,
4148}
4149
4150packet IoCapabilityRequest : EventPacket (event_code = IO_CAPABILITY_REQUEST){
4151  bd_addr : Address,
4152}
4153
4154packet IoCapabilityResponse : EventPacket (event_code = IO_CAPABILITY_RESPONSE){
4155  bd_addr : Address,
4156  io_capability : IoCapability,
4157  oob_data_present : OobDataPresent,
4158  authentication_requirements : AuthenticationRequirements,
4159}
4160
4161packet UserConfirmationRequest : EventPacket (event_code = USER_CONFIRMATION_REQUEST){
4162  bd_addr : Address,
4163  numeric_value : 20, // 0x00000-0xF423F (000000 - 999999)
4164  _reserved_ : 12,
4165}
4166
4167packet UserPasskeyRequest : EventPacket (event_code = USER_PASSKEY_REQUEST){
4168  bd_addr : Address,
4169}
4170
4171packet RemoteOobDataRequest : EventPacket (event_code = REMOTE_OOB_DATA_REQUEST){
4172  bd_addr : Address,
4173}
4174
4175packet SimplePairingComplete : EventPacket (event_code = SIMPLE_PAIRING_COMPLETE){
4176  status : ErrorCode,
4177  bd_addr : Address,
4178}
4179
4180packet LinkSupervisionTimeoutChanged : EventPacket (event_code = LINK_SUPERVISION_TIMEOUT_CHANGED){
4181  connection_handle : 12,
4182  _reserved_ : 4,
4183  link_supervision_timeout : 16, // 0x001-0xFFFF (0.625ms-40.9s)
4184}
4185
4186packet EnhancedFlushComplete : EventPacket (event_code = ENHANCED_FLUSH_COMPLETE){
4187  connection_handle : 12,
4188  _reserved_ : 4,
4189}
4190
4191packet UserPasskeyNotification : EventPacket (event_code = USER_PASSKEY_NOTIFICATION){
4192  bd_addr : Address,
4193  passkey : 20, // 0x00000-0xF423F (000000 - 999999)
4194  _reserved_ : 12,
4195}
4196
4197packet KeypressNotification : EventPacket (event_code = KEYPRESS_NOTIFICATION){
4198  bd_addr : Address,
4199  notification_type : KeypressNotificationType,
4200}
4201
4202packet RemoteHostSupportedFeaturesNotification : EventPacket (event_code = REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION){
4203  bd_addr : Address,
4204  host_supported_features : 64,
4205}
4206
4207packet LeMetaEvent : EventPacket (event_code = LE_META_EVENT) {
4208  subevent_code : SubeventCode,
4209  _body_,
4210}
4211
4212packet NumberOfCompletedDataBlocks : EventPacket (event_code = NUMBER_OF_COMPLETED_DATA_BLOCKS){
4213  _payload_, // placeholder (unimplemented)
4214}
4215
4216// LE Events
4217packet LeConnectionComplete : LeMetaEvent (subevent_code = CONNECTION_COMPLETE) {
4218  status : ErrorCode,
4219  connection_handle : 12,
4220  _reserved_ : 4,
4221  role : Role,
4222  peer_address_type : AddressType,
4223  peer_address : Address,
4224  conn_interval : 16, // 0x006 - 0x0C80 (7.5ms - 4000ms)
4225  conn_latency : 16,  // Number of connection events
4226  supervision_timeout : 16,  // 0x000A to 0x0C80 (100ms to 32s)
4227  master_clock_accuracy : ClockAccuracy,
4228}
4229
4230enum AdvertisingEventType : 8 {
4231  ADV_IND = 0x00,
4232  ADV_DIRECT_IND = 0x01,
4233  ADV_SCAN_IND = 0x02,
4234  ADV_NONCONN_IND = 0x03,
4235  SCAN_RESPONSE = 0x04,
4236}
4237
4238struct LeAdvertisingReport {
4239  event_type : AdvertisingEventType,
4240  address_type : AddressType,
4241  address : Address,
4242  _size_(advertising_data) : 8,
4243  advertising_data : GapData[],
4244  rssi : 8,
4245}
4246
4247packet LeAdvertisingReport : LeMetaEvent (subevent_code = ADVERTISING_REPORT) {
4248  _count_(advertising_reports) : 8,
4249  advertising_reports : LeAdvertisingReport[],
4250}
4251
4252packet LeConnectionUpdateComplete : LeMetaEvent (subevent_code = CONNECTION_UPDATE_COMPLETE) {
4253  status : ErrorCode,
4254  connection_handle : 12,
4255  _reserved_ : 4,
4256  conn_interval : 16, // 0x006 - 0x0C80 (7.5ms - 4000ms)
4257  conn_latency : 16,  // Number of connection events
4258  supervision_timeout : 16,  // 0x000A to 0x0C80 (100ms to 32s)
4259}
4260
4261packet LeReadRemoteFeaturesComplete : LeMetaEvent (subevent_code = READ_REMOTE_FEATURES_COMPLETE) {
4262  status : ErrorCode,
4263  connection_handle : 12,
4264  _reserved_ : 4,
4265  le_features : 64,
4266}
4267
4268packet LeLongTermKeyRequest : LeMetaEvent (subevent_code = LONG_TERM_KEY_REQUEST) {
4269  status : ErrorCode,
4270  connection_handle : 12,
4271  _reserved_ : 4,
4272  random_number : 64,
4273  encrypted_diversifier : 16,
4274}
4275
4276packet LeRemoteConnectionParameterRequest : LeMetaEvent (subevent_code = REMOTE_CONNECTION_PARAMETER_REQUEST) {
4277  connection_handle : 12,
4278  _reserved_ : 4,
4279  interval_min : 16, // 0x006 - 0x0C80 (7.5ms - 4s)
4280  interval_max : 16, // 0x006 - 0x0C80 (7.5ms - 4s)
4281  latency : 16,  // Number of connection events (0x0000 to 0x01f3 (499)
4282  timeout : 16,  // 0x000A to 0x0C80 (100ms to 32s)
4283}
4284
4285packet LeDataLengthChange : LeMetaEvent (subevent_code = DATA_LENGTH_CHANGE) {
4286  connection_handle : 12,
4287  _reserved_ : 4,
4288  max_tx_octets : 16, // 0x001B - 0x00FB
4289  max_tx_time : 16, // 0x0148 - 0x4290
4290  max_rx_octets : 16, // 0x001B - 0x00FB
4291  max_rx_time : 16, // 0x0148 - 0x4290
4292}
4293
4294packet ReadLocalP256PublicKeyComplete : LeMetaEvent (subevent_code = READ_LOCAL_P256_PUBLIC_KEY_COMPLETE) {
4295  status : ErrorCode,
4296  local_p_256_public_key : 8[64],
4297}
4298
4299packet GenerateDhKeyComplete : LeMetaEvent (subevent_code = GENERATE_DHKEY_COMPLETE) {
4300  status : ErrorCode,
4301  dh_key : 8[32],
4302}
4303
4304packet LeEnhancedConnectionComplete : LeMetaEvent (subevent_code = ENHANCED_CONNECTION_COMPLETE) {
4305  status : ErrorCode,
4306  connection_handle : 12,
4307  _reserved_ : 4,
4308  role : Role,
4309  peer_address_type : AddressType,
4310  peer_address : Address,
4311  local_resolvable_private_address : Address,
4312  peer_resolvable_private_address : Address,
4313  conn_interval : 16, // 0x006 - 0x0C80 (7.5ms - 4000ms)
4314  conn_latency : 16,  // Number of connection events
4315  supervision_timeout : 16,  // 0x000A to 0x0C80 (100ms to 32s)
4316  master_clock_accuracy : ClockAccuracy,
4317}
4318
4319enum DirectAdvertisingAddressType : 8 {
4320  PUBLIC_DEVICE_ADDRESS = 0x00,
4321  RANDOM_DEVICE_ADDRESS = 0x01,
4322  PUBLIC_IDENTITY_ADDRESS = 0x02,
4323  RANDOM_IDENTITY_ADDRESS = 0x03,
4324  CONTROLLER_UNABLE_TO_RESOLVE = 0xFE,
4325  NO_ADDRESS = 0xFF,
4326}
4327
4328enum DirectAdvertisingEventType : 8 {
4329  ADV_DIRECT_IND = 0x01,
4330}
4331
4332enum DirectAddressType : 8 {
4333  RANDOM_DEVICE_ADDRESS = 0x01,
4334}
4335
4336struct LeDirectedAdvertisingReport {
4337  event_type : DirectAdvertisingEventType,
4338  address_type : DirectAdvertisingAddressType,
4339  address : Address,
4340  direct_address_type : DirectAddressType,
4341  direct_address : Address,
4342  rssi : 8,
4343}
4344
4345packet LeDirectedAdvertisingReport : LeMetaEvent (subevent_code = DIRECTED_ADVERTISING_REPORT) {
4346  _count_(advertising_reports) : 8,
4347  advertising_reports : LeDirectedAdvertisingReport[],
4348}
4349
4350packet LePhyUpdateComplete : LeMetaEvent (subevent_code = PHY_UPDATE_COMPLETE) {
4351  _payload_, // placeholder (unimplemented)
4352}
4353
4354enum DataStatus : 2 {
4355  COMPLETE = 0x0,
4356  CONTINUING = 0x1,
4357  TRUNCATED = 0x2,
4358  RESERVED = 0x3,
4359}
4360
4361struct LeExtendedAdvertisingReport {
4362  connectable : 1,
4363  scannable : 1,
4364  directed : 1,
4365  scan_response : 1,
4366  data_status : DataStatus,
4367  _reserved_ : 10,
4368  address_type : DirectAdvertisingAddressType,
4369  address : Address,
4370  primary_phy : PrimaryPhyType,
4371  secondary_phy : SecondaryPhyType,
4372  advertising_sid : 4, // SID subfield in the ADI field
4373  _reserved_ : 4,
4374  tx_power : 8,
4375  rssi : 8, // -127 to +20 (0x7F means not available)
4376  periodic_advertising_interval : 16, // 0x006 to 0xFFFF (7.5 ms to 82s)
4377  direct_address_type : DirectAdvertisingAddressType,
4378  direct_address : Address,
4379  _size_(advertising_data) : 8,
4380  advertising_data : GapData[],
4381}
4382
4383packet LeExtendedAdvertisingReport : LeMetaEvent (subevent_code = EXTENDED_ADVERTISING_REPORT) {
4384  _count_(advertising_reports) : 8,
4385  advertising_reports : LeExtendedAdvertisingReport[],
4386}
4387
4388packet LePeriodicAdvertisingSyncEstablished : LeMetaEvent (subevent_code = PERIODIC_ADVERTISING_SYNC_ESTABLISHED) {
4389  _payload_, // placeholder (unimplemented)
4390}
4391
4392packet LePeriodicAdvertisingReport : LeMetaEvent (subevent_code = PERIODIC_ADVERTISING_REPORT) {
4393  _payload_, // placeholder (unimplemented)
4394}
4395
4396packet LePeriodicAdvertisingSyncLost : LeMetaEvent (subevent_code = PERIODIC_ADVERTISING_SYNC_LOST) {
4397  _payload_, // placeholder (unimplemented)
4398}
4399
4400packet LeScanTimeout : LeMetaEvent (subevent_code = SCAN_TIMEOUT) {
4401}
4402
4403packet LeAdvertisingSetTerminated : LeMetaEvent (subevent_code = ADVERTISING_SET_TERMINATED) {
4404  status : ErrorCode,
4405  advertising_handle : 8,
4406  connection_handle : 12,
4407  _reserved_ : 4,
4408  num_completed_extended_advertising_events : 8,
4409}
4410
4411packet LeScanRequestReceived : LeMetaEvent (subevent_code = SCAN_REQUEST_RECEIVED) {
4412  advertising_handle : 8,
4413  scanner_address_type : AddressType,
4414  scanner_address : Address,
4415}
4416
4417enum ChannelSelectionAlGorithm : 8 {
4418  ALGORITHM1 = 0,
4419  ALGORITHM2 = 1,
4420}
4421
4422packet LeChannelSelectionAlgorithm : LeMetaEvent (subevent_code = CHANNEL_SELECTION_ALGORITHM) {
4423  connection_handle : 12,
4424  _reserved_ : 4,
4425  channel_selection_algorithm : ChannelSelectionAlGorithm,
4426}
4427
4428packet LeConnectionlessIqReport : LeMetaEvent (subevent_code = CONNECTIONLESS_IQ_REPORT) {
4429  _payload_, // placeholder (unimplemented)
4430}
4431
4432packet LeConnectionIqReport : LeMetaEvent (subevent_code = CONNECTION_IQ_REPORT) {
4433  _payload_, // placeholder (unimplemented)
4434}
4435
4436packet LeCteRequestFailed : LeMetaEvent (subevent_code = CTE_REQUEST_FAILED) {
4437  _payload_, // placeholder (unimplemented)
4438}
4439
4440packet LePeriodicAdvertisingSyncTransferReceived : LeMetaEvent (subevent_code = PERIODIC_ADVERTISING_SYNC_TRANSFER_RECEIVED) {
4441  status : ErrorCode,
4442  connection_handle : 12,
4443  _reserved_ : 4,
4444  service_data : 16,
4445  sync_handle : 12,
4446  _reserved_ : 4,
4447  advertising_sid : 4,
4448  _reserved_ : 4,
4449  advertiser_address_type : AddressType,
4450  advertiser_address : Address,
4451  advertiser_phy : SecondaryPhyType,
4452  periodic_advertising_interval : 16,
4453  advertiser_clock_accuracy : ClockAccuracy,
4454}
4455
4456packet LeCisEstablished : LeMetaEvent (subevent_code = CIS_ESTABLISHED) {
4457  status : ErrorCode,
4458  connection_handle : 12,
4459  _reserved_ : 4,
4460  cig_sync_delay : 24,
4461  cis_sync_delay : 24,
4462  transport_latency_m_to_s : 24,
4463  transport_latency_s_to_m : 24,
4464  phy_m_to_s : SecondaryPhyType,
4465  phy_s_to_m : SecondaryPhyType,
4466  nse : 8,
4467  bn_m_to_s : 4,
4468  _reserved_ : 4,
4469  bn_s_to_m : 4,
4470  _reserved_ : 4,
4471  ft_m_to_s : 8,
4472  ft_s_to_m : 8,
4473  max_pdu_m_to_s : 8,
4474  _reserved_ : 8,
4475  max_pdu_s_to_m : 8,
4476  _reserved_ : 8,
4477  iso_interval : 16,
4478}
4479
4480packet LeCisRequest : LeMetaEvent (subevent_code = CIS_REQUEST) {
4481  acl_connection_handle : 12,
4482  _reserved_ : 4,
4483  cis_connection_handle : 12,
4484  _reserved_ : 4,
4485  cig_id : 8,
4486  cis_id : 8,
4487}
4488
4489packet LeCreateBigComplete : LeMetaEvent (subevent_code = CREATE_BIG_COMPLETE) {
4490  status : ErrorCode,
4491  big_handle : 8,
4492  big_sync_delay : 24,
4493  transport_latency_big: 24,
4494  phy : SecondaryPhyType,
4495  nse : 8,
4496  bn : 8,
4497  pto : 8,
4498  irc : 8,
4499  max_pdu : 16,
4500  iso_interval : 16,
4501  _size_(connection_handle) : 8,
4502  connection_handle : 16[],
4503}
4504
4505packet LeTerminateBigComplete : LeMetaEvent (subevent_code = TERMINATE_BIG_COMPLETE) {
4506  big_handle : 8,
4507  reason : ErrorCode,
4508}
4509
4510packet LeBigSyncEstablished : LeMetaEvent (subevent_code = BIG_SYNC_ESTABLISHED) {
4511  status : ErrorCode,
4512  big_handle : 8,
4513  transport_latency_big : 24,
4514  nse : 8,
4515  bn : 8,
4516  pto : 8,
4517  irc : 8,
4518  max_pdu : 16,
4519  iso_interval : 16,
4520  _size_(connection_handle) : 8,
4521  connection_handle : 16[],
4522}
4523
4524packet LeBigSyncLost : LeMetaEvent (subevent_code = BIG_SYNC_LOST) {
4525  big_handle : 8,
4526  reason : ErrorCode,
4527}
4528
4529packet LeRequestPeerScaComplete : LeMetaEvent (subevent_code = REQUEST_PEER_SCA_COMPLETE) {
4530  status : ErrorCode,
4531  connection_handle : 12,
4532  _reserved_ : 4,
4533  peer_clock_accuracy : ClockAccuracy,
4534}
4535
4536enum PathLossZone : 8 {
4537  LOW = 0,
4538  MID = 1,
4539  HIGH = 2,
4540}
4541
4542packet LePathLossThreshold : LeMetaEvent (subevent_code = PATH_LOSS_THRESHOLD) {
4543  connection_handle : 12,
4544  _reserved_ : 4,
4545  current_path_loss : 8,
4546  zone_entered : PathLossZone,
4547}
4548
4549packet LeTransmitPowerReporting : LeMetaEvent (subevent_code = TRANSMIT_POWER_REPORTING) {
4550  status : ErrorCode,
4551  connection_handle : 12,
4552  _reserved_ : 4,
4553  reason : 8,
4554  phy : 8,
4555  transmit_power_level : 8,
4556  transmit_power_level_flag : 8,
4557  delta : 8,
4558}
4559
4560packet LeBigInfoAdvertisingReport : LeMetaEvent (subevent_code = BIG_INFO_ADVERTISING_REPORT) {
4561  sync_handle : 12,
4562  _reserved_ : 4,
4563  num_bis : 8,
4564  nse : 8,
4565  iso_interval : 16,
4566  bn : 8,
4567  pto : 8,
4568  irc : 8,
4569  max_pdu : 16,
4570  sdu_interval : 24,
4571  max_sdu : 16,
4572  phy : SecondaryPhyType,
4573  framing : Enable,
4574  encryption : Enable,
4575}
4576
4577// Vendor specific events
4578
4579packet VendorSpecificEvent : EventPacket (event_code = VENDOR_SPECIFIC) {
4580  subevent_code : VseSubeventCode,
4581  _payload_,
4582}
4583
4584enum qualityReportId : 8 {
4585  MONITOR_MODE = 0x01,
4586  APPROACH_LSTO = 0x02,
4587  A2DP_AUDIO_CHOPPY = 0x03,
4588  SCO_VOICE_CHOPPY = 0x04,
4589  ROOT_INFLAMMATION = 0x05,
4590  LMP_LL_MESSAGE_TRACE = 0x11,
4591  BT_SCHEDULING_TRACE = 0x12,
4592  CONTROLLER_DBG_INFO = 0x13,
4593}
4594
4595packet BqrEvent : VendorSpecificEvent (subevent_code = BQR_EVENT) {
4596  quality_report_id : qualityReportId,
4597  _payload_,
4598}
4599
4600enum BqrPacketType : 8 {
4601  TYPE_ID = 0x01,
4602  TYPE_NULL = 0x02,
4603  TYPE_POLL = 0x03,
4604  TYPE_FHS = 0x04,
4605  TYPE_HV1 = 0x05,
4606  TYPE_HV2 = 0x06,
4607  TYPE_HV3 = 0x07,
4608  TYPE_DV = 0x08,
4609  TYPE_EV3 = 0x09,
4610  TYPE_EV4 = 0x0A,
4611  TYPE_EV5 = 0x0B,
4612  TYPE_2EV3 = 0x0C,
4613  TYPE_2EV5 = 0x0D,
4614  TYPE_3EV3 = 0x0E,
4615  TYPE_3EV5 = 0x0F,
4616  TYPE_DM1 = 0x10,
4617  TYPE_DH1 = 0x11,
4618  TYPE_DM3 = 0x12,
4619  TYPE_DH3 = 0x13,
4620  TYPE_DM5 = 0x14,
4621  TYPE_DH5 = 0x15,
4622  TYPE_AUX1 = 0x16,
4623  TYPE_2DH1 = 0x17,
4624  TYPE_2DH3 = 0x18,
4625  TYPE_2DH5 = 0x19,
4626  TYPE_3DH1 = 0x1A,
4627  TYPE_3DH3 = 0x1B,
4628  TYPE_3DH5 = 0x1C,
4629}
4630
4631packet BqrLinkQualityEvent : BqrEvent {
4632  packet_type : BqrPacketType,
4633  connection_handle : 12,
4634  _reserved_ : 4,
4635  connection_role : Role,
4636  tx_power_level : 8,
4637  rssi : 8,
4638  snr : 8,
4639  unused_afh_channel_count : 8,
4640  afh_select_unideal_channel_count : 8,
4641  lsto : 16,
4642  connection_piconet_clock : 32,
4643  retransmission_count : 32,
4644  no_rx_count : 32,
4645  nak_count : 32,
4646  last_tx_ack_timestamp : 32,
4647  flow_off_count : 32,
4648  last_flow_on_timestamp : 32,
4649  buffer_overflow_bytes : 32,
4650  buffer_underflow_bytes : 32,
4651  _payload_,
4652}
4653
4654packet BqrMonitorModeEvent : BqrLinkQualityEvent (quality_report_id = MONITOR_MODE) {
4655 _payload_, // vendor specific parameter
4656}
4657
4658packet BqrApproachLstoEvent : BqrLinkQualityEvent (quality_report_id = APPROACH_LSTO) {
4659 _payload_, // vendor specific parameter
4660}
4661
4662packet BqrA2dpAudioChoppyEvent : BqrLinkQualityEvent (quality_report_id = A2DP_AUDIO_CHOPPY) {
4663  _payload_, // vendor specific parameter
4664}
4665
4666packet BqrScoVoiceChoppyEvent : BqrLinkQualityEvent (quality_report_id = SCO_VOICE_CHOPPY) {
4667 _payload_, // vendor specific parameter
4668}
4669
4670packet BqrRootInflammationEvent : BqrEvent (quality_report_id = ROOT_INFLAMMATION) {
4671  error_code : 8,
4672  vendor_specific_error_code : 8,
4673  _payload_, // vendor specific parameter
4674}
4675
4676packet BqrLogDumpEvent : BqrEvent {
4677  connection_handle : 12,
4678  _reserved_ : 4,
4679  _payload_,
4680}
4681
4682packet BqrLmpLlMessageTraceEvent : BqrLogDumpEvent (quality_report_id = LMP_LL_MESSAGE_TRACE) {
4683  _payload_, // vendor specific parameter
4684}
4685
4686packet BqrBtSchedulingTraceEvent : BqrLogDumpEvent (quality_report_id = BT_SCHEDULING_TRACE) {
4687 _payload_, // vendor specific parameter
4688}
4689
4690packet BqrControllerDbgInfoEvent : BqrLogDumpEvent (quality_report_id = CONTROLLER_DBG_INFO) {
4691 _payload_, // vendor specific parameter
4692}
4693