Skip to content

Topic/rdkemw 16330#192

Open
jthomp007c wants to merge 7 commits intodevelopfrom
topic/RDKEMW-16330
Open

Topic/rdkemw 16330#192
jthomp007c wants to merge 7 commits intodevelopfrom
topic/RDKEMW-16330

Conversation

@jthomp007c
Copy link
Copy Markdown
Contributor

No description provided.

egalla204 and others added 3 commits March 6, 2026 10:25
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 <jason_thomson@comcast.com>
@jthomp007c jthomp007c requested a review from a team as a code owner April 2, 2026 19:51
Copilot AI review requested due to automatic review settings April 2, 2026 19:51
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the Thunder plugin wrapper with a boolean-returning JSONRPC helper and updates the PowerManager Thunder integration to use it, while also making small doc/comment adjustments.

Changes:

  • Added call_plugin_boolean() to invoke Thunder methods that return a JSONRPC boolean result.
  • Updated PowerManager getNetworkStandbyMode flow to use the new boolean helper instead of parsing a JsonObject response.
  • Corrected/expanded several header comments (though a few docstrings are now inconsistent with signatures).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
src/thunder/ctrlm_thunder_plugin.h Updates/introduces API documentation for plugin/property calls and adds the call_plugin_boolean declaration.
src/thunder/ctrlm_thunder_plugin.cpp Implements call_plugin_boolean() using Invoke<..., Core::JSON::Boolean>.
src/thunder/ctrlm_thunder_plugin_powermanager.cpp Switches getNetworkStandbyMode to the boolean helper and updates wakeup-reason comparison.
Comments suppressed due to low confidence (1)

src/thunder/ctrlm_thunder_plugin.h:142

  • In the call_controller doc comment, the third @param is labeled params again, but it refers to the response object. This makes the API docs ambiguous; please rename it to @param response (and keep the descriptions consistent with call_plugin).
    /**
     * 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)
     * @return True if the call succeeded, otherwise False.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 108 to 115
@@ -115,7 +115,7 @@ class ctrlm_thunder_plugin_t {
bool property_get(std::string property, void *response, unsigned int retries = 0);
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The docstring for property_get looks incorrect: it refers to @param method and @param params, but the signature is property_get(std::string property, void *response, ...) and there is no params argument. Please update the parameter names/descriptions to match the actual API to avoid misleading callers.

Copilot uses AI. Check for mistakes.
Comment on lines +131 to +132
* @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.
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The call_plugin_boolean doc comment doesn’t match the function signature: it documents a JsonObject response and a retries parameter, but the signature takes bool *response and has no retries argument. Please adjust the comment (or add a retries argument) so the header accurately describes the API.

Suggested change
* @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.
* @param response A pointer to the boolean response value from the call.

Copilot uses AI. Check for mistakes.
Comment on lines +266 to +276
auto clientObject = (JSONRPC::LinkType<Core::JSON::IElement>*)this->plugin_client;
JsonObject *jsonParams = (JsonObject *)params;
if(clientObject) {
if(!method.empty() && jsonParams && response) {
Core::JSON::Boolean jsonResponse;
uint32_t thunderRet = clientObject->Invoke<JsonObject, Core::JSON::Boolean>(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;
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

call_plugin_boolean does not implement timeout retry behavior like property_get and call_plugin (which retry on Core::ERROR_TIMEDOUT up to retries). If callers need the same robustness, consider adding an optional retries parameter and reusing the same retry loop/logging pattern to keep behavior consistent across Thunder calls.

Suggested change
auto clientObject = (JSONRPC::LinkType<Core::JSON::IElement>*)this->plugin_client;
JsonObject *jsonParams = (JsonObject *)params;
if(clientObject) {
if(!method.empty() && jsonParams && response) {
Core::JSON::Boolean jsonResponse;
uint32_t thunderRet = clientObject->Invoke<JsonObject, Core::JSON::Boolean>(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;
unsigned int attempts = 0;
const unsigned int retries = REGISTER_EVENTS_RETRY_MAX;
auto clientObject = (JSONRPC::LinkType<Core::JSON::IElement>*)this->plugin_client;
JsonObject *jsonParams = (JsonObject *)params;
if(clientObject) {
if(!method.empty() && jsonParams && response) {
Core::JSON::Boolean jsonResponse;
uint32_t thunderRet = Core::ERROR_TIMEDOUT;
while(thunderRet == Core::ERROR_TIMEDOUT && attempts <= retries) { // We only want to retry if return code is for TIMEDOUT
thunderRet = clientObject->Invoke<JsonObject, Core::JSON::Boolean>(CALL_TIMEOUT, _T(method), *jsonParams, jsonResponse);
if(thunderRet == Core::ERROR_NONE) {
*response = jsonResponse.Value();
ret = true;
} else {
attempts += 1;
XLOGD_ERROR("Thunder call failed <%s> <%u>, attempt %u of %u", method.c_str(), thunderRet, attempts, (thunderRet == Core::ERROR_TIMEDOUT ? retries : 0) + 1); // retries + initial attempt
}

Copilot uses AI. Check for mistakes.
Comment on lines +273 to +282
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__);
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

Logging in call_plugin_boolean includes explicit \n newlines and prefixes with __FUNCTION__, while other methods in this file log without trailing newlines and with consistent message formats. Consider aligning these logs with the surrounding conventions to avoid double-newlines and improve log consistency.

Suggested change
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__);
XLOGD_ERROR("Thunder call failed <%s> <%u>", method.c_str(), thunderRet);
} else {
*response = jsonResponse.Value();
ret = true;
}
} else {
XLOGD_ERROR("Invalid parameters");
}
} else {
XLOGD_ERROR("Client is NULL");

Copilot uses AI. Check for mistakes.
sem_wait(&this->semaphore);
if(this->call_plugin("getLastWakeupReason", (void *)&params, (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));
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

This uses strncmp(..., "WAKEUP_REASON_VOICE", 19) with a hard-coded length. To avoid magic numbers and potential off-by-one/partial-match issues, consider comparing the full string (or computing the length via strlen/std::string_view) so the check stays correct if the constant changes.

Suggested change
wakeup_reason_voice = (0 == strncmp(response["result"].String().c_str(), "WAKEUP_REASON_VOICE", 19));
wakeup_reason_voice = (response["result"].String() == "WAKEUP_REASON_VOICE");

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings April 2, 2026 22:34
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

src/thunder/ctrlm_thunder_plugin.h:112

  • The docstring still refers to a method parameter, but the function signature is property_get(std::string property, ...). This is misleading for callers/maintainers—please update the @param name/description to refer to the property being retrieved (and consider aligning wording with property_get).
     * 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)
     * @param retries The number of retries if the call times out.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

sem_wait(&this->semaphore);
if(this->call_plugin("getLastWakeupReason", (void *)&params, (void *)&response)) {
wakeup_reason_voice = (0 == strncmp(response["result"].String().c_str(), "VOICE", 5));
wakeup_reason_voice = (response["result"].String() == "WAKEUP_REASON_VOICE");
Copy link

Copilot AI Apr 2, 2026

Choose a reason for hiding this comment

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

The PowerManager Thunder JSONRPC getLastWakeupReason appears (per the curl example above) to return plain strings like "COLDBOOT"; the existing IARM path also uses strings like "VOICE". Comparing to "WAKEUP_REASON_VOICE" will likely never match and will prevent voice wake detection. Consider checking for "VOICE" (and optionally supporting both formats if needed).

Suggested change
wakeup_reason_voice = (response["result"].String() == "WAKEUP_REASON_VOICE");
string wakeup_reason = response["result"].String();
wakeup_reason_voice = (wakeup_reason == "VOICE" || wakeup_reason == "WAKEUP_REASON_VOICE");

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings April 3, 2026 16:36
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (1)

src/thunder/ctrlm_thunder_plugin.h:112

  • The docblock for property_get has an incorrect @param method entry, but the function parameter is named property. This is misleading for callers; update the tag/description to match the actual parameter name and meaning.
     * 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)
     * @param retries The number of retries if the call times out.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants