Repository navigation
Conversation
Backport of #103 and #104 from next-dev. After a disconnect, the reconnect went through scanAfterDelay(), which slept 2 s on a global queue before connecting. If iOS suspended the app during that sleep, no connect was pending and nothing woke the app until it was opened. With a G7 the pump doesn't provide a heartbeat, so the background pod polls that 3.14.8 still made were the only thing finishing that sleep; since loopandlearn/OmnipodKit#175 removed them, readings can stop for hours (LoopKit/Loop#2630). When the active peripheral disconnects or fails to connect, connect again at once with CBConnectPeripheralOptionStartDelayKey set to 30 s, so bluetoothd holds the request before the app can be suspended and the sensor's advertising tail passes first. Any other link ending rescans after 2 s on the manager queue. A scan leaves an active peripheral that is already connecting alone, so the per-cycle resumeScanning doesn't replace the delayed request with a plain connect. The reconnect line also goes to the device log.
Camji55
approved these changes
Nov 3, 2026
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.
Backport of #103 and #104 from next-dev, for the G7 gaps reported in LoopKit/Loop#2630.
Problem
After a disconnect, the reconnect went through
scanAfterDelay(), which slept 2 s on a global queue before callingconnect. If iOS suspended Loop during that sleep, no connect was pending, and nothing woke the app until it was next opened.With a G7,
providesBLEHeartbeatis true, so the pump never wakes Loop for the CGM. Up to 3.14.8, the "When Open" Pod Keep Alive still polled the pod in the background. Those polls gave Loop CPU time, which let the frozen sleep finish. loopandlearn/OmnipodKit#175 removed them in 3.14.9, and since then readings can stop for hours. In LoopKit/Loop#2630 there was a 4-hour overnight gap while the Dexcom app had every reading. Silent Tune hides it by keeping the app running.Change
CBConnectPeripheralOptionStartDelayKeyset to 30 s. bluetoothd holds the request before the app can be suspended, and the delay lets the sensor's advertising tail pass. The value has to be whole seconds.managerQueue.asyncAfter.scanAfterDelay()is removed.managerQueue_scanForPeripheralleaves an active peripheral that is.connectingalone. Otherwise the per-cyclefetchNewDataIfNeeded→resumeScanningwould replace the delayed request with a plain connect.logEventdelegate path with default implementations.Testing