Conversation
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>
There was a problem hiding this comment.
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
getNetworkStandbyModeflow 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_controllerdoc comment, the third@paramis labeledparamsagain, but it refers to the response object. This makes the API docs ambiguous; please rename it to@param response(and keep the descriptions consistent withcall_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.
| @@ -115,7 +115,7 @@ class ctrlm_thunder_plugin_t { | |||
| bool property_get(std::string property, void *response, unsigned int retries = 0); | |||
There was a problem hiding this comment.
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.
| * @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. |
There was a problem hiding this comment.
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.
| * @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. |
| 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; |
There was a problem hiding this comment.
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.
| 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 | |
| } |
src/thunder/ctrlm_thunder_plugin.cpp
Outdated
| 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__); |
There was a problem hiding this comment.
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.
| 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"); |
| 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)); |
There was a problem hiding this comment.
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.
| wakeup_reason_voice = (0 == strncmp(response["result"].String().c_str(), "WAKEUP_REASON_VOICE", 19)); | |
| wakeup_reason_voice = (response["result"].String() == "WAKEUP_REASON_VOICE"); |
There was a problem hiding this comment.
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
methodparameter, but the function signature isproperty_get(std::string property, ...). This is misleading for callers/maintainers—please update the@paramname/description to refer to the property being retrieved (and consider aligning wording withproperty_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 *)¶ms, (void *)&response)) { | ||
| wakeup_reason_voice = (0 == strncmp(response["result"].String().c_str(), "VOICE", 5)); | ||
| wakeup_reason_voice = (response["result"].String() == "WAKEUP_REASON_VOICE"); |
There was a problem hiding this comment.
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).
| 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"); |
There was a problem hiding this comment.
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_gethas an incorrect@param methodentry, but the function parameter is namedproperty. 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.
No description provided.