Skip to content

Smart alarm: instrument + warn when the strap keeps refusing the alarm (#34)#75

Merged
ryanbr merged 1 commit into
mainfrom
alarm-reject-warn
Jul 8, 2026
Merged

Smart alarm: instrument + warn when the strap keeps refusing the alarm (#34)#75
ryanbr merged 1 commit into
mainfrom
alarm-reject-warn

Conversation

@ryanbr

@ryanbr ryanbr commented Jul 8, 2026

Copy link
Copy Markdown
Owner

The diagnosis path for #34 (alarm not buzzing). A strap whose clock/alarm register has reset silently rejects SET_ALARM_TIME — the GET_ALARM_TIME readback keeps returning an old value (andresbernalc's stayed at a 2021 epoch across six writes) — so the firmware alarm never fires. Until now that mismatch was visible only in the debug export, and only as a one-shot. This makes it a persistent signal and surfaces it to the user.

No BLE command changes — pure observability + one conditional UI card.

#2 — instrumentation

  • FrameRouter: on each readback, count consecutive rejections (reported ≠ last sent). A matching readback resets the streak, so a transient (first read stale, then correct) never trips it; only a persistent refusal climbs.
  • recordAlarmArm: persist the strap-clock skew at arm. Skew ≈ 0 while the strap still rejects ⇒ a corrupted alarm register, not a clock problem — which pins whether a re-clock could ever help. (For [master] Alarm not buzzing #34's strap the clock had recovered, so this would read ≈0 and point straight at the register.)
  • Debug export Alarm block surfaces both: clock-at-arm on the Last arm line, N in a row on Strap reports.
  • disableStrapAlarm clears the streak (nothing armed to refuse once disarmed).

#4 — user warning

SmartAlarmView shows a card only when the alarm is on and the strap has refused ≥2 arms in a row: "Your strap isn't accepting the alarm… reset it in the official WHOOP app, keep your phone's Clock alarm meanwhile." Driven by @AppStorage("alarm.rejectStreak") so it appears and clears live.

Scope / honesty

Not a fix for a corrupted strap — that's firmware-side, only a strap reset clears it. This turns a silent, export-only failure into on-device guidance the affected user can act on. SwiftUI/BLE can't build on WSL; verified by inspection + streak/skew reasoning — needs a device to confirm the card + export lines.

Files: Strand/BLE/FrameRouter.swift, Strand/BLE/BLEManager.swift, Strand/System/DebugDataDiagnostics.swift, Strand/Screens/SmartAlarmView.swift.

…m time (#34)

When a strap's clock/alarm register is corrupted it silently rejects SET_ALARM_TIME
— the readback keeps reporting an old time — and the firmware alarm never fires.
Today that mismatch is detectable only in the debug export, and only as a one-shot.

Instrumentation (#2 — observability only, no BLE command change):
- FrameRouter: on each GET_ALARM_TIME readback, count CONSECUTIVE rejections
  (reported != last sent). A matching readback resets the streak, so a transient
  (first read stale, then correct) never trips it; only a persistent refusal climbs.
- recordAlarmArm: persist the strap-clock skew AT ARM. Skew ~0 while the strap still
  rejects ⇒ a corrupted alarm register, not a clock problem — pins whether a re-clock
  could ever help.
- Debug export Alarm block surfaces both (clock-at-arm on Last arm; "N in a row" on
  Strap reports).
- disableStrapAlarm clears the streak (nothing armed to refuse once disarmed).

User warning (#4):
- SmartAlarmView shows a card, ONLY when the alarm is on and the strap has refused
  >=2 arms in a row, telling the user the strap isn't accepting the alarm and to
  reset it via the official WHOOP app / keep a phone Clock alarm. Driven by
  @AppStorage so it appears/clears live.

Not a fix for a corrupted strap (that's firmware-side, #34) — it turns a silent,
export-only failure into a persistent signal and actionable on-device guidance.
@ryanbr ryanbr merged commit f4ee7f8 into main Jul 8, 2026
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