Add Whoop MG support and move BLE frame parsing to pure Swift#50
Open
naz3eh wants to merge 2 commits into
Open
Add Whoop MG support and move BLE frame parsing to pure Swift#50naz3eh wants to merge 2 commits into
naz3eh wants to merge 2 commits into
Conversation
|
@naz3eh Are you able to add in the R22 flags? I have a packet logs from my band if that helps at all |
Author
No, they aren't in this yet. this PR only adds MG Labrador (124/125/139 + K16/K17). R22 needs |
|
These are from my band yesterday, hopefully this can help with the R22 flags Thanks :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds compatibility for the Whoop MG and addresses the known performance issue by moving the per-notification frame parsing hot path from the Rust bridge to pure Swift.
WHOOP MG support
WhoopDeviceGenerationenum and adeviceGeneration/isWhoopMGproperty onGooseBLEClient, derived from the Device Information Service model number (already being read, so no extra BLE traffic).Performance: pure Swift frame parsing
Previously, every BLE notification batch went through
protocol.parse_frame_hex_batch: hex string → JSON encode → C FFI → Rust parse → JSON encode → FFI → JSON decode, on the parse queue. This round trip was the mainsource of the documented lag.
WhoopFrameParseris a drop-in replacement forNotificationFrameParserwith the sameparseBatchsignature, producing the sameNotificationFrameCompactSummaryshape directly in Swift:protocol.rs, with the identical motion intensity formula(
max(rawPeakRange/32767, accVectorRange/8192)clamped to [0, 1]).The Rust core is unchanged for everything else (historical sync decode, export, metrics), this only removes the bridge from the per-notification path. Output parity was checked against the Rust parser's compact summaries.
Notes