Skip to content

The watch keeps its session and central across a sensor change - #128

Merged
ps2 merged 1 commit into
LoopKit:next-devfrom
jeremybarnum:sportmode/one-session-per-sensor-change
Nov 24, 2026
Merged

ps2 merged 1 commit into
LoopKit:next-devfrom
jeremybarnum:sportmode/one-session-per-sensor-change

Conversation

@jeremybarnum

Copy link
Copy Markdown

Needs LoopKit/LoopKit#706

On the watch, a new sensor or code from the phone now goes to the existing G7CGMManager through adoptConfiguration(_:), as a pairing does on the phone: same session, same Bluetooth central. Before, the watch built a second manager while the first still held the restore identifier, and the new central reported .unsupported for good.

  • The old sensor's state is dropped, and anything started for it (a hold, a settle, a backoff) stands down.
  • A central that reports .unknown or .unsupported now starts the existing recheck-and-recreate itself.

Testing: G7SensorKit tests pass (210), including new ones for the same session and central across a sensor change and a code change. On a real watch with two emulated sensors, the watch followed each sensor and code change in place with no .unsupported. That run used the earlier, opt-in version of the call; this version has the same G7 behaviour and is not yet run on a device. The .unsupported recovery path has not been exercised on a device.

🤖 Generated with Claude Code

…tral

The watch built a second G7CGMManager for each new sensor or code while the first was still
registered with the restore identifier. watchOS refuses the duplicate and the new central reports
.unsupported for good: the watch never scanned for the new sensor until Loop was relaunched. Seen
on a device with the old sensor still live at the switch.

- G7CGMManager joins ShareableDeviceControl. adoptConfiguration(_:) takes the phone's changed
  export in place, as a pairing does on the phone: same session, same central; the old sensor's
  link or request is cancelled. A manager set up on this device keeps its own sensor.
- G7WatchAcquisition.sensorForgotten(): drops the old sensor's state; a hold, settle or backoff
  started for it stands down when it returns. A late link to the old sensor does not end the search.
- A central reporting .unknown or .unsupported starts the existing recheck and recreate itself, and
  says so in the device log; before, only a scan request did, and nothing asked once it arrived.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ps2
ps2 merged commit c86d9bb into LoopKit:next-dev Nov 24, 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>
yurique added a commit to Artificial-Pancreas/G7SensorKit that referenced this pull request Nov 27, 2026
… s rescan, connect after restore, watch handoff

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
…tral (LoopKit#128)

The watch built a second G7CGMManager for each new sensor or code while the first was still
registered with the restore identifier. watchOS refuses the duplicate and the new central reports
.unsupported for good: the watch never scanned for the new sensor until Loop was relaunched. Seen
on a device with the old sensor still live at the switch.

- G7CGMManager joins ShareableDeviceControl. adoptConfiguration(_:) takes the phone's changed
  export in place, as a pairing does on the phone: same session, same central; the old sensor's
  link or request is cancelled. A manager set up on this device keeps its own sensor.
- G7WatchAcquisition.sensorForgotten(): drops the old sensor's state; a hold, settle or backoff
  started for it stands down when it returns. A late link to the old sensor does not end the search.
- A central reporting .unknown or .unsupported starts the existing recheck and recreate itself, and
  says so in the device log; before, only a scan request did, and nothing asked once it arrived.

Co-authored-by: Jeremy Barnum <prefer not to supply>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit c86d9bb)
kristinkand pushed a commit to kristinkand/G7SensorKit that referenced this pull request Dec 4, 2026
…tral (LoopKit#128)

The watch built a second G7CGMManager for each new sensor or code while the first was still
registered with the restore identifier. watchOS refuses the duplicate and the new central reports
.unsupported for good: the watch never scanned for the new sensor until Loop was relaunched. Seen
on a device with the old sensor still live at the switch.

- G7CGMManager joins ShareableDeviceControl. adoptConfiguration(_:) takes the phone's changed
  export in place, as a pairing does on the phone: same session, same central; the old sensor's
  link or request is cancelled. A manager set up on this device keeps its own sensor.
- G7WatchAcquisition.sensorForgotten(): drops the old sensor's state; a hold, settle or backoff
  started for it stands down when it returns. A late link to the old sensor does not end the search.
- A central reporting .unknown or .unsupported starts the existing recheck and recreate itself, and
  says so in the device log; before, only a scan request did, and nothing asked once it arrived.

Co-authored-by: Jeremy Barnum <prefer not to supply>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit c86d9bb)
(cherry picked from commit 4134099)
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.

2 participants