From 4b93098dd02ee5a32d0d7710c24b4f6905483188 Mon Sep 17 00:00:00 2001 From: jthomp007c Date: Mon, 30 Mar 2026 14:32:21 +0000 Subject: [PATCH 1/6] RDKEMW-16330: Update Control Manager to use bool for NSM Reason for Chanage: RDK-E uses a boolean to report whether Networked Standby Mode is enabled, rather than a JsonObject Test Procedure: Confirm that Control Manager enters NSM when it should Risks: This change might not work in RDK-V. We'll test to check, for now this change is only on an RDK-E release branch Priority: P0 Signed-off-by: Jason Thomson --- src/thunder/ctrlm_thunder_plugin.cpp | 23 +++++++++++++++++++ src/thunder/ctrlm_thunder_plugin.h | 16 ++++++++++--- .../ctrlm_thunder_plugin_powermanager.cpp | 9 ++++---- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/thunder/ctrlm_thunder_plugin.cpp b/src/thunder/ctrlm_thunder_plugin.cpp index 3040fae5..0eee5808 100644 --- a/src/thunder/ctrlm_thunder_plugin.cpp +++ b/src/thunder/ctrlm_thunder_plugin.cpp @@ -261,6 +261,29 @@ bool ctrlm_thunder_plugin_t::call_plugin(std::string method, void *params, void return(ret); } +bool ctrlm_thunder_plugin_t::call_plugin_boolean(std::string method, void *params, bool *response) { + bool ret = false; + auto clientObject = (JSONRPC::LinkType*)this->plugin_client; + JsonObject *jsonParams = (JsonObject *)params; + if(clientObject) { + if(!method.empty() && jsonParams && response) { + Core::JSON::Boolean jsonResponse; + uint32_t thunderRet = clientObject->Invoke(CALL_TIMEOUT, _T(method), *jsonParams, jsonResponse); + if(thunderRet != Core::ERROR_NONE) { + XLOGD_ERROR("%s: Thunder call failed <%s> <%u>\n", __FUNCTION__, method.c_str(), thunderRet); + } else { + *response = jsonResponse.Value(); + ret = true; + } + } else { + XLOGD_ERROR("%s: Invalid parameters\n", __FUNCTION__); + } + } else { + XLOGD_ERROR("%s: Client is NULL\n", __FUNCTION__); + } + return(ret); +} + bool ctrlm_thunder_plugin_t::call_controller(std::string method, void *params, void *response) { bool ret = false; if(this->controller) { diff --git a/src/thunder/ctrlm_thunder_plugin.h b/src/thunder/ctrlm_thunder_plugin.h index f1a3944a..38a39e01 100644 --- a/src/thunder/ctrlm_thunder_plugin.h +++ b/src/thunder/ctrlm_thunder_plugin.h @@ -105,7 +105,7 @@ class ctrlm_thunder_plugin_t { std::string callsign_with_api(); /** - * This functions is used to get a Thunder Plugin property. + * This function is used to get a Thunder Plugin property. * @param method The method in which the user wants to call. * @param params The WPEFramework JsonObject containing the parameters for the call. (We can't include WPEFramework headers in controlMgr .h files as their logging macros clash) * @param response The WPEFramework JsonObject containing the response from the call. (We can't include WPEFramework headers in controlMgr .h files as their logging macros clash) @@ -115,7 +115,7 @@ class ctrlm_thunder_plugin_t { bool property_get(std::string property, void *response, unsigned int retries = 0); /** - * This functions is used to call a Thunder Plugin method. + * This function is used to call a Thunder Plugin method. * @param method The method in which the user wants to call. * @param params The WPEFramework JsonObject containing the parameters for the call. (We can't include WPEFramework headers in controlMgr .h files as their logging macros clash) * @param response The WPEFramework JsonObject containing the response from the call. (We can't include WPEFramework headers in controlMgr .h files as their logging macros clash) @@ -125,7 +125,17 @@ class ctrlm_thunder_plugin_t { bool call_plugin(std::string method, void *params, void *response, unsigned int retries = 0); /** - * This functions is used to call a Thunder Controller method. + * This function is used to call a Thunder Plugin method. + * @param method The method in which the user wants to call. + * @param params The WPEFramework JsonObject containing the parameters for the call. (We can't include WPEFramework headers in controlMgr .h files as their logging macros clash) + * @param response The WPEFramework JsonObject containing the response from the call. (We can't include WPEFramework headers in controlMgr .h files as their logging macros clash) + * @param retries The number of retries if the call times out. + * @return True if the call succeeded, otherwise False. + */ + bool call_plugin_boolean(std::string method, void *params, bool *response); + + /** + * This function is used to call a Thunder Controller method. * @param method The method in which the user wants to call. * @param params The WPEFramework JsonObject containing the parameters for the call. (We can't include WPEFramework headers in controlMgr .h files as their logging macros clash) * @param params The WPEFramework JsonObject containing the response from the call. (We can't include WPEFramework headers in controlMgr .h files as their logging macros clash) diff --git a/src/thunder/ctrlm_thunder_plugin_powermanager.cpp b/src/thunder/ctrlm_thunder_plugin_powermanager.cpp index 6e0c83b0..eca59c62 100755 --- a/src/thunder/ctrlm_thunder_plugin_powermanager.cpp +++ b/src/thunder/ctrlm_thunder_plugin_powermanager.cpp @@ -89,16 +89,15 @@ ctrlm_power_state_t ctrlm_thunder_plugin_powermanager_t::get_power_state() { /* root@pioneer-uhd:~# curl --request POST --url http://127.0.0.1:9998/jsonrpc --header 'Content-Type: application/json' --data '{ "jsonrpc": "2.0", "id": 1234567890, "method": "org.rdk.PowerManager.1.getNetworkStandbyMode", "params": {} }' {"jsonrpc":"2.0","id":1234567890,"result":true} */ bool ctrlm_thunder_plugin_powermanager_t::get_networked_standby_mode() { - JsonObject params, response; + JsonObject params; params = {}; bool networked_standby_mode = false; - sem_wait(&this->semaphore); - if(this->call_plugin("getNetworkStandbyMode", (void *)¶ms, (void *)&response)) { - networked_standby_mode = response["result"].Boolean(); + sem_wait(&this->semaphore); + if(this->call_plugin_boolean("getNetworkStandbyMode", (void *)¶ms, &networked_standby_mode)) { XLOGD_DEBUG("networked_standby_mode is %s", networked_standby_mode?"TRUE":"FALSE"); } else { - XLOGD_ERROR("getNetworkedStandbyMode call failed"); + XLOGD_ERROR("getNetworkStandbyMode call failed"); } sem_post(&this->semaphore); From e001a47dba0d0f2e4ba6fb780ebcd5d4ef2b3cb3 Mon Sep 17 00:00:00 2001 From: jthomp007c Date: Thu, 2 Apr 2026 19:49:53 +0000 Subject: [PATCH 2/6] Changing getWakeupReason string expectationwq --- src/thunder/ctrlm_thunder_plugin_powermanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thunder/ctrlm_thunder_plugin_powermanager.cpp b/src/thunder/ctrlm_thunder_plugin_powermanager.cpp index eca59c62..180923c7 100755 --- a/src/thunder/ctrlm_thunder_plugin_powermanager.cpp +++ b/src/thunder/ctrlm_thunder_plugin_powermanager.cpp @@ -113,7 +113,7 @@ bool ctrlm_thunder_plugin_powermanager_t::get_wakeup_reason_voice() { sem_wait(&this->semaphore); if(this->call_plugin("getLastWakeupReason", (void *)¶ms, (void *)&response)) { - wakeup_reason_voice = (0 == strncmp(response["result"].String().c_str(), "VOICE", 5)); + wakeup_reason_voice = (0 == strncmp(response["result"].String().c_str(), "WAKEUP_REASON_VOICE", 19)); XLOGD_DEBUG("voice_wakeup is %s", wakeup_reason_voice?"TRUE":"FALSE"); } else { XLOGD_ERROR("getLastWakeupReason call failed"); From 6479c825abe63c395a34d950b3949bc91159be53 Mon Sep 17 00:00:00 2001 From: jthomp007c Date: Thu, 2 Apr 2026 22:30:41 +0000 Subject: [PATCH 3/6] Improve string comparison --- src/thunder/ctrlm_thunder_plugin_powermanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thunder/ctrlm_thunder_plugin_powermanager.cpp b/src/thunder/ctrlm_thunder_plugin_powermanager.cpp index 180923c7..eb9b35e0 100755 --- a/src/thunder/ctrlm_thunder_plugin_powermanager.cpp +++ b/src/thunder/ctrlm_thunder_plugin_powermanager.cpp @@ -113,7 +113,7 @@ bool ctrlm_thunder_plugin_powermanager_t::get_wakeup_reason_voice() { sem_wait(&this->semaphore); if(this->call_plugin("getLastWakeupReason", (void *)¶ms, (void *)&response)) { - wakeup_reason_voice = (0 == strncmp(response["result"].String().c_str(), "WAKEUP_REASON_VOICE", 19)); + wakeup_reason_voice = (response["result"].String() == "WAKEUP_REASON_VOICE"); XLOGD_DEBUG("voice_wakeup is %s", wakeup_reason_voice?"TRUE":"FALSE"); } else { XLOGD_ERROR("getLastWakeupReason call failed"); From 9521142416dc9be76fa30be9573cc6d6db08c5b0 Mon Sep 17 00:00:00 2001 From: jthomp007c Date: Thu, 2 Apr 2026 22:33:50 +0000 Subject: [PATCH 4/6] Clean up error log --- src/thunder/ctrlm_thunder_plugin.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/thunder/ctrlm_thunder_plugin.cpp b/src/thunder/ctrlm_thunder_plugin.cpp index 0eee5808..380282a4 100644 --- a/src/thunder/ctrlm_thunder_plugin.cpp +++ b/src/thunder/ctrlm_thunder_plugin.cpp @@ -270,16 +270,16 @@ bool ctrlm_thunder_plugin_t::call_plugin_boolean(std::string method, void *param Core::JSON::Boolean jsonResponse; uint32_t thunderRet = clientObject->Invoke(CALL_TIMEOUT, _T(method), *jsonParams, jsonResponse); if(thunderRet != Core::ERROR_NONE) { - XLOGD_ERROR("%s: Thunder call failed <%s> <%u>\n", __FUNCTION__, method.c_str(), thunderRet); + XLOGD_ERROR("Thunder call failed <%s> <%u>", method.c_str(), thunderRet); } else { *response = jsonResponse.Value(); ret = true; } } else { - XLOGD_ERROR("%s: Invalid parameters\n", __FUNCTION__); + XLOGD_ERROR("Invalid parameters"); } } else { - XLOGD_ERROR("%s: Client is NULL\n", __FUNCTION__); + XLOGD_ERROR("Client is NULL"); } return(ret); } From 6319c52c324bfce4f2980e6260a1fd03f5525223 Mon Sep 17 00:00:00 2001 From: jthomp007c Date: Fri, 3 Apr 2026 13:13:54 +0000 Subject: [PATCH 5/6] Updating getWakeupReason --- src/thunder/ctrlm_thunder_plugin_powermanager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thunder/ctrlm_thunder_plugin_powermanager.cpp b/src/thunder/ctrlm_thunder_plugin_powermanager.cpp index eb9b35e0..4539a829 100755 --- a/src/thunder/ctrlm_thunder_plugin_powermanager.cpp +++ b/src/thunder/ctrlm_thunder_plugin_powermanager.cpp @@ -113,7 +113,7 @@ bool ctrlm_thunder_plugin_powermanager_t::get_wakeup_reason_voice() { sem_wait(&this->semaphore); if(this->call_plugin("getLastWakeupReason", (void *)¶ms, (void *)&response)) { - wakeup_reason_voice = (response["result"].String() == "WAKEUP_REASON_VOICE"); + wakeup_reason_voice = (response["wakeupReason"].String() == "WAKEUP_REASON_VOICE"); XLOGD_DEBUG("voice_wakeup is %s", wakeup_reason_voice?"TRUE":"FALSE"); } else { XLOGD_ERROR("getLastWakeupReason call failed"); From 61990b534305450189273787c14607c63cb1b54a Mon Sep 17 00:00:00 2001 From: jthomp007c Date: Fri, 3 Apr 2026 16:36:06 +0000 Subject: [PATCH 6/6] Log wakeup reason string for debug --- src/thunder/ctrlm_thunder_plugin_powermanager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/thunder/ctrlm_thunder_plugin_powermanager.cpp b/src/thunder/ctrlm_thunder_plugin_powermanager.cpp index 4539a829..593e1bef 100755 --- a/src/thunder/ctrlm_thunder_plugin_powermanager.cpp +++ b/src/thunder/ctrlm_thunder_plugin_powermanager.cpp @@ -113,7 +113,8 @@ bool ctrlm_thunder_plugin_powermanager_t::get_wakeup_reason_voice() { sem_wait(&this->semaphore); if(this->call_plugin("getLastWakeupReason", (void *)¶ms, (void *)&response)) { - wakeup_reason_voice = (response["wakeupReason"].String() == "WAKEUP_REASON_VOICE"); + XLOGD_INFO("received <%s>", response["result"].String().c_str()); + wakeup_reason_voice = (std::string(response["result"].String()) == "VOICE"); XLOGD_DEBUG("voice_wakeup is %s", wakeup_reason_voice?"TRUE":"FALSE"); } else { XLOGD_ERROR("getLastWakeupReason call failed");