Wire pump BLE heartbeat to CGM reading schedule + preserve manager state on missing plugin#2461
Open
loopkitdev wants to merge 2 commits into
Open
Wire pump BLE heartbeat to CGM reading schedule + preserve manager state on missing plugin#2461loopkitdev wants to merge 2 commits into
loopkitdev wants to merge 2 commits into
Conversation
Send the pump a PumpHeartbeatRequest (last CGM reading date + expected reading interval) when it must provide the BLE heartbeat, or nil when the CGM wakes the app itself, via the new setBLEHeartbeatRequest API. The last-reading time is refreshed after every CGM reading (processCGMReadingResult already calls updatePumpManagerBLEHeartbeatPreference), so the pump's heartbeat cadence tracks the actual reading schedule.
instantiateDeviceManagers restored a manager by assigning pumpManager/cgmManager = the result of ...FromRawValue(...). When the plugin wasn't available in the running build, that returned nil, and the nil assignment fired the didSet, which wrote rawPumpManager/rawCGMManager = nil and DELETED the persisted state — so launching a build missing a plugin permanently wiped the pod pairing (incl. session keys) or CGM config. Only assign when the manager instantiates; otherwise log and leave the saved state on disk so a later build that includes the plugin can restore it.
Contributor
TestI'm putting test notes in comments for this PR so they are in one place. Summary from initial testing: intermittent success
ConfigurationI started with LoopWorkspace next-dev commit 14b70bd. I am running 2 test phones:
Narrative
2nd gen, Omnipod 5 narrative
2026-07-19 06:16 lock 2nd gen (o5) phone 3rd gen, rPi DASH narrative
2026-07-19 06:16 lock 3rd gen (rPi DASH) phone |
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
Wires the pump BLE heartbeat to the CGM reading schedule (uses the coupled LoopKit
setBLEHeartbeatRequestAPI) and hardens device-manager restore:DeviceDataManager.updatePumpManagerBLEHeartbeatPreferencesends aPumpHeartbeatRequest(last CGM reading date + expected interval) when the pump must provide the heartbeat, ornilwhen the CGM wakes the app itself; refreshed after every CGM reading.pumpManager/cgmManager = nil, whosedidSetdeleted the persisted state — permanently wiping the pod pairing (incl. session keys) or CGM config. Now it logs and leaves the saved state on disk for a later build that includes the plugin.Requires the LoopKit
setBLEHeartbeatRequestPR to compile; pairs with the OmnipodKit PR. Merge together. (Cross-links below.)🤖 Generated with Claude Code
https://claude.ai/code/session_017Tbv6GBAMmGATWp6zwBDy7
Coupled PRs — merge together (three-way dependency)
PumpManager.setBLEHeartbeatRequestprotocol APILoop and OmnipodKit will not compile without the LoopKit protocol change; land all three together and bump the LoopWorkspace next-dev submodule pins in one commit.