Skip to content

Commit

Permalink
[nrf noup] followup to wifi issues fix
Browse files Browse the repository at this point in the history
This commit implement minors from previous wifi
fix signed PR number 404.

Signed-off-by: Patryk Lipinski <patryk.lipinski@nordicsemi.no>
  • Loading branch information
LipinskiPNordicSemi committed Mar 13, 2024
1 parent 7653e6c commit 556be37
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
13 changes: 9 additions & 4 deletions src/platform/nrfconnect/wifi/NrfWiFiDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,18 @@ void NrfWiFiDriver::OnNetworkStatusChanged(int connStatus)
if (mpNetworkStatusChangeCallback)
{
WiFiManager::WiFiInfo wifiInfo;
WiFiManager::WiFiNetwork wantedWifiInfo;

if (CHIP_NO_ERROR == WiFiManager::Instance().GetWiFiInfo(wifiInfo))
{
mpNetworkStatusChangeCallback->OnNetworkingStatusChange(status,
MakeOptional(ByteSpan(wifiInfo.mSsid, wifiInfo.mSsidLen)),
connStatus ? MakeOptional(connStatus) : NullOptional);
MakeOptional(ByteSpan(wifiInfo.mSsid, wifiInfo.mSsidLen)),
connStatus ? MakeOptional(connStatus) : NullOptional);
}
else if (CHIP_NO_ERROR == WiFiManager::Instance().GetWantedNetwork(wantedWifiInfo))
{
mpNetworkStatusChangeCallback->OnNetworkingStatusChange(status, MakeOptional(wantedWifiInfo.GetSsidSpan()),
connStatus ? MakeOptional(connStatus) : NullOptional);
}
}

Expand Down Expand Up @@ -258,8 +264,7 @@ void NrfWiFiDriver::LoadFromStorage()
void NrfWiFiDriver::OnScanWiFiNetworkDone(const wifi_status & status)
{
VerifyOrReturn(mScanCallback != nullptr);
mScanCallback->OnFinished(status.status ? Status::kUnknownError : Status::kSuccess,
CharSpan(), &mScanResponseIterator);
mScanCallback->OnFinished(status.status ? Status::kUnknownError : Status::kSuccess, CharSpan(), &mScanResponseIterator);
mScanCallback = nullptr;
}

Expand Down
23 changes: 19 additions & 4 deletions src/platform/nrfconnect/wifi/WiFiManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ CHIP_ERROR WiFiManager::Connect(const ByteSpan & ssid, const ByteSpan & credenti
{
ChipLogDetail(DeviceLayer, "Connecting to WiFi network: %*s", ssid.size(), ssid.data());

mHandling.mOnConnectionDone = handling.mOnConnectionDone;
mHandling.mConnectionTimeout = handling.mConnectionTimeout;
mHandling = handling;

mWiFiState = WIFI_STATE_ASSOCIATING;

Expand Down Expand Up @@ -278,6 +277,22 @@ CHIP_ERROR WiFiManager::GetWiFiInfo(WiFiInfo & info) const
return CHIP_ERROR_INTERNAL;
}

CHIP_ERROR WiFiManager::GetWantedNetwork(WiFiNetwork & info) const
{

if (mWantedNetwork.IsConfigured())
{
info.ssidLen = mWantedNetwork.ssidLen;
info.passLen = mWantedNetwork.passLen;
memcpy(info.ssid, mWantedNetwork.ssid, mWantedNetwork.ssidLen);
memcpy(info.pass, mWantedNetwork.pass, mWantedNetwork.passLen);

return CHIP_NO_ERROR;
}

return CHIP_ERROR_INTERNAL;
}

CHIP_ERROR WiFiManager::GetNetworkStatistics(NetworkStatistics & stats) const
{
net_stats_wifi data{};
Expand Down Expand Up @@ -420,8 +435,8 @@ void WiFiManager::ConnectHandler(Platform::UniquePtr<uint8_t> data)
{
CHIP_ERROR err = SystemLayer().ScheduleLambda([capturedData = data.get()] {
Platform::UniquePtr<uint8_t> safePtr(capturedData);
uint8_t * rawData = safePtr.get();
const wifi_status * status = reinterpret_cast<const wifi_status *>(rawData);
uint8_t * rawData = safePtr.get();
const wifi_status * status = reinterpret_cast<const wifi_status *>(rawData);

if (status->status)
{
Expand Down
1 change: 1 addition & 0 deletions src/platform/nrfconnect/wifi/WiFiManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ class WiFiManager
CHIP_ERROR ClearStationProvisioningData();
CHIP_ERROR Disconnect();
CHIP_ERROR GetWiFiInfo(WiFiInfo & info) const;
CHIP_ERROR GetWantedNetwork(WiFiNetwork & info) const;
CHIP_ERROR GetNetworkStatistics(NetworkStatistics & stats) const;
void AbortConnectionRecovery();
CHIP_ERROR SetLowPowerMode(bool onoff);
Expand Down

0 comments on commit 556be37

Please sign in to comment.