From 5455169449173e87d2bdd99b06be7bc19dc16a1d Mon Sep 17 00:00:00 2001 From: pankore <86098180+pankore@users.noreply.github.com> Date: Tue, 31 Jan 2023 00:45:41 +0800 Subject: [PATCH] [wifi] dont store wifi info in kvs if ssid is empty (#24719) - also initialize WifiNetwork structs to empty --- src/platform/Ameba/AmebaUtils.cpp | 6 ++++++ src/platform/Ameba/NetworkCommissioningDriver.h | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/platform/Ameba/AmebaUtils.cpp b/src/platform/Ameba/AmebaUtils.cpp index 4ec66872133429..1d202ccd53f644 100644 --- a/src/platform/Ameba/AmebaUtils.cpp +++ b/src/platform/Ameba/AmebaUtils.cpp @@ -76,6 +76,12 @@ CHIP_ERROR AmebaUtils::EnableStationMode(void) CHIP_ERROR AmebaUtils::SetWiFiConfig(rtw_wifi_config_t * config) { CHIP_ERROR err = CHIP_NO_ERROR; + // don't store if ssid is null + if (config->ssid[0] == 0) + { + return CHIP_NO_ERROR; + } + /* Store Wi-Fi Configurations in Storage */ err = PersistedStorage::KeyValueStoreMgr().Put(kWiFiSSIDKeyName, config->ssid, sizeof(config->ssid)); SuccessOrExit(err); diff --git a/src/platform/Ameba/NetworkCommissioningDriver.h b/src/platform/Ameba/NetworkCommissioningDriver.h index 0303642d3c6396..3942b89627741f 100644 --- a/src/platform/Ameba/NetworkCommissioningDriver.h +++ b/src/platform/Ameba/NetworkCommissioningDriver.h @@ -127,8 +127,8 @@ class AmebaWiFiDriver final : public WiFiDriver bool NetworkMatch(const WiFiNetwork & network, ByteSpan networkId); CHIP_ERROR StartScanWiFiNetworks(ByteSpan ssid); - WiFiNetwork mSavedNetwork; - WiFiNetwork mStagingNetwork; + WiFiNetwork mSavedNetwork = { 0 }; + WiFiNetwork mStagingNetwork = { 0 }; ScanCallback * mpScanCallback; ConnectCallback * mpConnectCallback; NetworkStatusChangeCallback * mpStatusChangeCallback = nullptr;