diff --git a/src/platform/nrfconnect/wifi/NrfWiFiDriver.cpp b/src/platform/nrfconnect/wifi/NrfWiFiDriver.cpp index 03720199961931..e8e5d10d73ae97 100644 --- a/src/platform/nrfconnect/wifi/NrfWiFiDriver.cpp +++ b/src/platform/nrfconnect/wifi/NrfWiFiDriver.cpp @@ -147,13 +147,21 @@ CHIP_ERROR NrfWiFiDriver::CommitConfiguration() CHIP_ERROR NrfWiFiDriver::RevertConfiguration() { + LoadFromStorage(); + if (WiFiManager::StationStatus::CONNECTING <= WiFiManager::Instance().GetStationStatus()) { + WiFiManager::WiFiInfo wifiInfo; + ReturnErrorOnFailure(WiFiManager::Instance().GetWiFiInfo(wifiInfo)); + if (mStagingNetwork.GetSsidSpan().data_equal(ByteSpan(wifiInfo.mSsid, wifiInfo.mSsidLen))) + { + // we are already connected to this network, so return prematurely + return CHIP_NO_ERROR; + } + WiFiManager::Instance().Disconnect(); } - LoadFromStorage(); - if (mStagingNetwork.IsConfigured()) { WiFiManager::ConnectionHandling handling{ [] { Instance().OnNetworkStatusChanged(Status::kSuccess); },