Add Bluetooth 6.3 Running Out of Bits support, fix LE event mask bit positions#215
Merged
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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(opcode0x00A4) — theLE_Event_Maskparameter 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 inInformationalCommandbut never implemented; both v1 and the new v2 (0x0010, 251 octets) now have return parameters sharing anHCISupportedCommandstype with anisSupported(octet:bit:)accessor (out-of-range octets read as unsupported), plus convenience methods.HCILESetEventMask.Eventextended 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.eventbecomes optional (LowEnergyEvent?) since most new events have noLowEnergyEventcase 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.connectionCompletehad raw value 0 — it set no bit at all — and every other case was1<<(N−1)instead of1<<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 default0x1Fequals 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 theStatusParametersCommandauto-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.