Skip to content
Merged
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
47 changes: 47 additions & 0 deletions src/thunder/ctrlm_thunder_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,53 @@ 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<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("Thunder call failed <%s> <%u>", method.c_str(), thunderRet);
} else {
*response = jsonResponse.Value();
ret = true;
Comment thread
jthomp007c marked this conversation as resolved.
}
} else {
XLOGD_ERROR("Invalid parameters");
}
} else {
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("Thunder call failed <%s> <%u>", method.c_str(), thunderRet);
} else {
*response = jsonString.Value();
ret = true;
}
Comment thread
jthomp007c marked this conversation as resolved.
} else {
XLOGD_ERROR("Invalid parameters");
}
} else {
XLOGD_ERROR("Client is NULL");
}
return(ret);
}


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

/**
* This functions 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)
* This function is used to get a Thunder Plugin property.
* @param property The name of the property that the user wants to get
* @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 property_get(std::string property, void *response, unsigned int retries = 0);
Comment thread
jthomp007c marked this conversation as resolved.

/**
* 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)
Expand All @@ -125,7 +124,25 @@ 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 boolean pointer which will be assigned the response from the call
* @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 The string pointer which will be assigned containing the response from the call.
* @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.
* @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)
Expand Down Expand Up @@ -164,4 +181,4 @@ class ctrlm_thunder_plugin_t {
};
};

#endif
#endif
21 changes: 12 additions & 9 deletions src/thunder/ctrlm_thunder_plugin_powermanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 *)&params, (void *)&response)) {
networked_standby_mode = response["result"].Boolean();
sem_wait(&this->semaphore);
if(this->call_plugin_boolean("getNetworkStandbyMode", (void *)&params, &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);

Expand All @@ -108,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");

return wakeup_reason_voice;
}

Expand Down
Loading