Skip to content

Commit 3379291

Browse files
committed
update frequncy to number
1 parent 0647bb1 commit 3379291

6 files changed

Lines changed: 23 additions & 77 deletions

interface/INetworkManager.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,14 @@ namespace WPEFramework
103103
WIFI_SECURITY_EAP /* @text: EAP */,
104104
};
105105

106+
enum WIFIFrequency : uint8_t
107+
{
108+
WIFI_FREQUENCY_NONE /* @text: NONE */,
109+
WIFI_FREQUENCY_2_4_GHZ /* @text: 2.4GHz */,
110+
WIFI_FREQUENCY_5_GHZ /* @text: 5GHz */,
111+
WIFI_FREQUENCY_6_GHZ /* @text: 6GHz */,
112+
};
113+
106114
struct EXTERNAL WiFiScanResults {
107115
string ssid;
108116
WIFISecurityMode security;
@@ -114,7 +122,7 @@ namespace WPEFramework
114122
string ssid;
115123
string passphrase;
116124
string bssid;
117-
string frequency;
125+
WIFIFrequency frequency;
118126
WIFISecurityMode security;
119127
string ca_cert;
120128
string client_cert;

plugin/NetworkManagerJsonRpc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,7 @@ namespace WPEFramework
782782
if (parameters.HasLabel("bssid"))
783783
ssid.bssid = parameters["bssid"].String();
784784
if (parameters.HasLabel("frequency"))
785-
ssid.frequency = parameters["frequency"].String();
785+
ssid.frequency = static_cast <Exchange::INetworkManager::WIFIFrequency> (parameters["frequency"].Number());
786786

787787
if (parameters.HasLabel("security"))
788788
ssid.security= static_cast <Exchange::INetworkManager::WIFISecurityMode> (parameters["security"].Number());

plugin/gnome/NetworkManagerGnomeProxy.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -638,7 +638,7 @@ namespace WPEFramework
638638
deviceState = nm_device_get_state(device);
639639
if(deviceState < NM_DEVICE_STATE_DISCONNECTED)
640640
{
641-
NMLOG_WARNING("Device state is not a valid state: (%d)", deviceState);
641+
NMLOG_WARNING("%s state is not a valid state: (%d)", interface.c_str(), deviceState);
642642
return Core::ERROR_GENERAL;
643643
}
644644

@@ -975,10 +975,8 @@ namespace WPEFramework
975975
return Core::ERROR_GENERAL;
976976
}
977977

978-
if(!nmUtils::isValidFrequency(ssid.frequency))
979-
{
980-
return Core::ERROR_GENERAL;
981-
}
978+
if(ssidinfo.frequency != Exchange::INetworkManager::WIFIFrequency::WIFI_FREQUENCY_NONE)
979+
NMLOG_INFO("Requested frequency is %d GHz", ssidinfo.frequency);
982980

983981
// Check the last scanning time and if it exceeds 5 sec do a rescanning
984982
if(!wifi->isWifiScannedRecently())

plugin/gnome/NetworkManagerGnomeUtils.cpp

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -209,53 +209,6 @@ namespace WPEFramework
209209

210210
return true;
211211
}
212-
213-
bool nmUtils::isValidFrequency(const std::string& frequency)
214-
{
215-
if (frequency.empty())
216-
return true; // Frequency is optional for connection, so empty value is considered valid
217-
218-
// 6 GHz frequency is not supported in current implementation gnom networkmanger
219-
if(frequency == "2.4" || frequency == "5")
220-
{
221-
NMLOG_DEBUG("Valid frequency: %s", frequency.c_str());
222-
return true;
223-
}
224-
else
225-
{
226-
NMLOG_ERROR("Invalid frequency: %s. Valid values are 2.4, 5 GHz.", frequency.c_str());
227-
}
228-
return false;
229-
}
230-
231-
bool nmUtils::isValidWifiFrequencyForBand(std::string& band, guint32 apFreq)
232-
{
233-
if (apFreq != 0)
234-
{
235-
if (band == "a")
236-
{
237-
// frequency range for 5 GHz band is typically 4915 MHz to 5825 MHz
238-
if (apFreq < 4915 || apFreq > 5825)
239-
return false;
240-
else
241-
NMLOG_INFO("Valid 5 GHz frequency: %u MHz", apFreq); // TODO change to debug
242-
}
243-
else if (band == "bg")
244-
{
245-
// frequency range for 2.4 GHz band is typically 2412 MHz to 2484 MHz
246-
if (apFreq < 2412 || apFreq > 2484)
247-
return false;
248-
else
249-
NMLOG_INFO("Valid 2.4 GHz frequency: %u MHz", apFreq); // TODO change to debug
250-
}
251-
else
252-
{
253-
NMLOG_ERROR("Invalid band: %s. Valid values are 'a' for 5 GHz and 'bg' for 2.4 GHz.", band.c_str());
254-
return false;
255-
}
256-
}
257-
return true;
258-
}
259212

260213
bool nmUtils::caseInsensitiveCompare(const std::string& str1, const std::string& str2)
261214
{

plugin/gnome/NetworkManagerGnomeUtils.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ namespace WPEFramework
5050
static bool isInterfaceEnabled(const std::string& interface);
5151
static bool writePersistentHostname(const std::string& hostname);
5252
static bool readPersistentHostname(std::string& hostname);
53-
static bool isValidFrequency(const std::string& frequency);
5453
static bool isValidBSSID(const std::string& bssid);
55-
static bool isValidWifiFrequencyForBand(std::string& band, guint32 apFreq);
5654
};
5755
}
5856
}

plugin/gnome/NetworkManagerGnomeWIFI.cpp

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ namespace WPEFramework
449449
}
450450
else
451451
{
452-
NMLOG_WARNING("SSID did not match: expected %s, got %s", ssidInfo.ssid.c_str(), ssidstr.c_str());
452+
NMLOG_DEBUG("SSID did not match: expected %s, got %s", ssidInfo.ssid.c_str(), ssidstr.c_str());
453453
// continue searching other APs in case of multiple APs with same SSID and matching BSSID or frequency
454454
// TODO hidden ssid handling - if ssidInfo.ssid is empty then matching based on bssid ?
455455
continue;
@@ -460,29 +460,19 @@ namespace WPEFramework
460460
std::string bssidStr = nm_access_point_get_bssid(ap);
461461
if(ssidInfo.bssid == bssidStr)
462462
{
463-
NMLOG_INFO("BSSID matched: %s", bssidStr.c_str()); // TODO remove log
463+
NMLOG_DEBUG("BSSID matched: %s", bssidStr.c_str());
464464
ssidMatch = true;
465465
}
466466
else
467467
{
468-
NMLOG_WARNING("BSSID did not match: expected %s, got %s", ssidInfo.bssid.c_str(), bssidStr.c_str());
468+
ssidMatch = false;
469+
NMLOG_WARNING("SSID matched but BSSID did not match: expected %s, got %s", ssidInfo.bssid.c_str(), bssidStr.c_str());
469470
continue;
470471
}
471472
}
472473

473-
if(!ssidInfo.frequency.empty())
474-
{
475-
if(nmUtils::isValidWifiFrequencyForBand(ssidInfo.frequency, nm_access_point_get_frequency(ap)))
476-
{
477-
NMLOG_INFO("Frequency matched: %s GHz", ssidInfo.frequency.c_str()); // TODO remove log
478-
ssidMatch = true;
479-
}
480-
else
481-
{
482-
NMLOG_WARNING("Frequency did not match: expected %s GHz, got %s GHz", ssidInfo.frequency.c_str(), ssidInfo.frequency.c_str());
483-
ssidMatch = false;
484-
}
485-
}
474+
// TODO frequency matching if ssidInfo.frequency ?
475+
// BSSID matching should be sufficient to identify the AP uniquely even if there are multiple APs with same SSID
486476

487477
if(ssidMatch)
488478
AccessPoint = ap;
@@ -696,19 +686,19 @@ namespace WPEFramework
696686
if(!ssidinfo.bssid.empty())
697687
g_object_set(sWireless, NM_SETTING_WIRELESS_BSSID, ssidinfo.bssid.c_str(), NULL);
698688

699-
if(!ssidinfo.frequency.empty())
689+
if(ssidinfo.frequency != Exchange::INetworkManager::WIFIFrequency::WIFI_FREQUENCY_NONE)
700690
{
701-
if(ssidinfo.frequency == "2.4")
691+
if(ssidinfo.frequency == Exchange::INetworkManager::WIFIFrequency::WIFI_FREQUENCY_2_4_GHZ)
702692
{
703693
g_object_set(sWireless, NM_SETTING_WIRELESS_BAND, "bg", NULL);
704694
}
705-
else if(ssidinfo.frequency == "5")
695+
else if(ssidinfo.frequency == Exchange::INetworkManager::WIFIFrequency::WIFI_FREQUENCY_5_GHZ)
706696
{
707697
g_object_set(sWireless, NM_SETTING_WIRELESS_BAND, "a", NULL);
708698
}
709699
else
710700
{
711-
NMLOG_WARNING("invalid frequency value: %s", ssidinfo.frequency.c_str());
701+
NMLOG_WARNING("invalid frequency value: %d", ssidinfo.frequency);
712702
return false;
713703
}
714704
}
@@ -719,7 +709,6 @@ namespace WPEFramework
719709
case Exchange::INetworkManager::WIFISecurityMode::WIFI_SECURITY_WPA_PSK:
720710
case Exchange::INetworkManager::WIFISecurityMode::WIFI_SECURITY_SAE:
721711
{
722-
723712
sSecurity = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new();
724713
nm_connection_add_setting(m_connection, NM_SETTING(sSecurity));
725714
if(Exchange::INetworkManager::WIFISecurityMode::WIFI_SECURITY_SAE == ssidinfo.security)

0 commit comments

Comments
 (0)