Repository navigation
v25: decode the optical samples and the sub-second field #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
abdulsaheel
merged 4 commits into
OpenStrap:main
from
magnetarQ:3-pr-protocol-v25-samples
Nov 29, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a3f88f6
v25: decode the optical samples and the sub-second field
magnetarQ 04c57ee
v25: clarify the rail-delta and sub-second comments
magnetarQ f22c5c3
Merge remote-tracking branch 'origin/main' into p87
abdulsaheel 9aac5a6
v25: note the tail offset and the sub-second docs
abdulsaheel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // v25_samples.dart — the optical samples of a WHOOP 4 v25 historical record. | ||
| // | ||
| // Same encoding as gen5's v26 window: an i32 first sample @ inner[15:19], then | ||
| // 24 saturating i16 deltas @ inner[19:67], 25 samples in all. So this reuses | ||
| // [reconstructSaturatedDeltaWindow] and its evidence about the tail. | ||
| // | ||
| // How it was checked (one WHOOP 4.0, firmware harvard 41.17.6.0, realtime raw | ||
| // stream on): 739 v25 records have an R11 frame with the same timestamp. In | ||
| // 734 the 25 samples equal R11 slot 1 lane A samples 0, 2, ..., 48 exactly. The | ||
| // other five hold 24 differing deltas, every one the live difference clamped | ||
| // to the i16 range, and every one a rail value. So all records without a rail | ||
| // delta matched, and all five records with one did not. A rail delta is | ||
| // ambiguous (the true difference may be larger), so the sample it reaches and | ||
| // every later absolute value in that record are not trustworthy. The next | ||
| // record starts from its own absolute value. | ||
| // Which LED/photodiode slot 1 lane A is, is not established. | ||
|
|
||
| import 'dart:typed_data'; | ||
|
|
||
| import 'constants.dart'; | ||
| import 'gen5_records.dart' | ||
| show Gen5PpgReconstruction, reconstructSaturatedDeltaWindow; | ||
|
|
||
| /// Samples of one v25 record (~26 Hz), or null when [inner] is not a v25 | ||
| /// historical record of at least 67 bytes. [inner] is the full inner record | ||
| /// (packet-type byte first), not `R24.rawTail`, which starts at inner[13]. | ||
| /// Decode each record on its own: the | ||
| /// first sample is absolute, never carry a sum across records. Use | ||
| /// [Gen5PpgReconstruction.trustedSamples]; do not trust the tail after a rail delta. | ||
| Gen5PpgReconstruction? reconstructV25Samples(Uint8List inner) { | ||
| if (inner.length < 67 || | ||
| inner[0] != PacketType.historicalData || | ||
| inner[1] != 25) { | ||
| return null; | ||
| } | ||
| final view = ByteData.sublistView(inner); | ||
| return reconstructSaturatedDeltaWindow(view.getInt32(15, Endian.little), [ | ||
| for (var k = 0; k < 24; k++) view.getInt16(19 + 2 * k, Endian.little), | ||
| ]); | ||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.