Skip to content

wearfit protocol (howear hk8 ultra / hk8 pro max) - #50

Merged
abdulsaheel merged 3 commits into
mainfrom
feat/wearfit-howear-protocol
Sep 5, 2026
Merged

abdulsaheel merged 3 commits into
mainfrom
feat/wearfit-howear-protocol

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

adds the wearfit frame envelope for howear-branded bands (hk8 ultra, hk8 pro max), paired through the wearfit / wearfit 2.0 / wearfit pro app family.

no crc, no encryption. only builds/parses the frame + the battery request/reply — no other opcode is decoded.

Summary by Sourcery

Add experimental WearFit framing and battery support for Howear bands.

New Features:

  • Add experimental WearFit protocol support for Howear HK8 Ultra, HK8 Pro Max, and similar bands.
  • Provide WearFit frame construction and parsing plus battery-status request and reply decoding.

Enhancements:

  • Expose the WearFit protocol through the package barrel while leaving unsupported opcodes as raw frames.

Tests:

  • Add coverage for captured WearFit frames, battery states, frame validation, round trips, and payload size limits.

frame envelope + battery request/reply for the wearfit / wearfit2 / wearfit
pro app family (0xab header, no crc, no encryption). pairs and banks bytes
only, decodes nothing but battery.
@sourcery-ai

sourcery-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Reviewer's Guide

Introduces an experimental WearFit protocol module for Howear HK8-family bands, exposing a no-CRC/no-encryption frame envelope, generic frame parsing/building, battery request/reply support, and comprehensive captured-byte validation tests.

Sequence diagram for WearFit battery request and reply

sequenceDiagram
    participant App
    participant Band

    App->>App: wearFitCmdGetBattery()
    App->>Band: Write 0xAB 0x00 0x04 0xFF 0x91 0x80 0x01
    Band-->>App: Notify battery frame
    App->>App: parseWearFitFrame(value)
    App->>App: parseWearFitBattery(f)
    App-->>App: WearFitBattery(chargeState, percent)
Loading

Flow diagram for WearFit frame parsing

flowchart LR
    Input[Notification bytes] --> Parse[parseWearFitFrame]
    Parse -->|valid header marker length| Frame[WearFitFrame]
    Parse -->|invalid frame| Reject[null]
    Frame --> Battery[parseWearFitBattery]
    Battery -->|opcode 0x91 and valid status| Report[WearFitBattery]
    Battery -->|other opcode or invalid values| Ignore[null]
Loading

File-Level Changes

Change Details Files
Adds an experimental, byte-oriented WearFit protocol implementation for Howear bands, including frame construction/parsing and battery handling.
  • Defines the 0xAB frame envelope with reserved byte, length, 0xFF marker, opcode, and payload.
  • Validates headers, markers, minimum lengths, and truncation while extracting payloads.
  • Builds arbitrary outbound frames and provides the documented battery request.
  • Parses opcode 0x91 battery replies with charge-state and percentage validation.
  • Exports the new protocol API through the package barrel.
lib/src/wearfit.dart
lib/openstrap_protocol.dart
Adds fixture-based coverage for framing and battery behavior.
  • Tests captured battery, device-info, and find-watch frames.
  • Covers frame round trips, empty payloads, malformed headers, markers, lengths, and truncation.
  • Verifies battery charge states, percentages, opcode filtering, short payloads, and invalid percentages.
test/wearfit_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 4, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 58 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: 4b1876aa-52dd-4de1-9799-1c9689b1c24f

📥 Commits

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

📒 Files selected for processing (3)
  • lib/openstrap_protocol.dart
  • lib/src/wearfit.dart
  • test/wearfit_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 4, 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 71e5671 into main Sep 5, 2026
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