Add experimental AirPods heart-rate monitoring - #702
Open
thibaup wants to merge 11 commits into
Open
Conversation
arctumn
pushed a commit
to arctumn/librepods
that referenced
this pull request
Aug 7, 2026
…epods-org#702) hr.rs = a faithful Rust port of RtBuddyHeartRateDecoder (frame reassembly across chunks + a bounded protobuf/varint parser + the full HEARTRATE validation: log types {1,3}, service 19, 18-byte payload, known status tail @15, BPM @offset 1 in 30..=220). aap.rs gets the enable sequence (AACP 1.3 CONNECT/CAPABILITIES init + HRM_STATE 0x30 + the RTBuddy START/STOP frames). IPC gains Snapshot.heart_rate + Command::SetHeartRate{on}. run_receiver feeds each recv chunk to the decoder only when HR is on (opt-in, off by default — it drains battery), publishes new BPM via push_state, and re-arms/clears across reconnects. Pro 3 only; experimental — needs on-hardware verification of the init timing + the stop path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
arctumn
pushed a commit
to arctumn/librepods
that referenced
this pull request
Aug 7, 2026
…epods-org#702) The RTBuddy stream almost never starts on the first enable (frame_prefix_hits=0 on hardware). Mirror the Android HeartRateMonitor: on SetHeartRate{on}, a dedicated retry thread runs a 15s campaign — each attempt STOP-resets + re-sends the init frames + HRM_STATE + START, then polls hr_got_sample for 8s; on the first decoded BPM it goes live (run_receiver keeps decoding), else it backs off (500/1000/2000ms) and retries until the window is spent. hr_got_sample is the run_receiver<->retry rendezvous; hr_retrying guards against stacking two campaigns. No L2CAP reconnect (service-level re-enable only). Reconnect re-arm goes through the same path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
arctumn
pushed a commit
to arctumn/librepods
that referenced
this pull request
Aug 7, 2026
Captured from a real iOS Fitness/Strava HR session via PacketLogger: at workout start the iPhone sends 04 00 04 00 44 00 04 00 02 00 03 07 (opcode 0x44, value 0x07) alongside the SensorDataWX frames — a command LibrePods never mapped. The PR librepods-org#702 enable (HRM_STATE + START) only yields empty status heartbeats; this is the suspected 'enter workout sampling mode' trigger. Sent right before START, mirroring the iPhone ordering. Experimental — validating on hardware.
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.
Adds an experimental Heart-rate test under Settings. It initializes the RTBuddy HEARTRATE stream and shows structurally validated samples in a live graph based on the protocol work in https://github.com/tomppi/airpods_rtbuddy_v37_probe. I also fixed a compatibility issue found during testing.
Tested with AirPods Pro 3 on a OnePlus 15