Skip to content

Commit

Permalink
wifi: RevertConfiguration optimization.
Browse files Browse the repository at this point in the history
Do not disconnect/reconnect to the already attached network.

Signed-off-by: Marcin Kajor <[email protected]>
  • Loading branch information
markaj-nordic authored and Damian-Nordic committed Jan 6, 2023
1 parent 948dd4a commit 74d8cd2
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/platform/nrfconnect/wifi/NrfWiFiDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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); },
Expand Down

0 comments on commit 74d8cd2

Please sign in to comment.