-
Notifications
You must be signed in to change notification settings - Fork 14
wire up realtime HR v2 dispatch + r10 hr=0 fix + readme cleanup #37
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1416,6 +1416,24 @@ Decoded _decodeDataRecord(Uint8List inner, | |
| final recType = inner.length > 1 ? inner[1] : -1; | ||
| // Compact realtime stream (small packet). | ||
| if (inner.length < 64) { | ||
| // Revision-2 realtime HR carries off-body state + garment location that | ||
| // the legacy v1 decoder below cannot see, and misreads byte [9] of a v2 | ||
| // body as a declared R-R count — try v2 first so those bytes never reach | ||
| // the v1 fallback. | ||
| if (recType == 2) { | ||
| final v2 = parseRealtimeHrV2(inner); | ||
| if (v2 != null) { | ||
| return Decoded('realtime_hr', { | ||
| 'rec_type': recType, | ||
| 'ts_epoch': v2.tsEpoch, | ||
| 'hr': v2.hrBpm, | ||
| 'hr_precise': v2.hrBpm.toDouble(), | ||
| 'rr_ms': const <int>[], | ||
| 'wearing': !v2.isOffBody, | ||
| 'location_raw': v2.locationRaw, | ||
| }); | ||
| } | ||
| } | ||
| final hr = parseRealtimeHr(inner); | ||
| if (hr != null) { | ||
| return Decoded('realtime_hr', { | ||
|
|
@@ -1432,16 +1450,21 @@ Decoded _decodeDataRecord(Uint8List inner, | |
| // Live R10 (HR + IMU) — surface HR for the live display. | ||
| if (recType == Record.r10) { | ||
| final r = parseR10Lite(inner); | ||
| if (r != null && r.hr > 0) { | ||
| if (r != null) { | ||
| // rr_ms too: parseR10Lite already accepted these beats, and the short | ||
| // realtime-HR branch above emits them — dropping them here silently | ||
| // halved the beat supply of anything reading live R10 through | ||
| // decodeFrame rather than live.dart. | ||
| // | ||
| // Emit even when hr == 0 — that's a real off-wrist reading (see | ||
| // live.dart's wristOn: hr > 0), not a failed decode. Falling through | ||
| // here used to collapse it into a bare 'data_record' with no wearing | ||
| // field at all, indistinguishable from an undecodable frame. | ||
| return Decoded('realtime_hr', { | ||
| 'rec_type': recType, | ||
| 'hr': r.hr, | ||
| 'rr_ms': r.rrIntervalsMs, | ||
| 'wearing': true, | ||
| 'wearing': r.hr > 0, | ||
|
Comment on lines
1463
to
+1467
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: #!/bin/bash
set -euo pipefail
rg -n -C 8 --glob '*.dart' "realtime_hr|ts_epoch|hr_precise" lib testRepository: OpenStrap/protocol Length of output: 18644 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- control.dart: R10 parser and dispatch ---'
rg -n -C 12 "parseR10Lite|class R10|realtime_hr|decodeFrame" lib/src/control.dart
printf '%s\n' '--- realtime_hr consumers and timestamp contract ---'
rg -n -C 8 --glob '*.dart' "realtime_hr|fields\\[['\"](ts_epoch|hr|rr_ms|wearing)['\"]\\]|ts_epoch" lib testRepository: OpenStrap/protocol Length of output: 26290 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '%s\n' '--- decodeFrame call sites and Decoded consumers ---'
rg -n -C 6 --glob '*.dart' "decodeFrame\\(|Decoded\\(|\\.kind|\\.fields" lib testRepository: OpenStrap/protocol Length of output: 24356 Preserve
Add 🤖 Prompt for AI Agents |
||
| }); | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: OpenStrap/protocol
Length of output: 860
Document the current test count.
If
434is the current total, add it to this line. The README currently documents only the 2,934-case TS-parity suite and contains no434count.🤖 Prompt for AI Agents