Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ PKG_CHECK_MODULES([DBUS], [dbus-1])

AC_CHECK_LIB(gthread-2.0, g_thread_init)

# Thunder COM-RPC plugin support
AC_ARG_ENABLE([thunder-plugin],
AS_HELP_STRING([--enable-thunder-plugin], [Enable Thunder COM-RPC plugin support (default: no)]),
[enable_thunder_plugin=$enableval],
[enable_thunder_plugin=no])

AM_CONDITIONAL([USE_THUNDER_PLUGIN], [test "x$enable_thunder_plugin" = "xyes"])

AS_IF([test "x$enable_thunder_plugin" = "xyes"],
[AC_DEFINE([USE_WPE_THUNDER_PLUGIN], [1], [Define to 1 to enable Thunder COM-RPC plugin support])
AC_MSG_NOTICE([Thunder COM-RPC plugin support enabled])],
Comment on lines +62 to +63
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--enable-thunder-plugin only AC_DEFINEs USE_WPE_THUNDER_PLUGIN into cfg/config.h, but no source in this repo includes config.h and the build files don’t add -DUSE_WPE_THUNDER_PLUGIN, so the option will not actually enable the Thunder codepaths. Also, enabling this feature doesn’t check for required Thunder headers/libs (WPEFrameworkCore/COM), so configure can succeed and fail later at build/link. Consider adding proper detection (PKG_CHECK_MODULES/AC_CHECK_LIB+AC_CHECK_HEADERS) and exporting the needed CPPFLAGS/LIBS when enabled.

Suggested change
[AC_DEFINE([USE_WPE_THUNDER_PLUGIN], [1], [Define to 1 to enable Thunder COM-RPC plugin support])
AC_MSG_NOTICE([Thunder COM-RPC plugin support enabled])],
[PKG_CHECK_MODULES([THUNDER],
[WPEFrameworkCore WPEFrameworkCOM],
[AC_DEFINE([USE_WPE_THUNDER_PLUGIN], [1], [Define to 1 to enable Thunder COM-RPC plugin support])
AC_MSG_NOTICE([Thunder COM-RPC plugin support enabled])],
[AC_MSG_ERROR([Thunder COM-RPC plugin support requested, but WPEFrameworkCore and/or WPEFrameworkCOM were not found])])],

Copilot uses AI. Check for mistakes.
[AC_MSG_NOTICE([Thunder COM-RPC plugin support disabled])])

# Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_PID_T
AC_TYPE_SIZE_T
Expand Down
4 changes: 3 additions & 1 deletion cov_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ cd ${RDK_SOURCE_PATH}
export STANDALONE_BUILD_ENABLED=y
export DS_MGRS=$WORKDIR

export USE_WPE_THUNDER_PLUGIN=y
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cov_build.sh script exports USE_WPE_THUNDER_PLUGIN=y but doesn't pass it as a compiler flag. The Makefile checks for USE_WPE_THUNDER_PLUGIN using ifdef, which checks if the variable is defined in the make environment or as a make variable, not as a shell environment variable. Either export it as a make variable using "export USE_WPE_THUNDER_PLUGIN" in the Makefile, or pass it to make using "make USE_WPE_THUNDER_PLUGIN=y", or add -DUSE_WPE_THUNDER_PLUGIN to CFLAGS.

Copilot uses AI. Check for mistakes.

find $WORKDIR -iname "*.o" -exec rm -v {} \;
find $WORKDIR -iname "*.so*" -exec rm -v {} \;

echo "##### Triggering make"
make CFLAGS+='-fPIC -DDSMGR_LOGGER_ENABLED=ON -DRDK_DSHAL_NAME=\"libdshal.so\" -I${DS_IF_PATH}/include -I${DS_HAL_PATH} -I${DS_MGRS}/stubs -I${IARMBUS_PATH}/core -I${IARMBUS_PATH}/core/include -I${IARM_MGRS}/sysmgr/include -I${DS_MGRS}/ds/include -I${DS_MGRS}/rpc/include -I${POWER_IF_PATH}/include/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I${IARM_MGRS}/mfr/include/ -I${IARM_MGRS}/mfr/common -I${DEEPSLEEP_IF_PATH}/include -I${IARM_MGRS}/hal/include -I${IARM_MGRS}/power -I${IARM_MGRS}/power/include' LDFLAGS="-L/usr/lib/x86_64-linux-gnu/ -L/usr/local/include -lglib-2.0 -lIARMBus -lWPEFrameworkPowerController -ldshal"
make CFLAGS+='-fPIC -DDSMGR_LOGGER_ENABLED=ON -DRDK_DSHAL_NAME=\"libdshal.so\" -I${DS_IF_PATH}/include -I${DS_HAL_PATH} -I${DS_MGRS}/stubs -I${IARMBUS_PATH}/core -I${IARMBUS_PATH}/core/include -I${IARM_MGRS}/sysmgr/include -I${DS_MGRS}/ds/include -I${DS_MGRS}/rpc/include -I${POWER_IF_PATH}/include/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I${IARM_MGRS}/mfr/include/ -I${IARM_MGRS}/mfr/common -I${DEEPSLEEP_IF_PATH}/include -I${IARM_MGRS}/hal/include -I${IARM_MGRS}/power -I${IARM_MGRS}/power/include' LDFLAGS="-L/usr/lib/x86_64-linux-gnu/ -L/usr/local/include -lglib-2.0 -lIARMBus -lWPEFrameworkPowerController -ldshal"
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The USE_WPE_THUNDER_PLUGIN environment variable is set on line 69, but the macro definition is not passed to the compiler in CFLAGS on line 75. The CFLAGS should include -DUSE_WPE_THUNDER_PLUGIN to ensure the conditional compilation directives (#ifdef USE_WPE_THUNDER_PLUGIN) in the source files work correctly. Without this, the Thunder code paths won't be compiled even though USE_WPE_THUNDER_PLUGIN is exported.

Suggested change
make CFLAGS+='-fPIC -DDSMGR_LOGGER_ENABLED=ON -DRDK_DSHAL_NAME=\"libdshal.so\" -I${DS_IF_PATH}/include -I${DS_HAL_PATH} -I${DS_MGRS}/stubs -I${IARMBUS_PATH}/core -I${IARMBUS_PATH}/core/include -I${IARM_MGRS}/sysmgr/include -I${DS_MGRS}/ds/include -I${DS_MGRS}/rpc/include -I${POWER_IF_PATH}/include/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I${IARM_MGRS}/mfr/include/ -I${IARM_MGRS}/mfr/common -I${DEEPSLEEP_IF_PATH}/include -I${IARM_MGRS}/hal/include -I${IARM_MGRS}/power -I${IARM_MGRS}/power/include' LDFLAGS="-L/usr/lib/x86_64-linux-gnu/ -L/usr/local/include -lglib-2.0 -lIARMBus -lWPEFrameworkPowerController -ldshal"
make CFLAGS+='-fPIC -DDSMGR_LOGGER_ENABLED=ON -DUSE_WPE_THUNDER_PLUGIN -DRDK_DSHAL_NAME=\"libdshal.so\" -I${DS_IF_PATH}/include -I${DS_HAL_PATH} -I${DS_MGRS}/stubs -I${IARMBUS_PATH}/core -I${IARMBUS_PATH}/core/include -I${IARM_MGRS}/sysmgr/include -I${DS_MGRS}/ds/include -I${DS_MGRS}/rpc/include -I${POWER_IF_PATH}/include/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I${IARM_MGRS}/mfr/include/ -I${IARM_MGRS}/mfr/common -I${DEEPSLEEP_IF_PATH}/include -I${IARM_MGRS}/hal/include -I${IARM_MGRS}/power -I${IARM_MGRS}/power/include' LDFLAGS="-L/usr/lib/x86_64-linux-gnu/ -L/usr/local/include -lglib-2.0 -lIARMBus -lWPEFrameworkPowerController -ldshal"

Copilot uses AI. Check for mistakes.
24 changes: 21 additions & 3 deletions rpc/cli/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,20 @@ CFLAGS += -g -fPIC -D_REENTRANT -Wall
LIBNAME := dshalcli
LIBNAMEFULL := lib$(LIBNAME).so
INSTALL := $(PWD)/install
OBJS := $(patsubst %.cpp,%.o,$(wildcard *.cpp))
OBJS += $(patsubst %.c,%.o,$(wildcard *.c))

# Conditional compilation: Thunder vs IARM
ifdef USE_WPE_THUNDER_PLUGIN
# Thunder mode - use *-com.cpp files, exclude legacy .c implementations
OBJS := $(patsubst %.cpp,%.o,$(wildcard *.cpp))
OBJS += $(patsubst %.c,%.o,$(filter-out dsFPD.c dsHdmiIn.c,$(wildcard *.c)))
else
# IARM mode - use legacy .c files, exclude Thunder -com.cpp implementations
OBJS := $(patsubst %.cpp,%.o,$(filter-out dsFPD-com.cpp dsHdmiIn-com.cpp dsConnectionManager.cpp,$(wildcard *.cpp)))
OBJS += $(patsubst %.c,%.o,$(wildcard *.c))
endif
Comment on lines 25 to 34
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When USE_WPE_THUNDER_PLUGIN is set, the build switches to dsFPD-com.cpp but does not add -DUSE_WPE_THUNDER_PLUGIN to the compiler flags. Because dsFPD-com.cpp wraps all symbols in #ifdef USE_WPE_THUNDER_PLUGIN, it will compile to an empty object and the FPD C API symbols will be missing (and dsFPD.c is excluded). Add the define to CFLAGS/CPPFLAGS in this branch (or remove the #ifdef from dsFPD-com.cpp and rely on build selection).

Copilot uses AI. Check for mistakes.

#OBJS := $(patsubst %.cpp,%.o,$(wildcard *.cpp))
#OBJS += $(patsubst %.c,%.o,$(wildcard *.c))
Comment on lines +36 to +37
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commented-out code on lines 36-37 should be removed. These appear to be the old versions of the lines that were replaced by the conditional compilation logic above. Leaving commented-out code can cause confusion and makes the codebase harder to maintain.

Suggested change
#OBJS := $(patsubst %.cpp,%.o,$(wildcard *.cpp))
#OBJS += $(patsubst %.c,%.o,$(wildcard *.c))

Copilot uses AI. Check for mistakes.
Comment on lines +36 to +37
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These commented-out lines should be removed rather than left as comments. Dead code in makefiles can cause confusion about the actual build logic.

Suggested change
#OBJS := $(patsubst %.cpp,%.o,$(wildcard *.cpp))
#OBJS += $(patsubst %.c,%.o,$(wildcard *.c))

Copilot uses AI. Check for mistakes.
INCLUDE := -I$(PWD) \
-I$(PWD)/hal/include \
-I$(PWD)/rpc/include
Expand All @@ -31,13 +43,19 @@ INCLUDE += $(HAL_INCLUDE)

CFLAGS += $(INCLUDE)

# Conditional linking flags
ifdef USE_WPE_THUNDER_PLUGIN
LDLIBS := -lWPEFrameworkCore -lWPEFrameworkCOM
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Thunder mode, LDLIBS is set to only -lWPEFrameworkCore/-lWPEFrameworkCOM, but most of the CLI objects (e.g., dsAudio.c/dsDisplay.c/dsHost.cpp) still call IARM_Bus_* APIs. Dropping -lIARMBus can lead to undefined-symbol failures at link/load time. Include -lIARMBus in Thunder mode as well (or gate the other IARM-based sources behind the same feature flag).

Suggested change
LDLIBS := -lWPEFrameworkCore -lWPEFrameworkCOM
LDLIBS := -lWPEFrameworkCore -lWPEFrameworkCOM -lIARMBus

Copilot uses AI. Check for mistakes.
else
LDLIBS := -lIARMBus
endif
Comment on lines +46 to +51
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When USE_WPE_THUNDER_PLUGIN is set as an environment variable or make variable, the Makefile correctly adjusts OBJS and LDLIBS. However, the C/C++ preprocessor directives in the source code also check for USE_WPE_THUNDER_PLUGIN. The Makefile should add -DUSE_WPE_THUNDER_PLUGIN to CFLAGS when this variable is set, otherwise the source files won't be compiled with the correct preprocessor definition.

Copilot uses AI. Check for mistakes.

all: install
@echo "Build Finished...."

library: $(OBJS)
@echo "Building $(LIBNAMEFULL) ...."
$(CXX) $(OBJS) $(CFLAGS) -lIARMBus -shared -o $(LIBNAMEFULL)
$(CXX) $(OBJS) $(CFLAGS) $(LDLIBS) -shared -o $(LIBNAMEFULL)

%.o: %.cpp
@echo "Building $@ ...."
Expand Down
19 changes: 18 additions & 1 deletion rpc/cli/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,21 @@ INCLUDE_FILES = -I=$(includedir)/rdk/halif/ds-hal \
lib_LTLIBRARIES = libdshalcli.la
libdshalcli_la_CPPFLAGS = $(INCLUDE_FILES)
libdshalcli_la_CFLAGS = -g -fPIC -D_REENTRANT -Wall
libdshalcli_la_SOURCES = dsAudio.c dsclientlogger.c dsDisplay.c dsFPD.c dsHost.cpp dsVideoDevice.c dsVideoPort.c

# Conditional compilation for Thunder COM-RPC
if USE_THUNDER_PLUGIN
FPD_SOURCE = dsFPD-com.cpp
HDMIIN_SOURCE = dsHdmiIn-com.cpp
COMPOSITEIN_SOURCE =
THUNDER_SOURCES = dsConnectionManager.cpp
THUNDER_LIBS = -lWPEFrameworkCore -lWPEFrameworkCOM
else
FPD_SOURCE = dsFPD.c
HDMIIN_SOURCE = dsHdmiIn.c
COMPOSITEIN_SOURCE = dsCompositeIn.c
THUNDER_SOURCES =
THUNDER_LIBS =
endif

libdshalcli_la_SOURCES = dsAudio.c dsclientlogger.c dsDisplay.c $(FPD_SOURCE) $(HDMIIN_SOURCE) $(COMPOSITEIN_SOURCE) $(THUNDER_SOURCES) dsHost.cpp dsVideoDevice.c dsVideoPort.c
libdshalcli_la_LIBADD = $(THUNDER_LIBS)
239 changes: 239 additions & 0 deletions rpc/cli/dsConnectionManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
/*
* If not stated otherwise in this file or this component's LICENSE file the

Check failure on line 2 in rpc/cli/dsConnectionManager.cpp

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'rpc/cli/dsConnectionManager.cpp' (Match: rdkcentral/unified-wifi-mesh/0.0.0-20251028151136-e65ddb1d9c2a, 15 lines, url: https://proxy.golang.org/github.com/rdkcentral/unified-wifi-mesh/@v/v0.0.0-20251028151136-e65ddb1d9c2a.zip, file: tests/test_l1_al_service_exception.cpp)
* following copyright and licenses apply:
*
* Copyright 2025 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.
*/

#ifdef USE_WPE_THUNDER_PLUGIN

#include <stdio.h>
#include <chrono>
#include <thread>
#include "dsConnectionManager.h"

using namespace WPEFramework;

namespace DeviceSettingsClient {

// Thunder callsign for DeviceSettings plugin
static constexpr const TCHAR callSign[] = _T("org.rdk.DeviceSettings");

// Static member initialization
ConnectionManager* ConnectionManager::_instance = nullptr;
Core::CriticalSection ConnectionManager::_dsConnectionManagerlock;

ConnectionManager::ConnectionManager()
: BaseClass()
, _fpdInterface(nullptr)
, _hdmiInInterface(nullptr)
, _connected(false)
, _shutdown(false)
{
printf("[dsConnectionManager] Initializing centralized connection manager\n");
(void)Connect();
}

ConnectionManager::~ConnectionManager()
{
printf("[dsConnectionManager] Destroying connection manager\n");
_shutdown = true;

// Release all component interfaces before closing base connection
if (_hdmiInInterface) {
_hdmiInInterface->Release();
_hdmiInInterface = nullptr;
}

if (_fpdInterface) {
_fpdInterface->Release();
_fpdInterface = nullptr;
}

BaseClass::Close(Core::infinite);
}

void ConnectionManager::Operational(const bool upAndRunning)
{
_dsConnectionManagerlock.Lock();

if (!_shutdown) {
printf("[dsConnectionManager] Operational callback: %s\n", upAndRunning ? "UP" : "DOWN");
}

if (upAndRunning) {
// Communicator opened && DeviceSettings is Activated
if (nullptr == _fpdInterface) {
printf("[dsConnectionManager] Plugin activated, acquiring primary FPD interface\n");
_fpdInterface = BaseClass::Interface();

if (_fpdInterface != nullptr) {
printf("[dsConnectionManager] Successfully established COM-RPC connection with DeviceSettings plugin\n");

// Acquire secondary interfaces via QueryInterface
if (nullptr == _hdmiInInterface) {
_hdmiInInterface = _fpdInterface->QueryInterface<Exchange::IDeviceSettingsHDMIIn>();
if (_hdmiInInterface != nullptr) {
printf("[dsConnectionManager] Successfully acquired HDMIIn interface via QueryInterface\n");
} else {
fprintf(stderr, "[dsConnectionManager] Failed to acquire HDMIIn interface via QueryInterface\n");
}
}

// Add more component interfaces here as needed:
// if (nullptr == _compositeInInterface) {
// _compositeInInterface = _fpdInterface->QueryInterface<Exchange::IDeviceSettingsCompositeIn>();
// }

} else {
fprintf(stderr, "[dsConnectionManager] Failed to get FPD interface - plugin implementation may have failed to load\n");
}
}
} else {
// DeviceSettings is Deactivated || Communicator closed
printf("[dsConnectionManager] Plugin deactivated, releasing all interfaces\n");

if (_hdmiInInterface != nullptr) {
_hdmiInInterface->Release();
_hdmiInInterface = nullptr;
}

if (_fpdInterface != nullptr) {
_fpdInterface->Release();
_fpdInterface = nullptr;
}
}

_dsConnectionManagerlock.Unlock();
}

void ConnectionManager::Init()
{
_dsConnectionManagerlock.Lock();
if (nullptr == _instance) {
_instance = new ConnectionManager();
}
_dsConnectionManagerlock.Unlock();
}

void ConnectionManager::Term()
{
_dsConnectionManagerlock.Lock();
if (nullptr != _instance) {
delete _instance;
_instance = nullptr;
}
_dsConnectionManagerlock.Unlock();
}

ConnectionManager* ConnectionManager::Instance()
{
return _instance;
}

bool ConnectionManager::IsOperational() const
{
_dsConnectionManagerlock.Lock();
bool result = (isConnected() && (nullptr != _fpdInterface));
_dsConnectionManagerlock.Unlock();
return result;
}

bool ConnectionManager::WaitForOperational(uint32_t timeoutMs) const
{
const uint32_t pollIntervalMs = 100;
uint32_t elapsedMs = 0;

while (elapsedMs < timeoutMs) {
if (IsOperational()) {
return true;
}
std::this_thread::sleep_for(std::chrono::milliseconds(pollIntervalMs));
elapsedMs += pollIntervalMs;
}
return false;
}

uint32_t ConnectionManager::Connect()
{
uint32_t status = Core::ERROR_NONE;

_dsConnectionManagerlock.Lock();

if (!isConnected()) {
printf("[dsConnectionManager] Attempting to connect to Thunder with callsign: %s\n", callSign);
uint32_t res = BaseClass::Open(RPC::CommunicationTimeOut, BaseClass::Connector(), callSign);
if (Core::ERROR_NONE == res) {
_connected = true;
printf("[dsConnectionManager] Successfully opened RPC connection to Thunder\n");
} else {
fprintf(stderr, "[dsConnectionManager] Failed to open RPC connection, error: %u. Is Thunder running?\n", res);
status = Core::ERROR_UNAVAILABLE;
}
} else {
printf("[dsConnectionManager] Already connected\n");
}

if (nullptr == _fpdInterface) {
status = Core::ERROR_NOT_EXIST;
printf("[dsConnectionManager] DeviceSettings plugin not yet operational, waiting for Operational() callback\n");
}

_dsConnectionManagerlock.Unlock();

return status;
}

uint32_t ConnectionManager::Disconnect()
{
uint32_t status = Core::ERROR_GENERAL;
bool close = false;

_dsConnectionManagerlock.Lock();

if (isConnected()) {
close = true;
_connected = false;
}

_dsConnectionManagerlock.Unlock();

if (close) {
status = BaseClass::Close(Core::infinite);
printf("[dsConnectionManager] Disconnected from Thunder\n");
}

return status;
}

Exchange::IDeviceSettingsFPD* ConnectionManager::GetFPDInterface()
{
_dsConnectionManagerlock.Lock();
Exchange::IDeviceSettingsFPD* interface = _fpdInterface;
_dsConnectionManagerlock.Unlock();
return interface;
}

Exchange::IDeviceSettingsHDMIIn* ConnectionManager::GetHDMIInInterface()
{
_dsConnectionManagerlock.Lock();
Exchange::IDeviceSettingsHDMIIn* interface = _hdmiInInterface;
_dsConnectionManagerlock.Unlock();
return interface;
}

} // namespace DeviceSettingsClient

#endif // USE_WPE_THUNDER_PLUGIN
Loading
Loading