Skip to content

Commit

Permalink
Injecting sdk version into platform response within template
Browse files Browse the repository at this point in the history
  • Loading branch information
parag-pv committed Jul 17, 2024
1 parent de680e1 commit 2148371
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/sdks/core/src/cpp/templates/Device/src/module_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,22 @@ namespace ${info.Title} {
std::string ${info.Title}Impl::version(Firebolt::Error *err) const
{
JsonObject jsonParameters;
FireboltSDK::JSON::String jsonResult;
JsonData_Versions jsonResult;
std::string version;

Firebolt::Error status = Firebolt::Error::NotConnected;
FireboltSDK::Transport<WPEFramework::Core::JSON::IElement>* transport = FireboltSDK::Accessor::Instance().GetTransport();
if (transport != nullptr) {

status = transport->Invoke("${info.title.lowercase}.version", jsonParameters, jsonResult);
if (status == Firebolt::Error::None) {
FIREBOLT_LOG_INFO(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "${info.Title}.version is successfully invoked, status: %s", jsonResult.Value().c_str());
version = jsonResult.Value().c_str();
/* TODO: Set major, minor values here*/
!jsonResult.IsSet() ? jsonResult.Clear() : (void)0;
!jsonResult.Sdk.IsSet() ? jsonResult.Sdk.Clear() : (void)0;
jsonResult.Sdk.Major = static_cast<int32_t>(${major});
jsonResult.Sdk.Minor = static_cast<int32_t>(${minor});
jsonResult.Sdk.Patch = static_cast<int32_t>(${patch});
jsonResult.Sdk.Readable = "${readable}";
jsonResult.ToString(version);
}

} else {
Expand Down

0 comments on commit 2148371

Please sign in to comment.