Skip to content

Commit

Permalink
RDK-000 - To test LNF
Browse files Browse the repository at this point in the history
Reason for change: To test LNF
Test Procedure: NA
Risks: Low
Priority: P1
Signed-off-by: Gururaaja ESR <[email protected]>
  • Loading branch information
Gururaaja E S R authored and Gururaaja E S R committed Jun 20, 2024
1 parent c1b939c commit ff829ae
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions NetworkManager/INetworkManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ namespace WPEFramework

virtual uint32_t WiFiConnect(const WiFiConnectTo& ssid /* @in */) = 0;
virtual uint32_t WiFiDisconnect(void) = 0;
virtual uint32_t LNFConnect(const WiFiConnectTo& ssid /* @in */) = 0;
virtual uint32_t GetConnectedSSID(WiFiSSIDInfo& ssidInfo /* @out */) = 0;

virtual uint32_t StartWPS(const WiFiWPS& method /* @in */, const string& wps_pin /* @in */) = 0;
Expand Down
1 change: 1 addition & 0 deletions NetworkManager/NetworkManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ namespace WPEFramework
uint32_t RemoveKnownSSID(const JsonObject& parameters, JsonObject& response);
uint32_t WiFiConnect(const JsonObject& parameters, JsonObject& response);
uint32_t WiFiDisconnect(const JsonObject& parameters, JsonObject& response);
uint32_t LNFConnect(const JsonObject& parameters, JsonObject& response);
uint32_t GetConnectedSSID(const JsonObject& parameters, JsonObject& response);
uint32_t StartWPS(const JsonObject& parameters, JsonObject& response);
uint32_t StopWPS(const JsonObject& parameters, JsonObject& response);
Expand Down
1 change: 1 addition & 0 deletions NetworkManager/NetworkManagerImplementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ namespace WPEFramework

uint32_t WiFiConnect(const WiFiConnectTo& ssid /* @in */) override;
uint32_t WiFiDisconnect(void) override;
uint32_t LNFConnect(const WiFiConnectTo& ssid /* @in */) override;
uint32_t GetConnectedSSID(WiFiSSIDInfo& ssidInfo /* @out */) override;

uint32_t StartWPS(const WiFiWPS& method /* @in */, const string& wps_pin /* @in */) override;
Expand Down
39 changes: 39 additions & 0 deletions NetworkManager/NetworkManagerJsonRpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ namespace WPEFramework
Register("RemoveKnownSSID", &NetworkManager::RemoveKnownSSID, this);
Register("WiFiConnect", &NetworkManager::WiFiConnect, this);
Register("WiFiDisconnect", &NetworkManager::WiFiDisconnect, this);
Register("LNFConnect", &NetworkManager::WiFiConnect, this);
Register("GetConnectedSSID", &NetworkManager::GetConnectedSSID, this);
Register("StartWPS", &NetworkManager::StartWPS, this);
Register("StopWPS", &NetworkManager::StopWPS, this);
Expand Down Expand Up @@ -104,6 +105,7 @@ namespace WPEFramework
Unregister("RemoveKnownSSID");
Unregister("WiFiConnect");
Unregister("WiFiDisconnect");
Unregister("LNFConnect");
Unregister("GetConnectedSSID");
Unregister("StartWPS");
Unregister("StopWPS");
Expand Down Expand Up @@ -834,6 +836,43 @@ namespace WPEFramework
return rc;
}

uint32_t NetworkManager::LNFConnect(const JsonObject& parameters, JsonObject& response)
{
LOGINFOMETHOD();
uint32_t rc = Core::ERROR_GENERAL;
Exchange::INetworkManager::WiFiConnectTo ssid{};

if (parameters.HasLabel("ssid"))
ssid.m_ssid = parameters["ssid"].String();
if (parameters.HasLabel("passphrase"))
ssid.m_passphrase = parameters["passphrase"].String();
if (parameters.HasLabel("securityMode"))
ssid.m_securityMode = static_cast <Exchange::INetworkManager::WIFISecurityMode> (parameters["securityMode"].Number());
//TODO Check Security modes
if (parameters.HasLabel("identity"))
ssid.m_identity = parameters["identity"].String();
if (parameters.HasLabel("caCert"))
ssid.m_caCert = parameters["caCert"].String();
if (parameters.HasLabel("clientCert"))
ssid.m_clientCert = parameters["clientCert"].String();
if (parameters.HasLabel("privateKey"))
ssid.m_privateKey = parameters["privateKey"].String();
if (parameters.HasLabel("privateKeyPasswd"))
ssid.m_privateKeyPasswd = parameters["privateKeyPasswd"].String();

if (_NetworkManager)
rc = _NetworkManager->LNFConnect(ssid);
else
rc = Core::ERROR_UNAVAILABLE;

if (Core::ERROR_NONE == rc)
{
response["success"] = true;
}
LOGTRACEMETHODFIN();
return rc;
}

uint32_t NetworkManager::WiFiDisconnect(const JsonObject& parameters, JsonObject& response)
{
LOGINFOMETHOD();
Expand Down
33 changes: 33 additions & 0 deletions NetworkManager/NetworkManagerRDKProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1075,6 +1075,39 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = {
return rc;
}

uint32_t NetworkManagerImplementation::LNFConnect(const WiFiConnectTo& ssid /* @in */)
{
LOG_ENTRY_FUNCTION();
uint32_t rc = Core::ERROR_RPC_CALL_FAILED;
IARM_Result_t retVal = IARM_RESULT_SUCCESS;
IARM_Bus_WiFiSrvMgr_Param_t param;
memset(&param, 0, sizeof(param));

if(ssid.m_ssid.length() || ssid.m_passphrase.length())
{
ssid.m_ssid.copy(param.data.connect.ssid, sizeof(param.data.connect.ssid) - 1);
ssid.m_passphrase.copy(param.data.connect.passphrase, sizeof(param.data.connect.passphrase) - 1);
param.data.connect.security_mode = (SsidSecurity)ssid.m_securityMode;
ssid.m_identity.copy(param.data.connect.eapIdentity, sizeof(param.data.connect.eapIdentity) - 1);
ssid.m_caCert.copy(param.data.connect.carootcert, sizeof(param.data.connect.carootcert) - 1);
ssid.m_clientCert.copy(param.data.connect.clientcert, sizeof(param.data.connect.clientcert) - 1);
ssid.m_privateKey.copy(param.data.connect.privatekey, sizeof(param.data.connect.privatekey) - 1);
}

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)
{
NMLOG_INFO ("WiFiConnect Success");
rc = Core::ERROR_NONE;
}
else
{
NMLOG_ERROR ("WiFiConnect failed");
}
return rc;
}

uint32_t NetworkManagerImplementation::WiFiDisconnect(void)
{
LOG_ENTRY_FUNCTION();
Expand Down

0 comments on commit ff829ae

Please sign in to comment.