Skip to content

garmin gfdi v2 wire format - #52

Merged
abdulsaheel merged 3 commits into
mainfrom
feat/garmin-gfdi-protocol
Sep 5, 2026
Merged

garmin gfdi v2 wire format#52
abdulsaheel merged 3 commits into
mainfrom
feat/garmin-gfdi-protocol

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

cobs + mlr multiplexing + gfdi frame/crc for garmin watches. covers the
close_all/register_ml handshake, the device-information push, current-time
answer, status ack, and a minimal protobuf reader/writer for one battery
round trip (Smart.device_status_service.remote_device_battery_status_*).

no ble here, bytes only. everything else in the protobuf container and the
numbered real-time streaming services are untouched.

Summary by Sourcery

Add experimental byte-level Garmin GFDI v2 protocol support for session setup, device identification, time synchronization, acknowledgements, and battery status exchange.

New Features:

  • Add experimental Garmin GFDI v2 byte-level protocol support, including Multi-Link multiplexing, COBS framing, CRC validation, GFDI messages, device information, current-time responses, status acknowledgements, and battery-status protobuf exchange.

Enhancements:

  • Expose the Garmin protocol through the package barrel while keeping BLE integration and unsupported streaming services out of scope.

Tests:

  • Add coverage for Garmin framing, multiplexing, device information, time responses, acknowledgements, and battery protobuf parsing.

…otobuf

pure-dart bytes only, no ble. covers close_all/register_ml handshake, cobs
reassembly, the gfdi frame + crc, the device-information push, current-time
answer, status ack, and a minimal protobuf reader/writer for one battery
round trip. everything else in the smart container stays untouched.
@sourcery-ai

sourcery-ai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Reviewer's Guide

Introduces an experimental, BLE-independent Garmin GFDI v2 byte protocol stack: MLR session multiplexing, COBS transport framing, CRC-validated GFDI messages, selected device/session responses, and a minimal battery-status protobuf round trip, with comprehensive unit tests while leaving unrelated protobuf and streaming services untouched.

Sequence diagram for Garmin GFDI battery-status round trip

sequenceDiagram
    participant Host
    participant Watch

    Host->>Watch: garminCloseAllRequest()
    Watch-->>Host: GarminCloseAllAck
    Host->>Watch: garminRegisterMlRequest(kGarminServiceGfdi)
    Watch-->>Host: GarminRegisterMlResponse
    Watch-->>Host: GarminGfdiFrame DEVICE_INFORMATION
    Host->>Watch: garminBuildStatusAck(kGarminMsgDeviceInformation)
    Watch->>Host: garminBuildProtobufRequest()
    Host-->>Watch: garminBuildStatusAck(kGarminMsgProtobufRequest)
    Watch-->>Host: GarminGfdiFrame PROTOBUF_RESPONSE
    Host->>Host: garminParseBatteryResponseProto()
    Host->>Watch: garminBuildStatusAck(kGarminMsgProtobufResponse)
Loading

File-Level Changes

Change Details Files
Add a public, bytes-only Garmin GFDI v2 protocol implementation covering session setup, framing, selected control messages, and battery status exchange.
  • Export the new Garmin protocol API from the package barrel.
  • Implement Multi-Link routing, CLOSE_ALL/REGISTER_ML handshake messages, and response decoding.
  • Implement COBS encoding/decoding and notification reassembly.
  • Implement Garmin nibble-table CRC16 and validated little-endian GFDI frame construction/parsing.
  • Build and parse status acknowledgements, current-time responses, device-information pushes, and system events.
  • Add a limited protobuf envelope and wire reader/writer for the Smart device-status battery request/response path, explicitly leaving chunked messages and other services unsupported.
lib/openstrap_protocol.dart
lib/src/garmin.dart
Add unit coverage for the new Garmin wire-format layers and supported message paths.
  • Test COBS round trips, edge cases, and notification reassembly.
  • Test CRC, GFDI validation, status acknowledgements, and time responses.
  • Test MLR handshake/data decoding and device-information parsing.
  • Test battery protobuf encoding/decoding and its GFDI envelope.
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

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 18 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: Team

Run ID: 6384aa10-7f43-49f3-a8f5-11c576fae109

📥 Commits

Reviewing files that changed from the base of the PR and between c78c176 and d8f073b.

📒 Files selected for processing (3)
  • lib/openstrap_protocol.dart
  • lib/src/garmin.dart
  • test/garmin_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 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.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@abdulsaheel

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Rate Limit Exceeded

@abdulsaheel have exceeded the limit for the number of chat messages per hour. Please wait 2 minutes and 24 seconds before sending another message.

@abdulsaheel

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown

Rate Limit Exceeded

@abdulsaheel have exceeded the limit for the number of chat messages per hour. Please wait 1 minutes and 19 seconds before sending another message.

@abdulsaheel

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 5, 2026

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@abdulsaheel
abdulsaheel merged commit 50b5cb6 into main Sep 5, 2026
2 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