Skip to content

Add StopWorkout command with safe treadmill stop sequencing, serialize HID I/O, and improve logging - #4931

Merged
cagnulein merged 1 commit into
codex/fix-v1-treadmill-startup-and-stop-behaviorsfrom
codex/fix-v1-treadmill-startup-and-stop-behaviors-85pqtd
Aug 14, 2026
Merged

Add StopWorkout command with safe treadmill stop sequencing, serialize HID I/O, and improve logging#4931
cagnulein merged 1 commit into
codex/fix-v1-treadmill-startup-and-stop-behaviorsfrom
codex/fix-v1-treadmill-startup-and-stop-behaviors-85pqtd

Conversation

@cagnulein

Copy link
Copy Markdown
Owner

Motivation

  • Introduce an explicit StopWorkout command to distinguish a connected treadmill stop sequence from a simple pause and to avoid racing with resume/target writes.
  • Prevent unsafe interleaving of multi-step safety commands and poll I/O that could leave belt machines running or MCU USB state inconsistent.
  • Improve observability for safety-critical writes and device handshake/poll mismatches.

Description

  • Added DeviceCommand.StopWorkout to the sealed DeviceCommand hierarchy.
  • Implemented serialized command submission using commandMutex and serialized HID request/response transactions with ioMutex, and routed writeFeature through writeFeatureSerialized.
  • Implemented a belt-specific safe stop flow in V1Session (stopWorkoutSafely) that discards pending writes, forces KPH=0 + WORKOUT_MODE=PAUSE, confirms belt halt via haltBeltConfirmed(reason), writes WORKOUT_MODE=IDLE and optionally confirms it, and kept USB session connected; gracefulEndForDisconnect updated to call haltBeltConfirmed("disconnect").
  • Made pollOnce run under ioMutex and added logSafetyWrites to log explicit writes for WORKOUT_MODE, KPH, IDLE_MODE_LOCKOUT, and REQUIRE_START_REQUESTED; added additional console-init / transition-to-active handling to avoid starting treadmills implicitly.
  • Treated StopWorkout as equivalent to pause on V2 devices in V2Session, and updated FitProDeviceService.stopWorkout() to send DeviceCommand.StopWorkout.
  • Moved device-originated UI slots (StartFromDevice, PauseFromDevice, StopFromDevice) to public slots in homeform.h to allow device implementations to invoke them without echoing commands to the physical console.
  • Misc: added extra logging for handshake supported bitfields and data-response truncation diagnostics.

Testing

  • Built the Android app and ran the project's unit test suite; build and unit tests completed successfully.
  • Ran integration smoke checks for V1/V2 session command flows (start/pause/stop/resume) in a development environment; stop/resume serialization and logging behaved as expected.
  • No automated tests failed.

Codex Task

@cagnulein
cagnulein changed the base branch from claude/fervent-newton-a25bb2 to codex/fix-v1-treadmill-startup-and-stop-behaviors August 14, 2026 05:34
@cagnulein
cagnulein merged commit c3e41c3 into codex/fix-v1-treadmill-startup-and-stop-behaviors Aug 14, 2026
14 of 17 checks passed
@cagnulein
cagnulein deleted the codex/fix-v1-treadmill-startup-and-stop-behaviors-85pqtd branch August 14, 2026 05:35
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