Skip to content

gate get_alarm_time on status like getclock/getdatarange - #60

Merged
abdulsaheel merged 1 commit into
mainfrom
fix/alarm-time-status-gate
Sep 18, 2026
Merged

abdulsaheel merged 1 commit into
mainfrom
fix/alarm-time-status-gate

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

gen5 GET_ALARM_TIME reply was decoded off the form byte alone, no status check. same bug class as getclock/getdatarange/getbatterypackinfo which already got this fix in this file - a failure/deferred reply leaves the body stale, so leftover bytes from a prior read could get reported as a confident current alarm epoch/active flag.

fix: gate the decode on !profile.isGen5 || status == 1, same pattern as the sibling opcodes. gen4 stays ungated (unconfirmed status convention there, same caveat as the other three).

added tests: gen5 non-success (0/2/3) emits neither field, gen5 success still decodes, gen4 stays ungated on failure.

Summary by Sourcery

Gate gen5 alarm-time decoding on a successful response status while retaining the existing gen4 behavior.

Bug Fixes:

  • Prevent gen5 alarm time and active-state fields from being decoded from failed or deferred replies with stale payload data.

Tests:

  • Add coverage for gen5 non-success and success statuses, while preserving ungated gen4 decoding behavior.

gen5 GET_ALARM_TIME reply was decoded off the form byte alone, no status
check. a failure/deferred reply leaves the body stale, so old alarm bytes
could get reported as the current alarm. same fix as the getclock/
getdatarange/getbatterypackinfo status gates already in this file, gen4
stays ungated for the same unconfirmed-status-byte reason.

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

@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 9 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: cc8c7557-c57e-4df2-8428-40b51cfadf3d

📥 Commits

Reviewing files that changed from the base of the PR and between 3a96e1d and 51c7bd0.

📒 Files selected for processing (2)
  • lib/src/control.dart
  • test/control_plane_offsets_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 18, 2026

Copy link
Copy Markdown

Reviewer's Guide

Updates GET_ALARM_TIME parsing to ignore potentially stale body data for non-success gen5 responses while retaining the existing ungated gen4 behavior, with focused regression tests for both profiles and status outcomes.

Sequence diagram for status-gated GET_ALARM_TIME parsing

sequenceDiagram
    participant Response
    participant Parser
    participant Decoded

    Response->>Parser: parseCommandResponse(inner, ...)
    Parser->>Parser: status = response status
    alt gen5 and status != 1
        Parser-->>Decoded: no alarm_epoch or active field
    else gen5 status == 1
        Parser->>Parser: inspect form and payload length
        Parser-->>Decoded: decode alarm_epoch and active
    else gen4
        Parser->>Parser: inspect form and payload length
        Parser-->>Decoded: decode alarm_epoch and active
    end
Loading

File-Level Changes

Change Details Files
Gate GET_ALARM_TIME field decoding by the confirmed gen5 outer status while preserving gen4 behavior.
  • Require status == 1 for gen5 alarm epoch and active-field decoding.
  • Keep gen4 decoding ungated because its status semantics remain unconfirmed.
  • Document the generation-specific status policy and stale-body rationale.
lib/src/control.dart
Add coverage for status handling across generations and response outcomes.
  • Verify gen5 statuses 0, 2, and 3 emit neither alarm field.
  • Verify gen5 success status continues to decode both fields.
  • Verify gen4 still decodes on a non-success status.
test/control_plane_offsets_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 eda21e8 into main Sep 18, 2026
4 checks passed
@abdulsaheel
abdulsaheel deleted the fix/alarm-time-status-gate branch September 18, 2026 21:04
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