Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OmnipodKit/Bluetooth/BlePodComms.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
9 changes: 6 additions & 3 deletions OmnipodKit/Bluetooth/BluetoothManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
}
Expand Down