Skip to content

fix: wire up gen5 framing on remaining unwired command builders - #65

Merged
abdulsaheel merged 1 commit into
mainfrom
fix/gen5-unwired-command-framing
Sep 19, 2026
Merged

abdulsaheel merged 1 commit into
mainfrom
fix/gen5-unwired-command-framing

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

cmdLinkValid, cmdGetHello, cmdGetHelloModern, cmdReportVersionInfo, cmdToggleHr, cmdSendR10R11, cmdEnableOptical took no [profile] param, so buildCommand always framed them gen4 (crc8 header) - a real gen5 strap can't parse that at all. same class of bug we already fixed on cmdGetBattery/cmdSetClock/cmdEnterHighFreqSync/cmdToggleImu etc, these eight just got missed.

also folded the gen5 payload branching for GET_DATA_RANGE/SEND_HISTORICAL_DATA (empty body on gen5 vs gen4's [0x00]) directly into cmdGetDataRange/cmdSendHistorical, and deleted cmdGetDataRangeGen5/cmdSendHistoricalGen5 since nothing called them (grepped edge/lib, ml/, and this repo's own tests/lib).

latent, not live - nothing in edge/lib calls any of these eight yet. semantics on cmdSendR10R11 (gen5 ignores 0x3F) and cmdEnableOptical (opcodes reversed on gen5) are still open per their own doc comments, this PR only fixes the wire envelope.

tests: added gen5+gen4 framing assertions for all 8 builders in doc_conformance_test.dart / whoop_protocol_update_test.dart. dart test -> 630 passed, 4 pre-existing skips.

Summary by Sourcery

Support gen5 framing across the remaining command builders and align command payloads with each hardware generation.

Bug Fixes:

  • Enable the remaining command builders to produce correctly framed gen5 commands while preserving gen4 behavior.
  • Use generation-specific payloads for GET_DATA_RANGE and SEND_HISTORICAL_DATA commands.

Enhancements:

  • Consolidate generation-specific command construction into the primary builders and remove unused gen5-only builder APIs.

Tests:

  • Add gen4 and gen5 framing coverage for the previously unwired command builders and generation-specific payload behavior.

cmdLinkValid, cmdGetHello, cmdGetHelloModern, cmdReportVersionInfo,
cmdToggleHr, cmdSendR10R11, cmdEnableOptical had no [profile] param at
all, so a gen5 caller always got gen4's crc8 header - unparseable on a
real gen5 strap. same bug already fixed on cmdGetBattery,
cmdSetClock, cmdEnterHighFreqSync etc, just missed these.

also folded the gen5 payload branch (empty body vs gen4's [0x00])
into cmdGetDataRange and cmdSendHistorical directly instead of
keeping separate Gen5 twins, since nothing called the twins anywhere
- deleted cmdGetDataRangeGen5/cmdSendHistoricalGen5.

nothing in edge/lib calls any of these yet so this is latent, not a
live fix. semantics on cmdSendR10R11/cmdEnableOptical stay unresolved
per their existing doc comments - this only fixes framing.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 6 days and 7 hours by commenting @sourcery-ai review. Upgrade to get a review now.

@coderabbitai

coderabbitai Bot commented Sep 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 22 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: bb729730-e9e4-4728-b011-2cb552aa6c75

📥 Commits

Reviewing files that changed from the base of the PR and between 3a6ad6a and fba1a7c.

📒 Files selected for processing (4)
  • lib/openstrap_protocol.dart
  • lib/src/commands.dart
  • test/doc_conformance_test.dart
  • test/whoop_protocol_update_test.dart

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Sep 19, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR makes the remaining command builders profile-aware so callers can generate parseable gen5 frames while preserving gen4 defaults, folds gen5 payload differences into the shared range and historical-data builders, removes unused gen5-specific APIs, and adds dual-profile conformance tests.

Sequence diagram for profile-aware command framing

sequenceDiagram
    participant Caller
    participant Builder as CommandBuilder
    participant Framer as buildCommand
    participant Device

    Caller->>Builder: cmdLinkValid(seq, profile)
    Builder->>Framer: buildCommand(seq, command, payload, profile)
    Framer->>Framer: Select gen4 or gen5 wire envelope
    Framer->>Device: Profile-compatible framed command
    Device-->>Caller: Parseable command
Loading

Flow diagram for profile-specific command payloads

flowchart LR
    A[cmdGetDataRange or cmdSendHistorical] --> B{profile.isGen5}
    B -->|yes| C[Build with empty payload]
    B -->|no| D[Build with 0x00 payload]
    C --> E[buildCommand with profile]
    D --> E
    E --> F[Gen5 or gen4 framed command]
Loading

File-Level Changes

Change Details Files
Added profile-aware framing to the remaining command builders.
  • Added optional BandProfile parameters while preserving gen4 defaults.
  • Passed the selected profile into buildCommand so gen5 uses its correct wire envelope.
  • Covered link, hello, version, HR, R10/R11, and optical builders without changing their command semantics.
lib/src/commands.dart
Unified generation-specific payload construction for historical-data and range commands.
  • Selected empty gen5 bodies versus the gen4 0x00 body inline based on BandProfile.
  • Removed unused dedicated gen5 builder functions and their public exports.
  • Kept the existing command opcodes and documented unresolved gen5 command-semantic differences out of scope.
lib/src/commands.dart
lib/openstrap_protocol.dart
Expanded protocol conformance coverage for both framing profiles and payload variants.
  • Verified GET_DATA_RANGE and SEND_HISTORICAL_DATA payload shapes for gen4 and gen5.
  • Added parseability assertions for all previously unwired builders under both profiles.
  • Added explicit gen5 envelope validation for GET_DATA_RANGE.
test/doc_conformance_test.dart
test/whoop_protocol_update_test.dart

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@abdulsaheel
abdulsaheel merged commit 67eb8ec into main Sep 19, 2026
4 checks passed
@abdulsaheel
abdulsaheel deleted the fix/gen5-unwired-command-framing branch September 19, 2026 07:03
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