Skip to content

Commit

Permalink
Revert "[nrf fromlist][nrfconnect] Add checking of Wi-Fi supplicant a…
Browse files Browse the repository at this point in the history
…nd Interface"

This reverts commit 324ff76.
  • Loading branch information
ArekBalysNordic committed Feb 27, 2024
1 parent 324ff76 commit 15d3293
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 52 deletions.
42 changes: 1 addition & 41 deletions src/platform/nrfconnect/wifi/WiFiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,33 +144,6 @@ const Map<uint32_t, WiFiManager::NetEventHandler, 5> WiFiManager::sEventHandlerM
{ NET_EVENT_WIFI_DISCONNECT_COMPLETE, WiFiManager::DisconnectHandler },
});

void WiFiManager::WiFiSupplicantEventHandler(net_mgmt_event_callback * cb, uint32_t mgmtEvent, net_if * iface)
{
switch (mgmtEvent)
{
case NET_EVENT_WPA_SUPP_READY:
Instance().mSupplicantReady = true;
break;
case NET_EVENT_WPA_SUPP_NOT_READY:
Instance().mSupplicantReady = false;
break;
case NET_EVENT_WPA_SUPP_IFACE_ADDED:
Instance().mInterfaceUp = true;
break;
case NET_EVENT_WPA_SUPP_IFACE_REMOVED:
Instance().mInterfaceUp = false;
break;
default:
break;
}

if (Instance().mSupplicantReady && Instance().mInterfaceUp)
{
// In this case the Supplicant and Interface is fully ready.
DeviceLayer::SystemLayer().CancelTimer(SupplicantInitTimeout, nullptr);
}
}

void WiFiManager::WifiMgmtEventHandler(net_mgmt_event_callback * cb, uint32_t mgmtEvent, net_if * iface)
{
if (iface == Instance().mNetIf)
Expand All @@ -197,16 +170,11 @@ CHIP_ERROR WiFiManager::Init()

net_mgmt_init_event_callback(&mWiFiMgmtClbk, WifiMgmtEventHandler, kWifiManagementEvents);
net_mgmt_init_event_callback(&mIPv6MgmtClbk, IPv6MgmtEventHandler, kIPv6ManagementEvents);
net_mgmt_init_event_callback(&mSuppMgmtClbk, WiFiSupplicantEventHandler, kSupplicantEvents);

net_mgmt_add_event_callback(&mWiFiMgmtClbk);
net_mgmt_add_event_callback(&mIPv6MgmtClbk);
net_mgmt_add_event_callback(&mSuppMgmtClbk);

// Set the timer and wait for the WiFi supplicant and interface ready.
DeviceLayer::SystemLayer().StartTimer(System::Clock::Milliseconds32(kSupplicantReadyTimeoutMs), SupplicantInitTimeout, nullptr);

ChipLogDetail(DeviceLayer, "WiFiManager initialization requested");
ChipLogDetail(DeviceLayer, "WiFiManager has been initialized");

return CHIP_NO_ERROR;
}
Expand Down Expand Up @@ -620,13 +588,5 @@ CHIP_ERROR WiFiManager::SetLowPowerMode(bool onoff)
return CHIP_NO_ERROR;
}

void WiFiManager::SupplicantInitTimeout(System::Layer * layer, void * param)
{
ChipLogError(DeviceLayer, "Wi-Fi supplicant and interface have not been initialized!");
// Wi-Fi driver must be initialized within the given timeout, when it is still not ready, do not to allow any further
// operations.
VerifyOrDie(Instance().mSupplicantReady && Instance().mInterfaceUp);
}

} // namespace DeviceLayer
} // namespace chip
11 changes: 0 additions & 11 deletions src/platform/nrfconnect/wifi/WiFiManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

extern "C" {
#include <src/utils/common.h>
#include <supp_events.h>
#include <wpa_supplicant/wpa_supplicant_i.h>
}

Expand Down Expand Up @@ -174,7 +173,6 @@ class WiFiManager
static constexpr uint32_t kConnectionRecoveryMaxIntervalMs = CONFIG_CHIP_WIFI_CONNECTION_RECOVERY_MAXIMUM_INTERVAL;
static constexpr uint32_t kConnectionRecoveryJitterMs = CONFIG_CHIP_WIFI_CONNECTION_RECOVERY_JITTER;
static constexpr uint32_t kConnectionRecoveryMaxRetries = CONFIG_CHIP_WIFI_CONNECTION_RECOVERY_MAX_RETRIES_NUMBER;
static constexpr uint32_t kSupplicantReadyTimeoutMs = 500;

CHIP_ERROR Init();
CHIP_ERROR Scan(const ByteSpan & ssid, ScanResultCallback resultCallback, ScanDoneCallback doneCallback,
Expand Down Expand Up @@ -202,13 +200,9 @@ class WiFiManager

constexpr static uint32_t kIPv6ManagementEvents = NET_EVENT_IPV6_ADDR_ADD | NET_EVENT_IPV6_ADDR_DEL;

constexpr static uint32_t kSupplicantEvents = NET_EVENT_WPA_SUPP_READY | NET_EVENT_WPA_SUPP_CMD_NOT_READY |
NET_EVENT_WPA_SUPP_IFACE_ADDED | NET_EVENT_WPA_SUPP_IFACE_REMOVED;

// Event handling
static void WifiMgmtEventHandler(net_mgmt_event_callback * cb, uint32_t mgmtEvent, net_if * iface);
static void IPv6MgmtEventHandler(net_mgmt_event_callback * cb, uint32_t mgmtEvent, net_if * iface);
static void WiFiSupplicantEventHandler(net_mgmt_event_callback * cb, uint32_t mgmtEvent, net_if * iface);
static void ScanResultHandler(Platform::UniquePtr<uint8_t> data);
static void ScanDoneHandler(Platform::UniquePtr<uint8_t> data);
static void ConnectHandler(Platform::UniquePtr<uint8_t> data);
Expand All @@ -227,21 +221,16 @@ class WiFiManager
// To avoid frequent recovery attempts when the signal to an access point is poor quality
// The connection recovery interval will be cleared after the defined delay in kConnectionRecoveryDelayToReset.
static void Recover(System::Layer * layer, void * param);
static void SupplicantInitTimeout(System::Layer * layer, void * param);
void ResetRecoveryTime();
System::Clock::Milliseconds32 CalculateNextRecoveryTime();

bool mSupplicantReady{ false };
bool mInterfaceUp{ false };
bool mSupplicantInitTimeoutElapsed{ false };
net_if * mNetIf{ nullptr };
ConnectionParams mWiFiParams{};
ConnectionHandling mHandling;
wifi_iface_state mWiFiState;
wifi_iface_state mCachedWiFiState;
net_mgmt_event_callback mWiFiMgmtClbk{};
net_mgmt_event_callback mIPv6MgmtClbk{};
net_mgmt_event_callback mSuppMgmtClbk{};
ScanResultCallback mScanResultCallback{ nullptr };
ScanDoneCallback mScanDoneCallback{ nullptr };
WiFiNetwork mWantedNetwork{};
Expand Down

0 comments on commit 15d3293

Please sign in to comment.