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-64891 - Network failed to connect after Reset #5117

Merged
merged 3 commits into from
Apr 4, 2024
Merged
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
12 changes: 11 additions & 1 deletion NetworkManager/service/NetworkManagerImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ namespace WPEFramework
string output{};
char buffer[1024];
JsonObject pingResult;
int exitStatus;

pipe = popen(commandToExecute.c_str(), "r");
if (pipe == NULL)
Expand Down Expand Up @@ -404,6 +405,15 @@ namespace WPEFramework
pingResult["error"] = "Bad Address";
}
}
exitStatus = pclose(pipe);
// Check the exit status to determine if the command was successful
if (WIFEXITED(exitStatus) && WEXITSTATUS(exitStatus) == 0) {
pingResult["success"] = true;
pingResult["error"] = "";
} else {
pingResult["success"] = false;
pingResult["error"] = "Could not ping endpoint";
}

pingResult.ToString(response);
NMLOG_INFO("Response is, %s", response.c_str());
Expand All @@ -422,10 +432,10 @@ namespace WPEFramework
list.Add(line);
}

pclose(pipe);
list.ToString(response);
NMLOG_INFO("Response is, %s", response.c_str());
}
fclose(pipe);
return;
}

Expand Down
17 changes: 12 additions & 5 deletions NetworkManager/service/NetworkManagerJsonRpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,14 @@ namespace WPEFramework
{
LOGINFOMETHOD();
uint32_t rc = Core::ERROR_GENERAL;
const string interface = parameters["interface"].String();
const string ipversion = parameters["ipversion"].String();
string interface = "";
string ipversion = "";
Exchange::INetworkManager::IPAddressInfo result{};

if (parameters.HasLabel("interface"))
interface = parameters["interface"].String();
if (parameters.HasLabel("ipversion"))
ipversion = parameters["ipversion"].String();
if (_NetworkManager)
rc = _NetworkManager->GetIPSettings(interface, ipversion, result);
else
Expand Down Expand Up @@ -287,9 +291,13 @@ namespace WPEFramework
LOGINFOMETHOD();
uint32_t rc = Core::ERROR_GENERAL;
Exchange::INetworkManager::IPAddressInfo result{};
const string interface = parameters["interface"].String();
const string ipversion = parameters["ipversion"].String();
string interface = "";
string ipversion = "";

if (parameters.HasLabel("interface"))
interface = parameters["interface"].String();
if (parameters.HasLabel("ipversion"))
ipversion = parameters["ipversion"].String();
result.m_autoConfig = parameters["autoconfig"].Boolean();
if (!result.m_autoConfig)
{
Expand Down Expand Up @@ -612,7 +620,6 @@ namespace WPEFramework
{
JsonObject reply;
reply.FromString(result);
reply["success"] = true;
response = reply;
}
LOGTRACEMETHODFIN();
Expand Down
62 changes: 58 additions & 4 deletions NetworkManager/service/NetworkManagerLegacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,18 @@ namespace WPEFramework
Register("startConnectivityMonitoring", &NetworkManager::StartConnectivityMonitoring, this);
Register("getCaptivePortalURI", &NetworkManager::GetCaptivePortalURI, this);
Register("stopConnectivityMonitoring", &NetworkManager::StopConnectivityMonitoring, this);
Register("cancelWPSPairing", &NetworkManager::StopWPS, this);
Register("cancelWPSPairing", &NetworkManager::cancelWPSPairing, this);
Register("clearSSID", &NetworkManager::clearSSID, this);
Register("connect", &NetworkManager::WiFiConnect, this);
Register("disconnect", &NetworkManager::WiFiDisconnect, this);
Register("disconnect", &NetworkManager::disconnect, this);
Register("getConnectedSSID", &NetworkManager::getConnectedSSID, this);
Register("startScan", &NetworkManager::StartWiFiScan, this);
Register("stopScan", &NetworkManager::StopWiFiScan, this);
Register("getPairedSSID", &NetworkManager::GetKnownSSIDs, this);
Register("getPairedSSIDInfo", &NetworkManager::GetConnectedSSID, this);
Register("initiateWPSPairing", &NetworkManager::initiateWPSPairing, this);
Register("isPaired", &NetworkManager::isPaired, this);
Register("saveSSID", &NetworkManager::AddToKnownSSIDs, this);
Register("saveSSID", &NetworkManager::saveSSID, this);
Register("getSupportedSecurityModes", &NetworkManager::GetSupportedSecurityModes, this);
Register("getCurrentState", &NetworkManager::GetWifiState, this);
}
Expand Down Expand Up @@ -229,6 +229,7 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = {

if (Core::ERROR_NONE == rc)
{
response["result"] = string();
response["success"] = true;
}
LOGTRACEMETHODFIN();
Expand Down Expand Up @@ -441,7 +442,8 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = {

if (Core::ERROR_NONE == rc)
{
response["success"] = true;
response["target"] = parameters["endpoint"];
response["guid"] = parameters["guid"];
}
LOGTRACEMETHODFIN();
return rc;
Expand Down Expand Up @@ -511,6 +513,10 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = {

tmpParameters["ssid"] = "";
rc = RemoveKnownSSID(tmpParameters, response);
if (Core::ERROR_NONE == rc)
{
response["result"] = 0;
}

LOGTRACEMETHODFIN();
return rc;
Expand Down Expand Up @@ -563,5 +569,53 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = {
LOGTRACEMETHODFIN();
return rc;
}

uint32_t NetworkManager::saveSSID (const JsonObject& parameters, JsonObject& response)
{
uint32_t rc = Core::ERROR_GENERAL;

LOGINFOMETHOD();

rc = AddToKnownSSIDs(parameters, response);
if (Core::ERROR_NONE == rc)
{
response["result"] = 0;
}

LOGTRACEMETHODFIN();
return rc;
}

uint32_t NetworkManager::disconnect (const JsonObject& parameters, JsonObject& response)
{
uint32_t rc = Core::ERROR_GENERAL;

LOGINFOMETHOD();

rc = WiFiDisconnect(parameters, response);
if (Core::ERROR_NONE == rc)
{
response["result"] = 0;
}

LOGTRACEMETHODFIN();
return rc;
}

uint32_t NetworkManager::cancelWPSPairing (const JsonObject& parameters, JsonObject& response)
{
uint32_t rc = Core::ERROR_GENERAL;

LOGINFOMETHOD();

rc = StopWPS(parameters, response);
if (Core::ERROR_NONE == rc)
{
response["result"] = string();
}

LOGTRACEMETHODFIN();
return rc;
}
}
}
10 changes: 6 additions & 4 deletions NetworkManager/service/NetworkManagerRDKProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -950,7 +950,7 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = {
param.data.connect.security_mode = (SsidSecurity) ssid.m_securityMode;

IARM_Result_t retVal = IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_WIFI_MGR_API_saveSSID, (void *)&param, sizeof(param));
if(retVal == IARM_RESULT_SUCCESS)
if((retVal == IARM_RESULT_SUCCESS) && param.status)
{
NMLOG_INFO ("AddToKnownSSIDs Success");
rc = Core::ERROR_NONE;
Expand All @@ -975,7 +975,7 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = {
(void)ssid;

IARM_Result_t retVal = IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_WIFI_MGR_API_clearSSID, (void *)&param, sizeof(param));
if(retVal == IARM_RESULT_SUCCESS)
if((retVal == IARM_RESULT_SUCCESS) && param.status)
{
NMLOG_INFO ("RemoveKnownSSID Success");
rc = Core::ERROR_NONE;
Expand Down Expand Up @@ -1004,7 +1004,7 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = {

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

if(retVal == IARM_RESULT_SUCCESS && param.status)
if((retVal == IARM_RESULT_SUCCESS) && param.status)
{
NMLOG_INFO ("WiFiConnect Success");
rc = Core::ERROR_NONE;
Expand All @@ -1019,11 +1019,13 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = {
uint32_t NetworkManagerImplementation::WiFiDisconnect(void)
{
LOG_ENTRY_FUNCTION();
IARM_Result_t retVal = IARM_RESULT_SUCCESS;
uint32_t rc = Core::ERROR_RPC_CALL_FAILED;
IARM_Bus_WiFiSrvMgr_Param_t param;
memset(&param, 0, sizeof(param));

if (IARM_RESULT_SUCCESS == IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_WIFI_MGR_API_disconnectSSID, (void *)&param, sizeof(param)))
retVal = IARM_Bus_Call(IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_WIFI_MGR_API_disconnectSSID, (void *)&param, sizeof(param));
if ((retVal == IARM_RESULT_SUCCESS) && param.status)
{
NMLOG_INFO ("WiFiDisconnect started");
rc = Core::ERROR_NONE;
Expand Down
Loading