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