Repository navigation
A link that delivered a reading isn't a stopped session - #127
Merged
Merged
Conversation
While eavesdropping, a disconnect with pendingAuth still set is read as the Dexcom app having stopped the session, which starts a 15 minute grace period and then a scan for a new sensor. On a slow link the flag can still be set after a reading arrived: on a test phone a reading at 09:36:52 was followed by a session-end suspicion at 09:36:57, the next three slots were lost to queue stalls, and when the grace period ran out Loop forgot the sensor until the Dexcom app authenticated it again. A reading on the current link is direct evidence that the session is running, so it rules the suspicion out.
A reading on the link already clears the session-end suspicion, but a link can lose the race for the reading and still carry other control responses: overnight on a test phone, three links that saw only the end of the Dexcom app's exchange (the final ea frame, or a 51 frame) were each flagged as a possible session end. The sensor answers on the control characteristic only within an authenticated session, so any response there shows the session is still running.
This was referenced Nov 23, 2026
jeremybarnum
pushed a commit
to jeremybarnum/G7SensorKit
that referenced
this pull request
Nov 26, 2026
…it#134), with the early bond record Upstream's phone reconnect changes (a 2 s rescan and a connect when another app connects, the connect reissued at power-on after a restore, a link with a reading is not a stopped session) and the watch's in-place sensor change (LoopKit#128, the same as this branch's own). Also: a watch whose bond was lost records it at the handshake's bond step, not only at its end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dnzxy
pushed a commit
to loopandlearn/G7SensorKit
that referenced
this pull request
Dec 1, 2026
* A link that delivered a reading isn't a stopped session While eavesdropping, a disconnect with pendingAuth still set is read as the Dexcom app having stopped the session, which starts a 15 minute grace period and then a scan for a new sensor. On a slow link the flag can still be set after a reading arrived: on a test phone a reading at 09:36:52 was followed by a session-end suspicion at 09:36:57, the next three slots were lost to queue stalls, and when the grace period ran out Loop forgot the sensor until the Dexcom app authenticated it again. A reading on the current link is direct evidence that the session is running, so it rules the suspicion out. * Any control response rules out a stopped session A reading on the link already clears the session-end suspicion, but a link can lose the race for the reading and still carry other control responses: overnight on a test phone, three links that saw only the end of the Dexcom app's exchange (the final ea frame, or a 51 frame) were each flagged as a possible session end. The sensor answers on the control characteristic only within an authenticated session, so any response there shows the session is still running. (cherry picked from commit 86a8a97)
kristinkand
pushed a commit
to kristinkand/G7SensorKit
that referenced
this pull request
Dec 4, 2026
* A link that delivered a reading isn't a stopped session While eavesdropping, a disconnect with pendingAuth still set is read as the Dexcom app having stopped the session, which starts a 15 minute grace period and then a scan for a new sensor. On a slow link the flag can still be set after a reading arrived: on a test phone a reading at 09:36:52 was followed by a session-end suspicion at 09:36:57, the next three slots were lost to queue stalls, and when the grace period ran out Loop forgot the sensor until the Dexcom app authenticated it again. A reading on the current link is direct evidence that the session is running, so it rules the suspicion out. * Any control response rules out a stopped session A reading on the link already clears the session-end suspicion, but a link can lose the race for the reading and still carry other control responses: overnight on a test phone, three links that saw only the end of the Dexcom app's exchange (the final ea frame, or a 51 frame) were each flagged as a possible session end. The sensor answers on the control characteristic only within an authenticated session, so any response there shows the session is still running. (cherry picked from commit 86a8a97) (cherry picked from commit 46756a2)
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.
While eavesdropping, Loop reads a disconnect with
pendingAuthstill set as the Dexcom app having stopped the session. That starts the 15-minute suspected-session-end grace period, and when it runs out Loop scans for a new sensor. On a slow link the flag can still be set after a reading has already arrived on that same link.On a test phone this happened three times in one night. Each time a link delivered a reading and was then flagged as a suspected session end a few seconds later. The next slots were lost to queue stalls, the grace period ran out, and Loop forgot the sensor. It then retried a different nearby G7 until the Dexcom app authenticated the right one again, 5 to 20 minutes later.
A reading on the current link shows the session is running, so
peripheralDidDisconnectnow checksmanager.readingReceivedOnCurrentLinkbefore settingsuspectedEndOfSession.This doesn't cover a link where Loop never subscribed in time and so got no reading. That case can still raise the suspicion falsely and needs a separate heuristic.