Skip to content

Commit

Permalink
[DELIA-65505 DELIA-65521: WiFi connection stuck at connecting screen …
Browse files Browse the repository at this point in the history
…after entering wrong password and another same wifi issue during FSR process (rdkcentral#5445)

* [DELIA-65505 DELIA-65521: WiFi connection stuck at connecting screen after entering wrong password and another same wifi issue during FSR process

Reason for change: onError EventHandling has been added to NetworkManagerInternalEventHandler, allowing us to obtain the WiFi error codes
Test Procedure: Verify in Jenkin Build
Risks: High
Signed-off-by: Thamim Razith tabbas651@cable.comcast.com
(cherry picked from commit ca8f610)
  • Loading branch information
tabbas651 authored and cmuhammedrafi committed Jul 2, 2024
1 parent d0f2f1f commit f193288
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 3 deletions.
58 changes: 55 additions & 3 deletions NetworkManager/LegacyPlugin_WiFiManagerAPIs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
**/
#include "LegacyPlugin_WiFiManagerAPIs.h"
#include "NetworkManagerLogger.h"

#include "INetworkManager.h"

using namespace std;
using namespace WPEFramework::Plugin;
Expand Down Expand Up @@ -529,17 +529,69 @@ namespace WPEFramework
m_timer.stop();
}

bool WiFiManager::ErrorCodeMapping(const uint32_t ipvalue, uint32_t &opvalue)
{
bool ret = true;

switch (ipvalue)
{
case Exchange::INetworkManager::WIFI_STATE_SSID_CHANGED:
opvalue = WIFI_SSID_CHANGED;
break;
case Exchange::INetworkManager::WIFI_STATE_CONNECTION_LOST:
opvalue = WIFI_CONNECTION_LOST;
break;
case Exchange::INetworkManager::WIFI_STATE_CONNECTION_FAILED:
opvalue = WIFI_CONNECTION_FAILED;
break;
case Exchange::INetworkManager::WIFI_STATE_CONNECTION_INTERRUPTED:
opvalue = WIFI_CONNECTION_INTERRUPTED;
break;
case Exchange::INetworkManager::WIFI_STATE_INVALID_CREDENTIALS:
opvalue = WIFI_INVALID_CREDENTIALS;
break;
case Exchange::INetworkManager::WIFI_STATE_SSID_NOT_FOUND:
opvalue = WIFI_NO_SSID;
break;
case Exchange::INetworkManager::WIFI_STATE_ERROR:
opvalue = WIFI_UNKNOWN;
break;
case Exchange::INetworkManager::WIFI_STATE_AUTHENTICATION_FAILED:
opvalue = WIFI_AUTH_FAILED;
break;
default:
ret = false;
break;
}
return ret;
}

/** Event Handling and Publishing */
void WiFiManager::onWiFiStateChange(const JsonObject& parameters)
{
LOGINFOMETHOD();
JsonObject legacyResult;
JsonObject legacyErrorResult;
uint32_t errorCode;
uint32_t state = parameters["state"].Number();

legacyResult["state"] = parameters["state"];
legacyResult["isLNF"] = false;

if(_gWiFiInstance)
_gWiFiInstance->Notify("onWIFIStateChanged", legacyResult);

{
if(ErrorCodeMapping(state, errorCode))
{
legacyErrorResult["code"] = errorCode;
NMLOG_INFO("onError with errorcode as, %u", errorCode);
_gWiFiInstance->Notify("onError", legacyErrorResult);
}
else
{
NMLOG_INFO("onWiFiStateChange with state as: %u", state);
_gWiFiInstance->Notify("onWIFIStateChanged", legacyResult);
}
}
return;
}

Expand Down
14 changes: 14 additions & 0 deletions NetworkManager/LegacyPlugin_WiFiManagerAPIs.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@
#include "Module.h"
#include "NetworkManagerTimer.h"

/*! Error code: A recoverable, unexpected error occurred,
* as defined by one of the following values */
typedef enum _WiFiErrorCode_t {
WIFI_SSID_CHANGED, /**< The SSID of the network changed */
WIFI_CONNECTION_LOST, /**< The connection to the network was lost */
WIFI_CONNECTION_FAILED, /**< The connection failed for an unknown reason */
WIFI_CONNECTION_INTERRUPTED, /**< The connection was interrupted */
WIFI_INVALID_CREDENTIALS, /**< The connection failed due to invalid credentials */
WIFI_NO_SSID, /**< The SSID does not exist */
WIFI_UNKNOWN, /**< Any other error */
WIFI_AUTH_FAILED /**< The connection failed due to auth failure */
} WiFiErrorCode_t;

namespace WPEFramework {

namespace Plugin {
Expand Down Expand Up @@ -87,6 +100,7 @@ namespace WPEFramework {
void UnregisterLegacyMethods();
void subscribeToEvents(void);
static std::string getInterfaceMapping(const std::string &interface);
static bool ErrorCodeMapping(const uint32_t ipvalue , uint32_t &opvalue);
void activatePrimaryPlugin();

private:
Expand Down
29 changes: 29 additions & 0 deletions NetworkManager/NetworkManagerRDKProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,27 @@ namespace WPEFramework
return Exchange::INetworkManager::WIFI_STATE_CONNECTION_FAILED;
}

Exchange::INetworkManager::WiFiState errorcode_to_wifi_state(WiFiErrorCode_t code) {
switch (code)
{
case WIFI_SSID_CHANGED:
return Exchange::INetworkManager::WIFI_STATE_SSID_CHANGED;
case WIFI_CONNECTION_LOST:
return Exchange::INetworkManager::WIFI_STATE_CONNECTION_LOST;
case WIFI_CONNECTION_INTERRUPTED:
return Exchange::INetworkManager::WIFI_STATE_CONNECTION_INTERRUPTED;
case WIFI_INVALID_CREDENTIALS:
return Exchange::INetworkManager::WIFI_STATE_INVALID_CREDENTIALS;
case WIFI_AUTH_FAILED:
return Exchange::INetworkManager::WIFI_STATE_AUTHENTICATION_FAILED;
case WIFI_NO_SSID:
return Exchange::INetworkManager::WIFI_STATE_SSID_NOT_FOUND;
case WIFI_UNKNOWN:
return Exchange::INetworkManager::WIFI_STATE_ERROR;
}
return Exchange::INetworkManager::WIFI_STATE_CONNECTION_FAILED;
}

void NetworkManagerInternalEventHandler(const char *owner, IARM_EventId_t eventId, void *data, size_t len)
{
LOG_ENTRY_FUNCTION();
Expand Down Expand Up @@ -505,6 +526,14 @@ namespace WPEFramework
::_instance->ReportWiFiStateChangedEvent(state);
break;
}
case IARM_BUS_WIFI_MGR_EVENT_onError:
{
IARM_BUS_WiFiSrvMgr_EventData_t* e = (IARM_BUS_WiFiSrvMgr_EventData_t *) data;
Exchange::INetworkManager::WiFiState state = errorcode_to_wifi_state(e->data.wifiError.code);
NMLOG_INFO("Event IARM_BUS_WIFI_MGR_EVENT_onError received; code=%d", e->data.wifiError.code);
::_instance->ReportWiFiStateChangedEvent(state);
break;
}
default:
{
NMLOG_INFO("Event %d received; Unhandled", eventId);
Expand Down

0 comments on commit f193288

Please sign in to comment.