diff --git a/definition/NetworkManager.json b/definition/NetworkManager.json index 2252aed0..7dd6d246 100644 --- a/definition/NetworkManager.json +++ b/definition/NetworkManager.json @@ -854,9 +854,12 @@ "type": "object", "properties": { "frequency": { - "summary": "The frequency to scan. An empty or `null` value scans all frequencies.", - "type": "string", - "example": "5" + "summary": "Frequency bands to scan. Array values: 1=2.4GHz, 2=5GHz, 3=6GHz. Omit this field or pass an empty array to scan all frequencies.", + "type": "array", + "items": { + "type": "integer" + }, + "example": [1, 2] }, "ssids": { "summary": "The list of SSIDs to be scanned.", diff --git a/docs/NetworkManagerPlugin.md b/docs/NetworkManagerPlugin.md index 9e4d969c..5702b9e5 100644 --- a/docs/NetworkManagerPlugin.md +++ b/docs/NetworkManagerPlugin.md @@ -89,7 +89,7 @@ NetworkManager interface methods: | [GetPublicIP](#method.GetPublicIP) | Gets the internet/public IP Address of the device | | [Ping](#method.Ping) | Pings the specified endpoint with the specified number of packets | | [Trace](#method.Trace) | Traces the specified endpoint with the specified number of packets using `traceroute` | -| [StartWiFiScan](#method.StartWiFiScan) | Initiates WiFi scaning | +| [StartWiFiScan](#method.StartWiFiScan) | Initiates WiFi scanning | | [StopWiFiScan](#method.StopWiFiScan) | Stops WiFi scanning | | [GetKnownSSIDs](#method.GetKnownSSIDs) | Gets list of saved SSIDs | | [AddToKnownSSIDs](#method.AddToKnownSSIDs) | Saves the SSID, passphrase, and security mode for upcoming and future sessions | @@ -1006,7 +1006,7 @@ Traces the specified endpoint with the specified number of packets using `tracer ## *StartWiFiScan [method](#head.Methods)* -Initiates WiFi scaning. This method supports scanning for specific range of frequency like 2.4GHz only or 5GHz only or 6GHz only or ALL. When no input passed about the frequency to be scanned, it scans for all. When list of SSIDs to be scanned specifically, it can be passed as input. It publishes 'onAvailableSSIDs' event upon completion. +Initiates WiFi scanning. This method supports scanning specific frequencies (2.4GHz, 5GHz, 6GHz). When no input is passed for frequency, it scans all supported frequencies. When list of SSIDs to be scanned specifically, it can be passed as input. It publishes 'onAvailableSSIDs' event upon completion. Also see: [onAvailableSSIDs](#event.onAvailableSSIDs) @@ -1015,7 +1015,8 @@ Also see: [onAvailableSSIDs](#event.onAvailableSSIDs) | Name | Type | Description | | :-------- | :-------- | :-------- | | params | object | | -| params?.frequency | string | *(optional)* The frequency to scan. An empty or `null` value scans all frequencies | +| params?.frequency | array | *(optional)* The frequency list to scan. Supported values are `1` (2.4GHz), `2` (5GHz), `3` (6GHz) | +| params?.frequency[#] | integer | *(optional)* Frequency enum value | | params?.ssids | array | *(optional)* The list of SSIDs to be scanned | | params?.ssids[#] | string | *(optional)* The SSID to scan | @@ -1036,7 +1037,9 @@ Also see: [onAvailableSSIDs](#event.onAvailableSSIDs) "id": 42, "method": "org.rdk.NetworkManager.1.StartWiFiScan", "params": { - "frequency": "5", + "frequency": [ + 2 + ], "ssids": [ "Xfinity Mobile" ] diff --git a/interface/INetworkManager.h b/interface/INetworkManager.h index 15c739cf..0d630471 100644 --- a/interface/INetworkManager.h +++ b/interface/INetworkManager.h @@ -30,7 +30,8 @@ namespace WPEFramework ID_NETWORKMANAGER = 0x800004E0, ID_NETWORKMANAGER_NOTIFICATION = ID_NETWORKMANAGER + 1, ID_NETWORKMANAGER_INTERFACE_DETAILS_ITERATOR = ID_NETWORKMANAGER + 2, - ID_NETWORKMANAGER_WIFI_SECURITY_MODE_ITERATOR = ID_NETWORKMANAGER + 3 + ID_NETWORKMANAGER_WIFI_SECURITY_MODE_ITERATOR = ID_NETWORKMANAGER + 3, + ID_NETWORKMANAGER_WIFI_FREQUENCY_ITERATOR = ID_NETWORKMANAGER + 4 }; /* @json @text:keep */ @@ -202,6 +203,7 @@ namespace WPEFramework using IInterfaceDetailsIterator = RPC::IIteratorType; using ISecurityModeIterator = RPC::IIteratorType; using IStringIterator = RPC::IIteratorType; + using IWIFIFrequencyIterator = RPC::IIteratorType; /* @brief Get all the Available Interfaces */ virtual uint32_t GetAvailableInterfaces (IInterfaceDetailsIterator*& interfaces/* @out */) = 0; @@ -248,7 +250,7 @@ namespace WPEFramework // WiFi Specific Methods /* @brief Initiate a WIFI Scan; This is Async method and returns the scan results as Event */ - virtual uint32_t StartWiFiScan(const string& frequency /* @in */, IStringIterator* const ssids/* @in */) = 0; + virtual uint32_t StartWiFiScan(IWIFIFrequencyIterator* const frequencies /* @in */, IStringIterator* const ssids/* @in */) = 0; virtual uint32_t StopWiFiScan(void) = 0; virtual uint32_t GetKnownSSIDs(IStringIterator*& ssids /* @out */) = 0; diff --git a/legacy/LegacyWiFiManagerAPIs.cpp b/legacy/LegacyWiFiManagerAPIs.cpp index 9132ed09..b8bbffeb 100644 --- a/legacy/LegacyWiFiManagerAPIs.cpp +++ b/legacy/LegacyWiFiManagerAPIs.cpp @@ -634,12 +634,42 @@ namespace WPEFramework { LOG_INPARAM(); uint32_t rc = Core::ERROR_GENERAL; - string frequency{}; + Exchange::INetworkManager::IWIFIFrequencyIterator* frequencies = nullptr; Exchange::INetworkManager::IStringIterator* ssids = NULL; + std::vector frequencyList; if (parameters.HasLabel("frequency")) - frequency = parameters["frequency"].String(); + { + JsonArray array = parameters["frequency"].Array(); + JsonArray::Iterator index(array.Elements()); + while (index.Next() == true) + { + if (Core::JSON::Variant::type::NUMBER == index.Current().Content()) + { + const int freq = index.Current().Number(); + if (freq < static_cast(Exchange::INetworkManager::WIFI_FREQUENCY_NONE) + || freq > static_cast(Exchange::INetworkManager::WIFI_FREQUENCY_6_GHZ)) + { + NMLOG_ERROR("Invalid frequency value in array"); + returnJson(rc); + } + frequencyList.push_back(static_cast(freq)); + } + else + { + NMLOG_ERROR("Unexpected variant type in frequency array."); + returnJson(rc); + } + } + } + if (!frequencyList.empty()) { + using FrequencyIterator = RPC::IteratorType; + frequencies = Core::Service::Create(frequencyList); + if (frequencies == nullptr) { + returnJson(rc); + } + } if (parameters.HasLabel("ssid")) { @@ -654,6 +684,8 @@ namespace WPEFramework ssids = (Core::Service::Create(inputSSIDlist)); if (ssids == nullptr) { + if (frequencies) + frequencies->Release(); returnJson(rc); } } @@ -661,12 +693,15 @@ namespace WPEFramework auto _nwmgr = m_service->QueryInterfaceByCallsign(NETWORK_MANAGER_CALLSIGN); if (_nwmgr) { - rc = _nwmgr->StartWiFiScan(frequency, ssids); + rc = _nwmgr->StartWiFiScan(frequencies, ssids); _nwmgr->Release(); } else rc = Core::ERROR_UNAVAILABLE; + if (frequencies) + frequencies->Release(); + if (ssids) ssids->Release(); diff --git a/plugin/NetworkManagerImplementation.cpp b/plugin/NetworkManagerImplementation.cpp index b4b5bca6..95ab4807 100644 --- a/plugin/NetworkManagerImplementation.cpp +++ b/plugin/NetworkManagerImplementation.cpp @@ -589,26 +589,39 @@ namespace WPEFramework } return; } - + + namespace { + Exchange::INetworkManager::WIFIFrequency GetFrequencyFromMHz(const double frequencyMHz) + { + // Normalize frequency to MHz even if reported in GHz (2.4/5/6) or report MHz (2412/5180/5955). + const double normalizedMHz = (frequencyMHz > 0.0 && frequencyMHz < 100.0) + ? (frequencyMHz * 1000.0) + : frequencyMHz; + + if ((normalizedMHz >= 2400.0) && (normalizedMHz < 2500.0)) { + return Exchange::INetworkManager::WIFI_FREQUENCY_2_4_GHZ; + } else if ((normalizedMHz >= 4900.0) && (normalizedMHz < 5925.0)) { + return Exchange::INetworkManager::WIFI_FREQUENCY_5_GHZ; + } else if ((normalizedMHz >= 5925.0) && (normalizedMHz < 7125.0)) { + return Exchange::INetworkManager::WIFI_FREQUENCY_6_GHZ; + } else { + return Exchange::INetworkManager::WIFI_FREQUENCY_NONE; + } + } + } void NetworkManagerImplementation::filterScanResults(JsonArray &ssids) { JsonArray result; - double filterFreq = 0.0; std::unordered_set scanForSsidsSet(m_filterSsidslist.begin(), m_filterSsidslist.end()); // If neither SSID list nor frequency is provided, exit - if (m_filterSsidslist.empty() && m_filterfrequency.empty()) + if (m_filterSsidslist.empty() && m_filterFrequencies.empty()) { NMLOG_DEBUG("Neither SSID nor Frequency is provided. Exiting function."); return; } - if (!m_filterfrequency.empty()) - { - filterFreq = std::stod(m_filterfrequency); - } - for (int i = 0; i < ssids.Length(); i++) { JsonObject object = ssids[i].Object(); @@ -618,7 +631,19 @@ namespace WPEFramework double frequencyValue = std::stod(frequency); bool ssidMatches = scanForSsidsSet.empty() || scanForSsidsSet.find(ssid) != scanForSsidsSet.end(); - bool freqMatches = m_filterfrequency.empty() || (filterFreq == frequencyValue); + bool freqMatches = m_filterFrequencies.empty(); + if (!freqMatches) + { + const auto ssidFrequencyBand = GetFrequencyFromMHz(frequencyValue); + for (const auto selectedFrequency : m_filterFrequencies) + { + if (selectedFrequency == ssidFrequencyBand) + { + freqMatches = true; + break; + } + } + } if (ssidMatches && freqMatches) result.Add(object); diff --git a/plugin/NetworkManagerImplementation.h b/plugin/NetworkManagerImplementation.h index f5bd49b1..46aa4831 100644 --- a/plugin/NetworkManagerImplementation.h +++ b/plugin/NetworkManagerImplementation.h @@ -216,7 +216,7 @@ namespace WPEFramework // WiFi Specific Methods /* @brief Initiate a WIFI Scan; This is Async method and returns the scan results as Event */ - uint32_t StartWiFiScan(const string& frequency /* @in */, IStringIterator* const ssids/* @in */) override; + uint32_t StartWiFiScan(IWIFIFrequencyIterator* const frequencies /* @in */, IStringIterator* const ssids/* @in */) override; uint32_t StopWiFiScan(void) override; uint32_t GetKnownSSIDs(IStringIterator*& ssids /* @out */) override; @@ -301,7 +301,7 @@ namespace WPEFramework uint16_t m_stunBindTimeout; uint16_t m_stunCacheTimeout; std::thread m_registrationThread; - string m_filterfrequency; + std::vector m_filterFrequencies; std::vector m_filterSsidslist; std::thread m_monitorThread; diff --git a/plugin/NetworkManagerJsonRpc.cpp b/plugin/NetworkManagerJsonRpc.cpp index 5ed0b60f..49d316bb 100644 --- a/plugin/NetworkManagerJsonRpc.cpp +++ b/plugin/NetworkManagerJsonRpc.cpp @@ -642,19 +642,50 @@ namespace WPEFramework { LOG_INPARAM(); uint32_t rc = Core::ERROR_GENERAL; - string frequency{}; - Exchange::INetworkManager::IStringIterator* ssids = NULL; - - if (parameters.HasLabel("frequency")) - frequency = parameters["frequency"].String(); - - if (parameters.HasLabel("ssids")) + Exchange::INetworkManager::IWIFIFrequencyIterator* frequencies = nullptr; + Exchange::INetworkManager::IStringIterator* ssids = NULL; + + const bool hasFrequencyLabel = parameters.HasLabel("frequency"); + std::vector frequencyList; + if (hasFrequencyLabel) + { + JsonArray array = parameters["frequency"].Array(); + JsonArray::Iterator index(array.Elements()); + while (index.Next() == true) + { + if (Core::JSON::Variant::type::NUMBER == index.Current().Content()) + { + const int freq = index.Current().Number(); + if (freq < static_cast(Exchange::INetworkManager::WIFI_FREQUENCY_NONE) + || freq > static_cast(Exchange::INetworkManager::WIFI_FREQUENCY_6_GHZ)) + { + NMLOG_ERROR("Invalid frequency value in array"); + returnJson(rc); + } + frequencyList.push_back(static_cast(freq)); + } + else + { + NMLOG_ERROR("Unexpected variant type in frequency array."); + returnJson(rc); + } + } + if (!frequencyList.empty()) { + using FrequencyIterator = RPC::IteratorType; + frequencies = Core::Service::Create(frequencyList); + if (frequencies == nullptr) { + returnJson(rc); + } + } + } + + if (parameters.HasLabel("ssids")) { JsonArray array = parameters["ssids"].Array(); std::vector ssidslist; - JsonArray::Iterator index(array.Elements()); + JsonArray::Iterator index(array.Elements()); - while (index.Next() == true) + while (index.Next() == true) { if (Core::JSON::Variant::type::STRING == index.Current().Content()) { @@ -663,20 +694,27 @@ namespace WPEFramework else { NMLOG_ERROR("Unexpected variant type in SSID array."); + if (frequencies) + frequencies->Release(); returnJson(rc); } } ssids = (Core::Service::Create(ssidslist)); if(ssids == nullptr){ + if (frequencies) + frequencies->Release(); returnJson(rc); } } if (_networkManager) - rc = _networkManager->StartWiFiScan(frequency, ssids); + rc = _networkManager->StartWiFiScan(frequencies, ssids); else rc = Core::ERROR_UNAVAILABLE; + if (frequencies) + frequencies->Release(); + if (ssids) ssids->Release(); diff --git a/plugin/gnome/NetworkManagerGnomeProxy.cpp b/plugin/gnome/NetworkManagerGnomeProxy.cpp index b661a8de..5a0db8fa 100644 --- a/plugin/gnome/NetworkManagerGnomeProxy.cpp +++ b/plugin/gnome/NetworkManagerGnomeProxy.cpp @@ -986,32 +986,46 @@ namespace WPEFramework return rc; } - uint32_t NetworkManagerImplementation::StartWiFiScan(const string& frequency /* @in */, IStringIterator* const ssids/* @in */) + uint32_t NetworkManagerImplementation::StartWiFiScan(IWIFIFrequencyIterator* const frequencies /* @in */, IStringIterator* const ssids/* @in */) { uint32_t rc = Core::ERROR_RPC_CALL_FAILED; //Cleared the Existing Store filterred SSID list m_filterSsidslist.clear(); - m_filterfrequency.clear(); + m_filterFrequencies.clear(); if(ssids) { string tmpssidlist{}; while (ssids->Next(tmpssidlist) == true) { - m_filterSsidslist.push_back(tmpssidlist.c_str()); - NMLOG_DEBUG("%s added to SSID filtering", tmpssidlist.c_str()); + if (!tmpssidlist.empty()) + { + m_filterSsidslist.push_back(tmpssidlist.c_str()); + NMLOG_DEBUG("%s added to SSID filtering", tmpssidlist.c_str()); + } + else + { + NMLOG_DEBUG("Empty SSID encountered in input list; skipping."); + } } } - if (!frequency.empty()) + if (frequencies && frequencies->Count() > 0) { - m_filterfrequency = frequency; - NMLOG_DEBUG("Scan SSIDs of frequency %s", m_filterfrequency.c_str()); + Exchange::INetworkManager::WIFIFrequency frequency = Exchange::INetworkManager::WIFI_FREQUENCY_NONE; + while (frequencies->Next(frequency) == true) + { + if (frequency != Exchange::INetworkManager::WIFI_FREQUENCY_NONE) + { + m_filterFrequencies.push_back(frequency); + NMLOG_DEBUG("Frequency %u added to scan filtering", static_cast(frequency)); + } + } } nmEvent->setwifiScanOptions(true); - if(wifi->wifiScanRequest(m_filterSsidslist.size() == 1 ? m_filterSsidslist[0] : "")) + if(wifi->wifiScanRequest(m_filterSsidslist)) rc = Core::ERROR_NONE; return rc; } diff --git a/plugin/gnome/NetworkManagerGnomeWIFI.cpp b/plugin/gnome/NetworkManagerGnomeWIFI.cpp index 2348124d..f80f7476 100644 --- a/plugin/gnome/NetworkManagerGnomeWIFI.cpp +++ b/plugin/gnome/NetworkManagerGnomeWIFI.cpp @@ -1685,7 +1685,7 @@ namespace WPEFramework g_main_loop_quit(_wifiManager->m_loop); } - bool wifiManager::wifiScanRequest(std::string ssidReq) + bool wifiManager::wifiScanRequest(const std::vector& ssidsToFilter) { if(!createClientNewConnection()) return false; @@ -1696,23 +1696,25 @@ namespace WPEFramework return false; } m_isSuccess = false; - if(!ssidReq.empty()) + if(!ssidsToFilter.empty()) { - NMLOG_INFO("starting wifi scanning .. %s", ssidReq.c_str()); + NMLOG_INFO("Starting wifi scanning for %d SSIDs:",static_cast(ssidsToFilter.size())); GVariantBuilder builder, array_builder; GVariant *options; g_variant_builder_init(&builder, G_VARIANT_TYPE_VARDICT); g_variant_builder_init(&array_builder, G_VARIANT_TYPE("aay")); - g_variant_builder_add(&array_builder, "@ay", - g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, (const guint8 *) ssidReq.c_str(), ssidReq.length(), 1) - ); + for (const auto& ssid : ssidsToFilter) { + g_variant_builder_add(&array_builder, "@ay", + g_variant_new_fixed_array(G_VARIANT_TYPE_BYTE, (const guint8 *) ssid.c_str(), ssid.length(), 1) + ); + } g_variant_builder_add(&builder, "{sv}", "ssids", g_variant_builder_end(&array_builder)); options = g_variant_builder_end(&builder); nm_device_wifi_request_scan_options_async(wifiDevice, options, m_cancellable, wifiScanCb, this); g_variant_unref(options); // Unreference the GVariant after passing it to the async function } else { - NMLOG_INFO("staring normal wifi scanning .."); + NMLOG_INFO("Starting normal wifi scanning .."); nm_device_wifi_request_scan_async(wifiDevice, m_cancellable, wifiScanCb, this); } wait(m_loop); diff --git a/plugin/gnome/NetworkManagerGnomeWIFI.h b/plugin/gnome/NetworkManagerGnomeWIFI.h index 51164aa5..4d0fa086 100644 --- a/plugin/gnome/NetworkManagerGnomeWIFI.h +++ b/plugin/gnome/NetworkManagerGnomeWIFI.h @@ -31,6 +31,7 @@ #include #include #include +#include #define WPS_RETRY_WAIT_IN_MS 10 // 10 sec #define WPS_RETRY_COUNT 10 @@ -54,7 +55,7 @@ namespace WPEFramework bool activateKnownConnection(std::string iface, std::string knowConnectionID=""); bool wifiConnectedSSIDInfo(Exchange::INetworkManager::WiFiSSIDInfo &ssidinfo); bool wifiConnect(const Exchange::INetworkManager::WiFiConnectTo &ssidInfo); - bool wifiScanRequest(std::string ssidReq = ""); + bool wifiScanRequest(const std::vector& ssidsToFilter = {}); bool isWifiScannedRecently(int timelimitInSec = 5); // default 5 sec as shotest scanning interval bool getKnownSSIDs(std::list& ssids); bool addToKnownSSIDs(const Exchange::INetworkManager::WiFiConnectTo &ssidinfo); diff --git a/plugin/gnome/gdbus/NetworkManagerGdbusProxy.cpp b/plugin/gnome/gdbus/NetworkManagerGdbusProxy.cpp index 73aa49d9..e0387786 100644 --- a/plugin/gnome/gdbus/NetworkManagerGdbusProxy.cpp +++ b/plugin/gnome/gdbus/NetworkManagerGdbusProxy.cpp @@ -216,7 +216,7 @@ namespace WPEFramework return rc; } - uint32_t NetworkManagerImplementation::StartWiFiScan(const string& frequency /* @in */, IStringIterator* const ssids/* @in */) + uint32_t NetworkManagerImplementation::StartWiFiScan(IWIFIFrequencyIterator* const frequencies /* @in */, IStringIterator* const ssids/* @in */) { uint32_t rc = Core::ERROR_GENERAL; _nmGdbusEvents->setwifiScanOptions(true); /* Enable event posting */ diff --git a/plugin/rdk/NetworkManagerRDKProxy.cpp b/plugin/rdk/NetworkManagerRDKProxy.cpp index f218d61c..4a55b2f0 100644 --- a/plugin/rdk/NetworkManagerRDKProxy.cpp +++ b/plugin/rdk/NetworkManagerRDKProxy.cpp @@ -965,7 +965,7 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN+1] = { return rc; } - uint32_t NetworkManagerImplementation::StartWiFiScan(const string& frequency /* @in */, IStringIterator* const ssids/* @in */) + uint32_t NetworkManagerImplementation::StartWiFiScan(IWIFIFrequencyIterator* const frequencies /* @in */, IStringIterator* const ssids/* @in */) { LOG_ENTRY_FUNCTION(); uint32_t rc = Core::ERROR_RPC_CALL_FAILED; @@ -974,7 +974,6 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN+1] = { //Cleared the Existing Store filterred SSID list m_filterSsidslist.clear(); - m_filterfrequency.clear(); if(ssids) { @@ -986,10 +985,9 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN+1] = { } } - if (!frequency.empty()) + if (frequencies && frequencies->Count() > 0) { - m_filterfrequency = frequency; - NMLOG_DEBUG("Scan SSIDs of frequency %s", m_filterfrequency.c_str()); + NMLOG_DEBUG("Scan SSIDs of frequency not supported"); } memset(¶m, 0, sizeof(param)); diff --git a/tests/mocks/INetworkManagerMock.h b/tests/mocks/INetworkManagerMock.h index 27a8b287..e7c72e35 100644 --- a/tests/mocks/INetworkManagerMock.h +++ b/tests/mocks/INetworkManagerMock.h @@ -36,7 +36,7 @@ class MockINetworkManager : public WPEFramework::Exchange::INetworkManager { MOCK_METHOD(uint32_t, GetPublicIP, (string& interface, string& ipversion, string& ipaddress), (override)); MOCK_METHOD(uint32_t, Ping, (const string ipversion, const string endpoint, const uint32_t count, const uint16_t timeout, const string guid, string& response), (override)); MOCK_METHOD(uint32_t, Trace, (const string ipversion, const string endpoint, const uint32_t nqueries, const string guid, string& response), (override)); - MOCK_METHOD(uint32_t, StartWiFiScan, (const string& frequency, IStringIterator* const ssids), (override)); + MOCK_METHOD(uint32_t, StartWiFiScan, (IWIFIFrequencyIterator* const frequencies, IStringIterator* const ssids), (override)); MOCK_METHOD(uint32_t, StopWiFiScan, (), (override)); MOCK_METHOD(uint32_t, GetKnownSSIDs, (IStringIterator*& ssids), (override)); MOCK_METHOD(uint32_t, AddToKnownSSIDs, (const WiFiConnectTo& ssid), (override)); diff --git a/tools/plugincli/NetworkManagerLibnmTest.cpp b/tools/plugincli/NetworkManagerLibnmTest.cpp index 650a1ba1..3a358b56 100644 --- a/tools/plugincli/NetworkManagerLibnmTest.cpp +++ b/tools/plugincli/NetworkManagerLibnmTest.cpp @@ -220,7 +220,8 @@ int main() NMLOG_INFO("Sending WiFi scan request%s", ssid.empty() ? " (all SSIDs)" : (" for SSID: " + ssid).c_str()); - if (wifiMgr->wifiScanRequest(ssid)) { + bool scanRequestSent = ssid.empty() ? wifiMgr->wifiScanRequest() : wifiMgr->wifiScanRequest({ssid}); + if (scanRequestSent) { NMLOG_INFO("WiFi scan request sent successfully."); } else { NMLOG_ERROR("Failed to send WiFi scan request.");