Reconnect: on a failed attempt, engage a scan to recover an inert standing connect#3
Open
loopkitdev wants to merge 1 commit into
Open
Reconnect: on a failed attempt, engage a scan to recover an inert standing connect#3loopkitdev wants to merge 1 commit into
loopkitdev wants to merge 1 commit into
Conversation
…nding connect
Field log (device-log diagnostic) showed the failure this fixes: after a
restored-cache handshake failure ("device disconnected from us"), the re-armed
standing connect was inert -- the peripheral sat .disconnected (peripheral.state=0)
with iOS silently dropping the pending connect, and with no fallback it stalled
for 15 minutes.
The failed reconnect ATTEMPT is the error evidence, so in the re-arm's
"disconnected, nothing pending" branch we now ALSO start a scan (guarded on
.poweredOn). The scan makes iOS actively reacquire the sensor; a fresh discovery
re-declares the connect on a fresh handle (handleScannerEvent(.didDiscover)),
driving a fresh connect + fresh handshake. The scan is stopped the moment a
session is established. Targeted (only after a failure), not an always-on scan.
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
Follow-up to #2. When a reconnect attempt fails, engage a scan to recover an inert standing connect.
The failure this fixes
The
peripheral.statediagnostic added in #2 caught it in the field: after a restored-cache handshake failure (didDisconnect "the specified device has disconnected from us",SensorSessionError error 4), the re-armed standing connect was inert — the peripheral sat.disconnected(peripheral.state=0) with iOS silently dropping the pending connect, and with no fallback it stalled for ~15 minutes until a manual relaunch. Retaining the peripheral (a separate LibreCRKit change) keeps it alive but does not make that standing connect land, so it wasn't sufficient on its own.Change
In the reconnect re-arm's "disconnected, nothing pending" branch, the failed attempt is treated as the error evidence: alongside re-declaring the standing connect, we now start a scan (guarded on
.poweredOn). The scan makes iOS actively reacquire the sensor, and a fresh discovery re-declares the connect on a fresh handle (handleScannerEvent(.didDiscover), from #2) → fresh connect + fresh handshake. The scan is stopped the moment a session is established (self.monitor = monitor).Targeted — it only runs after a reconnect failure, not the always-on scan we deliberately avoided.
One file, +15/−7. Compile-verified; the reconnect path was exercised on-device alongside #2.