Skip to content

Commit

Permalink
DELIA-66446 : Implement RDKLogger Support to NetworkManager Plugin
Browse files Browse the repository at this point in the history
Reason for change: Implement RDKLogger Support to NetworkManager Plugin
Test Procedure: Verify logs are printed properly
Risks: Low
Signed-off-by: Karunakaran A <[email protected]>
  • Loading branch information
karuna2git committed Oct 1, 2024
1 parent 5bc1b30 commit f2cba41
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 31 deletions.
17 changes: 16 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ add_compile_definitions(NETWORKMANAGER_PATCH_VERSION=${VERSION_PATCH})

set(PROJECT_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})


include(CmakeHelperFunctions)

option(USE_RDK_LOGGER "Enable RDK Logger for logging" OFF )

string(TOLOWER ${NAMESPACE} STORAGE_DIRECTORY)
get_directory_property(SEVICES_DEFINES COMPILE_DEFINITIONS)

Expand Down Expand Up @@ -60,6 +61,20 @@ message("Setup ${PROJECT_NAME} v${PROJECT_VERSION}")

set(PLUGIN_NETWORKMANAGER_LOGLEVEL "5" CACHE STRING "To configure default loglevel NetworkManager plugin")

if (USE_RDK_LOGGER)
find_package(rdklogger REQUIRED)
add_definitions(-DUSE_RDK_LOGGER)

include_directories(${RDKLOGGER_INCLUDE_DIRS})

add_dependencies(${MODULE_NAME} rdklogger)
add_dependencies(${PLUGIN_LEGACY_DEPRECATED_NETWORK} rdklogger)
add_dependencies(${PLUGIN_LEGACY_DEPRECATED_WIFI} rdklogger)

target_link_libraries(${MODULE_NAME} PRIVATE ${RDKLOGGER_LIBRARIES})
target_link_libraries(${PLUGIN_LEGACY_DEPRECATED_NETWORK} PRIVATE ${RDKLOGGER_LIBRARIES})
target_link_libraries(${PLUGIN_LEGACY_DEPRECATED_WIFI} PRIVATE ${RDKLOGGER_LIBRARIES})
endif (USE_RDK_LOGGER)

include_directories(${PROJECT_SOURCE_DIR})
# Build the main plugin that runs inside the WPEFramework daemon
Expand Down
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Contributing
============

If you would like to contribute code to this project you can do so through GitHub by forking the repository and sending a pull request. Before RDK accepts your code into the project you must sign the RDK Contributor License Agreement (CLA).
4 changes: 2 additions & 2 deletions NetworkManagerImplementation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ namespace WPEFramework
snprintf(cmd, sizeof(cmd), "ping -c %d -W %d '%s' 2>&1", noOfRequest, timeOutInSeconds, endpoint.c_str());
}

NMLOG_INFO ("The Command is %s", cmd);
NMLOG_TRACE ("The Command is %s", cmd);
string commandToExecute(cmd);
executeExternally(NETMGR_PING, commandToExecute, response);

Expand All @@ -321,7 +321,7 @@ namespace WPEFramework
snprintf(cmd, 256, "traceroute -w 3 -m 6 -q %d %s 52 2>&1", noOfRequest, endpoint.c_str());
}

NMLOG_INFO ("The Command is %s", cmd);
NMLOG_TRACE ("The Command is %s", cmd);
string commandToExecute(cmd);
executeExternally(NETMGR_TRACE, commandToExecute, tempResult);

Expand Down
2 changes: 1 addition & 1 deletion NetworkManagerLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#endif

namespace NetworkManagerLogger {
static LogLevel gDefaultLogLevel = TRACE_LEVEL;
static LogLevel gDefaultLogLevel = INFO_LEVEL;

const char* methodName(const std::string& prettyFunction)
{
Expand Down
47 changes: 23 additions & 24 deletions NetworkManagerRDKProxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,8 @@ namespace WPEFramework
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_NO_SSID:
return Exchange::INetworkManager::WIFI_STATE_SSID_NOT_FOUND;
case WIFI_UNKNOWN:
return Exchange::INetworkManager::WIFI_STATE_ERROR;
}
Expand Down Expand Up @@ -818,23 +818,22 @@ namespace WPEFramework

strncpy(iarmData.ipversion, ipversion.c_str(), 16);
iarmData.isSupported = true;
NMLOG_INFO("NetworkManagerImplementation::GetIPSettings - Before Calling IARM");

if (IARM_RESULT_SUCCESS == IARM_Bus_Call (IARM_BUS_NM_SRV_MGR_NAME, IARM_BUS_NETSRVMGR_API_getIPSettings, (void *)&iarmData, sizeof(iarmData)))
{
NMLOG_INFO("NetworkManagerImplementation::GetIPSettings - IARM Success.. Filling the data");
NMLOG_TRACE("NetworkManagerImplementation::GetIPSettings - IARM Success.. Filling the data");
result.m_ipAddrType = string(iarmData.ipversion);
result.m_autoConfig = iarmData.autoconfig;
result.m_dhcpServer = string(iarmData.dhcpserver,MAX_IP_ADDRESS_LEN - 1);
result.m_v6LinkLocal = "";
result.m_ipAddress = string(iarmData.ipaddress,MAX_IP_ADDRESS_LEN - 1);
if (0 == strcasecmp("ipv4", iarmData.ipversion))
result.m_prefix = NetmaskToPrefix(iarmData.netmask);
else if (0 == strcasecmp("ipv6", iarmData.ipversion))
else if (0 == strcasecmp("ipv6", iarmData.ipversion))
result.m_prefix = std::atoi(iarmData.netmask);
result.m_gateway = string(iarmData.gateway,MAX_IP_ADDRESS_LEN - 1);
result.m_primaryDns = string(iarmData.primarydns,MAX_IP_ADDRESS_LEN - 1);
result.m_secondaryDns = string(iarmData.secondarydns,MAX_IP_ADDRESS_LEN - 1);
NMLOG_INFO("NetworkManagerImplementation::GetIPSettings - IARM Success.. Filled the data");
rc = Core::ERROR_NONE;
}
else
Expand Down Expand Up @@ -1214,36 +1213,36 @@ const string CIDR_PREFIXES[CIDR_NETMASK_IP_LEN] = {
signalStrength = ssidInfo.m_signalStrength;

if (!signalStrength.empty())
{
{
signalStrengthOut = std::stof(signalStrength.c_str());
NMLOG_INFO ("WiFiSignalStrength in dB = %s",signalStrengthOut);
}
NMLOG_INFO ("WiFiSignalStrength in dB = %s",signalStrengthOut);
}

if (signalStrengthOut == 0)
{
{
quality = WIFI_SIGNAL_DISCONNECTED;
signalStrength = "0";
}
signalStrength = "0";
}
else if (signalStrengthOut >= signalStrengthThresholdExcellent && signalStrengthOut < 0)
{
{
quality = WIFI_SIGNAL_EXCELLENT;
signalStrength = "100";
}
signalStrength = "100";
}
else if (signalStrengthOut >= signalStrengthThresholdGood && signalStrengthOut < signalStrengthThresholdExcellent)
{
{
quality = WIFI_SIGNAL_GOOD;
signalStrength = "75";
}
signalStrength = "75";
}
else if (signalStrengthOut >= signalStrengthThresholdFair && signalStrengthOut < signalStrengthThresholdGood)
{
{
quality = WIFI_SIGNAL_FAIR;
signalStrength = "50";
}
signalStrength = "50";
}
else
{
{
quality = WIFI_SIGNAL_WEAK;
signalStrength = "25";
}
signalStrength = "25";
}

NMLOG_INFO ("GetWiFiSignalStrength success");
rc = Core::ERROR_NONE;
Expand Down
5 changes: 2 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ The documentation for legacy [Network](https://github.com/rdkcentral/rdkservices

## Release ##
There are 2 active branches namely `develop` and `main`. As the name conveys, `develop` branch is for active development and for contributions.
The Plugin workflow verifies every PR and also the team verifies the plugin on the RPi and RDK Device
The Plugin workflow verifies every PR and also the team verifies the plugin on the RPi and RDK Device. The verified changes are taken to `main` branch and releases will be made from there

## Questions? ##
If you have any questions or concerns reach out to [Jacob Gladish](mailto:[email protected])
and [Karunakaran Amirthalingam](mailto:[email protected]).
If you have any questions or concerns reach out to [Jacob Gladish](mailto:[email protected]) and [Karunakaran Amirthalingam](mailto:[email protected]).

38 changes: 38 additions & 0 deletions cmake/Findrdklogger.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#############################################################################
# If not stated otherwise in this file or this component's Licenses.txt file
# the following copyright and licenses apply:
#
# Copyright 2016 RDK Management
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#############################################################################

find_package(PkgConfig)

find_library(RDKLOGGER_LIBRARIES NAMES rdkloggers)
find_path(RDKLOGGER_INCLUDE_DIRS NAMES rdk_debug.h)

set(RDKLOGGER_LIBRARIES ${RDKLOGGER_LIBRARIES} CACHE PATH "Path to rdkLogger library")
set(RDKLOGGER_INCLUDE_DIRS ${RDKLOGGER_INCLUDE_DIRS} )
set(RDKLOGGER_INCLUDE_DIRS ${RDKLOGGER_INCLUDE_DIRS} CACHE PATH "Path to rdkLogger include")

include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(RDKLOGGER DEFAULT_MSG RDKLOGGER_INCLUDE_DIRS RDKLOGGER_LIBRARIES)

mark_as_advanced(
RDKLOGGER_FOUND
RDKLOGGER_INCLUDE_DIRS
RDKLOGGER_LIBRARIES
RDKLOGGER_LIBRARY_DIRS
RDKLOGGER_FLAGS)

0 comments on commit f2cba41

Please sign in to comment.