From 6fecf78f1728762b3b4cbe2fa4fe9bc22f332f2d Mon Sep 17 00:00:00 2001 From: Pete Schwamb Date: Mon, 12 Oct 2026 11:50:20 -0500 Subject: [PATCH] Log why the G7 manager doesn't scan managerQueue_scanForPeripheral returned silently when it had no delegate or its sensor was connected, and fell through without a word when it couldn't retrieve the sensor it was following. A stalled reconnect leaves no trace of which way it went; now each exit logs. --- G7SensorKit/G7CGMManager/G7BluetoothManager.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/G7SensorKit/G7CGMManager/G7BluetoothManager.swift b/G7SensorKit/G7CGMManager/G7BluetoothManager.swift index 4d34879..563a1e7 100644 --- a/G7SensorKit/G7CGMManager/G7BluetoothManager.swift +++ b/G7SensorKit/G7CGMManager/G7BluetoothManager.swift @@ -294,6 +294,7 @@ class G7BluetoothManager: NSObject { // not start scanning again in that window: the sensor it just paired // admits one display, and the session manager is claiming it. guard delegate != nil else { + log.default("Not scanning: no delegate") return } @@ -306,6 +307,7 @@ class G7BluetoothManager: NSObject { let currentState = activePeripheral?.state ?? .disconnected guard currentState != .connected else { + log.default("Not scanning: active peripheral is connected") return } @@ -313,6 +315,9 @@ class G7BluetoothManager: NSObject { log.default("Retrieved peripheral %{public}@", peripheral.identifier.uuidString) handleDiscoveredPeripheral(peripheral) } else { + if let peripheralID = activePeripheralIdentifier { + log.default("Could not retrieve peripheral %{public}@; active peripheral %{public}@", peripheralID.uuidString, activePeripheral?.identifier.uuidString ?? "none") + } for peripheral in centralManager.retrieveConnectedPeripherals(withServices: [ SensorServiceUUID.advertisement.cbUUID, SensorServiceUUID.cgmService.cbUUID