fix: garmin MLR routing byte, ultrahuman decode copy, dead battery check - #70
Conversation
…r-record copy in ultrahuman decode garminDecodeMlr wasn't stripping the routing byte before wrapping GFDI data in GarminMlrData, corrupting COBS framing on every watch-to-host data frame (the class doc already said it should be stripped). Gen5HelloInfo's battery gate had a dead `>= 0` check on an always non-negative value. parseUltrahumanRecord copied the whole input on every call; the one caller (parseUltrahumanRecords) already passes a Uint8List, so skip the copy when we already have one instead of copying per-record.
There was a problem hiding this comment.
Sorry @abdulsaheel, you've used your own review budget of 250,000 diff characters for the last 7 days.
You can request another review in 3 days and 23 hours by commenting @sourcery-ai review. Upgrade to get a review now.
|
Understand this PR’s impact Explore downstream dependencies and potential security impact with Blast Radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe PR strips the Garmin MLR routing byte from decoded payloads, adds a matching test assertion, simplifies the battery check, and avoids unnecessary copying for Uint8List inputs. ChangesGarmin MLR payload decoding
Parser simplification
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Reviewer's guide (collapsed on small PRs)Reviewer's GuideFixes Garmin MLR payload framing by removing the routing byte, reduces unnecessary Ultrahuman buffer copying during record decoding, and simplifies Gen5 battery validation by removing an impossible unsigned-value check. Sequence diagram for Garmin MLR payload decodingsequenceDiagram
participant MLR as Garmin MLR
participant Decoder as garminDecodeMlr
participant GFDI as GFDI decoder
MLR->>Decoder: garminDecodeMlr(data)
Decoder->>Decoder: Uint8List.fromList(data.sublist(1))
Decoder->>GFDI: Hand off payload without routing byte
GFDI-->>Decoder: Decode COBS-framed data
Flow diagram for Gen5 battery validationflowchart LR
A[Gen5HelloInfo parser] --> B["batteryRaw = u32(body, 1) / 10"]
B --> C{batteryRaw <= 100}
C -->|yes| D[Set batteryPct]
C -->|no| E[Set batteryPct to null]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
found while doing a full-codebase pass. three things:
>= 0check on an already-unsigned battery value in the gen5 hello parserall green locally (dart test, 631 passing).
🤖 Generated with Claude Code
Summary by Sourcery
Fix Garmin data-frame decoding and reduce unnecessary Ultrahuman parsing work while simplifying Gen5 battery validation.
Bug Fixes:
Tests:
Summary by CodeRabbit
Bug Fixes
Tests