Skip to content

V1 FitPro: avoid auto WARM_UP on treadmill connect and add safe StopWorkout sequence - #4916

Merged
cagnulein merged 5 commits into
claude/fervent-newton-a25bb2from
codex/fix-v1-treadmill-startup-and-stop-behaviors
Aug 16, 2026
Merged

V1 FitPro: avoid auto WARM_UP on treadmill connect and add safe StopWorkout sequence#4916
cagnulein merged 5 commits into
claude/fervent-newton-a25bb2from
codex/fix-v1-treadmill-startup-and-stop-behaviors

Conversation

@cagnulein

Copy link
Copy Markdown
Owner

Motivation

  • Prevent unsafe automatic treadmill belt motion observed when V1 sessions wrote WORKOUT_MODE=WARM_UP during startup, by keeping V1 treadmills in a stopped IDLE state until an explicit start is requested.
  • Provide a proper, connected "Stop" operation (distinct from Pause) that brings a belt machine to a confirmed stopped state without disconnecting USB or stopping polling.
  • Add targeted diagnostic logging around state transitions and safety-critical writes so future hardware logs are conclusive.

Description

  • Skip automatic activation for V1 treadmills at session startup by not writing WARM_UP in transitionToActive() for DeviceType.TREADMILL; leave the treadmill in IDLE after prepareConsole() so the belt cannot be started just by connecting. (Changed: V1Session.kt.)
  • Introduce a new StopWorkout command and map the JNI stopWorkout() to it instead of PauseWorkout. (Changed: DeviceCommand.kt, FitProDeviceService.kt.)
  • Implement a connected, serialized V1 belt-stop sequence used for software Stop that reuses the existing halt logic: discard pending writes, write KPH=0 + WORKOUT_MODE=PAUSE, poll KPH until stopped (bounded timeout), then write/confirm WORKOUT_MODE=IDLE, while keeping the USB session and poll loop active. This reuses and centralizes the safety-critical halt behavior used by disconnect teardown. (Changed: V1Session.kt.)
  • Add synchronization (IO/command mutexes) so multi-step stop sequences cannot be interleaved with the poll loop or a concurrent Resume, preventing races that could restart the belt mid-stop. (Changed: V1Session.kt.)
  • Preserve non-treadmill V1 behaviour and V2 semantics; V2 continues to treat Stop as pause (unchanged active behaviour for bikes/ellipticals/rowers). (Changed: V2Session.kt.)
  • Improve diagnostic logging: log detected device type at startup, the current/explicit WORKOUT_MODE writes, explicit KPH writes, IDLE_MODE_LOCKOUT/REQUIRE_START_REQUESTED writes, belt-halt phases and KPH readbacks, and richer diagnostics when poll responses are truncated (report requested/decoded field names and the MCU supported bitfield set). (Changed: V1Session.kt.)
  • Did not change the field decoding/parsing behavior; instead enhanced logging for the 25/18-field warning so future logs show requested vs decoded fields and supported bitfield indices. (Changed: V1Session.kt.)
  • Files changed: src/android/fitpro/com/nettarion/hyperborea/core/model/DeviceCommand.kt, src/android/src/FitProDeviceService.kt, src/android/fitpro/com/nettarion/hyperborea/hardware/fitpro/v2/V2Session.kt, src/android/fitpro/com/nettarion/hyperborea/hardware/fitpro/v1/V1Session.kt.

Testing

  • ✅ Ran repository sanity checks: git diff --check and inspected the produced diff and commit; changes are limited to the four FitPro files and commit created.
  • ⚠️ Attempted to compile and run Android unit tests (./gradlew compileDebugKotlin testDebugUnitTest) but the environment blocked dependency resolution (repository requests returned HTTP 403), so build and unit test execution could not complete here.
  • ✅ Verified no unrelated files were modified and that new StopWorkout command is wired to the JNI surface and V1 stop sequence in code review and local static inspection.

If you want I can (1) add unit tests using a mock/fake HidTransport for V1Session exercising startup (no WARM_UP writes), Resume/Pause/Stop behaviours and truncated-response diagnostics, or (2) prepare a short hardware test plan with exact commands/logging to run on a V1 treadmill to validate KPH readback timing and the Stop timeout thresholds.


Codex Task

@cagnulein

Copy link
Copy Markdown
Owner Author

#4931 closed in favour of this

@cagnulein cagnulein closed this Aug 14, 2026
@cagnulein cagnulein reopened this Aug 14, 2026
@cagnulein
cagnulein merged commit bd438b0 into claude/fervent-newton-a25bb2 Aug 16, 2026
23 of 28 checks passed
@cagnulein
cagnulein deleted the codex/fix-v1-treadmill-startup-and-stop-behaviors branch August 16, 2026 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant