[Darwin][Ble] Keep scanning while connecting to a device until didConnectPeripheral fires (#36595)
diff --git a/src/platform/Darwin/BleConnectionDelegateImpl.mm b/src/platform/Darwin/BleConnectionDelegateImpl.mm
index b0c1e2e..7b5d68b 100644
--- a/src/platform/Darwin/BleConnectionDelegateImpl.mm
+++ b/src/platform/Darwin/BleConnectionDelegateImpl.mm
@@ -447,6 +447,7 @@
MATTER_LOG_METRIC_BEGIN(kMetricBLEDiscoveredServices);
[peripheral setDelegate:self];
[peripheral discoverServices:nil];
+ [self stopScanning];
}
// End CBCentralManagerDelegate
@@ -734,7 +735,7 @@
MATTER_LOG_METRIC_BEGIN(kMetricBLEDiscoveredMatchingPeripheral);
ChipLogProgress(Ble, "Connecting to cached device: %p", peripheral);
[self connect:peripheral];
- [self stopScanning];
+ // The cached peripheral might be obsolete, so continue scanning until didConnectPeripheral is triggered.
} else {
[self setupTimer:kScanningWithDiscriminatorTimeoutInSeconds];
}