diff --git a/OmnipodKit/Bluetooth/BlePodComms.swift b/OmnipodKit/Bluetooth/BlePodComms.swift index cdf0569f..3f72e2aa 100644 --- a/OmnipodKit/Bluetooth/BlePodComms.swift +++ b/OmnipodKit/Bluetooth/BlePodComms.swift @@ -93,7 +93,7 @@ class BlePodComms: PodComms { // would hang without ever timing out. Always schedule on the main run loop. DispatchQueue.main.async { Timer.scheduledTimer(withTimeInterval: 1, repeats: true) { timer in - let devices = self.bluetoothManager.getConnectedDevices() + let devices = self.bluetoothManager.getConnectedPairingCandidates() if devices.count > 1 { self.log.default("Multiple pods found while scanning") diff --git a/OmnipodKit/Bluetooth/BluetoothManager.swift b/OmnipodKit/Bluetooth/BluetoothManager.swift index c765ab55..1f4b73f8 100644 --- a/OmnipodKit/Bluetooth/BluetoothManager.swift +++ b/OmnipodKit/Bluetooth/BluetoothManager.swift @@ -846,7 +846,7 @@ class BluetoothManager: NSObject { delayedProbeInFlight = false alarmScanSuppressed = false manager.stopScan() - for device in devices { + for device in devices where autoConnectIDs.contains(device.manager.peripheral.identifier.uuidString) { let peripheral = device.manager.peripheral switch peripheral.state { case .connecting where !isConnectWatchdogActive(peripheral): @@ -1302,10 +1302,13 @@ class BluetoothManager: NSObject { // MARK: - Accessors - func getConnectedDevices() -> [Omni] { + func getConnectedPairingCandidates() -> [Omni] { var connected: [Omni] = [] managerQueue.sync { - connected = self.devices.filter { $0.manager.peripheral.state == .connected } + connected = self.devices.filter { + $0.manager.peripheral.state == .connected && + ($0.advertisement?.pairable == true || self.autoConnectIDs.contains($0.manager.peripheral.identifier.uuidString)) + } } return connected }