Skip to content
Open
Show file tree
Hide file tree
Changes from 5 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
30 changes: 27 additions & 3 deletions src/thunder/ctrlm_thunder_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,20 +270,44 @@ bool ctrlm_thunder_plugin_t::call_plugin_boolean(std::string method, void *param
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);
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);
}

bool ctrlm_thunder_plugin_t::call_plugin_string(std::string method, void *params, std::string *response) {
bool ret = false;
auto clientObject = (JSONRPC::LinkType<Core::JSON::IElement>*)this->plugin_client;
JsonObject *jsonParams = (JsonObject *)params;
if(clientObject) {
if(!method.empty() && jsonParams && response) {
Core::JSON::String jsonString;
uint32_t thunderRet = clientObject->Invoke<JsonObject, Core::JSON::String>(CALL_TIMEOUT, _T(method), *jsonParams, jsonString);
if(thunderRet != Core::ERROR_NONE) {
XLOGD_ERROR("%s: Thunder call failed <%s> <%u>", __FUNCTION__, method.c_str(), thunderRet);
} else {
Comment on lines +287 to +297
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

call_plugin_string largely duplicates call_plugin_boolean (client cast, parameter validation, Invoke, error handling). Consider extracting a small internal templated helper for primitive-return Invoke calls to reduce duplication and keep logging/handling consistent as more typed helpers are added.

Copilot uses AI. Check for mistakes.
*response = jsonString.Value();
ret = true;
}
} else {
XLOGD_ERROR("%s: Invalid parameters", __FUNCTION__);
}
} else {
XLOGD_ERROR("%s: Client is NULL", __FUNCTION__);
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

call_plugin_string uses __FUNCTION__ in its error logs, but the other call helpers in this file (property_get, call_plugin, call_plugin_boolean) log without a function prefix (e.g., XLOGD_ERROR("Invalid parameters")). For consistency (and to avoid duplicating function names if the logger already adds them), align the new logging format with the existing helpers in this file.

Suggested change
XLOGD_ERROR("%s: Thunder call failed <%s> <%u>", __FUNCTION__, method.c_str(), thunderRet);
} else {
*response = jsonString.Value();
ret = true;
}
} else {
XLOGD_ERROR("%s: Invalid parameters", __FUNCTION__);
}
} else {
XLOGD_ERROR("%s: Client is NULL", __FUNCTION__);
XLOGD_ERROR("Thunder call failed <%s> <%u>", method.c_str(), thunderRet);
} else {
*response = jsonString.Value();
ret = true;
}
} else {
XLOGD_ERROR("Invalid parameters");
}
} else {
XLOGD_ERROR("Client is NULL");

Copilot uses AI. Check for mistakes.
}
return(ret);
}


bool ctrlm_thunder_plugin_t::call_controller(std::string method, void *params, void *response) {
bool ret = false;
if(this->controller) {
Expand Down
16 changes: 12 additions & 4 deletions src/thunder/ctrlm_thunder_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class ctrlm_thunder_plugin_t {

/**
* This function is used to get a Thunder Plugin property.
* @param method The method in which the user wants to call.
* @param property The property the user wants to get
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

Docstring punctuation/grammar: add a trailing period to the @param property description to match the surrounding documentation style.

Suggested change
* @param property The property the user wants to get
* @param property The property the user wants to get.

Copilot uses AI. Check for mistakes.
* @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)
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

The property_get docblock still lists a params parameter, but the function signature is property_get(std::string property, void *response, unsigned int retries = 0) and has no params argument. This can confuse callers; update the comment to describe only property, response, and retries (or adjust the API if params are actually required).

Suggested change
* @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)

Copilot uses AI. Check for mistakes.
* @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.
Expand All @@ -128,12 +128,20 @@ class ctrlm_thunder_plugin_t {
* 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.
* @param response A pointer to a boolean which will be assigned true or false
* @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 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 A pointer a string which will be assigned
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

Typo/grammar in the new call_plugin_string documentation: "A pointer a string" is missing "to", and the description is incomplete. Please clarify that response is an output parameter assigned to the returned string.

Suggested change
* @param response A pointer a string which will be assigned
* @param response A pointer to a string output parameter which will be assigned the returned string.

Copilot uses AI. Check for mistakes.
* @return True if the call succeeded, otherwise False.
*/
bool call_plugin_string(std::string method, void *params, std::string *response);

/**
* This function is used to call a Thunder Controller method.
* @param method The method in which the user wants to call.
Expand Down Expand Up @@ -174,4 +182,4 @@ class ctrlm_thunder_plugin_t {
};
};

#endif
#endif
12 changes: 8 additions & 4 deletions src/thunder/ctrlm_thunder_plugin_powermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,23 @@ bool ctrlm_thunder_plugin_powermanager_t::get_networked_standby_mode() {
/* 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.getLastWakeupReason", "params": {} }'
{"jsonrpc":"2.0","id":1234567890,"result":"COLDBOOT"} */
bool ctrlm_thunder_plugin_powermanager_t::get_wakeup_reason_voice() {
JsonObject params, response;
JsonObject params;
std::string response;
params = {};
bool wakeup_reason_voice = false;

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));
XLOGD_DEBUG("voice_wakeup is %s", wakeup_reason_voice?"TRUE":"FALSE");
if(this->call_plugin_string("getLastWakeupReason", (void *)&params, &response)) {
if(response == "VOICE") {
wakeup_reason_voice = true;
}
} else {
XLOGD_ERROR("getLastWakeupReason call failed");
}
sem_post(&this->semaphore);

XLOGD_DEBUG("voice_wakeup is %s", wakeup_reason_voice?"TRUE":"FALSE");

Comment on lines 120 to +126
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

voice_wakeup is now logged unconditionally, including when getLastWakeupReason fails. This can be misleading because failures will be reported as FALSE in debug logs even though the value is actually unknown. Consider logging only on success, or include an explicit "call failed"/"unknown" indication in the debug message.

Suggested change
} else {
XLOGD_ERROR("getLastWakeupReason call failed");
}
sem_post(&this->semaphore);
XLOGD_DEBUG("voice_wakeup is %s", wakeup_reason_voice?"TRUE":"FALSE");
XLOGD_DEBUG("voice_wakeup is %s", wakeup_reason_voice?"TRUE":"FALSE");
} else {
XLOGD_ERROR("getLastWakeupReason call failed");
}
sem_post(&this->semaphore);

Copilot uses AI. Check for mistakes.
return wakeup_reason_voice;
}

Expand Down
Loading