Skip to content

Add Bluetooth 6.3 Running Out of Bits support, fix LE event mask bit positions#215

Merged
colemancda merged 1 commit into
masterfrom
feature/hci-6-3-roob
Jul 10, 2026
Merged

Add Bluetooth 6.3 Running Out of Bits support, fix LE event mask bit positions#215
colemancda merged 1 commit into
masterfrom
feature/hci-6-3-roob

Conversation

@colemancda

Copy link
Copy Markdown
Member

Implements the HCI surface of Running Out of Bits, the one Core 6.3 feature implementable without the Channel Sounding stack (the other two 6.3 features are CS enhancements). Definitions taken directly from the Core 6.3 redline spec, Vol 4 Part E §7.4.2 and §7.8.1.

What changed

  • HCILESetEventMaskV2 (opcode 0x00A4) — the LE_Event_Mask parameter widened from 8 to 255 octets. Per spec, v1 sets bits 0–63 and leaves 64+ unchanged; v2 sets all bits. No LE events above bit 63 are assigned yet, so the tail encodes as zeros (documented).
  • HCIReadLocalSupportedCommands — v1 (0x0002, 64 octets) was declared in InformationalCommand but never implemented; both v1 and the new v2 (0x0010, 251 octets) now have return parameters sharing an HCISupportedCommands type with an isSupported(octet:bit:) accessor (out-of-range octets read as unsupported), plus convenience methods.
  • HCILESetEventMask.Event extended with bits 20–55 from the complete Core 6.3 bit table: CTE (20–22), PAST Received (23), CIS/BIG (24–29, 41), SCA (30), path loss/power reporting (31–32), BIGInfo (33), subrating (34), the PAwR v2 events (35–41), Read All Remote Features (42), Channel Sounding (43–50, 55), Monitored Advertisers (51), Frame Space Update (52), UTP (53), Connection Rate (54). Event.event becomes optional (LowEnergyEvent?) since most new events have no LowEnergyEvent case yet; every case has a proper description.

Bug fix: v1 event mask was off by one

The new bit-position tests exposed a pre-existing defect: Event.connectionComplete had raw value 0 — it set no bit at all — and every other case was 1<<(N−1) instead of 1<<N. Every mask the v1 command encoded was shifted one bit down from the spec: enabling "advertising report" actually enabled "connection complete", and connection-complete events could never be unmasked. The existing test asserting that the 5-bit default 0x1F equals six events had enshrined the bug (a zero raw value is an empty set member); it now asserts the correct five events of bits 0–4.

This is the fourth silent constant-drift bug found this way (after setDefaultPhy, setExtendedAdvertisingParameters, and the StatusParametersCommand auto-increment gap) — all caught by asserting spec values in tests rather than trusting the enum.

Tests

Bit-position assertions for representative bits across the whole range, uniqueness and description sweeps over all 56 cases, byte-exact 255-octet v2 mask vectors, v1/v2 supported-commands decode with octet/bit access and length rejection, and a mock host-controller round trip. Full suite: 316 tests pass; lint clean.

…it positions

Implements the HCI surface of the Core 6.3 Running Out of Bits feature
(Vol 4 Part E 7.4.2, 7.8.1):

- HCILESetEventMaskV2 (opcode 0x00A4): the LE_Event_Mask parameter
  widened from 8 to 255 octets. The v1 command sets bits 0-63 leaving
  bits 64+ unchanged; v2 sets all bits. No events above bit 63 are
  assigned yet, so the tail encodes as zero.
- HCIReadLocalSupportedCommands v1 (0x0002, 64 octets, previously
  declared but unimplemented) and v2 (0x0010, 251 octets) return
  parameters with an HCISupportedCommands octet/bit accessor, plus
  host controller convenience methods.
- Extend HCILESetEventMask.Event with bits 20-55 per the complete
  Core 6.3 bit table (CTE, PAST, CIS/BIG, SCA, path loss, power
  reporting, BIGInfo, subrating, PAwR v2, Read All Remote Features,
  Channel Sounding, Monitored Advertisers, Frame Space Update, UTP,
  Connection Rate). The Event.event property becomes optional since
  most new events have no LowEnergyEvent case yet.

Also fixes a pre-existing off-by-one bug in the v1 event mask enum:
connectionComplete had raw value 0 (setting no bit at all) and every
other case was assigned 1<<(N-1) instead of 1<<N, so the entire
encoded mask was shifted one bit down from the specification. The
existing test asserting that the 5-bit default value 0x1F equals six
events had enshrined the bug; corrected to the five events of
bits 0-4.
@colemancda colemancda merged commit cfabe93 into master Jul 10, 2026
38 checks passed
@colemancda colemancda deleted the feature/hci-6-3-roob branch July 10, 2026 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant