lefun ring/band: pairs and connects, reports nothing yet - #341
lefun ring/band: pairs and connects, reports nothing yet#341abdulsaheel wants to merge 4 commits into
Conversation
Reviewer's GuideAdds experimental support for pairing Lefun-protocol rings and bands, performing a single battery poll, archiving valid notifications as raw records, and intentionally exposing no derived health signals; the implementation also wires lifecycle, background sync, UI pairing, teardown, and replay coverage. The PR depends on the openstrap/protocol Lefun implementation and a corresponding pubspec Git pin update before merging. Sequence diagram for Lefun pairing and bounded battery syncsequenceDiagram
participant User
participant DevicePicker
participant HrsLink
participant LefunLink
participant LefunAdapter
participant LefunDevice
participant Archive
User->>DevicePicker: pairNotifySensor(kLefun, device, tier: null)
DevicePicker->>HrsLink: pairNotifySensor
HrsLink-->>User: paired device with no measurement tier
LefunLink->>LefunDevice: connect()
LefunLink->>LefunDevice: discoverServices()
LefunLink->>LefunAdapter: run(link)
LefunAdapter->>LefunDevice: write(kLefunWriteChar, buildLefunFrame(kLefunReportBattery))
LefunDevice-->>LefunAdapter: notify(kLefunNotifyChar)
LefunAdapter->>Archive: SampleBatch([], raw: frames)
LefunAdapter-->>LefunLink: BandNote(battery, pct)
LefunLink->>LefunDevice: disconnect()
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Review limit reachedNext included review available in 9 minutes. View limit detailsLimit 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. Review configuration: ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Team Run ID: ⛔ Files ignored due to path filters (4)
📒 Files selected for processing (9)
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. Comment |
There was a problem hiding this comment.
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/hrs_link.dart" line_range="589-595" />
<code_context>
await OuraLink.forgetRing(id);
return;
}
+ if (row?['adapter_id'] == kLefun.id) {
+ // No secret to drop — the envelope this device speaks has no key
+ // exchange — so this is a plain stop-and-delete, same shape as Oura's
+ // forget minus the keychain half.
+ await LefunLink.instance.stop();
+ await LocalDb.deleteDevice(id);
+ return;
+ }
// Before the row goes, not after: a live session would keep writing rows
</code_context>
<issue_to_address>
**issue (bug_risk):** Forgetting any Lefun row stops the singleton Lefun session, regardless of which device ID is being forgotten. If another Lefun device is currently syncing, unpairing an inactive or different Lefun row disconnects that other device and interrupts its archive flush.
**Triggers:** When multiple Lefun devices are paired and one is forgotten while another device has an active session.
**Suggested fix:** Associate the live session with its device ID and stop it only when the forgotten row is the active session; otherwise only delete the requested row.
</issue_to_address>Sourcery assessment
Needs a human reviewer. 1 finding to address first, and the new path writes and persists raw Lefun notifications and battery data even though the device protocol is unencrypted and unauthenticated, so a protocol or device-identification mistake could create incorrect archived records. Reverting stops future polling, while already stored records are bounded and can be removed or repaired.
Blocking findings: lib/ble/hrs_link.dart:595
PR Reviewer Guide 🔍(Review updated until commit 2127edb)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 2127edb Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit a7290a8
|
|
Persistent review updated to latest commit 2127edb |
|
Failed to generate code suggestions for PR |
User description
adds the lefun-protocol family (a bunch of ~$10 storefront rings/bands sharing one reference design) as a pairable device. plain notify-class pairing, one battery poll, everything else it sends gets archived raw. no signals declared, nothing derived — same shape as the oura/hrs entries.
needs the openstrap/protocol lefun-protocol PR merged and the git pin in pubspec.yaml bumped before this can merge (using a local pubspec_overrides.yaml for now).
Summary by Sourcery
Integrate experimental Lefun rings and bands into pairing and synchronization while preserving their un-derived data as raw archives.
New Features:
Bug Fixes:
Build:
Tests:
PR Type
Enhancement, Bug fix
Description
Add experimental Lefun ring and band support.
Archive raw Lefun frames without deriving metrics.
Fix chest-strap disarm bug during device removal.
Diagram Walkthrough
File Walkthrough
6 files
Add Lefun GATT service and registry entriesImplement LefunAdapter for bounded battery pollingImplement LefunLink host for connection and archivingAdd Lefun sync to headless background sync flowAdd UI blurb for Lefun devices in pickerAdd Lefun to sensor pairing options and icons1 files
Fix HRS disarm bug and allow null tier3 files
Add Lefun to adapter signals registry testAdd tests for LefunAdapter behavior and framesUpdate band registry test to include Lefun