Skip to content

garmin: echo time request reference id - #76

Merged
abdulsaheel merged 2 commits into
mainfrom
fix/sweep-r4-protocol-main-1
Oct 3, 2026
Merged

abdulsaheel merged 2 commits into
mainfrom
fix/sweep-r4-protocol-main-1

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

the 5052 time answer always sent reference_id 0. it now reads the u32 id from the request payload and echoes it, so the watch can match the answer to what it asked.

garminBuildTimeResponse takes the request frame now and returns null if there's no id to echo. edge's garmin adapter needs to pass the frame through when it repins.

Summary by Sourcery

Echo Garmin time request reference IDs in responses and reject requests that cannot provide one.

New Features:

  • Echo the request reference ID in Garmin CURRENT_TIME_RESPONSE messages so watches can correlate responses with requests.

Bug Fixes:

  • Prevent time responses from being generated when the request is invalid or lacks a reference ID.

Tests:

  • Add coverage for reference ID echoing and requests without an ID.

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

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

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

Next included review available in 27 minutes.

Check out review usage here.

View limit details

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

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: ae5ad88a-61f8-4ad3-99c5-34d9d368d777
📥 Commits

Reviewing files that changed from the base of the PR and between f789f8e and 0db8496.

📒 Files selected for processing (2)
  • lib/src/garmin.dart
  • test/garmin_test.dart
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 Oct 3, 2026

Copy link
Copy Markdown

Reviewer's Guide

The PR changes Garmin 5052 time responses to require the original request frame, echo its little-endian reference ID for watch-side correlation, and abstain when the ID is unavailable; tests cover both successful correlation and malformed requests.

Sequence diagram for Garmin time request correlation

sequenceDiagram
    participant Watch
    participant Adapter
    participant Garmin

    Watch->>Adapter: CURRENT_TIME_REQUEST (5052)
    Adapter->>Garmin: garminBuildTimeResponse(request, nowUnixSeconds, utcOffsetSeconds)
    Garmin->>Garmin: Read request.payload reference_id
    Garmin-->>Adapter: RESPONSE (5000) with echoed reference_id
    Adapter-->>Watch: Time response
Loading

File-Level Changes

Change Details Files
Build time responses by validating and echoing the request’s reference ID.
  • Require a 5052 request frame with at least four payload bytes.
  • Decode the little-endian u32 reference ID and place it in the response.
  • Return null when the request cannot provide an ID.
  • Preserve timestamp, UTC offset, and zeroed DST fields.
lib/src/garmin.dart
Update tests to verify request correlation and invalid-request handling.
  • Construct the response from a parsed time request.
  • Assert the echoed reference ID alongside existing response fields.
  • Add coverage for short requests returning null.
test/garmin_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 b9591a1 into main Oct 3, 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