Skip to content

Commit

Permalink
Merge branch 'rdkcentral:develop' into release/unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
parvathika authored Jan 3, 2025
2 parents 9738d24 + a196415 commit 259291b
Show file tree
Hide file tree
Showing 16 changed files with 446 additions and 388 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ All notable changes to this RDK Service will be documented in this file.

* Changes in CHANGELOG should be updated when commits are added to the main or release branches. There should be one CHANGELOG entry per JIRA Ticket. This is not enforced on sprint branches since there could be multiple changes for the same JIRA ticket during development.

## [0.7.0] - 2024-12-30
### Added
- Gnome WPS custom design implemented
- Handle interface status based on IPAddress change event
- Cleanup STUN client codebase
- Handle JSON Event Subscription
- Handle Platform Init and Configure functions of out-of-process
- Handle the startup order
- Added L1 test cases for the plugins

## [0.6.0] - 2024-12-10
### Added
- Added specific SSID/frequency scanning
Expand Down
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ find_package(WPEFramework)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
set(VERSION_MAJOR 0)
set(VERSION_MINOR 6)
set(VERSION_MINOR 7)
set(VERSION_PATCH 0)

add_compile_definitions(NETWORKMANAGER_MAJOR_VERSION=${VERSION_MAJOR})
Expand All @@ -32,9 +32,9 @@ find_package(${NAMESPACE}Core REQUIRED)
find_package(${NAMESPACE}Plugins REQUIRED)
find_package(CURL)

set(PLUGIN_NETWORKMANAGER_STARTUPORDER "55" CACHE STRING "To configure startup order of Unified NetworkManager plugin")
set(PLUGIN_LEGACY_NW_STARTUPORDER "56" CACHE STRING "To configure startup order of Legacy Network plugin")
set(PLUGIN_LEGACY_WIFI_STARTUPORDER "56" CACHE STRING "To configure startup order of Legacy WiFi plugin")
set(PLUGIN_NETWORKMANAGER_STARTUPORDER "25" CACHE STRING "To configure startup order of Unified NetworkManager plugin")
set(PLUGIN_LEGACY_NW_STARTUPORDER "35" CACHE STRING "To configure startup order of Legacy Network plugin")
set(PLUGIN_LEGACY_WIFI_STARTUPORDER "35" CACHE STRING "To configure startup order of Legacy WiFi plugin")

set(PLUGIN_BUILD_REFERENCE ${PROJECT_VERSION} CACHE STRING "To Set the Hash for the plugin")
add_definitions(-DPLUGIN_BUILD_REFERENCE=${PLUGIN_BUILD_REFERENCE})
Expand Down
12 changes: 6 additions & 6 deletions INetworkManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace WPEFramework
INTERNET_LIMITED /* @text: LIMITED_INTERNET */,
INTERNET_CAPTIVE_PORTAL /* @text: CAPTIVE_PORTAL */,
INTERNET_FULLY_CONNECTED /* @text: FULLY_CONNECTED */,
INTERNET_UNKNOWN /* @text: NO_INTERNET */,
INTERNET_UNKNOWN /* @text: UNKNOWN */,
};

enum WiFiWPS : uint8_t
Expand Down Expand Up @@ -237,13 +237,13 @@ namespace WPEFramework
/* @brief Get Authentication URL if the device is behind Captive Portal */
virtual uint32_t GetCaptivePortalURI(string &uri/* @out */) const = 0;

/* @brief Start The Internet Connectivity Monitoring */
/* @brief Start The Internet Connectivity Monitoring */
virtual uint32_t StartConnectivityMonitoring(const uint32_t interval /* @in */) = 0;
/* @brief Stop The Internet Connectivity Monitoring */
/* @brief Stop The Internet Connectivity Monitoring */
virtual uint32_t StopConnectivityMonitoring(void) const = 0;

/* @brief Get the Public IP used for external world communication */
virtual uint32_t GetPublicIP (const string &ipversion /* @in */, string& ipaddress /* @out */) = 0;
virtual uint32_t GetPublicIP (string &ipversion /* @inout */, string& ipaddress /* @out */) = 0;

/* @brief Request for ping and get the response in as event. The GUID used in the request will be returned in the event. */
virtual uint32_t Ping (const string ipversion /* @in */, const string endpoint /* @in */, const uint32_t count /* @in */, const uint16_t timeout /* @in */, const string guid /* @in */, string& response /* @out */) = 0;
Expand Down Expand Up @@ -275,8 +275,8 @@ namespace WPEFramework
virtual uint32_t SetLogLevel(const Logging& level /* @in */) = 0;
virtual uint32_t GetLogLevel(Logging& level /* @out */) = 0;

/* @brief configure network manager plugin */
virtual uint32_t Configure(const string& configLine /* @in */) = 0;
/* @brief Configure the Network Manager plugin */
virtual uint32_t Configure(PluginHost::IShell* service /* @in */) = 0;

/* @event */
struct EXTERNAL INotification : virtual public Core::IUnknown
Expand Down
25 changes: 14 additions & 11 deletions LegacyPlugin_NetworkAPIs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "NetworkManagerLogger.h"
#include "NetworkManagerJsonEnum.h"


using namespace std;
using namespace WPEFramework::Plugin;
#define API_VERSION_NUMBER_MAJOR 2
Expand Down Expand Up @@ -84,7 +83,6 @@ namespace WPEFramework
, m_subsInternetChange(false)
{
_gNWInstance = this;
m_defaultInterface = "wlan0";
m_timer.connect(std::bind(&Network::subscribeToEvents, this));
registerLegacyMethods();
}
Expand Down Expand Up @@ -167,7 +165,13 @@ namespace WPEFramework

void Network::Deinitialize(PluginHost::IShell* /* service */)
{
m_timer.stop();
unregisterLegacyMethods();

if (m_networkmanager)
m_networkmanager.reset();

m_networkmanager = NULL;
m_service->Release();
m_service = nullptr;
_gNWInstance = nullptr;
Expand Down Expand Up @@ -204,7 +208,7 @@ namespace WPEFramework
Register("getInternetConnectionState", &Network::getInternetConnectionState, this);
Register("ping", &Network::doPing, this);
Register("isConnectedToInternet", &Network::isConnectedToInternet, this);
Register("setStunEndPoint", &Network::setStunEndPoint, this);
Register("setStunEndPoint", &Network::setStunEndpoint, this);
Register("trace", &Network::doTrace, this);
Register("setConnectivityTestEndpoints", &Network::setConnectivityTestEndpoints, this);
Register("startConnectivityMonitoring", &Network::startConnectivityMonitoring, this);
Expand All @@ -219,6 +223,8 @@ namespace WPEFramework
*/
void Network::unregisterLegacyMethods(void)
{
Unregister("getStbIp");
Unregister("getSTBIPFamily");
Unregister("getInterfaces");
Unregister("isInterfaceEnabled");
Unregister("getPublicIP");
Expand All @@ -230,6 +236,8 @@ namespace WPEFramework
Unregister("getInternetConnectionState");
Unregister("ping");
Unregister("isConnectedToInternet");
Unregister("setStunEndPoint");
Unregister("trace");
Unregister("setConnectivityTestEndpoints");
Unregister("startConnectivityMonitoring");
Unregister("getCaptivePortalURI");
Expand Down Expand Up @@ -319,19 +327,19 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN+1] = {
returnJson(rc);
}

uint32_t Network::setStunEndPoint(const JsonObject& parameters, JsonObject& response)
uint32_t Network::setStunEndpoint(const JsonObject& parameters, JsonObject& response)
{
LOG_INPARAM();
uint32_t rc = Core::ERROR_GENERAL;
string endPoint = parameters["server"].String();
string endpoint = parameters["server"].String();
uint32_t port = parameters["port"].Number();
uint32_t bindTimeout = parameters["timeout"].Number();
uint32_t cacheTimeout = parameters["cache_timeout"].Number();

auto _nwmgr = m_service->QueryInterfaceByCallsign<Exchange::INetworkManager>(NETWORK_MANAGER_CALLSIGN);
if (_nwmgr)
{
rc = _nwmgr->SetStunEndpoint(endPoint, port, bindTimeout, cacheTimeout);
rc = _nwmgr->SetStunEndpoint(endpoint, port, bindTimeout, cacheTimeout);
_nwmgr->Release();
}
else
Expand Down Expand Up @@ -1017,8 +1025,6 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN+1] = {
legacyParams["oldInterfaceName"] = getInterfaceNameToType(parameters["prevActiveInterface"].String());
legacyParams["newInterfaceName"] = getInterfaceNameToType(parameters["currentActiveInterface"].String());

m_defaultInterface = parameters["currentActiveInterface"].String();

string json;
legacyParams.ToString(json);

Expand Down Expand Up @@ -1049,9 +1055,6 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN+1] = {

Notify("onIPAddressStatusChanged", legacyParams);

// if ("ACQUIRED" == parameters["status"].String())
// m_defaultInterface = parameters["interface"].String();

return;
}

Expand Down
3 changes: 1 addition & 2 deletions LegacyPlugin_NetworkAPIs.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace WPEFramework {
uint32_t getCaptivePortalURI(const JsonObject& parameters, JsonObject& response);
uint32_t stopConnectivityMonitoring(const JsonObject& parameters, JsonObject& response);
uint32_t getPublicIP(const JsonObject& parameters, JsonObject& response);
uint32_t setStunEndPoint(const JsonObject& parameters, JsonObject& response);
uint32_t setStunEndpoint(const JsonObject& parameters, JsonObject& response);
uint32_t getStbIp(const JsonObject& parameters, JsonObject& response);
uint32_t getSTBIPFamily(const JsonObject& parameters, JsonObject& response);

Expand Down Expand Up @@ -88,7 +88,6 @@ namespace WPEFramework {
PluginHost::IShell* m_service;
std::shared_ptr<WPEFramework::JSONRPC::SmartLinkType<WPEFramework::Core::JSON::IElement>> m_networkmanager;
//WPEFramework::Exchange::INetworkManager* m_nwmgr;
string m_defaultInterface;
NetworkManagerTimer m_timer;

bool m_subsIfaceStateChange;
Expand Down
6 changes: 6 additions & 0 deletions LegacyPlugin_WiFiManagerAPIs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,13 @@ namespace WPEFramework

void WiFiManager::Deinitialize(PluginHost::IShell* /* service */)
{
m_timer.stop();
unregisterLegacyMethods();

if (m_networkmanager)
m_networkmanager.reset();

m_networkmanager = NULL;
m_service->Release();
m_service = nullptr;
_gWiFiInstance = nullptr;
Expand Down
19 changes: 12 additions & 7 deletions NetworkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ namespace WPEFramework
*/
const string NetworkManager::Initialize(PluginHost::IShell *service)
{
string message{};
// Make sure everything is null as we expect
ASSERT(_service == nullptr);
ASSERT(_networkManager == nullptr);
Expand All @@ -84,20 +85,24 @@ namespace WPEFramework
// Still running inside the main WPEFramework process - the child process will have now been spawned and registered if necessary
if (_networkManager != nullptr)
{
// set the plugin configuration
Exchange::INetworkManager::Logging _loglevel;
_networkManager->Configure(_service->ConfigLine());
if (_networkManager->Configure(service) != Core::ERROR_NONE)
{
SYSLOG(Logging::Startup, (_T("Configuring NetworkManager")));
message = _T("NetworkManager failed to configure");
}

// configure loglevel in libWPEFrameworkNetworkManager.so
// Set the plugin log level
Exchange::INetworkManager::Logging _loglevel;
_networkManager->GetLogLevel(_loglevel);
NetworkManagerLogger::SetLevel(static_cast <NetworkManagerLogger::LogLevel>(_loglevel));


// Register Notifications
_networkManager->Register(&_notification);

// Register all custom JSON-RPC methods
RegisterAllMethods();


// Get IPlugin interface for this plugin
_networkManagerImpl = _networkManager->QueryInterface<PluginHost::IPlugin>();
}
Expand All @@ -109,11 +114,11 @@ namespace WPEFramework
_service = nullptr;

// Returning a string signals that we failed to initialize - WPEFramework will print this as an error message
return "Failed to initialize NetworkManager";
message = _T("Failed to initialize NetworkManager");
}

// Success
return "";
return message;
}

/**
Expand Down
8 changes: 8 additions & 0 deletions NetworkManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,14 @@ namespace WPEFramework
void Deinitialize(PluginHost::IShell *service) override;
string Information() const override;

//override Subscribe from IDispatcher
uint32_t Subscribe(const uint32_t channel, const string& event, const string& designator) override
{
NMLOG_DEBUG("Subscription received for %s event from channelID (%u) with designator as %s", event.c_str(), channel, designator.c_str());
JSONRPC::Subscribe(channel, event, designator);
return Core::ERROR_NONE;
}

// Do not allow copy/move constructors
NetworkManager(const NetworkManager &) = delete;
NetworkManager &operator=(const NetworkManager &) = delete;
Expand Down
4 changes: 2 additions & 2 deletions NetworkManager.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"status": "development",
"description": "A Unified `NetworkManager` plugin that allows you to manage Ethernet and Wifi interfaces on the device.",
"sourcelocation": "https://github.com/rdkcentral/networkmanager/blob/main/NetworkManager.json",
"version": "0.6.0"
"version": "0.7.0"
},
"definitions": {
"success": {
Expand Down Expand Up @@ -1242,7 +1242,7 @@
}
},
"GetWiFiSignalStrength":{
"summary": "Get WiFiSignalStrength of connected SSID. The signal quality is identifed based on the signal strength. The possible states are \n* 'Excellent' \n* 'Good' \n* 'Fair' \n* 'Weak' \n* 'Disconnected' \n",
"summary": "Get WiFiSignalStrength of connected SSID. The signal quality is identifed based on the signal strength. The possible states are\n* 'Excellent'\n* 'Good'\n* 'Fair'\n* 'Weak'\n* 'Disconnected'\n",
"events":{
"onWiFiSignalStrengthChange" : "Triggered when Wifi signal strength switches between Excellent, Good, Fair, Weak."
},
Expand Down
Loading

0 comments on commit 259291b

Please sign in to comment.