Skip to content

Commit

Permalink
Merge branch 'rdkcentral:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
gururaajar committed Jan 28, 2025
2 parents 927e728 + 4f6125b commit 8256363
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 23 deletions.
11 changes: 10 additions & 1 deletion NetworkManager.json
Original file line number Diff line number Diff line change
Expand Up @@ -1251,23 +1251,32 @@
"type": "object",
"properties": {
"NONE": {
"summary": "Security mode for open network",
"type": "integer",
"example": 0
},
"WPA_PSK": {
"summary": "Supports security mode WPA,WPA-PSK,WPA2-PSK, WPA3-Personal-Transition",
"type": "integer",
"example": 1
},
"SAE": {
"summary": "Supports security mode WPA3-Personal",
"type": "integer",
"example": 2
},
"EAP": {
"summary": "Supports security mode WPA enterpise",
"type": "integer",
"example": 3
}
},
"required": []
"required": [
"NONE",
"WPA_PSK",
"SAE",
"EAP"
]
},
"success":{
"$ref": "#/definitions/success"
Expand Down
40 changes: 22 additions & 18 deletions NetworkManagerGnomeWIFI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -952,11 +952,13 @@ namespace WPEFramework
void wifiManager::wpsAction()
{
FILE *fp = nullptr;
const std::string securityPattern = "key_mgmt=";
const std::string ssidPattern = "ssid=";
const std::string passphrasePattern = "psk=";
std::string line = "";
std::string securityPattern = "key_mgmt=";
std::string ssidPattern = "ssid=";
std::string passphrasePattern = "psk=";
std::string security = "", ssid = "", passphrase = "";
std::string security = "";
std::string ssid = "";
std::string passphrase = "";
std::string wpaCliResult = "";
gboolean wpsConnect = false;
struct timespec startTime = {}, endTime = {};
Expand Down Expand Up @@ -995,7 +997,7 @@ namespace WPEFramework
for (guint apCount = 0; apCount < aps->len; apCount++) {
NMAccessPoint *ap = static_cast<NMAccessPoint *>(g_ptr_array_index(aps, apCount));
guint32 flags = nm_access_point_get_flags(ap);
GBytes *ssid;
GBytes *ssidBytes;
gsize size;
std::string ssidStr;

Expand All @@ -1009,8 +1011,8 @@ namespace WPEFramework
apList[wpsApCount].bssid[sizeof(apList[wpsApCount].bssid) - 1] = '\0';
}
NMLOG_DEBUG("PBC enabled access point bssid = %s", bssid);
ssid = nm_access_point_get_ssid(ap);
const guint8 *ssidData = static_cast<const guint8 *>(g_bytes_get_data(ssid, &size));
ssidBytes = nm_access_point_get_ssid(ap);
const guint8 *ssidData = static_cast<const guint8 *>(g_bytes_get_data(ssidBytes, &size));
std::string ssidTmp(reinterpret_cast<const char *>(ssidData), size);
strncpy(apList[wpsApCount].ssid, ssidTmp.c_str(), sizeof(apList[wpsApCount].ssid) - 1);
apList[wpsApCount].ssid[sizeof(apList[wpsApCount].ssid) - 1] = '\0';
Expand Down Expand Up @@ -1103,19 +1105,21 @@ namespace WPEFramework
size_t pos;

// Fetch ssid value
pos = line.find(ssidPattern);
if (pos != std::string::npos)
{
pos += ssidPattern.length();
size_t end = line.find('"', pos + 1);
if (end == std::string::npos)
if (ssid.empty()) {
pos = line.find(ssidPattern);
if (pos != std::string::npos)
{
end = line.length();
pos += ssidPattern.length();
size_t end = line.find('"', pos + 1);
if (end == std::string::npos)
{
end = line.length();
}
ssid = line.substr(pos + 1, end - pos - 1);
wpsConnect = true;
NMLOG_DEBUG("SSID found");
continue;
}
ssid = line.substr(pos + 1, end - pos - 1);
wpsConnect = true;
NMLOG_DEBUG("SSID found");
continue;
}

if (wpsConnect) {
Expand Down
8 changes: 4 additions & 4 deletions docs/NetworkManagerPlugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -1615,10 +1615,10 @@ This method takes no parameters.
| :-------- | :-------- | :-------- |
| result | object | |
| result.security_modes | object | The supported security modes and its associated integer value |
| result.security_modes?.NONE | integer | <sup>*(optional)*</sup> |
| result.security_modes?.WPA_PSK | integer | <sup>*(optional)*</sup> |
| result.security_modes?.SAE | integer | <sup>*(optional)*</sup> |
| result.security_modes?.EAP | integer | <sup>*(optional)*</sup> |
| result.security_modes.NONE | integer | Security mode for open network |
| result.security_modes.WPA_PSK | integer | Supports security mode WPA,WPA-PSK,WPA2-PSK, WPA3-Personal-Transition |
| result.security_modes.SAE | integer | Supports security mode WPA3-Personal |
| result.security_modes.EAP | integer | Supports security mode WPA enterpise |
| result.success | boolean | Whether the request succeeded |

### Example
Expand Down

0 comments on commit 8256363

Please sign in to comment.