Skip to content

Commit

Permalink
DELIA-64891 - Network failed to connect after Reset
Browse files Browse the repository at this point in the history
Reason for change: Added the missing changes from Network
Test Procedure: Build and verified with curl commands
Risks: Low
Priority: P0
Signed-off-by: Gururaaja ESR <[email protected]>
  • Loading branch information
Gururaaja E S R authored and Gururaaja E S R committed Apr 4, 2024
1 parent e3bf082 commit 640d65a
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 14 deletions.
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 @@ -425,7 +426,16 @@ namespace WPEFramework
list.ToString(response);
NMLOG_INFO("Response is, %s", response.c_str());
}
fclose(pipe);
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);
}
return;
}

Expand Down
13 changes: 8 additions & 5 deletions NetworkManager/service/NetworkManagerJsonRpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,12 @@ 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{};

interface = parameters["interface"].String();
ipversion = parameters["ipversion"].String();
if (_NetworkManager)
rc = _NetworkManager->GetIPSettings(interface, ipversion, result);
else
Expand Down Expand Up @@ -287,9 +289,11 @@ 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 = "";

interface = parameters["interface"].String();
ipversion = parameters["ipversion"].String();
result.m_autoConfig = parameters["autoconfig"].Boolean();
if (!result.m_autoConfig)
{
Expand Down Expand Up @@ -612,7 +616,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

0 comments on commit 640d65a

Please sign in to comment.