Skip to content

smaq2oss: pairs and banks raw data, decodes nothing yet - #352

Open
abdulsaheel wants to merge 6 commits into
mainfrom
feat/smaq2oss-adapter
Open

smaq2oss: pairs and banks raw data, decodes nothing yet#352
abdulsaheel wants to merge 6 commits into
mainfrom
feat/smaq2oss-adapter

Conversation

@abdulsaheel

@abdulsaheel abdulsaheel commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

pairs-only adapter for the SMA-Q2-OSS watch. no signals declared, no commands sent.

Summary by Sourcery

Add experimental SMA-Q2-OSS support that pairs with the watch and archives its notifications as un decoded raw frames.

New Features:

  • Add experimental SMA-Q2-OSS pairing, background synchronization, and manual sync support.
  • Archive incoming SMA-Q2-OSS notifications as raw data without decoding signals or issuing commands.

Enhancements:

  • Register the SMA-Q2-OSS service and characteristics, expose it in device selection and profile UI, and enforce serialized, bounded listen sessions with cleanup.

Tests:

  • Add registry and adapter tests covering the empty signal set, raw frame archiving, ignored empty notifications, absence of writes, and absence of offload checkpoints.

@sourcery-ai

sourcery-ai Bot commented Sep 4, 2026

Copy link
Copy Markdown

Reviewer's Guide

Adds an explicitly experimental SMA-Q2-OSS adapter that discovers a configured GATT service, listens without sending commands or decoding signals, archives notifications verbatim during bounded foreground/background sync sessions, and exposes the device through pairing and profile UI.

File-Level Changes

Change Details Files
Registers the SMA-Q2-OSS as an experimental notify-only band with no decoded signals.
  • Adds board-specific service, write, and notify UUIDs.
  • Adds a registry entry anchored to arrival time with empty signal declarations.
  • Includes the adapter in signal and registry coverage tests.
lib/ble/adapters/_registry.dart
lib/ble/adapters/smaq2oss.dart
test/adapter_signals_registry_test.dart
test/band_registry_test.dart
Implements raw-frame collection without issuing commands or decoding data.
  • Subscribes to the notify characteristic and archives each non-empty notification verbatim.
  • Emits no samples or offload checkpoints and performs no writes.
  • Tests raw preservation, empty-frame handling, and the no-write/no-checkpoint contract.
lib/ble/adapters/smaq2oss.dart
test/adapters/smaq2oss_test.dart
Adds a bounded secondary-device sync host that persists received frames.
  • Looks up the paired device, serializes syncs, acquires a secondary-link slot, and connects for a 20-second listen window.
  • Validates required GATT characteristics and safely tears down the link and host.
  • Builds archive rows with raw hex, packet type, arrival timestamp, null counter, and a dedicated reason.
lib/ble/smaq2oss_link.dart
Integrates SMA-Q2-OSS pairing, manual sync, and background sync into the app.
  • Piggybacks the adapter onto headless background synchronization without failing the primary cycle.
  • Adds pairing metadata, device-detail sync handling, picker copy, and a watch icon.
  • Keeps the device out of derived-signal sources and presents the feature as raw-data-only.
lib/sync/background_sync.dart
lib/ui2/pairing/device_picker.dart
lib/ui2/profile/devices.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
Contributor

Warning

Review limit reached

Next included review available in 51 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: 94824f52-3fc6-43d8-80cd-8f81dc419c02

📥 Commits

Reviewing files that changed from the base of the PR and between b98cae6 and 4e20a30.

⛔ Files ignored due to path filters (3)
  • test/adapter_signals_registry_test.dart is excluded by !test/**
  • test/adapters/smaq2oss_test.dart is excluded by !test/**
  • test/band_registry_test.dart is excluded by !test/**
📒 Files selected for processing (6)
  • lib/ble/adapters/_registry.dart
  • lib/ble/adapters/smaq2oss.dart
  • lib/ble/smaq2oss_link.dart
  • lib/sync/background_sync.dart
  • lib/ui2/pairing/device_picker.dart
  • lib/ui2/profile/devices.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 found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="lib/ble/smaq2oss_link.dart" line_range="64-76" />
<code_context>
+  }
+
+  Future<bool> _sync() async {
+    final row = await pairedRow();
+    if (row == null) return false;
+    final deviceId = row['id'] as String?;
</code_context>
<issue_to_address>
**issue (bug_risk):** `sync()` calls `pairedRow()` before entering the `_sync` try/catch, so a failure from `LocalDb.deviceRows()` escapes despite the method's contract stating that it never throws. The profile sync action does not catch this exception and reports an unhandled failure to the UI.

**Triggers:** When the database read used to locate the paired watch fails.

**Suggested fix:** Move the paired-row lookup and row field validation inside the existing try/catch, or catch and convert those failures to `false`.

```suggestion
  Future<bool> _sync() async {
    try {
      final row = await pairedRow();
      if (row == null) return false;
      final deviceId = row['id'] as String?;
      final remoteId = row['remote_id'] as String?;
      if (deviceId == null || remoteId == null || remoteId.isEmpty) return false;
      if (deviceId == LocalDb.kPrimaryDeviceId) {
        debugPrint('[smaq2oss] refusing to sync: the row claims the primary '
            'device id — re-pair it with a minted id.');
        return false;
      }
```
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and if this is wrong, the background and manual sync paths can persist incorrect or unwanted raw notification frames in the archive, and reverting the code would not remove those rows. The stored data is bounded and can be deleted or repaired, so the consequence is recoverable rather than an irreversible external action.

Blocking findings: lib/ble/smaq2oss_link.dart:76


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

Comment thread lib/ble/smaq2oss_link.dart
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

@abdulsaheel

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor
⚠️ 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

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor
⚠️ 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

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor
⚠️ 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

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor
⚠️ 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.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

@abdulsaheel

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Rate Limit Exceeded

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

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

@abdulsaheel

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor
⚠️ 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.

@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

l is never null in a running app, so l?.devicesSyncNowSub always won
and the family branch under it never ran.
@github-actions

github-actions Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Failed to generate code suggestions for PR

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