Skip to content

Read a G7 directly on the watch - #2605

Merged
ps2 merged 1 commit into
next-devfrom
watch-direct-read
Oct 24, 2026
Merged

ps2 merged 1 commit into
next-devfrom
watch-direct-read

Conversation

@ps2

@ps2 ps2 commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Lets the Loop watch app read a G7 itself, so readings carry on when the phone isn't there.

With Read on Apple Watch on in the G7 settings, the phone puts the G7's exported configuration in the watch context. The watch builds its own G7 manager from it, in the sensor's watch slot, keeps it across launches, and lets go of the sensor when the phone stops sharing.

  • WatchCGMHost hosts the manager. It rebuilds only when the export names a different sensor or code, and it starts at launch so a relaunch for the sensor's link finds it.
  • The watch's readings go into its glucose store beside the phone's. The same reading from both carries the same sync identifier, so the store keeps one. The glance and complications show the watch's reading while it's newer than the phone's.
  • Glucose backfill from the phone starts no later than the phone's own last reading, so the watch's readings don't hide a gap.
  • Bluetooth wakes are handled on the main queue (watchOS can deliver them on CoreBluetooth's queue). A Bluetooth wake is held for 25 s, through the reading. A background refresh 60 s after each reading re-checks that a connect is lodged. It comes after the G7's 35 s wait, so it never connects into the sensor's advertising tail.
  • A third page, shown while the watch reads a sensor, shows its name, the G7's note when it needs the code or is searching, the last reading and connection, and a countdown to the next reading.
  • The watch app links and embeds G7SensorKit and LoopKit, and declares bluetooth-central with a Bluetooth usage description.

Needs LoopKit/LoopKit#626 and LoopKit/G7SensorKit#80. The registry, the context field and the project entries use the names and IDs of the Sport Mode Loop PR (#2545), which can drop its own copies once this lands.

Tested on an Apple Watch Series 9 with a real G7: the watch paired from the phone's export and read every window in the background with the phone's Bluetooth off.

With Read on Apple Watch on in the G7 settings, the phone puts the
CGM's exported configuration in the watch context
(DeviceConfigurationSharing, from LoopKit/LoopKit#626). The watch
builds its own G7 manager from it, in the sensor's watch slot, keeps
it across launches, and lets go of the sensor when the phone stops
sharing. Readings continue on the watch when the phone isn't there.

- WatchCGMHost hosts the manager. It rebuilds only when the export
  names a different sensor or code, saves the manager's state, and is
  started at launch so a relaunch for the sensor's link finds it.
- The watch's readings go into its glucose store beside the phone's;
  the same reading from both carries the same sync identifier, so the
  store keeps one. The glance and the complications show the watch's
  reading while it is newer than the phone's, the rest of the phone's
  context as before, and the chart redraws on each one.
- Glucose backfill from the phone starts no later than the phone's
  own last reading, so the watch's readings don't hide a gap.
- Wakes: a Bluetooth wake task is held 25 s, through the reading. The
  app opening, each phone context and a background refresh 60 s after
  each reading re-check that a connect is standing, in case watchOS
  froze the app during the G7's 35 s wait before it lodged one; the
  refresh comes after that wait, so it never connects early.
- Wakes are handled on the main queue: watchOS can deliver the
  Bluetooth wake on CoreBluetooth's queue.
- A third page, shown while the watch reads a sensor, has the
  sensor's name, the G7's note when it needs the code or is
  searching, the last reading and connection, and a countdown to the
  next reading.
- The watch app links and embeds G7SensorKit and LoopKit, and declares
  bluetooth-central with a Bluetooth usage description.

The registry, the context field and the project entries use the names
and IDs of the Sport Mode Loop PR (#2545), which can drop
its own copies once this lands. Needs LoopKit/LoopKit#626 and
LoopKit/G7SensorKit#80.
@ps2
ps2 marked this pull request as ready for review October 24, 2026 17:52
@ps2
ps2 merged commit 7bb91c3 into next-dev Oct 24, 2026
JoelonGit pushed a commit to JoelonGit/LoopWorkspace that referenced this pull request Oct 24, 2026
Points LoopKit, G7SensorKit and Loop at their next-dev merges of
LoopKit/LoopKit#626, LoopKit/G7SensorKit#80 and LoopKit/Loop#2605.
Loop also picks up LoopKit/Loop#2606.
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