You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
iflet first = deviceManager.watches.first, deviceManager.watches.count <=1{
208
+
// Switch to the user's next watch
203
209
pairedDeviceID = first.uuid
204
210
pairedDevice = deviceManager.fetchDevice()
205
211
}else{
212
+
// The user doesn't have another watch, this will show the welcome view
206
213
pairedDeviceID =nil
207
214
}
208
215
209
216
log("Unpaired from \(pairedDevice?.name ??"InfiniTime")", type:.info, caller:"BLEManager", target:.ble)
210
217
211
218
if device ==nil{
212
-
// This only disconnects and removes the watch from the recognized device list. If using secure pairing, the bond will still be kept
219
+
// FIXME: this only disconnects and removes the watch from the recognized device list in the app. If using secure pairing, iOS will still keep the bond
213
220
disconnect()
214
221
startScanning()
215
222
}
@@ -218,6 +225,8 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
if peripheral.name =="InfiniTime" && !newPeripherals.contains(where:{ $0.identifier.uuidString == peripheral.identifier.uuidString }){
245
-
if isPairingNewDevice {
246
-
if !deviceManager.watches.compactMap({ $0.uuid }).contains(peripheral.identifier.uuidString){
255
+
if peripheral.name =="InfiniTime" && !newPeripherals.contains(where:{ $0.identifier.uuidString == peripheral.identifier.uuidString }){ // The peripheral has not already been discovered
256
+
if isPairingNewDevice { // Only check if we know the device when pairing a new watch, because we don't one to show up
257
+
if !deviceManager.watches.compactMap({ $0.uuid }).contains(peripheral.identifier.uuidString){ // The discovered watch is not already paired
247
258
newPeripherals.append(peripheral)
248
259
}
249
260
}else{
@@ -268,20 +279,21 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
268
279
}
269
280
}
270
281
282
+
// The connection was abruptly terminated, so we try connecting again
0 commit comments