Repository navigation
fix(ble): pair WHOOP4 clock correlation with its capture wall, not now - #1427
Merged
Merged
Conversation
The Android backfiller clock correlation is re-seeded on every offload from (strapNewestTs, now). WHOOP4 does not re-fetch GET_DATA_RANGE at each offload (only WHOOP5 does), so strapNewestTs stays frozen between fetches while `now` advances — inflating the offset by all the elapsed wall time since the last fetch. A strap log shows it climbing 46s → ~3700s over ~30 min, snapping back to ~46s only when a fresh GET_DATA_RANGE lands. Pair strapNewestTs with the wall clock captured at the SAME instant it was read from the GET_DATA_RANGE reply, so the offset stays the strap RTC skew regardless of how stale strapNewestTs is — no extra BLE round-trip. Scope: the offset is a no-op for type-47 historical records (they carry their own unix timestamp), so stored offload data is unaffected — this corrects the REALTIME_RAW_DATA fallback stamping and, importantly, the strap-log diagnostics that the inflated offset was making unreadable. Android-only: Swift reads the real clock via GET_CLOCK and derives its strapNewestTs fallback ONCE (sticky), so it does not have this per-offload re-seed inflation. Validation: compiles clean; BLE-path, so hardware-confirmed by a strap log showing the offset holding at the true ~46s skew (per CLAUDE.md BLE rule).
ryanbr
added a commit
that referenced
this pull request
Aug 18, 2026
Build numbers only. MARKETING_VERSION / versionName stay 10.1.1 — the staging line is one above the latest release (v10.1.0) and holds there until 10.1.1 actually ships. versionCode 341 -> 342 and CURRENT_PROJECT_VERSION 223 -> 224, both +1 past the previous staging build so a sideloaded update installs in place rather than being refused as a downgrade. Picks up since the last testing build (f2271cd): backup build provenance (#1422), the CTL/ATL/TSB training-load engine (#1423) and its Trends card (#1425), sleep-vs-wake HR contrast (#1424), the v20 optical decoder + CRC gate (#895), the Sleep UI split (#1426), the WHOOP4 clock-correlation fix (#1427), the settings waist-row layout + copy fix (#1428), hourly Apple step import (#1429), Low refresh (#1430), and Power saving moving into More with a 35% ceiling (#1431).
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.
The bug (found tracing a v10.1.1-staging strap log)
The Android backfiller clock correlation is re-seeded on every offload from
(strapNewestTs, now). WHOOP4 doesn't re-fetchGET_DATA_RANGEat each offload (only WHOOP5 does), sostrapNewestTsstays frozen between fetches whilenowadvances — inflating the offset by all the elapsed wall time since the last fetch. Straight from the log:The offset should be the strap's constant RTC skew (~46s), not a number that climbs with elapsed time.
The fix
Capture the wall clock at the same instant
strapNewestTsis read from theGET_DATA_RANGEreply, and pair that with the device time when seeding the correlation — instead of a laternow. The offset then reflects the true skew regardless of how stalestrapNewestTsis. No extra BLE round-trip.Scope (deliberately narrow)
REALTIME_RAW_DATAfallback stamping, and — concretely — the strap-log diagnostics the inflated offset was making unreadable (it read as a ~1h clock skew that isn't real).GET_CLOCKand derives itsstrapNewestTsfallback once (sticky), so it has no per-offload re-seed inflation. No parity change.Validation
Compiles clean (
compileFullDebugKotlin). BLE path → hardware-confirmed by a strap log showing the offset holding at the true ~46s skew across an offload burst (per CLAUDE.md's BLE-validation rule; no CI/unit coverage for the CoreBluetooth path).