Skip to content

activity: store detailed heart data for workouts and sleep - #1898

Draft
sahil7886 wants to merge 6 commits into
coredevices:mainfrom
sahil7886:activity/sleep-workout-telemetry
Draft

activity: store detailed heart data for workouts and sleep#1898
sahil7886 wants to merge 6 commits into
coredevices:mainfrom
sahil7886:activity/sleep-workout-telemetry

Conversation

@sahil7886

@sahil7886 sahil7886 commented Aug 20, 2026

Copy link
Copy Markdown

Summary

This change saves detailed heart data during a built-in Workout and during detected sleep.

A user can start a Workout as usual. The watch keeps one heart-rate value each second. On watches that support HRV, it also keeps accepted pulse-to-pulse interval (PPI) values. The watch stores this data locally. It does not need a phone connection while the Workout runs.

During a detected overnight sleep period, the watch stores accepted PPI values, one heart-rate value every 30 seconds, and a 30-second motion summary. The normal activity session stays the main Workout summary. These new records add detail to that summary.

Before this change

  • Background heart-rate sampling used BPM only. The watch sampled at the user-selected interval: 10 minutes by default, 30 minutes, one hour, or disabled.
  • Each background sampling run used a one-second sensor interval. It stopped after 60 seconds or after enough good readings.
  • An open Workout requested BPM updates at a one-second interval.
  • Workout readings updated the current BPM, heart-rate zones, and the average heart rate in the normal Workout summary.
  • Valid BPM readings also entered the general heart-rate log. They were not a separate, clearly bounded Workout dataset.
  • The watch did not keep raw PPI values.

After this change

  • The existing background heart-rate log and Workout summary behavior stays in place.
  • An active Workout saves at most one BPM record per UTC second in a Workout-specific stream.
  • On watches with HRV support, an active Workout also saves every accepted PPI value.
  • The watch stores this detail locally and sends it through the normal DataLogging transfer.
  • Detected overnight sleep also stores PPI values, a BPM value every 30 seconds, and 30-second motion summaries.

What this enables

A companion or analysis tool can:

  • Reconstruct the BPM timeline for one specific Workout, without paused time.
  • Know when the full Workout dataset is complete.
  • Use raw PPI data on supported watches for beat-to-beat and HRV analysis.
  • Correlate overnight PPI, BPM, and motion with detected sleep.

This change records and transfers the new detail. It does not add a user-facing chart or insight by itself. A companion-side consumer must read these streams to present the data.

Implementation

  • Add three system DataLogging streams: Workout heart rate, Workout PPI, and sleep capture.
  • Use versioned, fixed-size records. Each record has a session ID, sequence number, time, value, quality, and state flags.
  • Add a final record when a Workout or sleep capture ends. The companion can use this record to know that a stream is complete.
  • Keep the Workout PPI stream at its raw accepted values. The watch does not invent missing intervals or calculate new HRV values.
  • Start the HRV sensor feature only during an active Workout or sleep capture. Return to BPM-only operation when it ends.
  • Make the HRM manager refresh a live sensor subscription after its feature set changes.
  • Resume the sleep stream after a reboot. Use a non-zero session ID and sequence gaps to keep replay safe.
  • Add unit-test links and fakes for the new telemetry paths.

User effect

  • Workout detail stays on the watch until the normal DataLogging transfer can send it.
  • Sleep detail can support later analysis without changing the existing activity summary.
  • The change adds no public SDK API and no user interface.

Validation

  • Rebased onto current Core Devices main; the six commits apply without conflicts.
  • Ran gitlint and git diff --check.
  • Ran the full local QEMU test suite: ./waf test -k (pass).
  • PR CI will also run the project container, QEMU tests, and firmware builds.

sahil7886 and others added 6 commits August 20, 2026 02:00
Add a buffered system DataLogging stream for one-second workout heart-rate readings.

The normal activity session remains the authoritative workout summary. A terminal record
carries the exact stop time.

Co-authored-by: GPT-5.6 <noreply@openai.com>
Signed-off-by: Sahil Shaikh <sahilshaikh2705@gmail.com>
Co-authored-by: GPT-5.6 <noreply@openai.com>
Signed-off-by: Sahil Shaikh <sahilshaikh2705@gmail.com>
Co-authored-by: GPT-5.6 <noreply@openai.com>
Signed-off-by: Sahil Shaikh <sahilshaikh2705@gmail.com>
Buffer accepted PPI, periodic BPM, and motion inputs locally

during the detected sleep interval.

Co-authored-by: GPT-5.6 <noreply@openai.com>
Signed-off-by: Sahil Shaikh <sahilshaikh2705@gmail.com>
Prevent motion-summary overflow.

Use a robust nonzero session ID so DataLogging replay remains idempotent after a reboot.

Co-authored-by: GPT-5.6 <noreply@openai.com>
Signed-off-by: Sahil Shaikh <sahilshaikh2705@gmail.com>
Add the sleep-capture source and test fakes.
This lets Activity and Workout unit tests link the telemetry paths.

Signed-off-by: Sahil Shaikh <sahilshaikh2705@gmail.com>
Co-authored-by: GPT-5.6 <noreply@openai.com>
@sahil7886
sahil7886 force-pushed the activity/sleep-workout-telemetry branch from 1496944 to 9574f5f Compare August 20, 2026 02:15
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