diff --git a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp index 1b2fe4c9a..7d7799b63 100644 --- a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp +++ b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp @@ -234,6 +234,18 @@ void CoreSDKTest::GetDeviceName() } } +void CoreSDKTest::GetDeviceVersion() +{ + Firebolt::Error error = Firebolt::Error::None; + const std::string version = Firebolt::IFireboltAccessor::Instance().DeviceInterface().version(&error); + + if (error == Firebolt::Error::None) { + cout << "Get Device Version = " << version.c_str() << endl; + } else { + cout << "Get Device Version status = " << static_cast(error) << endl; + } +} + void CoreSDKTest::OnDeviceNameChangedNotification::onDeviceNameChanged(const std::string& name) { cout << "Name changed, new name --> " << name << endl; diff --git a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h index 698884ea4..8c07ccd22 100644 --- a/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h +++ b/src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h @@ -92,6 +92,7 @@ class CoreSDKTest { static void GetAccountUid(); static void GetDeviceName(); + static void GetDeviceVersion(); static void SubscribeDeviceNameChanged(); static void UnsubscribeDeviceNameChanged(); static void GetDeviceModel(); diff --git a/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp b/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp index c4087ad94..9d2dffb63 100644 --- a/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp +++ b/src/sdks/core/src/cpp/sdk/cpptest/Main.cpp @@ -58,6 +58,7 @@ void RunAllTests() { runTest(CoreSDKTest::GetDeviceModel, "GetDeviceModel"); runTest(CoreSDKTest::GetDeviceSku, "GetDeviceSku"); runTest(CoreSDKTest::GetDeviceName, "GetDeviceName"); + runTest(CoreSDKTest::GetDeviceName, "GetDeviceVersion"); runTest(CoreSDKTest::SubscribeDeviceNameChanged, "SubscribeDeviceNameChanged"); runTest(CoreSDKTest::UnsubscribeDeviceNameChanged, "UnsubscribeDeviceNameChanged"); runTest(CoreSDKTest::GetDeviceAudio, "GetDeviceAudio"); diff --git a/src/sdks/core/src/cpp/templates/Device/include/module.h b/src/sdks/core/src/cpp/templates/Device/include/module.h new file mode 100644 index 000000000..a4d42be2c --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Device/include/module.h @@ -0,0 +1,37 @@ +/* Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ +#pragma once + +#include "error.h" +/* ${IMPORTS} */ + +${if.declarations} +namespace Firebolt { + namespace ${info.Title} { + ${if.enums}/* ${ENUMS} */${end.if.enums} + ${if.types}/* ${TYPES} */${end.if.types} + ${if.providers}/* ${PROVIDERS} */${end.if.providers}${if.xuses}/* ${XUSES} */${end.if.xuses} + ${if.methods}struct I${info.Title} { + // Methods & Events + /* ${METHODS:declarations} */ + virtual ~I${info.Title}() = default; + virtual std::string version( Firebolt::Error *err = nullptr ) const = 0; + }; + ${end.if.methods} + } //namespace ${info.Title} +} +${end.if.declarations} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/templates/Device/src/module_impl.cpp b/src/sdks/core/src/cpp/templates/Device/src/module_impl.cpp new file mode 100644 index 000000000..242897d9d --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Device/src/module_impl.cpp @@ -0,0 +1,65 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "${info.title.lowercase}_impl.h" + +${if.implementations} +namespace Firebolt { +namespace ${info.Title} { +${if.providers} +/* ${PROVIDERS} */${end.if.providers} + std::string ${info.Title}Impl::version(Firebolt::Error *err) const + { + JsonObject jsonParameters; + JsonData_Versions jsonResult; + std::string version; + + Firebolt::Error status = Firebolt::Error::NotConnected; + FireboltSDK::Transport* transport = FireboltSDK::Accessor::Instance().GetTransport(); + if (transport != nullptr) { + + status = transport->Invoke("${info.title.lowercase}.version", jsonParameters, jsonResult); + if (status == Firebolt::Error::None) { + !jsonResult.IsSet() ? jsonResult.Clear() : (void)0; + !jsonResult.Sdk.IsSet() ? jsonResult.Sdk.Clear() : (void)0; + jsonResult.Sdk.Major = static_cast(${major}); + jsonResult.Sdk.Minor = static_cast(${minor}); + jsonResult.Sdk.Patch = static_cast(${patch}); + jsonResult.Sdk.Readable = "${readable}"; + jsonResult.ToString(version); + } + + } else { + FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module(), "Error in getting Transport err = %d", status); + } + return version; + } + // Methods + /* ${METHODS} */ + + // Events + /* ${EVENTS} */ + +}//namespace ${info.Title} +}${end.if.implementations} +${if.enums} + +namespace WPEFramework { + +/* ${ENUMS} */ +}${end.if.enums} \ No newline at end of file diff --git a/src/sdks/core/src/cpp/templates/Device/src/module_impl.h b/src/sdks/core/src/cpp/templates/Device/src/module_impl.h new file mode 100644 index 000000000..b96de7778 --- /dev/null +++ b/src/sdks/core/src/cpp/templates/Device/src/module_impl.h @@ -0,0 +1,54 @@ +/* + * Copyright 2023 Comcast Cable Communications Management, LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "FireboltSDK.h" +#include "IModule.h" +#include + + +/* ${IMPORTS} */ +#include "${info.title.lowercase}.h" + +${if.implementations} +namespace Firebolt { +namespace ${info.Title} { +${if.enums} + +/* ${ENUMS:json-types} */${end.if.enums} +${if.types} + // Types +/* ${TYPES:json-types} */${end.if.types} + ${if.methods}class ${info.Title}Impl : public I${info.Title}, public IModule { + + public: + ${info.Title}Impl() = default; + ${info.Title}Impl(const ${info.Title}Impl&) = delete; + ${info.Title}Impl& operator=(const ${info.Title}Impl&) = delete; + + ~${info.Title}Impl() override = default; + + std::string version(Firebolt::Error *err = nullptr) const override; + + // Methods & Events + /* ${METHODS:declarations-override} */ + };${end.if.methods} + +}//namespace ${info.Title} +}${end.if.implementations} \ No newline at end of file