aboutsummaryrefslogtreecommitdiff
path: root/pw_bluetooth/public/pw_bluetooth/hci_common.emb
diff options
context:
space:
mode:
Diffstat (limited to 'pw_bluetooth/public/pw_bluetooth/hci_common.emb')
-rw-r--r--pw_bluetooth/public/pw_bluetooth/hci_common.emb503
1 files changed, 503 insertions, 0 deletions
diff --git a/pw_bluetooth/public/pw_bluetooth/hci_common.emb b/pw_bluetooth/public/pw_bluetooth/hci_common.emb
new file mode 100644
index 000000000..58287161a
--- /dev/null
+++ b/pw_bluetooth/public/pw_bluetooth/hci_common.emb
@@ -0,0 +1,503 @@
+# Copyright 2023 The Pigweed Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+# This file contains Emboss definitions for Host Controller Interface packets
+# and types found in the Bluetooth Core Specification. The Emboss compiler is
+# used to generate a C++ header from this file.
+
+[$default byte_order: "LittleEndian"]
+[(cpp) namespace: "pw::bluetooth::emboss"]
+# =========================== Common Definitions =================================
+
+
+enum StatusCode:
+ -- HCI Error Codes. Refer to Core Spec v5.0, Vol 2, Part D for definitions and
+ -- descriptions. All enum values are in increasing numerical order, however the
+ -- values are listed below for clarity.
+ [maximum_bits: 8]
+ SUCCESS = 0x00
+ UNKNOWN_COMMAND = 0x01
+ UNKNOWN_CONNECTION_ID = 0x02
+ HARDWARE_FAILURE = 0x03
+ PAGE_TIMEOUT = 0x04
+ AUTHENTICATION_FAILURE = 0x05
+ PIN_OR_KEY_MISSING = 0x06
+ MEMORY_CAPACITY_EXCEEDED = 0x07
+ CONNECTION_TIMEOUT = 0x08
+ CONNECTION_LIMIT_EXCEEDED = 0x09
+ SYNCHRONOUS_CONNECTION_LIMIT_EXCEEDED = 0x0A
+ CONNECTION_ALREADY_EXISTS = 0x0B
+ COMMAND_DISALLOWED = 0x0C
+ CONNECTION_REJECTED_LIMITED_RESOURCES = 0x0D
+ CONNECTION_REJECTED_SECURITY = 0x0E
+ CONNECTION_REJECTED_BAD_BD_ADDR = 0x0F
+ CONNECTION_ACCEPT_TIMEOUT_EXCEEDED = 0x10
+ UNSUPPORTED_FEATURE_OR_PARAMETER = 0x11
+ INVALID_HCI_COMMAND_PARAMETERS = 0x12
+ REMOTE_USER_TERMINATED_CONNECTION = 0x13
+ REMOTE_DEVICE_TERMINATED_CONNECTION_LOW_RESOURCES = 0x14
+ REMOTE_DEVICE_TERMINATED_CONNECTION_POWER_OFF = 0x15
+ CONNECTION_TERMINATED_BY_LOCAL_HOST = 0x16
+ REPEATED_ATTEMPTS = 0x17
+ PAIRING_NOT_ALLOWED = 0x18
+ UNKNOWN_LMP_PDU = 0x19
+ UNSUPPORTED_REMOTE_FEATURE = 0x1A
+ SCO_OFFSET_REJECTED = 0x1B
+ SCO_INTERVAL_REJECTED = 0x1C
+ SCO_AIRMODE_REJECTED = 0x1D
+ INVALID_LMP_OR_LL_PARAMETERS = 0x1E
+ UNSPECIFIED_ERROR = 0x1F
+ UNSUPPORTED_LMP_OR_LL_PARAMETER_VALUE = 0x20
+ ROLE_CHANGE_NOT_ALLOWED = 0x21
+ LMP_OR_LL_RESPONSE_TIMEOUT = 0x22
+ LMP_ERROR_TRANSACTION_COLLISION = 0x23
+ LMP_PDU_NOT_ALLOWED = 0x24
+ ENCRYPTION_MODE_NOT_ACCEPTABLE = 0x25
+ LINK_KEY_CANNOT_BE_CHANGED = 0x26
+ REQUESTED_QOS_NOT_SUPPORTED = 0x27
+ INSTANT_PASSED = 0x28
+ PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED = 0x29
+ DIFFERENT_TRANSACTION_COLLISION = 0x2A
+ RESERVED_0 = 0x2B
+ QOS_UNACCEPTABLE_PARAMETER = 0x2C
+ QOS_REJECTED = 0x2D
+ CHANNEL_CLASSIFICATION_NOT_SUPPORTED = 0x2E
+ INSUFFICIENT_SECURITY = 0x2F
+ PARAMETER_OUT_OF_MANDATORY_RANGE = 0x30
+ RESERVED_1 = 0x31
+ ROLE_SWITCH_PENDING = 0x32
+ RESERVED_2 = 0x33
+ RESERVED_SLOT_VIOLATION = 0x34
+ ROLE_SWITCH_FAILED = 0x35
+ EXTENDED_INQUIRY_RESPONSE_TOO_LARGE = 0x36
+ SECURE_SIMPLE_PAIRING_NOT_SUPPORTED_BY_HOST = 0x37
+ HOST_BUSY_PAIRING = 0x38
+ CONNECTION_REJECTED_NO_SUITABLE_CHANNEL_FOUND = 0x39
+ CONTROLLER_BUSY = 0x3A
+ UNACCEPTABLE_CONNECTION_PARAMETERS = 0x3B
+ DIRECTED_ADVERTISING_TIMEOUT = 0x3C
+ CONNECTION_TERMINATED_MIC_FAILURE = 0x3D
+ CONNECTION_FAILED_TO_BE_ESTABLISHED = 0x3E
+ MAC_CONNECTION_FAILED = 0x3F
+ COARSE_CLOCK_ADJUSTMENT_REJECTED = 0x40
+ # 5.0
+ TYPE_0_SUBMAP_NOT_DEFINED = 0x41
+ UNKNOWN_ADVERTISING_IDENTIFIER = 0x42
+ LIMIT_REACHED = 0x43
+ OPERATION_CANCELLED_BY_HOST = 0x44
+
+
+enum MajorDeviceClass:
+ [maximum_bits: 5]
+ MISCELLANEOUS = 0x00
+ COMPUTER = 0x01
+ PHONE = 0x02
+ LAN = 0x03
+ AUDIO_VIDEO = 0x04
+ PERIPHERAL = 0x05
+ IMAGING = 0x06
+ WEARABLE = 0x07
+ TOY = 0x08
+ HEALTH = 0x09
+ UNCATEGORIZED = 0x1F
+
+
+bits MajorServiceClasses:
+ 0 [+1] Flag limited_discoverable_mode
+ $next [+1] Flag le_audio
+ $next [+1] Flag reserved
+ $next [+1] Flag positioning
+ $next [+1] Flag networking
+ $next [+1] Flag rendering
+ $next [+1] Flag capturing
+ $next [+1] Flag object_transfer
+ $next [+1] Flag audio
+ $next [+1] Flag telephony
+ $next [+1] Flag information
+
+
+enum ComputerMinorDeviceClass:
+ [maximum_bits: 6]
+ UNCATEGORIZED = 0x00
+ DESKTOP_WORKSTATION = 0x01
+ SERVER_CLASS = 0x02
+ LAPTOP = 0x03
+ HANDHELD_PC = 0x04
+ PALM_SIZE_PC = 0x05
+ WEARABLE = 0x06
+ TABLET = 0x07
+
+
+enum PhoneMinorDeviceClass:
+ [maximum_bits: 6]
+ UNCATEGORIZED = 0x00
+ CELLULAR = 0x01
+ CORDLESS = 0x02
+ SMARTPHONE = 0x03
+ WIRED_MODEM_OR_VOID_GATEWAY = 0x04
+ COMMON_ISDN_ACCESS = 0x05
+
+
+enum LANMinorDeviceClass:
+ [maximum_bits: 6]
+ FULLY_AVAILABLE = 0x00
+ UTILIZED_1_TO_17 = 0x08
+ UTILIZED_17_TO_33 = 0x10
+ UTILIZED_33_TO_50 = 0x18
+ UTILIZED_50_TO_67 = 0x20
+ UTILIZED_67_TO_83 = 0x28
+ UTILIZED_83_TO_99 = 0x30
+ NO_SERVICE_AVAILABLE = 0x38
+
+
+enum AudioVideoMinorDeviceClass:
+ [maximum_bits: 6]
+ UNCATEGORIZED = 0x00
+ WEARABLE_HEADSET_DEVICE = 0x01
+ HANDS_FREE_DEVICE = 0x02
+ RESERVED_0 = 0x03
+ MICROPHONE = 0x04
+ LOUDSPEAKER = 0x05
+ HEADPHONES = 0x06
+ PORTABLE_AUDIO = 0x07
+ CAR_AUDIO = 0x08
+ SET_TOP_BOX = 0x09
+ HIFI_AUDIO_DEVICE = 0x0A
+ VCR = 0x0B
+ VIDEO_CAMERA = 0x0C
+ CAMCORDER = 0x0D
+ VIDEO_MONITOR = 0x0E
+ VIDEO_DISPLAY_AND_LOUDSPEAKER = 0x0F
+ VIDEO_CONFERENCING = 0x10
+ RESERVED_1 = 0x11
+ GAMING_TOY = 0x12
+
+
+enum PeripheralMinorDeviceClass0:
+ [maximum_bits: 4]
+ UNCATEGORIZED = 0x00
+ JOYSTICK = 0x01
+ GAMEPAD = 0x02
+ REMOTE_CONTROL = 0x03
+ SENSING_DEVICE = 0x04
+ DIGITIZER_TABLET = 0x05
+ CARD_READER = 0x06
+ DIGITAL_PEN = 0x07
+ HANDHELD_SCANNER = 0x08
+ HANDHELD_GESTURAL_INPUT_DEVICE = 0x09
+
+
+enum PeripheralMinorDeviceClass1:
+ [maximum_bits: 2]
+ UNCATEGORIZED = 0x00
+ KEYBOARD = 0x01
+ POINTING_DEVICE = 0x02
+ COMBO_KEYBOARD_POINTING_DEVICE = 0x03
+
+
+bits PeripheralMinorDeviceClass:
+ 0 [+4] PeripheralMinorDeviceClass0 device_class_0
+ $next [+2] PeripheralMinorDeviceClass1 device_class_1
+
+
+enum ImagingMinorDeviceClass:
+ [maximum_bits: 2]
+ UNCATEGORIZED = 0x00
+
+
+bits ImagingMinorDeviceClassBits:
+ 0 [+2] ImagingMinorDeviceClass device_class
+ $next [+1] Flag display
+ $next [+1] Flag camera
+ $next [+1] Flag scanner
+ $next [+1] Flag printer
+
+
+enum WearableMinorDeviceClass:
+ [maximum_bits: 6]
+ WRISTWATCH = 0x01
+ PAGER = 0x02
+ JACKET = 0x03
+ HELMET = 0x04
+ GLASSES = 0x05
+
+
+enum ToyMinorDeviceClass:
+ [maximum_bits: 6]
+ ROBOT = 0x01
+ VEHICLE = 0x02
+ DOLL = 0x03
+ CONTROLLER = 0x04
+ GAME = 0x05
+
+
+enum HealthMinorDeviceClass:
+ [maximum_bits: 6]
+ UNDEFINED = 0x00
+ BLOOD_PRESSURE_MONITOR = 0x01
+ THERMOMETER = 0x02
+ WEIGHING_SCALE = 0x03
+ GLUCOSE_METER = 0x04
+ PULSE_OXIMETER = 0x05
+ HEART_PULSE_RATE_MONITOR = 0x06
+ HEALTH_DATA_DISPLAY = 0x07
+ STEP_COUNTER = 0x08
+ BODY_COMPOSITION_ANALYZER = 0x09
+ PEAK_FLOW_MONITOR = 0x0A
+ MEDICATION_MONITOR = 0x0B
+ KNEE_PROSTHESIS = 0x0C
+ ANKLE_PROSTHESIS = 0x0D
+ GENERIC_HEALTH_MANAGER = 0x0E
+ PERSONAL_MOBILITY_DEVICE = 0x0F
+
+
+enum GenericEnableParam:
+ -- Binary values that can be generically passed to HCI commands that expect a
+ -- 1-octet boolean "enable"/"disable" parameter.
+ [maximum_bits: 8]
+ DISABLE = 0x00
+ ENABLE = 0x01
+
+
+enum GenericPresenceParam:
+ [maximum_bits: 8]
+ NOT_PRESENT = 0x00
+ PRESENT = 0x01
+
+
+struct BdAddr:
+ -- Bluetooth Device Address
+ 0 [+6] UInt bd_addr
+
+
+bits ClassOfDevice:
+ -- Defined in Assigned Numbers for the Baseband
+ -- https://www.bluetooth.com/specifications/assigned-numbers/baseband
+ 0 [+2] UInt zero
+ [requires: this == 0]
+
+ if major_device_class == MajorDeviceClass.COMPUTER:
+ 2 [+6] ComputerMinorDeviceClass computer_minor_device_class
+
+ if major_device_class == MajorDeviceClass.PHONE:
+ 2 [+6] PhoneMinorDeviceClass phone_minor_device_class
+
+ if major_device_class == MajorDeviceClass.LAN:
+ 2 [+6] LANMinorDeviceClass lan_minor_device_class
+
+ if major_device_class == MajorDeviceClass.AUDIO_VIDEO:
+ 2 [+6] AudioVideoMinorDeviceClass audio_video_minor_device_class
+
+ if major_device_class == MajorDeviceClass.PERIPHERAL:
+ 2 [+6] PeripheralMinorDeviceClass peripheral_minor_device_class
+
+ if major_device_class == MajorDeviceClass.IMAGING:
+ 2 [+6] ImagingMinorDeviceClassBits imaging_minor_device_class
+
+ if major_device_class == MajorDeviceClass.WEARABLE:
+ 2 [+6] WearableMinorDeviceClass wearable_minor_device_class
+
+ if major_device_class == MajorDeviceClass.TOY:
+ 2 [+6] ToyMinorDeviceClass toy_minor_device_class
+
+ if major_device_class == MajorDeviceClass.HEALTH:
+ 2 [+6] HealthMinorDeviceClass health_minor_device_class
+
+ 8 [+5] MajorDeviceClass major_device_class
+ $next [+11] MajorServiceClasses major_service_classes
+
+
+enum ConnectionRole:
+ [maximum_bits: 8]
+ CENTRAL = 0x00
+ PERIPHERAL = 0x01
+
+
+enum LEPeerAddressType:
+ -- Possible values that can be used for the address_type parameters in various
+ -- HCI commands
+ [maximum_bits: 8]
+ PUBLIC = 0x00
+ RANDOM = 0x01
+ ANONYMOUS = 0xFF
+
+
+enum LEPeerAddressTypeNoAnon:
+ -- Possible values that can be used for the address_type parameters in various
+ -- HCI commands
+ [maximum_bits: 8]
+ PUBLIC = 0x00
+ RANDOM = 0x01
+
+
+bits ClockOffset:
+ -- Clock Offset. The lower 15 bits are set to the clock offset as retrieved
+ -- by an Inquiry. The highest bit is set to 1 if the rest of this parameter
+ -- is valid.
+ 15 [+1] Flag valid
+ if valid:
+ 0 [+15] UInt clock_offset
+
+
+enum LEPrimaryAdvertisingPHY:
+ [maximum_bits: 8]
+ LE_1M = 0x01
+ LE_CODED = 0x03
+ LE_CODED_S2 = 0x04
+
+
+enum LESecondaryAdvertisingPHY:
+ [maximum_bits: 8]
+ NONE = 0x00
+ LE_1M = 0x01
+ LE_2M = 0x02
+ LE_CODED = 0x03
+ LE_CODED_S2 = 0x04
+
+
+enum LEAddressType:
+ -- Possible values that can be reported for various |*_address_type| parameters in various LE
+ -- packets.
+ [maximum_bits: 8]
+ PUBLIC = 0x00
+ -- Public Device Address (default)
+
+ RANDOM = 0x01
+ -- Random Device Address
+
+ PUBLIC_IDENTITY = 0x02
+ -- Public Identity Address (corresponds to Resolved Private Address)
+
+ RANDOM_IDENTITY = 0x03
+ -- Random (static) Identity Address (corresponds to Resolved Private Address)
+
+
+enum LEExtendedAddressType:
+ -- Possible values that can be reported for various |*_address_type| parameters in various LE
+ -- packets.
+ [maximum_bits: 8]
+ PUBLIC = 0x00
+ -- Public Device Address (default)
+
+ RANDOM = 0x01
+ -- Random Device Address
+
+ PUBLIC_IDENTITY = 0x02
+ -- Public Identity Address (corresponds to Resolved Private Address)
+
+ RANDOM_IDENTITY = 0x03
+ -- Random (static) Identity Address (corresponds to Resolved Private Address)
+
+ ANONYMOUS = 0xFF
+ -- No address provided (anonymous advertisement)
+ -- This is a special value that is only used in LE Advertising Report events.
+
+
+enum PageScanRepetitionMode:
+ -- The page scan repetition mode, representing a maximum time between Page Scans.
+ -- (See Core Spec v5.0, Volume 2, Part B, Section 8.3.1)
+ [maximum_bits: 8]
+ R0_ = 0x00 # Continuous Scan
+ R1_ = 0x01 # <= 1.28s
+ R2_ = 0x02 # <= 2.56s
+
+
+enum CodingFormat:
+ -- Coding formats from assigned numbers.
+ -- (https://www.bluetooth.com/specifications/assigned-numbers/host-controller-interface)
+ [maximum_bits: 8]
+ U_LAW = 0x00
+ A_LAW = 0x01
+ CVSD = 0x02
+ TRANSPARENT = 0x03
+ LINEAR_PCM = 0x04
+ MSBC = 0x05
+ LC3 = 0x06
+ G729A = 0x07
+ VENDOR_SPECIFIC = 0xFF
+
+
+enum IoCapability:
+ -- All other values reserved for future use.
+ [maximum_bits: 8]
+ DISPLAY_ONLY = 0x00
+ DISPLAY_YES_NO = 0x01
+ KEYBOARD_ONLY = 0x02
+ NO_INPUT_NO_OUTPUT = 0x03
+
+# inclusive-language: disable
+
+
+enum AuthenticationRequirements:
+ -- All options without MITM do not require MITM protection, and a numeric
+ -- comparison with automatic accept is allowed.
+ -- All options with MITM do require MITM protection, and IO capabilities should
+ -- be used to determine the authentication procedure.
+ [maximum_bits: 8]
+ NO_BONDING = 0x00
+ MITM_NO_BONDING = 0x01
+ DEDICATED_BONDING = 0x02
+ MITM_DEDICATED_BONDING = 0x03
+ GENERAL_BONDING = 0x04
+ MITM_GENERAL_BONDING = 0x05
+
+# inclusive-language: enable
+
+
+struct LinkKey:
+ 0 [+16] UInt:8[16] value
+
+# ========================= HCI packet headers ==========================
+
+
+bits OpCodeBits:
+ # Emboss currently lacks support for default field values and cross-type integral equality.
+ # (https://github.com/google/emboss/issues/21)
+ # (https://github.com/google/emboss/issues/23)
+ # Upon the addition of these features, we will transition OpCodeBits to be a parameterized
+ # field which defaults for each HCI packet type to its corresponding OpCode.
+ 0 [+10] UInt ocf
+ $next [+6] UInt ogf
+
+
+struct CommandHeader:
+ -- HCI Command packet header.
+ 0 [+2] OpCodeBits opcode
+ $next [+1] UInt parameter_total_size
+
+
+struct EventHeader:
+ -- HCI Event packet header.
+ 0 [+1] UInt event_code
+ $next [+1] UInt parameter_total_size
+
+
+struct CommandCompleteEvent:
+ -- Core Spec v5.3 Vol 4, Part E, Section 7.7.14
+ -- EventHeader.opcode == 0xe
+ let hdr_size = EventHeader.$size_in_bytes
+ 0 [+hdr_size] EventHeader header
+ $next [+1] UInt num_hci_command_packets
+ $next [+2] OpCodeBits command_opcode
+ let event_fixed_size = $size_in_bytes-hdr_size
+ let return_parameters_size = header.parameter_total_size-event_fixed_size
+
+
+struct VendorDebugEvent:
+ -- This opcode is reserved for vendor-specific debugging events.
+ -- See Core Spec v5.3 Vol 4, Part E, Section 5.4.4.
+ let hdr_size = EventHeader.$size_in_bytes
+ 0 [+hdr_size] EventHeader header
+ $next [+1] UInt subevent_code
+ -- The event code for the vendor subevent.