diff --git a/NetworkManager/INetworkManager.h b/NetworkManager/INetworkManager.h index ec034d219a..baf872704e 100644 --- a/NetworkManager/INetworkManager.h +++ b/NetworkManager/INetworkManager.h @@ -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; diff --git a/NetworkManager/NetworkManager.h b/NetworkManager/NetworkManager.h index a32ed86436..06669ff763 100644 --- a/NetworkManager/NetworkManager.h +++ b/NetworkManager/NetworkManager.h @@ -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); diff --git a/NetworkManager/NetworkManagerImplementation.h b/NetworkManager/NetworkManagerImplementation.h index 76cbd00b5a..1599f0aa0c 100644 --- a/NetworkManager/NetworkManagerImplementation.h +++ b/NetworkManager/NetworkManagerImplementation.h @@ -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; diff --git a/NetworkManager/NetworkManagerJsonRpc.cpp b/NetworkManager/NetworkManagerJsonRpc.cpp index 8c2ab1142d..a918297bbc 100644 --- a/NetworkManager/NetworkManagerJsonRpc.cpp +++ b/NetworkManager/NetworkManagerJsonRpc.cpp @@ -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); @@ -104,6 +105,7 @@ namespace WPEFramework Unregister("RemoveKnownSSID"); Unregister("WiFiConnect"); Unregister("WiFiDisconnect"); + Unregister("LNFConnect"); Unregister("GetConnectedSSID"); Unregister("StartWPS"); Unregister("StopWPS"); @@ -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 (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(); diff --git a/NetworkManager/NetworkManagerRDKProxy.cpp b/NetworkManager/NetworkManagerRDKProxy.cpp index 861afcb4ec..0f04baabd6 100644 --- a/NetworkManager/NetworkManagerRDKProxy.cpp +++ b/NetworkManager/NetworkManagerRDKProxy.cpp @@ -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(¶m, 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 *)¶m, 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();