Skip to content

cmdGetBattery: take a profile like its siblings - #63

Merged
abdulsaheel merged 1 commit into
mainfrom
fix/cmd-get-battery-gen5-profile
Sep 19, 2026
Merged

abdulsaheel merged 1 commit into
mainfrom
fix/cmd-get-battery-gen5-profile

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

control.dart already branches on profile.isGen5 to decode GET_BATTERY_LEVEL's reply (gen4 u16 LE deci-percent vs gen5 direct u8 percent), but cmdGetBattery had no profile param at all, so it always built the gen4 envelope. every other request builder that got a gen-aware decode grew the same {BandProfile profile = BandProfile.gen4} param (cmdGetClock, cmdAbortHistorical in #62, etc). this one just never did.

no current callers (edge builds this opcode inline via its own session profile), so it's a live trap for whoever calls the exported helper next rather than a shipped bug.

dart test green.

Summary by Sourcery

Support profile-specific framing when building GET_BATTERY_LEVEL requests.

New Features:

  • Make the GET_BATTERY_LEVEL command builder profile-aware while preserving gen4 as the default.

Tests:

  • Add round-trip coverage confirming gen4 and gen5 battery command framing and profile compatibility.

control.dart already branches on profile.isGen5 to decode this exact
opcode's reply (gen4 u16 deci-percent vs gen5 direct u8 percent), but
the request builder had no way to frame gen5 at all. same fix as
cmdAbortHistorical got in #62.

@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 8 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 38 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: 8403f6cf-754d-4acd-bdff-a12aa7ba3911

📥 Commits

Reviewing files that changed from the base of the PR and between 86e4e1d and 6718f05.

📒 Files selected for processing (2)
  • lib/src/commands.dart
  • test/gen5_command_surface_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

Adds the missing profile parameter to cmdGetBattery, forwards it into command framing, and covers both gen5 framing and backward-compatible gen4 defaults with round-trip tests.

Sequence diagram for profile-aware battery command framing

sequenceDiagram
    participant Caller
    participant cmdGetBattery
    participant buildCommand
    participant Device

    Caller->>cmdGetBattery: cmdGetBattery(seq, profile)
    cmdGetBattery->>buildCommand: buildCommand(seq, Cmd.getBatteryLevel, const [], profile)
    buildCommand-->>cmdGetBattery: framed GET_BATTERY_LEVEL command
    cmdGetBattery-->>Caller: command bytes
    Caller->>Device: send command
    Device-->>Caller: battery-level reply
Loading

File-Level Changes

Change Details Files
Make the battery-level command builder profile-aware while preserving gen4 behavior by default.
  • Add an optional BandProfile parameter defaulting to gen4.
  • Forward the selected profile to buildCommand so gen5 frames use the correct envelope.
lib/src/commands.dart
Add round-trip coverage for profile-specific battery command framing.
  • Verify gen5 output parses as a valid gen5 GET_BATTERY_LEVEL frame and not as gen4.
  • Verify the no-argument call remains valid gen4 output.
test/gen5_command_surface_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 3a6ad6a into main Sep 19, 2026
4 checks passed
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