File tree Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Expand file tree Collapse file tree 3 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -259,7 +259,7 @@ class G7BluetoothManager: NSObject {
259259 The sleep gives the transmitter time to shut down, but keeps the app running.
260260
261261 */
262- fileprivate func scanAfterDelay( ) {
262+ func scanAfterDelay( ) {
263263 DispatchQueue . global ( qos: . utility) . async {
264264 Thread . sleep ( forTimeInterval: 5 )
265265
Original file line number Diff line number Diff line change @@ -237,14 +237,14 @@ public class G7CGMManager: CGMManager {
237237 return nil
238238 }
239239
240- public func scanForNewSensor( ) {
240+ public func scanForNewSensor( scanAfterDelay : Bool = false ) {
241241 logDeviceCommunication ( " Forgetting existing sensor and starting scan for new sensor. " , type: . connection)
242242
243243 mutateState { state in
244244 state. sensorID = nil
245245 state. activatedAt = nil
246246 }
247- sensor. scanForNewSensor ( )
247+ sensor. scanForNewSensor ( scanAfterDelay : scanAfterDelay )
248248 }
249249
250250 private var device : HKDevice ? {
@@ -319,7 +319,7 @@ extension G7CGMManager: G7SensorDelegate {
319319 public func sensorDisconnected( _ sensor: G7Sensor , suspectedEndOfSession: Bool ) {
320320 logDeviceCommunication ( " Sensor disconnected: suspectedEndOfSession= \( suspectedEndOfSession) " , type: . connection)
321321 if suspectedEndOfSession {
322- scanForNewSensor ( )
322+ scanForNewSensor ( scanAfterDelay : true )
323323 }
324324 }
325325
Original file line number Diff line number Diff line change @@ -99,11 +99,15 @@ public final class G7Sensor: G7BluetoothManagerDelegate {
9999 bluetoothManager. delegate = self
100100 }
101101
102- public func scanForNewSensor( ) {
102+ public func scanForNewSensor( scanAfterDelay : Bool = false ) {
103103 self . sensorID = nil
104104 bluetoothManager. disconnect ( )
105105 bluetoothManager. forgetPeripheral ( )
106- bluetoothManager. scanForPeripheral ( )
106+ if scanAfterDelay {
107+ bluetoothManager. scanAfterDelay ( )
108+ } else {
109+ bluetoothManager. scanForPeripheral ( )
110+ }
107111 }
108112
109113 public func resumeScanning( ) {
You can’t perform that action at this time.
0 commit comments