xref: /aosp_15_r20/external/pigweed/pw_bluetooth/public/pw_bluetooth/hci_common.emb (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2023 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15# This file contains Emboss definitions for Host Controller Interface packets
16# and types found in the Bluetooth Core Specification. The Emboss compiler is
17# used to generate a C++ header from this file.
18
19[$default byte_order: "LittleEndian"]
20[(cpp) namespace: "pw::bluetooth::emboss"]
21# =========================== Common Definitions =================================
22
23
24enum StatusCode:
25  -- HCI Error Codes. Refer to Core Spec v5.4, Vol 1, Part F for definitions and
26  -- descriptions. All enum values are in increasing numerical order, however the
27  -- values are listed below for clarity.
28  [maximum_bits: 8]
29  SUCCESS                                           = 0x00
30  UNKNOWN_COMMAND                                   = 0x01
31  UNKNOWN_CONNECTION_ID                             = 0x02
32  HARDWARE_FAILURE                                  = 0x03
33  PAGE_TIMEOUT                                      = 0x04
34  AUTHENTICATION_FAILURE                            = 0x05
35  PIN_OR_KEY_MISSING                                = 0x06
36  MEMORY_CAPACITY_EXCEEDED                          = 0x07
37  CONNECTION_TIMEOUT                                = 0x08
38  CONNECTION_LIMIT_EXCEEDED                         = 0x09
39  SYNCHRONOUS_CONNECTION_LIMIT_EXCEEDED             = 0x0A
40  CONNECTION_ALREADY_EXISTS                         = 0x0B
41  COMMAND_DISALLOWED                                = 0x0C
42  CONNECTION_REJECTED_LIMITED_RESOURCES             = 0x0D
43  CONNECTION_REJECTED_SECURITY                      = 0x0E
44  CONNECTION_REJECTED_BAD_BD_ADDR                   = 0x0F
45  CONNECTION_ACCEPT_TIMEOUT_EXCEEDED                = 0x10
46  UNSUPPORTED_FEATURE_OR_PARAMETER                  = 0x11
47  INVALID_HCI_COMMAND_PARAMETERS                    = 0x12
48  REMOTE_USER_TERMINATED_CONNECTION                 = 0x13
49  REMOTE_DEVICE_TERMINATED_CONNECTION_LOW_RESOURCES = 0x14
50  REMOTE_DEVICE_TERMINATED_CONNECTION_POWER_OFF     = 0x15
51  CONNECTION_TERMINATED_BY_LOCAL_HOST               = 0x16
52  REPEATED_ATTEMPTS                                 = 0x17
53  PAIRING_NOT_ALLOWED                               = 0x18
54  UNKNOWN_LMP_PDU                                   = 0x19
55  UNSUPPORTED_REMOTE_FEATURE                        = 0x1A
56  SCO_OFFSET_REJECTED                               = 0x1B
57  SCO_INTERVAL_REJECTED                             = 0x1C
58  SCO_AIRMODE_REJECTED                              = 0x1D
59  INVALID_LMP_OR_LL_PARAMETERS                      = 0x1E
60  UNSPECIFIED_ERROR                                 = 0x1F
61  UNSUPPORTED_LMP_OR_LL_PARAMETER_VALUE             = 0x20
62  ROLE_CHANGE_NOT_ALLOWED                           = 0x21
63  LMP_OR_LL_RESPONSE_TIMEOUT                        = 0x22
64  LMP_ERROR_TRANSACTION_COLLISION                   = 0x23
65  LMP_PDU_NOT_ALLOWED                               = 0x24
66  ENCRYPTION_MODE_NOT_ACCEPTABLE                    = 0x25
67  LINK_KEY_CANNOT_BE_CHANGED                        = 0x26
68  REQUESTED_QOS_NOT_SUPPORTED                       = 0x27
69  INSTANT_PASSED                                    = 0x28
70  PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED               = 0x29
71  DIFFERENT_TRANSACTION_COLLISION                   = 0x2A
72  RESERVED_0                                        = 0x2B
73  QOS_UNACCEPTABLE_PARAMETER                        = 0x2C
74  QOS_REJECTED                                      = 0x2D
75  CHANNEL_CLASSIFICATION_NOT_SUPPORTED              = 0x2E
76  INSUFFICIENT_SECURITY                             = 0x2F
77  PARAMETER_OUT_OF_MANDATORY_RANGE                  = 0x30
78  RESERVED_1                                        = 0x31
79  ROLE_SWITCH_PENDING                               = 0x32
80  RESERVED_2                                        = 0x33
81  RESERVED_SLOT_VIOLATION                           = 0x34
82  ROLE_SWITCH_FAILED                                = 0x35
83  EXTENDED_INQUIRY_RESPONSE_TOO_LARGE               = 0x36
84  SECURE_SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST       = 0x37
85  HOST_BUSY_PAIRING                                 = 0x38
86  CONNECTION_REJECTED_NO_SUITABLE_CHANNEL_FOUND     = 0x39
87  CONTROLLER_BUSY                                   = 0x3A
88  UNACCEPTABLE_CONNECTION_PARAMETERS                = 0x3B
89  DIRECTED_ADVERTISING_TIMEOUT                      = 0x3C
90  CONNECTION_TERMINATED_MIC_FAILURE                 = 0x3D
91  CONNECTION_FAILED_TO_BE_ESTABLISHED               = 0x3E
92  MAC_CONNECTION_FAILED                             = 0x3F
93  COARSE_CLOCK_ADJUSTMENT_REJECTED                  = 0x40
94  # 5.0
95  TYPE_0_SUBMAP_NOT_DEFINED                         = 0x41
96  UNKNOWN_ADVERTISING_IDENTIFIER                    = 0x42
97  LIMIT_REACHED                                     = 0x43
98  OPERATION_CANCELLED_BY_HOST                       = 0x44
99  PACKET_TOO_LONG                                   = 0x45
100  TOO_LATE                                          = 0x46
101  TOO_EARLY                                         = 0x47
102
103
104enum OpCode:
105  -- HCI Command OpCodes. See Core Spec v5.0, Vol 2, Part E, Section 7 for definitions.
106
107  [maximum_bits: 16]
108
109  UNSPECIFIED                                                  = 0x0000
110    -- No OpCode set
111
112  ### Link Control Commands - Core Spec v5.0, Vol 2, Part E, Section 7.1 (OGF 0x01)
113
114  INQUIRY                                                      = 0x0401
115    -- Inquiry Command (v1.1) (BR/EDR)
116
117  INQUIRY_CANCEL                                               = 0x0402
118    -- Inquiry Cancel Command (v1.1) (BR/EDR)
119
120  CREATE_CONNECTION                                            = 0x0405
121    -- Create Connection (v1.1) (BR/EDR)
122
123  DISCONNECT                                                   = 0x0406
124    -- Disconnect Command (v1.1) (BR/EDR & LE)
125
126  CREATE_CONNECTION_CANCEL                                     = 0x0408
127    -- Create Connection Cancel (v1.1) (BR/EDR)
128
129  ACCEPT_CONNECTION_REQUEST                                    = 0x0409
130    -- Accept Connection Request (v1.1) (BR/EDR)
131
132  REJECT_CONNECTION_REQUEST                                    = 0x040A
133    -- Reject Connection Request (v1.1) (BR/EDR)
134
135  LINK_KEY_REQUEST_REPLY                                       = 0x040B
136    -- Link Key Request Reply Command (v1.1) (BR/EDR)
137
138  LINK_KEY_REQUEST_NEGATIVE_REPLY                              = 0x040C
139    -- Link Key Request Negative Reply Command (v1.1) (BR/EDR)
140
141  AUTHENTICATION_REQUESTED                                     = 0x0411
142    -- Authentication Requested Command (v1.1) (BR/EDR)
143
144  SET_CONNECTION_ENCRYPTION                                    = 0x0413
145    -- Set Connection Encryption Command (v1.1) (BR/EDR)
146
147  REMOTE_NAME_REQUEST                                          = 0x0419
148    -- Remote Name Request Command (v1.1) (BR/EDR)
149
150  READ_REMOTE_SUPPORTED_FEATURES                               = 0x041B
151    -- Read Remote Supported Features Command (v1.1) (BR/EDR)
152
153  READ_REMOTE_EXTENDED_FEATURES                                = 0x041C
154    -- Read Remote Extended Features Command (v1.2) (BR/EDR)
155
156  READ_REMOTE_VERSION_INFO                                     = 0x041D
157    -- Read Remote Version Information Command (v1.1) (BR/EDR & LE)
158
159  IO_CAPABILITY_REQUEST_REPLY                                  = 0x042B
160    -- IO Capability Request Reply Command (v2.1 + EDR) (BR/EDR)
161
162  USER_CONFIRMATION_REQUEST_REPLY                              = 0x042C
163    -- User Confirmation Request Reply Command (v2.1 + EDR) (BR/EDR)
164
165  USER_PASSKEY_REQUEST_REPLY                                   = 0x042E
166    -- User Passkey Request Reply Command (v2.1 + EDR) (BR/EDR)
167
168  USER_PASSKEY_REQUEST_NEGATIVE_REPLY                          = 0x042F
169    -- User Passkey Request Negative Reply Command (v2.1 + EDR) (BR/EDR)
170
171  IO_CAPABILITY_REQUEST_NEGATIVE_REPLY                         = 0x0434
172    -- IO Capability Request Negative Reply Command (v2.1 + EDR) (BR/EDR)
173
174  ### Link Policy Commands - Core Spec v5.4, Part E, Section 7.32 (OGF 0x02)
175
176  SNIFF_MODE                                                   = 0x0803
177    -- Sniff Mode Command
178
179  ### Controller & Baseband Commands - Core Spec v5.0 Vol 2, Part E, Section 7.3 (OGF 0x03)
180
181  SET_EVENT_MASK                                               = 0x0C01
182    -- Set Event Mask Command (v1.1)
183
184  RESET                                                        = 0x0C03
185    -- Reset Command (v1.1)
186
187  WRITE_LOCAL_NAME                                             = 0x0C13
188    -- Write Local Name Command (v1.1) (BR/EDR)
189
190  READ_LOCAL_NAME                                              = 0x0C14
191    -- Read Local Name Command (v1.1) (BR/EDR)
192
193  WRITE_PAGE_TIMEOUT                                           = 0x0C18
194    -- Write Page Timeout Command (v1.1) (BR/EDR)
195
196  READ_SCAN_ENABLE                                             = 0x0C19
197    -- Read Scan Enable Command (v1.1) (BR/EDR)
198
199  WRITE_SCAN_ENABLE                                            = 0x0C1A
200    -- Write Scan Enable Command (v1.1) (BR/EDR)
201
202  READ_PAGE_SCAN_ACTIVITY                                      = 0x0C1B
203    -- Read Page Scan Activity Command (v1.1) (BR/EDR)
204
205  WRITE_PAGE_SCAN_ACTIVITY                                     = 0x0C1C
206    -- Write Page Scan Activity Command (v1.1) (BR/EDR)
207
208  READ_INQUIRY_SCAN_ACTIVITY                                   = 0x0C1D
209    -- Read Inquiry Scan Activity Command (v1.1) (BR/EDR)
210
211  READ_CLASS_OFDEVICE                                          = 0x0C23
212    -- Read Class of Device Command (v1.1) (BR/EDR)
213
214  WRITE_CLASS_OFDEVICE                                         = 0x0C24
215    -- Write Class Of Device Command (v1.1) (BR/EDR)
216
217  READ_TRANSMIT_POWER_LEVEL                                    = 0x0C2D
218    -- Read Transmit Transmit Power Level Command (v1.1) (BR/EDR & LE)
219
220  READ_INQUIRY_SCAN_TYPE                                       = 0x0C42
221    -- Read Inquiry Scan Type (v1.2) (BR/EDR)
222
223  WRITE_INQUIRY_SCAN_TYPE                                      = 0x0C43
224    -- Write Inquiry Scan Type (v1.2) (BR/EDR)
225
226  READ_INQUIRY_MODE                                            = 0x0C44
227    -- Read Inquiry Mode (v1.2) (BR/EDR)
228
229  WRITE_INQUIRY_MODE                                           = 0x0C45
230    -- Write Inquiry Mode (v1.2) (BR/EDR)
231
232  READ_PAGE_SCAN_TYPE                                          = 0x0C46
233    -- Read Page Scan Type (v1.2) (BR/EDR)
234
235  WRITE_PAGE_SCAN_TYPE                                         = 0x0C47
236    -- Write Page Scan Type (v1.2) (BR/EDR)
237
238  READ_SIMPLE_PAIRING_MODE                                     = 0x0C55
239    -- Read Simple Pairing Mode (v2.1 + EDR) (BR/EDR)
240
241  WRITE_SIMPLE_PAIRING_MODE                                    = 0x0C56
242    -- Write Simple Pairing Mode (v2.1 + EDR) (BR/EDR)
243
244  SET_EVENT_MASK_PAGE2                                         = 0x0C63
245    -- Set Event Mask Page 2 Command (v3.0 + HS)
246
247  READ_FLOW_CONTROL_MODE                                       = 0x0C66
248    -- Read Flow Control Mode Command (v3.0 + HS) (BR/EDR & AMP)
249
250  WRITE_FLOW_CONTROL_MODE                                      = 0x0C67
251    -- Write Flow Control Mode Command (v3.0 + HS) (BR/EDR & AMP)
252
253  READ_LE_HOST_SUPPORT                                         = 0x0C6C
254    -- Read LE Host Support Command (v4.0) (BR/EDR)
255
256  WRITE_LE_HOST_SUPPORT                                        = 0x0C6D
257    -- Write LE Host Support Command (v4.0) (BR/EDR)
258
259  ### Informational Parameters - Core Spec v5.0 Vol 2, Part E, Section 7.4 (OGF 0x04)
260
261  READ_LOCAL_VERSION_INFO                                      = 0x1001
262    -- Read Local Version Information Command (v1.1)
263
264  READ_LOCAL_SUPPORTED_COMMANDS                                = 0x1002
265    -- Read Local Supported Commands Command (v1.2)
266
267  READ_LOCAL_SUPPORTED_FEATURES                                = 0x1003
268    -- Read Local Supported Features Command (v1.1)
269
270  READ_LOCAL_EXTENDED_FEATURES                                 = 0x1004
271    -- Read Local Extended Features Command (v1.2) (BR/EDR)
272
273  READ_BUFFER_SIZE                                             = 0x1005
274    -- Read Buffer Size Command (v1.1)
275
276  READ_BD_ADDR                                                 = 0x1009
277    -- Read BD_ADDR Command (v1.1) (BR/EDR, LE)
278
279  READ_DATA_BLOCK_SIZE                                         = 0x100A
280    -- Read Data Block Size Command (v3.0 + HS) (BR/EDR & AMP)
281
282  READ_LOCAL_SUPPORTED_CODECS_V1                               = 0x100B
283    -- Read Local Supported Codecs Command [v1] (CSA2)
284
285  READ_LOCAL_SIMPLE_PAIRING_OPTIONS                            = 0x100C
286    -- Read Local Simple Pairing Options Command (Erratum 10734)
287
288  READ_LOCAL_SUPPORTED_CODECS_V2                               = 0x100D
289    -- Read Local Supported Codecs Command [v2] (v5.2)
290
291  READ_LOCAL_SUPPORTED_CODEC_CAPABILITIES                      = 0x100E
292    -- Read Local Supported Codec Capabilities Command (v5.2)
293
294  READ_LOCAL_SUPPORTED_CONTROLLER_DELAY                        = 0x100F
295    -- Read Local Supported Controller Delay Command (v5.2)
296
297  ### Status Parameters - Core Spec v5.0, Vol 2, Part E, Section 7.5 (OGF 0x05)
298
299  READ_RSSI                                                    = 0x1405
300    -- Read RSSI Command (v1.1)
301
302  READ_ENCRYPTION_KEY_SIZE                                     = 0x1408
303    -- Read Encryption Key Size (v1.1) (BR/EDR)
304
305  ### LE Controller Commands - Core Spec v5.0 Vol 2, Part E, Section 7.8 (OGF 0x08)
306
307  LE_SET_EVENT_MASK                                            = 0x2001
308    -- LE Set Event Mask Command (v4.0) (LE)
309
310  LE_READ_BUFFER_SIZE_V1                                       = 0x2002
311    -- LE Read Buffer Size [v1] Command (v4.0) (LE)
312
313  LE_READ_LOCAL_SUPPORTED_FEATURES                             = 0x2003
314    -- LE Read Local Supported Features Command (v4.0) (LE)
315
316  LE_SET_RANDOM_ADDRESS                                        = 0x2005
317    -- LE Set Random Address Command (v4.0) (LE)
318
319  LE_SET_ADVERTISING_PARAMETERS                                = 0x2006
320    -- LE Set Advertising Parameters Command (v4.0) (LE)
321
322  LE_READ_ADVERTISING_CHANNEL_TX_POWER                         = 0x2007
323    -- LE Read Advertising Physical Channel Tx Power Command (v4.0) (LE)
324
325  LE_SET_ADVERTISING_DATA                                      = 0x2008
326    -- LE Set Advertising Data Command (v4.0) (LE)
327
328  LE_SET_SCAN_RESPONSE_DATA                                    = 0x2009
329    -- LE Set Scan Response Data Command (v4.0) (LE)
330
331  LE_SET_ADVERTISING_ENABLE                                    = 0x200A
332    -- LE Set Advertising Enable Command (v4.0) (LE)
333
334  LE_SET_SCAN_PARAMETERS                                       = 0x200B
335    -- LE Set Scan Parameters Command (v4.0) (LE)
336
337  LE_SET_SCAN_ENABLE                                           = 0x200C
338    -- LE Set Scan Enable Command (v4.0) (LE)
339
340  LE_CREATE_CONNECTION                                         = 0x200D
341    -- LE Create Connection Command (v4.0) (LE)
342
343  LE_CREATE_CONNECTION_CANCEL                                  = 0x200E
344    -- LE Create Connection Cancel Command (v4.0) (LE)
345
346  LE_CLEAR_FILTER_ACCEPT_LIST                                  = 0x2010
347    -- LE Clear Filter Accept List Command (v4.0) (LE)
348
349  LE_CONNECTION_UPDATE                                         = 0x2013
350    -- LE Connection Update Command (v4.0) (LE)
351
352  LE_READ_CHANNEL_MAP                                          = 0x2015
353    -- LE Read Channel Map Command (v4.0) (LE)
354
355  LE_READ_REMOTE_FEATURES                                      = 0x2016
356    -- LE Read Remote Features Command (v4.0) (LE)
357
358  LE_ENCRYPT                                                   = 0x2017
359    -- LE Encrypt Command (v4.0) (LE)
360
361  LE_RAND                                                      = 0x2018
362    -- LE Rand Command (v4.0) (LE)
363
364  LE_START_ENCRYPTION                                          = 0x2019
365    -- LE Start Encryption Command (v4.0) (LE)
366
367  LE_LONG_TERM_KEY_REQUEST_REPLY                               = 0x201A
368    -- LE Long Term Key Request Reply Command (v4.0) (LE)
369
370  LE_READ_SUPPORTED_STATES                                     = 0x201C
371    -- LE Read Supported States Command (v4.0) (LE)
372
373  LE_RECEIVER_TEST                                             = 0x201D
374    -- LE Receiver Test Command (v4.0) (LE)
375
376  LE_TRANSMITTER_TEST                                          = 0x201E
377    -- LE Transmitter Test Command (v4.0) (LE)
378
379  LE_TEST_END                                                  = 0x201F
380    -- LE Test End Command (v4.0) (LE)
381
382  LE_SET_DATA_LENGTH                                           = 0x2022
383    -- LE Set Data Length Command (v4.2) (LE)
384
385  LE_READ_LOCAL_P256_PUBLIC_KEY                                = 0x2025
386    -- LE Read Local P-256 Public Key Command (v4.2) (LE)
387
388  LE_GENERATE_DH_KEY                                           = 0x2026
389    -- LE Generate DH Key Command (v4.2) (LE)
390
391  LE_CLEAR_RESOLVING_LIST                                      = 0x2029
392    -- LE Clear Resolving List Command (v4.2) (LE)
393
394  LE_READ_RESOLVING_LIST_SIZE                                  = 0x202A
395    -- LE Read Resolving List Size Command (v4.2) (LE)
396
397  LE_READ_MAXIMUM_DATA_LENGTH                                  = 0x202F
398    -- LE Read Maximum Data Length Command (v4.2) (LE)
399
400  LE_READ_PHY                                                  = 0x2030
401    -- LE Read PHY Command (v5.0) (LE)
402
403  LE_SET_DEFAULT_PHY                                           = 0x2031
404    -- LE Set Default PHY Command (v5.0) (LE)
405
406  LE_SET_PHY                                                   = 0x2032
407    -- LE Set PHY Command (v5.0) (LE)
408
409  LE_ENHANCED_RECEIVER_TEXT                                    = 0x2033
410    -- LE Enhanced Receiver Test Command (v5.0) (LE)
411
412  LE_ENHANCED_TRANSMITTER_TEST                                 = 0x2034
413    -- LE Enhanced Transmitter Test Command (v5.0) (LE)
414
415  LE_SET_ADVERTISING_SET_RANDOM_ADDRESS                        = 0x2035
416    -- LE Set Advertising Set Random Address Command (v5.0) (LE)
417
418  LE_SET_EXTENDED_ADVERTISING_PARAMETERS_V1                    = 0x2036
419    -- LE Set Extended Advertising Parameters [v1] (v5.0) (LE)
420
421  LE_SET_EXTENDED_ADVERTISING_DATA                             = 0x2037
422    -- LE Set Extended Advertising Data Command (v5.0) (LE)
423
424  LE_SET_EXTENDED_SCAN_RESPONSE_DATA                           = 0x2038
425    -- LE Set Extended Scan Response Data Command (v5.0) (LE)
426
427  LE_SET_EXTENDED_ADVERTISING_ENABLE                           = 0x2039
428    -- LE Set Extended Advertising Enable Command (v5.0) (LE)
429
430  LE_READ_MAXIMUM_ADVERTISING_DATA_LENGTH                      = 0x203A
431    -- LE Read Maximum Advertising Data Length Command (v5.0) (LE)
432
433  LE_READ_NUMBER_OF_SUPPORTED_ADVERTISING_SETS                 = 0x203B
434    -- LE Read Number of Supported Advertising Sets Command (v5.0) (LE)
435
436  LE_REMOVE_ADVERTISING_SET                                    = 0x203C
437    -- LE Remove Advertising Set Command (v5.0) (LE)
438
439  LE_CLEAR_ADVERTISING_SETS                                    = 0x203D
440    -- LE Clear Advertising Sets Command (v5.0) (LE)
441
442  LE_SET_EXTENDED_SCAN_ENABLE                                  = 0x2042
443    -- LE Set Extended Scan Enable Command (v5.0) (LE)
444
445  LE_READ_TRANSMIT_POWER                                       = 0x204B
446    -- LE Read Transmit Power Command (v5.0) (LE)
447
448  LE_READ_RF_PATH_COMPENSATION                                 = 0x204C
449    -- LE Read RF Path Compensation Command (v5.0) (LE)
450
451  LE_WRITE_RF_PATH_COMPENSATION                                = 0x204D
452    -- LE Write RF Path Compensation Command (v5.0) (LE)
453
454  LE_SET_PRIVACY_MODE                                          = 0x204E
455    -- LE Set Privacy Mode Command (v5.0) (LE)
456
457  LE_SET_PERIODIC_ADVERTISING_RECEIVE_ENABLE                   = 0x2059
458    -- LE Set Periodic Advertising Receive Enable Command (v5.1) (LE)
459
460  LE_PERIODIC_ADVERTISING_SYNC_TRANSFER                        = 0x205A
461    -- LE Periodic Advertising Sync Transfer Command (v5.1) (LE)
462
463  LE_PERIODIC_ADVERTISING_SET_INFO_TRANSFER                    = 0x205B
464    -- LE Periodic Advertising Set Info Transfer Command (v5.1) (LE)
465
466  LE_SET_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS         = 0x205C
467    -- LE Set Periodic Advertising Sync Transfer Parameters Command (v5.1) (LE)
468
469  LE_SET_DEFAULT_PERIODIC_ADVERTISING_SYNC_TRANSFER_PARAMETERS = 0x205D
470    -- LE Set Default Periodic Advertising Sync Transfer Parameters Command (v5.1) (LE)
471
472  LE_MODIFY_SLEEP_CLOCK_ACCURACY                               = 0x205F
473    -- LE Modify Sleep Clock Accuracy Command (v5.1) (LE)
474
475  LE_READ_BUFFER_SIZE_V2                                       = 0x2060
476    -- LE Read Buffer Size [v2] Command (v5.2) (LE)
477
478  LE_READ_ISO_TX_SYNC                                          = 0x2061
479    -- LE Read ISO TX Sync Command (v5.2) (LE)
480
481  LE_SET_CIG_PARAMETERS                                        = 0x2062
482    -- LE Set CIG Parameters Command (v5.2) (LE)
483
484  LE_SET_CIG_PARAMETERS_TEST                                   = 0x2063
485    -- LE Set CIG Parameters Test Command (v5.2) (LE)
486
487  LE_CREATE_CIS                                                = 0x2064
488    -- LE Create CIS Command (v5.2) (LE)
489
490  LE_REMOVE_CIG                                                = 0x2065
491    -- LE Remove CIG Command (v5.2) (LE)
492
493  LE_ACCEPT_CIS_REQUEST                                        = 0x2066
494    -- LE Accept CIS Request Command (v5.2) (LE)
495
496  LE_REJECT_CIS_REQUEST                                        = 0x2067
497    -- LE Reject CIS Request Command (v5.2) (LE)
498
499  LE_CREATE_BIG                                                = 0x2068
500    -- LE Create BIG Command (v5.2) (LE)
501
502  LE_CREATE_BIG_TEST                                           = 0x2069
503    -- LE Create BIG Test Command (v5.2) (LE)
504
505  LE_TERMINATE_BIG                                             = 0x206A
506    -- LE Terminate BIG Command (v5.2) (LE)
507
508  LE_BIG_CREATE_SYNC                                           = 0x206B
509    -- LE BIG Create Sync Command (v5.2) (LE)
510
511  LE_BIG_TERMINATE_SYNC                                        = 0x206C
512    -- LE BIG Terminate Sync Command (v5.2) (LE)
513
514  LE_REQUEST_PEER_SCA                                          = 0x206D
515    -- LE Request Peer SCA Command (v5.2) (LE)
516
517  LE_SETUP_ISO_DATA_PATH                                       = 0x206E
518    -- LE Setup ISO Data Path Command (v5.2) (LE)
519
520  LE_REMOVE_ISO_DATA_PATH                                      = 0x206F
521    -- LE Remove ISO Data Path Command (v5.2) (LE)
522
523  LE_ISO_TRANSMIT_TEST                                         = 0x2070
524    -- LE ISO Transmit Test Command (v5.2) (LE)
525
526  LE_ISO_RECEIVE_TEST                                          = 0x2071
527    -- LE ISO Receive Test Command (v5.2) (LE)
528
529  LE_ISO_READ_TEST_COUNTERS                                    = 0x2072
530    -- LE ISO Read Test Counters Command (v5.2) (LE)
531
532  LE_ISO_TEST_END                                              = 0x2073
533    -- LE ISO Test End Command (v5.2) (LE)
534
535  LE_SET_HOST_FEATURE                                          = 0x2074
536    -- LE Set Host Feature Command (v5.2) (LE)
537
538  LE_READ_ISO_LINK_QUALITY                                     = 0x2075
539    -- LE Read ISO Link Quality Command (v5.2) (LE)
540
541  LE_SET_EXTENDED_ADVERTISING_PARAMETERS_V2                    = 0x207F
542    -- LE Set Extended Advertising Parameters Command (v5.4) (LE)
543
544
545enum EventCode:
546  -- HCI Event Codes. See Core Spec v5.0 Vol 2, Part E, Section 7.7.
547  [maximum_bits: 8]
548  INQUIRY_COMPLETE                            = 0x01
549  INQUIRY_RESULT                              = 0x02
550  CONNECTION_COMPLETE                         = 0x03
551  CONNECTION_REQUEST                          = 0x04
552  DISCONNECTION_COMPLETE                      = 0x05
553  AUTHENTICATION_COMPLETE                     = 0x06
554  REMOTE_NAME_REQUEST_COMPLETE                = 0x07
555  ENCRYPTION_CHANGE                           = 0x08
556  CHANGE_CONNECTION_LINK_KEY_COMPLETE         = 0x09
557  CENTRAL_LINK_KEY_COMPLETE                   = 0x0A
558  READ_REMOTE_SUPPORTED_FEATURES_COMPLETE     = 0x0B
559  READ_REMOTE_VERSION_INFORMATION_COMPLETE    = 0x0C
560  QOS_SETUP_COMPLETE                          = 0x0D
561  COMMAND_COMPLETE                            = 0x0E
562  COMMAND_STATUS                              = 0x0F
563  HARDWARE_ERROR                              = 0x10
564  FLUSH_OCCURRED                              = 0x11
565  ROLE_CHANGE                                 = 0x12
566  NUMBER_OF_COMPLETED_PACKETS                 = 0x13
567  MODE_CHANGE                                 = 0x14
568  RETURN_LINK_KEYS                            = 0x15
569  PIN_CODE_REQUEST                            = 0x16
570  LINK_KEY_REQUEST                            = 0x17
571  LINK_KEY_NOTIFICATION                       = 0x18
572  LOOPBACK_COMMAND                            = 0x19
573  DATA_BUFFER_OVERFLOW                        = 0x1A
574  MAX_SLOTS_CHANGE                            = 0x1B
575  READ_CLOCK_OFFSET_COMPLETE                  = 0x1C
576  CONNECTION_PACKET_TYPE_CHANGED              = 0x1D
577  QOS_VIOLATION                               = 0x1E
578  PAGE_SCAN_REPETITION_MODE_CHANGE            = 0x20
579  FLOW_SPECIFICATION_COMPLETE                 = 0x21
580  INQUIRY_RESULT_WITH_RSSI                    = 0x22
581  READ_REMOTE_EXTENDED_FEATURES_COMPLETE      = 0x23
582  SYNCHRONOUS_CONNECTION_COMPLETE             = 0x2C
583  SYNCHRONOUS_CONNECTION_CHANGED              = 0x2D
584  SNIFF_SUBRATING                             = 0x2E
585  EXTENDED_INQUIRY_RESULT                     = 0x2F
586  ENCRYPTION_KEY_REFRESH_COMPLETE             = 0x30
587  IO_CAPABILITY_REQUEST                       = 0x31
588  IO_CAPABILITY_RESPONSE                      = 0x32
589  USER_CONFIRMATION_REQUEST                   = 0x33
590  USER_PASSKEY_REQUEST                        = 0x34
591  REMOTE_OOB_DATA_REQUEST                     = 0x35
592  SIMPLE_PAIRING_COMPLETE                     = 0x36
593  LINK_SUPERVISION_TIMEOUT_CHANGED            = 0x38
594  ENHANCED_FLUSH_COMPLETE                     = 0x39
595  USER_PASSKEY_NOTIFICATION                   = 0x3B
596  KEYPRESS_NOTIFICATION                       = 0x3C
597  REMOTE_HOST_SUPPORTED_FEATURES_NOTIFICATION = 0x3D
598  LE_META_EVENT                               = 0x3E
599  NUMBER_OF_COMPLETED_DATA_BLOCKS             = 0x48
600  VENDOR_DEBUG                                = 0xFF
601
602
603enum LeSubEventCode:
604  -- HCI LE Meta event SubEvent codes
605  -- Core Spec v6.0 Vol 4, Part E, Section 7.7.65
606  [maximum_bits: 8]
607  CONNECTION_COMPLETE                   = 0x01
608  ADVERTISING_REPORT                    = 0x02
609  CONNECTION_UPDATE_COMPLETE            = 0x03
610  READ_REMOTE_FEATURES_COMPLETE         = 0x04
611  LONG_TERM_KEY_REQUEST                 = 0x05
612  REMOTE_CONNECTION_PARAMETER_REQUEST   = 0x06
613  DATA_LENGTH_CHANGE                    = 0x07
614  READ_LOCAL_P256_PUBLIC_KEY_COMPLETE   = 0x08
615  GENERATE_DH_KEY_COMPLETE              = 0x09
616  ENHANCED_CONNECTION_COMPLETE_V1       = 0x0A
617  DIRECTED_ADVERTISING_REPORT           = 0x0B
618  PHY_UPDATE_COMPLETE                   = 0x0C
619  EXTENDED_ADVERTISING_REPORT           = 0x0D
620  PERIODIC_ADVERTISING_SYNC_ESTABLISHED = 0x0E
621  PERIODIC_ADVERTISING_REPORT           = 0x0F
622  PERIODIC_ADVERTISING_SYNC_LOST        = 0x10
623  SCAN_TIMEOUT                          = 0x11
624  ADVERTISING_SET_TERMINATED            = 0x12
625  SCAN_REQUEST_RECEIVED                 = 0x13
626  CHANNEL_SELECTION_ALGORITHM           = 0x14
627  CIS_ESTABLISHED                       = 0x19
628  REQUEST_PEER_SCA_COMPLETE             = 0x1F
629  CIS_REQUEST                           = 0x1A
630  ENHANCED_CONNECTION_COMPLETE_V2       = 0x29
631
632
633enum MajorDeviceClass:
634  [maximum_bits: 5]
635  MISCELLANEOUS = 0x00
636  COMPUTER      = 0x01
637  PHONE         = 0x02
638  LAN           = 0x03
639  AUDIO_VIDEO   = 0x04
640  PERIPHERAL    = 0x05
641  IMAGING       = 0x06
642  WEARABLE      = 0x07
643  TOY           = 0x08
644  HEALTH        = 0x09
645  UNCATEGORIZED = 0x1F
646
647
648bits MajorServiceClasses:
649  0     [+1]  Flag  limited_discoverable_mode
650  $next [+1]  Flag  le_audio
651  $next [+1]  Flag  reserved
652  $next [+1]  Flag  positioning
653  $next [+1]  Flag  networking
654  $next [+1]  Flag  rendering
655  $next [+1]  Flag  capturing
656  $next [+1]  Flag  object_transfer
657  $next [+1]  Flag  audio
658  $next [+1]  Flag  telephony
659  $next [+1]  Flag  information
660
661
662enum ComputerMinorDeviceClass:
663  [maximum_bits: 6]
664  UNCATEGORIZED       = 0x00
665  DESKTOP_WORKSTATION = 0x01
666  SERVER_CLASS        = 0x02
667  LAPTOP              = 0x03
668  HANDHELD_PC         = 0x04
669  PALM_SIZE_PC        = 0x05
670  WEARABLE            = 0x06
671  TABLET              = 0x07
672
673
674enum PhoneMinorDeviceClass:
675  [maximum_bits: 6]
676  UNCATEGORIZED               = 0x00
677  CELLULAR                    = 0x01
678  CORDLESS                    = 0x02
679  SMARTPHONE                  = 0x03
680  WIRED_MODEM_OR_VOID_GATEWAY = 0x04
681  COMMON_ISDN_ACCESS          = 0x05
682
683
684enum LANMinorDeviceClass:
685  [maximum_bits: 6]
686  FULLY_AVAILABLE      = 0x00
687  UTILIZED_1_TO_17     = 0x08
688  UTILIZED_17_TO_33    = 0x10
689  UTILIZED_33_TO_50    = 0x18
690  UTILIZED_50_TO_67    = 0x20
691  UTILIZED_67_TO_83    = 0x28
692  UTILIZED_83_TO_99    = 0x30
693  NO_SERVICE_AVAILABLE = 0x38
694
695
696enum AudioVideoMinorDeviceClass:
697  [maximum_bits: 6]
698  UNCATEGORIZED                 = 0x00
699  WEARABLE_HEADSET_DEVICE       = 0x01
700  HANDS_FREE_DEVICE             = 0x02
701  RESERVED_0                    = 0x03
702  MICROPHONE                    = 0x04
703  LOUDSPEAKER                   = 0x05
704  HEADPHONES                    = 0x06
705  PORTABLE_AUDIO                = 0x07
706  CAR_AUDIO                     = 0x08
707  SET_TOP_BOX                   = 0x09
708  HIFI_AUDIO_DEVICE             = 0x0A
709  VCR                           = 0x0B
710  VIDEO_CAMERA                  = 0x0C
711  CAMCORDER                     = 0x0D
712  VIDEO_MONITOR                 = 0x0E
713  VIDEO_DISPLAY_AND_LOUDSPEAKER = 0x0F
714  VIDEO_CONFERENCING            = 0x10
715  RESERVED_1                    = 0x11
716  GAMING_TOY                    = 0x12
717
718
719enum PeripheralMinorDeviceClass0:
720  [maximum_bits: 4]
721  UNCATEGORIZED                  = 0x00
722  JOYSTICK                       = 0x01
723  GAMEPAD                        = 0x02
724  REMOTE_CONTROL                 = 0x03
725  SENSING_DEVICE                 = 0x04
726  DIGITIZER_TABLET               = 0x05
727  CARD_READER                    = 0x06
728  DIGITAL_PEN                    = 0x07
729  HANDHELD_SCANNER               = 0x08
730  HANDHELD_GESTURAL_INPUT_DEVICE = 0x09
731
732
733enum PeripheralMinorDeviceClass1:
734  [maximum_bits: 2]
735  UNCATEGORIZED                  = 0x00
736  KEYBOARD                       = 0x01
737  POINTING_DEVICE                = 0x02
738  COMBO_KEYBOARD_POINTING_DEVICE = 0x03
739
740
741bits PeripheralMinorDeviceClass:
742  0     [+4]  PeripheralMinorDeviceClass0  device_class_0
743  $next [+2]  PeripheralMinorDeviceClass1  device_class_1
744
745
746enum ImagingMinorDeviceClass:
747  [maximum_bits: 2]
748  UNCATEGORIZED = 0x00
749
750
751bits ImagingMinorDeviceClassBits:
752  0     [+2]  ImagingMinorDeviceClass  device_class
753  $next [+1]  Flag                     display
754  $next [+1]  Flag                     camera
755  $next [+1]  Flag                     scanner
756  $next [+1]  Flag                     printer
757
758
759enum WearableMinorDeviceClass:
760  [maximum_bits: 6]
761  WRISTWATCH = 0x01
762  PAGER      = 0x02
763  JACKET     = 0x03
764  HELMET     = 0x04
765  GLASSES    = 0x05
766
767
768enum ToyMinorDeviceClass:
769  [maximum_bits: 6]
770  ROBOT      = 0x01
771  VEHICLE    = 0x02
772  DOLL       = 0x03
773  CONTROLLER = 0x04
774  GAME       = 0x05
775
776
777enum HealthMinorDeviceClass:
778  [maximum_bits: 6]
779  UNDEFINED                 = 0x00
780  BLOOD_PRESSURE_MONITOR    = 0x01
781  THERMOMETER               = 0x02
782  WEIGHING_SCALE            = 0x03
783  GLUCOSE_METER             = 0x04
784  PULSE_OXIMETER            = 0x05
785  HEART_PULSE_RATE_MONITOR  = 0x06
786  HEALTH_DATA_DISPLAY       = 0x07
787  STEP_COUNTER              = 0x08
788  BODY_COMPOSITION_ANALYZER = 0x09
789  PEAK_FLOW_MONITOR         = 0x0A
790  MEDICATION_MONITOR        = 0x0B
791  KNEE_PROSTHESIS           = 0x0C
792  ANKLE_PROSTHESIS          = 0x0D
793  GENERIC_HEALTH_MANAGER    = 0x0E
794  PERSONAL_MOBILITY_DEVICE  = 0x0F
795
796
797enum GenericEnableParam:
798  -- Binary values that can be generically passed to HCI commands that expect a
799  -- 1-octet boolean "enable"/"disable" parameter.
800  [maximum_bits: 8]
801  DISABLE = 0x00
802  ENABLE  = 0x01
803
804
805enum GenericPresenceParam:
806  [maximum_bits: 8]
807  NOT_PRESENT = 0x00
808  PRESENT     = 0x01
809
810
811struct BdAddr:
812  -- Bluetooth Device Address
813  0 [+6]  UInt  bd_addr
814
815
816enum CommonDataType:
817  -- Defined in section 2.3 of BT Core Specification Assigned Numbers
818  -- https://www.bluetooth.com/specifications/assigned-numbers/
819  [maximum_bits: 8]
820  FLAGS                                            = 0x01
821  INCOMPLETE_LIST_16_BIT_SERVICE_CLASS_UUIDS       = 0x02
822  COMPLETE_LIST_16_BIT_SERVICE_CLASS_UUIDS         = 0x03
823  INCOMPLETE_LIST_32_BIT_SERVICE_CLASS_UUIDS       = 0x04
824  COMPLETE_LIST_32_BIT_SERVICE_CLASS_UUIDS         = 0x05
825  INCOMPLETE_LIST_128_BIT_SERVICE_CLASS_UUIDS      = 0x06
826  COMPLETE_LIST_128_BIT_SERVICE_CLASS_UUIDS        = 0x07
827  SHORTENED_LOCAL_NAME                             = 0x08
828  COMPLETE_LOCAL_NAME                              = 0x09
829  TX_POWER_LEVEL                                   = 0x0A
830  CLASS_OF_DEVICE                                  = 0x0D
831  SIMPLE_PAIRING_HASH_C_192                        = 0x0E
832  SIMPLE_PAIRING_RANDOMIZER_R_192                  = 0x0F
833  DEVICE_ID                                        = 0x10
834  SECURITY_MANAGER_OUT_OF_BAND_FLAGS               = 0x11
835  PERIPHERAL_CONNECTION_INTERVAL_RANGE             = 0x12
836  LIST_16_BIT_SERVICE_SOLICITATION_UUIDS           = 0x14
837  LIST_128_BIT_SERVICE_SOLICITATION_UUIDS          = 0x15
838  SERVICE_DATA_16_BIT_UUID                         = 0x16
839  PUBLIC_TARGET_ADDRESS                            = 0x17
840  RANDOM_TARGET_ADDRESS                            = 0x18
841  APPEARANCE                                       = 0x19
842  ADVERTISING_INTERVAL                             = 0x1A
843  LE_BLUETOOTH_DEVICE_ADDRESS                      = 0x1B
844  LE_ROLE                                          = 0x1C
845  SIMPLE_PAIRING_HASH_C_256                        = 0x1D
846  SIMPLE_PAIRING_RANDOMIZER_R_256                  = 0x1E
847  LIST_32_BIT_SERVICE_SOLICITATION_UUIDS           = 0x1F
848  SERVICE_DATA_32_BIT_UUID                         = 0x20
849  SERVICE_DATA_128_BIT_UUID                        = 0x21
850  LE_SECURE_CONNECTIONS_CONFIRMATION_VALUE         = 0x22
851  LE_SECURE_CONNECTIONS_RANDOM_VALUE               = 0x23
852  URI                                              = 0x24
853  INDOOR_POSITIONING                               = 0x25
854  TRANSPORT_DISCOVERY_DATA                         = 0x26
855  LE_SUPPORTED_FEATURES                            = 0x27
856  CHANNEL_MAP_UPDATE_INFORMATION                   = 0x28
857  PB_ADV                                           = 0x29
858  MESH_MESSAGE                                     = 0x2A
859  MESH_BEACON                                      = 0x2B
860  BIG_INFO                                         = 0x2C
861  BROADCAST_CODE                                   = 0x2D
862  RESOLVABLE_IDENTIFIER                            = 0x2E
863  ADVERTISING_INTERVAL_LONG                        = 0x2F
864  BROADCAST_NAME                                   = 0x30
865  ENCRYPTED_ADVERTISING_DATA                       = 0x31
866  PERIODIC_ADVERTISING_RESPONSE_TIMING_INFORMATION = 0x32
867  ELECTRONIC_SHELF_LABEL                           = 0x34
868  INFORMATION_DATA_3D                              = 0x3D
869  MANUFACTURER_SPECIFIC_DATA                       = 0xFF
870
871
872bits ClassOfDevice:
873  -- Defined in Assigned Numbers for the Baseband
874  -- https://www.bluetooth.com/specifications/assigned-numbers/baseband
875  0     [+2]    UInt                         zero
876    [requires: this == 0]
877
878  if major_device_class == MajorDeviceClass.COMPUTER:
879    2     [+6]  ComputerMinorDeviceClass     computer_minor_device_class
880
881  if major_device_class == MajorDeviceClass.PHONE:
882    2     [+6]  PhoneMinorDeviceClass        phone_minor_device_class
883
884  if major_device_class == MajorDeviceClass.LAN:
885    2     [+6]  LANMinorDeviceClass          lan_minor_device_class
886
887  if major_device_class == MajorDeviceClass.AUDIO_VIDEO:
888    2     [+6]  AudioVideoMinorDeviceClass   audio_video_minor_device_class
889
890  if major_device_class == MajorDeviceClass.PERIPHERAL:
891    2     [+6]  PeripheralMinorDeviceClass   peripheral_minor_device_class
892
893  if major_device_class == MajorDeviceClass.IMAGING:
894    2     [+6]  ImagingMinorDeviceClassBits  imaging_minor_device_class
895
896  if major_device_class == MajorDeviceClass.WEARABLE:
897    2     [+6]  WearableMinorDeviceClass     wearable_minor_device_class
898
899  if major_device_class == MajorDeviceClass.TOY:
900    2     [+6]  ToyMinorDeviceClass          toy_minor_device_class
901
902  if major_device_class == MajorDeviceClass.HEALTH:
903    2     [+6]  HealthMinorDeviceClass       health_minor_device_class
904
905  8     [+5]    MajorDeviceClass             major_device_class
906  $next [+11]   MajorServiceClasses          major_service_classes
907
908
909bits ScanEnableBits:
910  -- Bitmask Values for the Scan_Enable parameter in a HCI_(Read,Write)_Scan_Enable command.
911  0 [+1]  Flag  inquiry
912    -- Inquiry scan enabled
913
914  1 [+1]  Flag  page
915    -- Page scan enabled
916
917
918enum ConnectionRole:
919  [maximum_bits: 8]
920  CENTRAL    = 0x00
921  PERIPHERAL = 0x01
922
923
924enum LEAdvertisingType:
925  [maximum_bits: 8]
926  CONNECTABLE_AND_SCANNABLE_UNDIRECTED = 0x00
927    -- ADV_IND
928
929  CONNECTABLE_HIGH_DUTY_CYCLE_DIRECTED = 0x01
930    -- ADV_DIRECT_IND
931
932  SCANNABLE_UNDIRECTED                 = 0x02
933    -- ADV_SCAN_IND
934
935  NOT_CONNECTABLE_UNDIRECTED           = 0x03
936    -- ADV_NONCONN_IND
937
938  CONNECTABLE_LOW_DUTY_CYCLE_DIRECTED  = 0x04
939    -- ADV_DIRECT_IND
940
941
942enum LEOwnAddressType:
943  -- Possible values that can be used for the |own_address_type| parameter in various LE packets.
944
945  [maximum_bits: 8]
946
947  PUBLIC                    = 0x00
948    -- Public Device Address
949
950  RANDOM                    = 0x01
951    -- Random Device Address
952
953  PRIVATE_DEFAULT_TO_PUBLIC = 0x02
954    -- Controller generates the Resolvable Private Address based on the local IRK from the resolving
955    -- list. If the resolving list contains no matching entry, then use the public address.
956
957  PRIVATE_DEFAULT_TO_RANDOM = 0x03
958    -- Controller generates the Resolvable Private Address based on the local IRK from the resolving
959    -- list. If the resolving list contains no matching entry, then use the random address from
960    -- LE_Set_Random_Address.
961
962
963enum LEPeerAddressType:
964  -- Possible values that can be used for the address_type parameters in various
965  -- HCI commands
966  [maximum_bits: 8]
967  PUBLIC    = 0x00
968  RANDOM    = 0x01
969  ANONYMOUS = 0xFF
970
971
972enum LEPeerAddressTypeNoAnon:
973  -- Possible values that can be used for the address_type parameters in various
974  -- HCI commands
975  [maximum_bits: 8]
976  PUBLIC = 0x00
977  RANDOM = 0x01
978
979
980bits ClockOffset:
981  -- Clock Offset. The lower 15 bits are set to the clock offset as retrieved
982  -- by an Inquiry. The highest bit is set to 1 if the rest of this parameter
983  -- is valid.
984  15 [+1]     Flag  valid
985  if valid:
986    0  [+15]  UInt  clock_offset
987
988
989enum LEPrimaryAdvertisingPHY:
990  [maximum_bits: 8]
991  LE_1M       = 0x01
992  LE_CODED    = 0x03
993  LE_CODED_S2 = 0x04
994
995
996enum LESecondaryAdvertisingPHY:
997  [maximum_bits: 8]
998  NONE        = 0x00
999  LE_1M       = 0x01
1000  LE_2M       = 0x02
1001  LE_CODED    = 0x03
1002  LE_CODED_S2 = 0x04
1003
1004
1005enum LEAddressType:
1006  -- Possible values that can be reported for various |*_address_type| parameters in various LE
1007  -- packets.
1008  [maximum_bits: 8]
1009  PUBLIC          = 0x00
1010    -- Public Device Address (default)
1011
1012  RANDOM          = 0x01
1013    -- Random Device Address
1014
1015  PUBLIC_IDENTITY = 0x02
1016    -- Public Identity Address (corresponds to Resolved Private Address)
1017
1018  RANDOM_IDENTITY = 0x03
1019    -- Random (static) Identity Address (corresponds to Resolved Private Address)
1020
1021
1022enum LEExtendedAddressType:
1023  -- Possible values that can be reported for various |*_address_type| parameters in various LE
1024  -- packets.
1025  [maximum_bits: 8]
1026  PUBLIC          = 0x00
1027    -- Public Device Address (default)
1028
1029  RANDOM          = 0x01
1030    -- Random Device Address
1031
1032  PUBLIC_IDENTITY = 0x02
1033    -- Public Identity Address (corresponds to Resolved Private Address)
1034
1035  RANDOM_IDENTITY = 0x03
1036    -- Random (static) Identity Address (corresponds to Resolved Private Address)
1037
1038  ANONYMOUS       = 0xFF
1039    -- No address provided (anonymous advertisement)
1040    -- This is a special value that is only used in LE Advertising Report events.
1041
1042
1043bits LEAdvertisingChannels:
1044  0     [+1]  Flag  channel_37
1045  $next [+1]  Flag  channel_38
1046  $next [+1]  Flag  channel_39
1047
1048
1049enum LEAdvertisingFilterPolicy:
1050  [maximum_bits: 8]
1051
1052  ALLOW_ALL                                                  = 0x00
1053    -- Process scan and connection requests from all devices (i.e., the Filter
1054    -- Accept List is not in use) (default).
1055
1056  ALLOW_ALL_CONNECTIONS_AND_USE_FILTER_ACCEPT_LIST_FOR_SCANS = 0x01
1057    -- Process connection requests from all devices and scan requests only from
1058    -- devices that are in the Filter Accept List.
1059
1060  ALLOW_ALL_SCANS_AND_USE_FILTER_ACCEPT_LIST_FOR_CONNECTIONS = 0x02
1061    -- Process scan requests from all devices and connection requests only from
1062    -- devices that are in the Filter Accept List.
1063
1064  ALLOW_FILTER_ACCEPT_LIST_ONLY                              = 0x03
1065    -- Process scan and connection requests only from devices in the Filter
1066    -- Accept List.
1067
1068
1069enum PageScanRepetitionMode:
1070  -- The page scan repetition mode, representing a maximum time between Page Scans.
1071  -- (See Core Spec v5.0, Volume 2, Part B, Section 8.3.1)
1072  [maximum_bits: 8]
1073  R0_ = 0x00  # Continuous Scan
1074  R1_ = 0x01  # <= 1.28s
1075  R2_ = 0x02  # <= 2.56s
1076
1077
1078enum CodingFormat:
1079  -- Coding formats from assigned numbers.
1080  -- (https://www.bluetooth.com/specifications/assigned-numbers/host-controller-interface)
1081  [maximum_bits: 8]
1082  U_LAW           = 0x00
1083  A_LAW           = 0x01
1084  CVSD            = 0x02
1085  TRANSPARENT     = 0x03
1086  LINEAR_PCM      = 0x04
1087  MSBC            = 0x05
1088  LC3             = 0x06
1089  G729A           = 0x07
1090  VENDOR_SPECIFIC = 0xFF
1091
1092
1093enum IoCapability:
1094  -- All other values reserved for future use.
1095  [maximum_bits: 8]
1096  DISPLAY_ONLY       = 0x00
1097  DISPLAY_YES_NO     = 0x01
1098  KEYBOARD_ONLY      = 0x02
1099  NO_INPUT_NO_OUTPUT = 0x03
1100  KEYBOARD_DISPLAY   = 0x04
1101
1102
1103enum LESleepClockAccuracyRange:
1104  -- Accuracy of the sleep clock, provided as a range
1105  [maximum_bits: 8]
1106  PPM_251_TO_500 = 0x00
1107  PPM_151_TO_250 = 0x01
1108  PPM_101_TO_150 = 0x02
1109  PPM_76_TO_100  = 0x03
1110  PPM_51_TO_75   = 0x04
1111  PPM_31_TO_50   = 0x05
1112  PPM_21_TO_30   = 0x06
1113  PPM_0_TO_20    = 0x07
1114
1115# inclusive-language: disable
1116
1117
1118enum AuthenticationRequirements:
1119  -- All options without MITM do not require MITM protection, and a numeric
1120  -- comparison with automatic accept is allowed.
1121  -- All options with MITM do require MITM protection, and IO capabilities should
1122  -- be used to determine the authentication procedure.
1123  [maximum_bits: 8]
1124  NO_BONDING             = 0x00
1125  MITM_NO_BONDING        = 0x01
1126  DEDICATED_BONDING      = 0x02
1127  MITM_DEDICATED_BONDING = 0x03
1128  GENERAL_BONDING        = 0x04
1129  MITM_GENERAL_BONDING   = 0x05
1130
1131# inclusive-language: enable
1132
1133
1134enum PinType:
1135  [maximum_bits: 8]
1136  VARIABLE = 0x00
1137  FIXED    = 0x01
1138
1139
1140enum InquiryScanType:
1141  [maximum_bits: 8]
1142  STANDARD   = 0x00
1143    -- Standard scan (Default) (Mandatory)
1144
1145  INTERLACED = 0x01
1146
1147
1148enum InquiryMode:
1149  [maximum_bits: 8]
1150  STANDARD = 0x00
1151    -- Standard Inquiry Result format (default)
1152
1153  RSSI     = 0x01
1154    -- Inquiry Result format with RSSI
1155
1156  EXTENDED = 0x02
1157    -- Inquiry Result format with RSSI or EIR format
1158
1159
1160enum PageScanType:
1161  [maximum_bits: 8]
1162  STANDARD_SCAN   = 0x00
1163    -- Standard scan (default) (mandatory)
1164
1165  INTERLACED_SCAN = 0x01
1166    -- Interlaced scan (optional)
1167
1168
1169struct LinkKey:
1170  0 [+16]  UInt:8[16]  value
1171
1172# ========================= HCI packet headers ==========================
1173
1174
1175bits OpCodeBits:
1176  # Emboss currently lacks support for default field values and cross-type integral equality.
1177  # (https://github.com/google/emboss/issues/21)
1178  # (https://github.com/google/emboss/issues/23)
1179  # Upon the addition of these features, we will transition OpCodeBits to be a parameterized
1180  # field which defaults for each HCI packet type to its corresponding OpCode.
1181  0     [+10]  UInt  ocf
1182  $next [+6]   UInt  ogf
1183
1184
1185struct CommandHeader:
1186  -- HCI Command packet header.
1187
1188  0     [+2]  OpCode      opcode_enum
1189    -- Full HCI command opcode.
1190
1191  0     [+2]  OpCodeBits  opcode_bits
1192    # Note that this field overlaps opcode_enum field.
1193    -- Access opcode ogf or ocf sub-fields.
1194
1195  let opcode = opcode_bits
1196  # TODO: https://pwbug.dev/338068316 - Once Fuchsia has transitioned off using
1197  # opcode for OpCodeBits, opcode_enum will be renamed to opcode and this alias
1198  # will be dropped.
1199
1200  $next [+1]  UInt        parameter_total_size
1201
1202
1203struct EventHeader:
1204  -- HCI Event packet header.
1205
1206  0     [+1]  EventCode  event_code_enum
1207
1208  0     [+1]  UInt       event_code_uint
1209  # Note that this field overlaps the event_code_enum field.
1210
1211  let event_code = event_code_uint
1212  # TODO: https://pwbug.dev/338068316 - Once Fuchsia has transitioned off using
1213  # event_code for UInt, event_code_enum will be renamed to event_code and
1214  # this event_code_uint alias will be dropped.
1215
1216  $next [+1]  UInt       parameter_total_size
1217
1218
1219struct CommandCompleteEvent:
1220  -- Core Spec v5.3 Vol 4, Part E, Section 7.7.14
1221  -- EventHeader.opcode == 0xe
1222  let hdr_size = EventHeader.$size_in_bytes
1223  0          [+hdr_size]  EventHeader  header
1224  hdr_size   [+1]         UInt         num_hci_command_packets
1225  hdr_size+1 [+2]         OpCode       command_opcode_enum
1226  hdr_size+1 [+2]         OpCodeBits   command_opcode_bits
1227  hdr_size+1 [+2]         UInt         command_opcode_uint
1228    # Note that this field overlaps command_opcode_enum field.
1229    -- Access opcode ogf or ocf sub-fields.
1230
1231  let command_opcode = command_opcode_bits
1232  # TODO: https://pwbug.dev/338068316 - Once Fuchsia has transitioned off using
1233  # command_opcode for OpCodeBits, command_opcode_enum will be renamed to
1234  # command_opcode and this alias will be dropped.
1235  let event_fixed_size = $size_in_bytes-hdr_size
1236  let return_parameters_size = header.parameter_total_size-event_fixed_size
1237
1238
1239struct VendorDebugEvent:
1240  -- This opcode is reserved for vendor-specific debugging events.
1241  -- See Core Spec v5.3 Vol 4, Part E, Section 5.4.4.
1242  let hdr_size = EventHeader.$size_in_bytes
1243  0     [+hdr_size]  EventHeader  header
1244  $next [+1]         UInt         subevent_code
1245    -- The event code for the vendor subevent.
1246