From 878f7bddc551a95c8dc61d613e326acafde9df12 Mon Sep 17 00:00:00 2001 From: Mathieu Kardous Date: Thu, 19 Dec 2024 14:59:17 -0500 Subject: [PATCH] address review comments --- src/platform/silabs/NetworkCommissioningWiFiDriver.cpp | 10 +++++++++- src/platform/silabs/wifi/SiWx/WifiInterface.cpp | 4 ++-- src/platform/silabs/wifi/rs911x/WifiInterface.cpp | 5 +++-- src/platform/silabs/wifi/wf200/WifiInterface.cpp | 9 ++++++++- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp b/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp index 9e8beb7cd6b881..88373b85d2e12c 100644 --- a/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp +++ b/src/platform/silabs/NetworkCommissioningWiFiDriver.cpp @@ -266,7 +266,15 @@ chip::BitFlags SlWiFiDriver::ConvertSecuritytype(wfx_sec_t securit bool SlWiFiDriver::StartScanWiFiNetworks(ByteSpan ssid) { ChipLogProgress(DeviceLayer, "Start Scan WiFi Networks"); - return StartNetworkScan(ssid, OnScanWiFiNetworkDone) == CHIP_NO_ERROR; + CHIP_ERROR err = StartNetworkScan(ssid, OnScanWiFiNetworkDone); + + if (err != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "StartNetworkScan failed: %s", chip::ErrorStr(err)); + return false; + } + + return true; } void SlWiFiDriver::OnScanWiFiNetworkDone(wfx_wifi_scan_result_t * aScanResult) diff --git a/src/platform/silabs/wifi/SiWx/WifiInterface.cpp b/src/platform/silabs/wifi/SiWx/WifiInterface.cpp index a0c1be43b1bc37..fbf61765e0aaae 100644 --- a/src/platform/silabs/wifi/SiWx/WifiInterface.cpp +++ b/src/platform/silabs/wifi/SiWx/WifiInterface.cpp @@ -205,7 +205,7 @@ constexpr uint16_t kWifiScanTimeoutTicks = 10000; */ sl_status_t BackgroundScanCallback(sl_wifi_event_t event, sl_wifi_scan_result_t * result, uint32_t result_length, void * arg) { - SL_WIFI_ARGS_CHECK_NULL_POINTER(result); + VerifyOrReturnError(result != nullptr, SL_STATUS_NULL_POINTER); VerifyOrReturnError(wfx_rsi.scan_cb != nullptr, SL_STATUS_INVALID_HANDLE); uint32_t nbreResults = result->scan_count; @@ -871,7 +871,7 @@ void wfx_dhcp_got_ipv4(uint32_t ip) /* * Acquire the new IP address */ - wfx_rsi.ip4_addr[0] = (ip) &0xFF; + wfx_rsi.ip4_addr[0] = (ip) & 0xFF; wfx_rsi.ip4_addr[1] = (ip >> 8) & 0xFF; wfx_rsi.ip4_addr[2] = (ip >> 16) & 0xFF; wfx_rsi.ip4_addr[3] = (ip >> 24) & 0xFF; diff --git a/src/platform/silabs/wifi/rs911x/WifiInterface.cpp b/src/platform/silabs/wifi/rs911x/WifiInterface.cpp index 6177f783ccc923..8253bfaa03c420 100644 --- a/src/platform/silabs/wifi/rs911x/WifiInterface.cpp +++ b/src/platform/silabs/wifi/rs911x/WifiInterface.cpp @@ -699,7 +699,8 @@ void ProcessEvent(WifiPlatformEvent event) chip::ByteSpan requestedSsid(wfx_rsi.scan_ssid, wfx_rsi.scan_ssid_length); if (!requestedSsid.empty() && !requestedSsid.data_equal(scannedSsid)) { - continue; // we found the targeted ssid. + // Scanned SSID entry does not match the requested SSID. Continue to the next. + continue; } // TODO: convert security mode from RSI to WFX @@ -810,7 +811,7 @@ void wfx_dhcp_got_ipv4(uint32_t ip) /* * Acquire the new IP address */ - wfx_rsi.ip4_addr[0] = (ip) &0xFF; + wfx_rsi.ip4_addr[0] = (ip) & 0xFF; wfx_rsi.ip4_addr[1] = (ip >> 8) & 0xFF; wfx_rsi.ip4_addr[2] = (ip >> 16) & 0xFF; wfx_rsi.ip4_addr[3] = (ip >> 24) & 0xFF; diff --git a/src/platform/silabs/wifi/wf200/WifiInterface.cpp b/src/platform/silabs/wifi/wf200/WifiInterface.cpp index ec20e16d3a6d79..05cdc2bd7303cd 100644 --- a/src/platform/silabs/wifi/wf200/WifiInterface.cpp +++ b/src/platform/silabs/wifi/wf200/WifiInterface.cpp @@ -310,6 +310,13 @@ CHIP_ERROR StartNetworkScan(chip::ByteSpan ssid, ScanCallback callback) // SSID Max Length that is supported by the Wi-Fi SDK is 32 VerifyOrReturnError(ssid.size() <= WFX_MAX_SSID_LENGTH, CHIP_ERROR_INVALID_STRING_LENGTH); + // Make sure memory is cleared before starting a new scan + if (scan_ssid) + { + chip::Platform::MemoryFree(scan_ssid); + scan_ssid = nullptr; + } + if (ssid.empty()) { scan_ssid_length = 0; @@ -1232,7 +1239,7 @@ void wfx_dhcp_got_ipv4(uint32_t ip) */ uint8_t ip4_addr[4]; - ip4_addr[0] = (ip) &0xFF; + ip4_addr[0] = (ip) & 0xFF; ip4_addr[1] = (ip >> 8) & 0xFF; ip4_addr[2] = (ip >> 16) & 0xFF; ip4_addr[3] = (ip >> 24) & 0xFF;