Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DELIA-66222: onAvailableSSIDs event not functioning correctly in the WiFi plugin #16

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ All notable changes to this RDK Service will be documented in this file.

* Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development.

## [0.4.1] - 2024-10-08
- Added Fitler Frequency logic in StartWifiScan

## [0.4.0] - 2024-10-04
### Added
- Added RDKLogger Integration
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ find_package(WPEFramework)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
set(VERSION_MAJOR 0)
set(VERSION_MINOR 4)
set(VERSION_PATCH 0)
set(VERSION_PATCH 1)

add_compile_definitions(NETWORKMANAGER_MAJOR_VERSION=${VERSION_MAJOR})
add_compile_definitions(NETWORKMANAGER_MINOR_VERSION=${VERSION_MINOR})
Expand Down
2 changes: 1 addition & 1 deletion NetworkManagerGnomeEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,7 @@ namespace WPEFramework

if(_nmEventInstance->doScanNotify) {
_nmEventInstance->doScanNotify = false;
_instance->ReportAvailableSSIDsEvent(ssidListJson);
_instance->ReportAvailableSSIDsEvent(ssidList);
}
}

Expand Down
52 changes: 51 additions & 1 deletion NetworkManagerImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,49 @@ namespace WPEFramework
return;
}

void NetworkManagerImplementation::filterScanResults(JsonArray &ssids)
{
JsonArray result;

if (scanForFreq != WIFI_FREQUENCY_WHATEVER)
{
for(int i=0; i<ssids.Length(); i++)
{
JsonObject object = ssids[i].Object();
std::string filterValue;

switch (scanForFreq) {
case WIFI_FREQUENCY_2_4_GHZ:
filterValue = "2.4";
break;
case WIFI_FREQUENCY_5_GHZ:
filterValue = "5";
break;
case WIFI_FREQUENCY_6_GHZ:
filterValue = "6";
break;
default:
filterValue = "";
break;
}

NMLOG_INFO("filtervalue %s received", filterValue);

if(object["frequency"].String() != filterValue)
{
NMLOG_INFO("Frequency filter out %s != %s", object["frequency"].String().c_str(), filterValue.c_str());
continue;
}
result.Add(object);
}
ssids = result;
}
else
{
NMLOG_INFO("No frequency filter applied (UNKNOWN), returning all SSIDs.");
}
}

// WiFi Specific Methods
/* @brief Initiate a WIFI Scan; This is Async method and returns the scan results as Event */
uint32_t NetworkManagerImplementation::GetSupportedSecurityModes(ISecurityModeIterator*& securityModes /* @out */) const
Expand Down Expand Up @@ -541,10 +584,17 @@ namespace WPEFramework
_notificationLock.Unlock();
}

void NetworkManagerImplementation::ReportAvailableSSIDsEvent(const string jsonOfWiFiScanResults)
void NetworkManagerImplementation::ReportAvailableSSIDsEvent(JsonArray &arrayofWiFiScanResults)
{
LOG_ENTRY_FUNCTION();
_notificationLock.Lock();

string jsonOfWiFiScanResults;

filterScanResults(arrayofWiFiScanResults);

arrayofWiFiScanResults.ToString(jsonOfWiFiScanResults);

NMLOG_INFO("Posting onAvailableSSIDs result is, %s", jsonOfWiFiScanResults.c_str());
for (const auto callback : _notificationCallbacks) {
callback->onAvailableSSIDs(jsonOfWiFiScanResults);
Expand Down
5 changes: 4 additions & 1 deletion NetworkManagerImplementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ namespace WPEFramework
void ReportIPAddressChangedEvent(const string& interface, bool isAcquired, bool isIPv6, const string& ipAddress);
void ReportActiveInterfaceChangedEvent(const string prevActiveInterface, const string currentActiveinterface);
void ReportInternetStatusChangedEvent(const InternetStatus oldState, const InternetStatus newstate);
void ReportAvailableSSIDsEvent(const string jsonOfWiFiScanResults);
void ReportAvailableSSIDsEvent(JsonArray &arrayofWiFiScanResults);
void ReportWiFiStateChangedEvent(const INetworkManager::WiFiState state);
void ReportWiFiSignalStrengthChangedEvent(const string ssid , const string signalLevel , const WiFiSignalQuality signalQuality);

Expand All @@ -228,6 +228,7 @@ namespace WPEFramework
void retryIarmEventRegistration();
void threadEventRegistration();
void executeExternally(NetworkEvents event, const string commandToExecute, string& response);
void filterScanResults(JsonArray &ssids);

private:
std::list<Exchange::INetworkManager::INotification *> _notificationCallbacks;
Expand All @@ -240,6 +241,8 @@ namespace WPEFramework
uint16_t m_stunBindTimeout;
uint16_t m_stunCacheTimeout;
std::thread m_registrationThread;
INetworkManager::WiFiFrequency scanForFreq;

public:
WiFiSignalStrengthMonitor m_wifiSignalMonitor;
mutable ConnectivityMonitor connectivityMonitor;
Expand Down
22 changes: 21 additions & 1 deletion NetworkManagerJsonRpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,27 @@ namespace WPEFramework
{
LOG_INPARAM();
uint32_t rc = Core::ERROR_GENERAL;
const Exchange::INetworkManager::WiFiFrequency frequency = static_cast <Exchange::INetworkManager::WiFiFrequency> (parameters["frequency"].Number());
Exchange::INetworkManager::WiFiFrequency frequency = Exchange::INetworkManager::WiFiFrequency::WIFI_FREQUENCY_WHATEVER;

string freqString = parameters["frequency"].String();

NMLOG_INFO("Received frequency string: %s", freqString.c_str());

if (freqString == "2.4") {
frequency = Exchange::INetworkManager::WiFiFrequency::WIFI_FREQUENCY_2_4_GHZ;
}
else if (freqString == "5") {
frequency = Exchange::INetworkManager::WiFiFrequency::WIFI_FREQUENCY_5_GHZ;
}
else if (freqString == "6") {
frequency = Exchange::INetworkManager::WiFiFrequency::WIFI_FREQUENCY_6_GHZ;
}
else {
NMLOG_ERROR("Invalid frequency value received: %s", freqString.c_str());
frequency = Exchange::INetworkManager::WiFiFrequency::WIFI_FREQUENCY_WHATEVER;
}

NMLOG_INFO("Frequency value mapped to enum: %d", frequency);

if (_networkManager)
rc = _networkManager->StartWiFiScan(frequency);
Expand Down
8 changes: 4 additions & 4 deletions NetworkManagerRDKProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,8 @@ namespace WPEFramework
}

JsonArray ssids = eventDocument["getAvailableSSIDs"].Array();
string json;
ssids.ToString(json);

::_instance->ReportAvailableSSIDsEvent(json);
::_instance->ReportAvailableSSIDsEvent(ssids);
}
case IARM_BUS_WIFI_MGR_EVENT_onWIFIStateChanged:
{
Expand Down Expand Up @@ -994,7 +992,9 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = {
IARM_Result_t retVal = IARM_RESULT_SUCCESS;

memset(&param, 0, sizeof(param));
(void) frequency;

NMLOG_INFO ("StartWifiScan frequency value :%d",frequency);
scanForFreq = frequency;

retVal = IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_WIFI_MGR_API_getAvailableSSIDsAsync, (void *)&param, sizeof(IARM_Bus_WiFiSrvMgr_SsidList_Param_t));

Expand Down