Skip to content

Commit

Permalink
Merge branch 'next' into feature/cpp-app-passthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
ksentak authored Jul 25, 2024
2 parents 62993bc + 92e1687 commit b6357ca
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(error) << endl;
}
}

void CoreSDKTest::OnDeviceNameChangedNotification::onDeviceNameChanged(const std::string& name)
{
cout << "Name changed, new name --> " << name << endl;
Expand Down
1 change: 1 addition & 0 deletions src/sdks/core/src/cpp/sdk/cpptest/CoreSDKTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class CoreSDKTest {
static void GetAccountUid();

static void GetDeviceName();
static void GetDeviceVersion();
static void SubscribeDeviceNameChanged();
static void UnsubscribeDeviceNameChanged();
static void GetDeviceModel();
Expand Down
1 change: 1 addition & 0 deletions src/sdks/core/src/cpp/sdk/cpptest/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
37 changes: 37 additions & 0 deletions src/sdks/core/src/cpp/templates/Device/include/module.h
Original file line number Diff line number Diff line change
@@ -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}
65 changes: 65 additions & 0 deletions src/sdks/core/src/cpp/templates/Device/src/module_impl.cpp
Original file line number Diff line number Diff line change
@@ -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<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) {
!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 {
FIREBOLT_LOG_ERROR(FireboltSDK::Logger::Category::OpenRPC, FireboltSDK::Logger::Module<FireboltSDK::Accessor>(), "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}
54 changes: 54 additions & 0 deletions src/sdks/core/src/cpp/templates/Device/src/module_impl.h
Original file line number Diff line number Diff line change
@@ -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 <string>


/* ${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}

0 comments on commit b6357ca

Please sign in to comment.