Skip to content

Eavesdropping: listen for control responses without waiting to observe authentication - #124

Merged
ps2 merged 1 commit into
next-devfrom
fix/observe-completed-auth-nd
Nov 17, 2026
Merged

ps2 merged 1 commit into
next-devfrom
fix/observe-completed-auth-nd

Conversation

@ps2

@ps2 ps2 commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

Port of #121 to next-dev. It only affects eavesdropping mode; direct mode runs its own handshake.

When the Dexcom app finishes authenticating before Loop subscribes to the authentication characteristic, Loop never sees the authenticated notification, so it never enables control notifications and misses the reading. Issue reports from the developer portal show this in about 0.2–1.7% of eavesdropping sessions. Direct sessions didn't show it.

Change

  • Enable control notifications right after subscribing to authentication.
  • A glucose response clears pendingAuth, and the device log notes a reading that arrived before authentication was observed.

How widely it was seen

From the G7 issue reports on the LoopKit developer portal:

  • 14 of the 15 eavesdropping-only next-dev reports (3.15.2) lost readings this way: 96 of 15,098 slots (0.6%). Most phones lost 0.2–1.1% of their slots.
  • 4 more next-dev reports that switched between eavesdropping and direct mode had 3–6 each, all in eavesdropping sessions.
  • Across main and next-dev, 21 of 24 eavesdropping reports had it.
  • None of the direct-only reports did.

Testing

LoopWorkspace next-dev builds. The same change on main ran on an iPhone alongside the Dexcom G7 app. This port hasn't run on a phone.

When the Dexcom app authenticates before Loop subscribes to the
authentication characteristic, the authenticated notification has already
gone by. Loop then never enables control notifications, drops the reading,
and treats the sensor's normal disconnect as a suspected end of session.

Enable control notifications right after subscribing to authentication.
The authentication characteristic is not readable (write, notify,
indicate), so its state can't be checked after the fact, and the sensor
accepts the control subscription before the app-level auth exchange.

A glucose response also clears pendingAuth, since it shows the session
was authenticated. When that happens before authentication was observed,
note it in the device log so these sessions can be counted in reports.
@ps2
ps2 merged commit 1a82d04 into next-dev Nov 17, 2026
yurique added a commit to Artificial-Pancreas/G7SensorKit that referenced this pull request Nov 21, 2026
…xes, settings split, async delegates

Brings in LoopKit/G7SensorKit next-dev up to 7e15158:
- LoopKit#118 readings go through delegate.notify, in order with events and alerts.
- LoopKit#124 listen for control responses without waiting to observe authentication.
- LoopKit#125 use the reconnect start delay only after a link that delivered a reading.
- LoopKit#126 enable control notifications before authentication when eavesdropping.
- LoopKit#114 settings split into Sensor and Session sections.
- LoopKit#119, LoopKit#110 watch target changes (not built by iAPS); the manager now
  notifies CGMManagerStatusObservers of status, search and note changes.

Adapted to the iAPS LoopKit dev line as before: delegate calls inside the
notify blocks are not awaited, and delegateQueue stays, backed by the
WeakSynchronizedDelegate queue. Needs isSearchingForSensor and
shortStatusNote on CGMManager (LoopKit next-dev-port).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
dnzxy pushed a commit to loopandlearn/G7SensorKit that referenced this pull request Dec 1, 2026
LoopKit#124)

When the Dexcom app authenticates before Loop subscribes to the
authentication characteristic, the authenticated notification has already
gone by. Loop then never enables control notifications, drops the reading,
and treats the sensor's normal disconnect as a suspected end of session.

Enable control notifications right after subscribing to authentication.
The authentication characteristic is not readable (write, notify,
indicate), so its state can't be checked after the fact, and the sensor
accepts the control subscription before the app-level auth exchange.

A glucose response also clears pendingAuth, since it shows the session
was authenticated. When that happens before authentication was observed,
note it in the device log so these sessions can be counted in reports.

(cherry picked from commit 1a82d04)
@ps2
ps2 deleted the fix/observe-completed-auth-nd branch December 3, 2026 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant