From 35bb9a81bb5418403ea6258d887803d2bb0bfba9 Mon Sep 17 00:00:00 2001 From: Jakub Latusek Date: Wed, 25 Oct 2023 15:32:55 +0200 Subject: [PATCH] [Tizen] [lighting-app] Add GPIO control and dbus UI (#29958) * Add simple gpio implementation * dbus - add xml and integrate in gn * Integrate dbus controller into app * Use property instead of method call * Use gdbus_library GN template for generating iface * Expose Matter clusters via Tizen App D-Bus * Update for color cluster * Fix color temperature set * Expose Identify cluster via example app D-Bus API * Alight D-Bus API property names with Matter * Add led manager * Add license * clean unused callback * Preserve the state of the color temperature * Set color temperature mode as default * Remove unused static variable * Update signals name * Add else to define to remove warning * Remove unused value * Add [-with-ui] to tinze in all_targets_linux_x64.txt * Verify by CI that -with-ui works * Restyled by gn --------- Co-authored-by: Arkadiusz Bokowy Co-authored-by: Restyled.io --- .github/workflows/examples-tizen.yaml | 2 +- config/tizen/chip-gn/platform/BUILD.gn | 5 + examples/lighting-app/tizen/BUILD.gn | 24 ++ .../lighting-app/tizen/include/LedManager.h | 45 ++++ .../lighting-app/tizen/src/DBusInterface.cpp | 230 ++++++++++++++++++ .../lighting-app/tizen/src/DBusInterface.h | 79 ++++++ .../lighting-app/tizen/src/LedManager.cpp | 69 ++++++ examples/lighting-app/tizen/src/main.cpp | 98 +++++++- .../lighting-app/tizen/tizen-manifest.xml | 1 + .../lighting-app/tizen/xml/DBusLightApp.xml | 17 ++ scripts/build/build/targets.py | 1 + scripts/build/builders/tizen.py | 3 + .../build/testdata/all_targets_linux_x64.txt | 2 +- .../color-control-server.cpp | 8 +- 14 files changed, 572 insertions(+), 12 deletions(-) create mode 100644 examples/lighting-app/tizen/include/LedManager.h create mode 100644 examples/lighting-app/tizen/src/DBusInterface.cpp create mode 100644 examples/lighting-app/tizen/src/DBusInterface.h create mode 100644 examples/lighting-app/tizen/src/LedManager.cpp create mode 100644 examples/lighting-app/tizen/xml/DBusLightApp.xml diff --git a/.github/workflows/examples-tizen.yaml b/.github/workflows/examples-tizen.yaml index 6099113b021e38..f6ca3bb793dc87 100644 --- a/.github/workflows/examples-tizen.yaml +++ b/.github/workflows/examples-tizen.yaml @@ -55,7 +55,7 @@ jobs: --enable-flashbundle \ --target tizen-arm-all-clusters \ --target tizen-arm-chip-tool-ubsan \ - --target tizen-arm-light \ + --target tizen-arm-light-with-ui \ build \ --copy-artifacts-to out/artifacts \ " diff --git a/config/tizen/chip-gn/platform/BUILD.gn b/config/tizen/chip-gn/platform/BUILD.gn index 7d2f25e9bcf4f8..bea16af373fd15 100644 --- a/config/tizen/chip-gn/platform/BUILD.gn +++ b/config/tizen/chip-gn/platform/BUILD.gn @@ -20,6 +20,10 @@ import("${chip_root}/config/tizen/chip-gn/args.gni") import("${build_root}/config/linux/pkg_config.gni") import("${chip_root}/src/platform/device.gni") +pkg_config("capi-system-peripheral-io") { + packages = [ "capi-system-peripheral-io" ] +} + pkg_config("dlog") { packages = [ "dlog" ] } @@ -69,6 +73,7 @@ source_set("tizen") { ":glib", ":capi-appfw-preference", ":capi-system-info", + ":capi-system-peripheral-io", ] if (chip_mdns == "platform") { diff --git a/examples/lighting-app/tizen/BUILD.gn b/examples/lighting-app/tizen/BUILD.gn index 4344f742f964c5..c0a38e7c113a91 100644 --- a/examples/lighting-app/tizen/BUILD.gn +++ b/examples/lighting-app/tizen/BUILD.gn @@ -15,15 +15,31 @@ import("//build_overrides/chip.gni") import("//build_overrides/tizen.gni") +import("${chip_root}/build/chip/linux/gdbus_library.gni") import("${chip_root}/build/chip/tools.gni") import("${chip_root}/src/app/common_flags.gni") import("${tizen_sdk_build_root}/tizen_sdk.gni") assert(chip_build_tools) +declare_args() { + # Enable D-Bus based UI functionality for example app + chip_examples_enable_ui = false +} + +gdbus_library("chip-lighting-app-manager") { + sources = [ "xml/DBusLightApp.xml" ] + interface_prefix = "org.tizen.matter.example.lighting" + c_namespace = "LightApp" + c_generate_object_manager = true + dbus_out_dir = "dbus" +} + executable("chip-lighting-app") { sources = [ "include/CHIPProjectAppConfig.h", + "include/LedManager.h", + "src/LedManager.cpp", "src/main.cpp", ] @@ -34,6 +50,14 @@ executable("chip-lighting-app") { "${chip_root}/src/lib", ] + if (chip_examples_enable_ui) { + sources += [ "src/DBusInterface.cpp" ] + deps += [ ":chip-lighting-app-manager" ] + defines = [ "ENABLE_DBUS_UI=1" ] + } else { + defines = [ "ENABLE_DBUS_UI=0" ] + } + include_dirs = [ "include" ] output_dir = root_out_dir diff --git a/examples/lighting-app/tizen/include/LedManager.h b/examples/lighting-app/tizen/include/LedManager.h new file mode 100644 index 00000000000000..690ffefbab01ef --- /dev/null +++ b/examples/lighting-app/tizen/include/LedManager.h @@ -0,0 +1,45 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * 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. + */ + +#pragma once + +#include +#include + +#include + +namespace example { +class LedManager +{ +public: + explicit LedManager(chip::EndpointId endpointId); + void SetOnOff(bool on); + CHIP_ERROR Init(); + +private: + void InitOnOff(); + + // Numbers of GPIO used to control LED in order: RED, GREEN, BLUE + static constexpr int number_of_pins = 3; + static constexpr int pins[number_of_pins] = { 20, 19, 18 }; + peripheral_gpio_h gpio[number_of_pins] = {}; + + const chip::EndpointId mEndpointId; +}; + +} // namespace example diff --git a/examples/lighting-app/tizen/src/DBusInterface.cpp b/examples/lighting-app/tizen/src/DBusInterface.cpp new file mode 100644 index 00000000000000..86ae799dc1f5a2 --- /dev/null +++ b/examples/lighting-app/tizen/src/DBusInterface.cpp @@ -0,0 +1,230 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * 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. + */ + +#include "DBusInterface.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "dbus/DBusLightApp.h" + +using namespace chip; +using namespace chip::app; + +namespace example { + +// Dummy class to satisfy the CommandHandler::Callback interface. +class CommandHandlerCallback : public CommandHandler::Callback +{ +public: + using Status = Protocols::InteractionModel::Status; + void OnDone(CommandHandler & apCommandObj) {} + void DispatchCommand(CommandHandler & apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & apPayload) {} + Status CommandExists(const ConcreteCommandPath & aCommandPath) { return Status::Success; } +}; + +DBusInterface::DBusInterface(chip::EndpointId endpointId) : mEndpointId(endpointId) +{ + mManager = g_dbus_object_manager_server_new("/"); + mIfaceIdentify = light_app_identify_skeleton_new(); + mIfaceOnOff = light_app_on_off_skeleton_new(); + mIfaceLevelControl = light_app_level_control_skeleton_new(); + mIfaceColorControl = light_app_color_control_skeleton_new(); +} + +DBusInterface::~DBusInterface() +{ + g_object_unref(mIfaceIdentify); + g_object_unref(mIfaceOnOff); + g_object_unref(mIfaceLevelControl); + g_object_unref(mIfaceColorControl); + g_object_unref(mManager); +} + +CHIP_ERROR DBusInterface::Init() +{ + // During the initialization we are going to connect glib signals, so we need to be + // on the GLib Matter context. Otherwise, signals will be emitted on the glib default + // main context. + return chip::DeviceLayer::PlatformMgrImpl().GLibMatterContextInvokeSync(InitOnGLibMatterContext, this); +} + +void DBusInterface::Identify(uint16_t time) +{ + light_app_identify_emit_identify(mIfaceIdentify, time); +} + +void DBusInterface::SetOnOff(bool on) +{ + InternalSetGuard guard(this); + if (light_app_on_off_get_on_off(mIfaceOnOff) != on) + light_app_on_off_set_on_off(mIfaceOnOff, on); +} + +void DBusInterface::SetCurrentLevel(uint8_t value) +{ + InternalSetGuard guard(this); + if (light_app_level_control_get_current_level(mIfaceLevelControl) != value) + light_app_level_control_set_current_level(mIfaceLevelControl, value); +} + +void DBusInterface::SetColorMode(chip::app::Clusters::ColorControl::ColorMode colorMode) +{ + InternalSetGuard guard(this); + if (light_app_color_control_get_color_mode(mIfaceColorControl) != colorMode) + light_app_color_control_set_color_mode(mIfaceColorControl, colorMode); +} + +void DBusInterface::SetColorTemperature(uint16_t value) +{ + InternalSetGuard guard(this); + if (light_app_color_control_get_color_temperature_mireds(mIfaceColorControl) != value) + light_app_color_control_set_color_temperature_mireds(mIfaceColorControl, value); +} + +CHIP_ERROR DBusInterface::InitOnGLibMatterContext(DBusInterface * self) +{ + g_autoptr(GDBusConnection) bus = nullptr; + g_autoptr(GError) error = nullptr; + + if ((bus = g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &error)) == nullptr) + { + ChipLogError(NotSpecified, "Couldn't get D-Bus bus: %s", error->message); + return CHIP_ERROR_NOT_CONNECTED; + } + + LightAppObjectSkeleton * object = light_app_object_skeleton_new("/app"); + g_dbus_object_manager_server_export(self->mManager, G_DBUS_OBJECT_SKELETON(object)); + + light_app_object_skeleton_set_identify(object, self->mIfaceIdentify); + light_app_object_skeleton_set_on_off(object, self->mIfaceOnOff); + light_app_object_skeleton_set_level_control(object, self->mIfaceLevelControl); + light_app_object_skeleton_set_color_control(object, self->mIfaceColorControl); + + self->InitOnOff(); + self->InitColor(); + + g_dbus_object_manager_server_set_connection(self->mManager, bus); + g_object_unref(object); + + g_signal_connect(self->mIfaceOnOff, "notify::on-off", G_CALLBACK(OnOnOffChanged), self); + g_signal_connect(self->mIfaceLevelControl, "notify::current-level", G_CALLBACK(OnCurrentLevelChanged), self); + g_signal_connect(self->mIfaceColorControl, "notify::color-temperature-mireds", G_CALLBACK(OnColorTemperatureChanged), self); + + g_bus_own_name_on_connection(bus, "org.tizen.matter.example.lighting", G_BUS_NAME_OWNER_FLAGS_NONE, + reinterpret_cast(OnBusAcquired), + reinterpret_cast(OnBusLost), self, nullptr); + + return CHIP_NO_ERROR; +} + +void DBusInterface::OnBusAcquired(GDBusConnection *, const char *, DBusInterface * self) +{ + self->mNameAcquired = true; +} + +void DBusInterface::OnBusLost(GDBusConnection *, const char * name, DBusInterface * self) +{ + VerifyOrReturn(self->mNameAcquired, /* connection was lost after name was acquired, so it's not an error */); + ChipLogError(NotSpecified, "Couldn't acquire D-Bus name. Please check D-Bus configuration. Requested name: %s", name); +} + +gboolean DBusInterface::OnOnOffChanged(LightAppOnOff * onOff, GDBusMethodInvocation * invocation, DBusInterface * self) +{ + // Do not handle on-change event if it was triggered by internal set + VerifyOrReturnValue(!self->mInternalSet, G_DBUS_METHOD_INVOCATION_HANDLED); + + chip::DeviceLayer::StackLock lock; + OnOffServer::Instance().setOnOffValue(self->mEndpointId, + light_app_on_off_get_on_off(onOff) ? Clusters::OnOff::Commands::On::Id + : Clusters::OnOff::Commands::Off::Id, + false /* initiatedByLevelChange */); + return G_DBUS_METHOD_INVOCATION_HANDLED; +} + +gboolean DBusInterface::OnCurrentLevelChanged(LightAppLevelControl * levelControl, GDBusMethodInvocation * invocation, + DBusInterface * self) +{ + // Do not handle on-change event if it was triggered by internal set + VerifyOrReturnValue(!self->mInternalSet, G_DBUS_METHOD_INVOCATION_HANDLED); + + Clusters::LevelControl::Commands::MoveToLevel::DecodableType data; + data.level = light_app_level_control_get_current_level(levelControl); + data.optionsMask.Set(Clusters::LevelControl::LevelControlOptions::kExecuteIfOff); + data.optionsOverride.Set(Clusters::LevelControl::LevelControlOptions::kExecuteIfOff); + + chip::DeviceLayer::StackLock lock; + LevelControlServer::MoveToLevel(self->mEndpointId, data); + + return G_DBUS_METHOD_INVOCATION_HANDLED; +} + +gboolean DBusInterface::OnColorTemperatureChanged(LightAppColorControl * colorControl, GDBusMethodInvocation * invocation, + DBusInterface * self) +{ + // Do not handle on-change event if it was triggered by internal set + VerifyOrReturnValue(!self->mInternalSet, G_DBUS_METHOD_INVOCATION_HANDLED); + + CommandHandlerCallback callback; + CommandHandler handler(&callback); + + ConcreteCommandPath path{ self->mEndpointId, Clusters::ColorControl::Id, 0 }; + + Clusters::ColorControl::Commands::MoveToColorTemperature::DecodableType data; + data.colorTemperatureMireds = light_app_color_control_get_color_temperature_mireds(colorControl); + + chip::DeviceLayer::StackLock lock; + ColorControlServer::Instance().moveToColorTempCommand(&handler, path, data); + + return G_DBUS_METHOD_INVOCATION_HANDLED; +} + +void DBusInterface::InitOnOff() +{ + bool isOn = false; + auto status = Clusters::OnOff::Attributes::OnOff::Get(mEndpointId, &isOn); + VerifyOrReturn(status == EMBER_ZCL_STATUS_SUCCESS, ChipLogError(NotSpecified, "Error getting OnOff: 0x%x", status)); + light_app_on_off_set_on_off(mIfaceOnOff, isOn); +} + +void DBusInterface::InitColor() +{ + { + uint8_t value = 0; + auto status = Clusters::ColorControl::Attributes::ColorMode::Get(mEndpointId, &value); + VerifyOrReturn(status == EMBER_ZCL_STATUS_SUCCESS, ChipLogError(NotSpecified, "Error getting ColorMode: 0x%x", status)); + light_app_color_control_set_color_mode(mIfaceColorControl, value); + } + { + uint16_t value = 0; + auto status = Clusters::ColorControl::Attributes::ColorTemperatureMireds::Get(mEndpointId, &value); + VerifyOrReturn(status == EMBER_ZCL_STATUS_SUCCESS, + ChipLogError(NotSpecified, "Error getting ColorTemperatureMireds: 0x%x", status)); + light_app_color_control_set_color_temperature_mireds(mIfaceColorControl, value); + } +} + +}; // namespace example diff --git a/examples/lighting-app/tizen/src/DBusInterface.h b/examples/lighting-app/tizen/src/DBusInterface.h new file mode 100644 index 00000000000000..c5d58775dde384 --- /dev/null +++ b/examples/lighting-app/tizen/src/DBusInterface.h @@ -0,0 +1,79 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * 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. + */ + +#pragma once + +#include + +#include +#include +#include + +#include "dbus/DBusLightApp.h" + +namespace example { + +class DBusInterface +{ +public: + explicit DBusInterface(chip::EndpointId endpointId); + ~DBusInterface(); + + CHIP_ERROR Init(); + + void Identify(uint16_t time); + void SetOnOff(bool on); + void SetCurrentLevel(uint8_t value); + void SetColorMode(chip::app::Clusters::ColorControl::ColorMode colorMode); + void SetColorTemperature(uint16_t value); + +private: + static CHIP_ERROR InitOnGLibMatterContext(DBusInterface * self); + static void OnBusAcquired(GDBusConnection *, const char *, DBusInterface * self); + static void OnBusLost(GDBusConnection *, const char * name, DBusInterface * self); + + static gboolean OnOnOffChanged(LightAppOnOff *, GDBusMethodInvocation *, DBusInterface *); + static gboolean OnCurrentLevelChanged(LightAppLevelControl *, GDBusMethodInvocation *, DBusInterface *); + static gboolean OnColorTemperatureChanged(LightAppColorControl *, GDBusMethodInvocation *, DBusInterface *); + + void InitOnOff(); + void InitColor(); + + class InternalSetGuard + { + public: + InternalSetGuard(DBusInterface * iface) : mIface(iface) { mIface->mInternalSet = true; } + ~InternalSetGuard() { mIface->mInternalSet = false; } + + private: + DBusInterface * mIface; + }; + + const chip::EndpointId mEndpointId; + + GDBusObjectManagerServer * mManager = nullptr; + bool mNameAcquired = false; + + LightAppIdentify * mIfaceIdentify = nullptr; + LightAppOnOff * mIfaceOnOff = nullptr; + LightAppLevelControl * mIfaceLevelControl = nullptr; + LightAppColorControl * mIfaceColorControl = nullptr; + bool mInternalSet = false; +}; + +} // namespace example diff --git a/examples/lighting-app/tizen/src/LedManager.cpp b/examples/lighting-app/tizen/src/LedManager.cpp new file mode 100644 index 00000000000000..0848675c7c0fef --- /dev/null +++ b/examples/lighting-app/tizen/src/LedManager.cpp @@ -0,0 +1,69 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * 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. + */ + +#include + +#include +#include +#include +#include +#include + +namespace example { + +using namespace chip; +using namespace chip::app; + +LedManager::LedManager(chip::EndpointId endpointId) : mEndpointId(endpointId){}; + +CHIP_ERROR LedManager::Init() +{ + InitOnOff(); + int ret = 0; + for (auto i = 0; i < number_of_pins; ++i) + { + ret = peripheral_gpio_open(pins[i], &gpio[i]); + VerifyOrReturnError(ret == PERIPHERAL_ERROR_NONE, CHIP_ERROR_INTERNAL, + ChipLogError(DeviceLayer, "Error openning gpio, pin number: %d", pins[i])); + ret = peripheral_gpio_set_direction(gpio[i], PERIPHERAL_GPIO_DIRECTION_OUT_INITIALLY_LOW); + VerifyOrReturnError(ret == PERIPHERAL_ERROR_NONE, CHIP_ERROR_INTERNAL, + ChipLogError(DeviceLayer, "Error setting direction of gpio, pin number: %d", pins[i])); + } + return CHIP_NO_ERROR; +} + +void LedManager::SetOnOff(const bool isOn) +{ + for (auto i = 0; i < number_of_pins; ++i) + { + int ret = 0; + ret = peripheral_gpio_write(gpio[i], isOn ? 1 : 0); + VerifyOrReturn(ret == PERIPHERAL_ERROR_NONE, + ChipLogError(DeviceLayer, "Error setting value to gpio, pin number: %d", pins[i])); + } +} + +void LedManager::InitOnOff() +{ + bool isOn = false; + auto status = Clusters::OnOff::Attributes::OnOff::Get(mEndpointId, &isOn); + VerifyOrReturn(status == EMBER_ZCL_STATUS_SUCCESS, ChipLogError(NotSpecified, "Error getting OnOff: 0x%x", status)); + SetOnOff(isOn); +} + +} // namespace example diff --git a/examples/lighting-app/tizen/src/main.cpp b/examples/lighting-app/tizen/src/main.cpp index 8f0bafaec72e31..6a32e84b50cb6c 100644 --- a/examples/lighting-app/tizen/src/main.cpp +++ b/examples/lighting-app/tizen/src/main.cpp @@ -16,40 +16,127 @@ * limitations under the License. */ +#include #include #include #include #include #include +#include #include #include +#if ENABLE_DBUS_UI +#include "DBusInterface.h" +#endif + using namespace chip; using namespace chip::app; -using namespace chip::app::Clusters; -#if CHIP_DEVICE_CONFIG_ENABLE_WIFI namespace { + +static constexpr chip::EndpointId chipEndpoint(1); + +#if ENABLE_DBUS_UI +example::DBusInterface sDBusInterface(chipEndpoint); +#endif + +static example::LedManager ledManager(chipEndpoint); + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI DeviceLayer::NetworkCommissioning::TizenWiFiDriver sTizenWiFiDriver; Clusters::NetworkCommissioning::Instance sWiFiNetworkCommissioningInstance(0, &sTizenWiFiDriver); -} // namespace #endif +} // namespace + void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath & attributePath, uint8_t type, uint16_t size, uint8_t * value) { - if (attributePath.mClusterId == OnOff::Id && attributePath.mAttributeId == OnOff::Attributes::OnOff::Id) + ChipLogDetail( + NotSpecified, "MatterPostAttributeChangeCallback: EndPoint=0x%x, Cluster=" ChipLogFormatMEI ", Attribute=" ChipLogFormatMEI, + attributePath.mEndpointId, ChipLogValueMEI(attributePath.mClusterId), ChipLogValueMEI(attributePath.mAttributeId)); + switch (attributePath.mClusterId) { - LightingMgr().InitiateAction(*value ? LightingManager::ON_ACTION : LightingManager::OFF_ACTION); + case Clusters::OnOff::Id: + switch (attributePath.mAttributeId) + { + case Clusters::OnOff::Attributes::OnOff::Id: + LightingMgr().InitiateAction(*value ? LightingManager::ON_ACTION : LightingManager::OFF_ACTION); + ledManager.SetOnOff(*value); +#if ENABLE_DBUS_UI + sDBusInterface.SetOnOff(*value); +#endif + break; + default: + ChipLogDetail(NotSpecified, "Not handled OnOff cluster attribute ID: " ChipLogFormatMEI, + ChipLogValueMEI(attributePath.mAttributeId)); + } + break; +#if ENABLE_DBUS_UI + case Clusters::Identify::Id: + switch (attributePath.mAttributeId) + { + case Clusters::Identify::Attributes::IdentifyTime::Id: + VerifyOrDie(size == sizeof(uint16_t)); + sDBusInterface.Identify(*reinterpret_cast(value)); + break; + default: + ChipLogDetail(NotSpecified, "Not handled Identify cluster attribute ID: " ChipLogFormatMEI, + ChipLogValueMEI(attributePath.mAttributeId)); + } + break; + case Clusters::LevelControl::Id: + switch (attributePath.mAttributeId) + { + case Clusters::LevelControl::Attributes::CurrentLevel::Id: + sDBusInterface.SetCurrentLevel(*value); + break; + default: + ChipLogDetail(NotSpecified, "Not handled LevelControl cluster attribute ID: " ChipLogFormatMEI, + ChipLogValueMEI(attributePath.mAttributeId)); + } + break; + case Clusters::ColorControl::Id: + switch (attributePath.mAttributeId) + { + case Clusters::ColorControl::Attributes::ColorMode::Id: + sDBusInterface.SetColorMode(static_cast(*value)); + break; + case Clusters::ColorControl::Attributes::ColorTemperatureMireds::Id: + VerifyOrDie(size == sizeof(uint16_t)); + sDBusInterface.SetColorTemperature(*reinterpret_cast(value)); + break; + default: + ChipLogDetail(NotSpecified, "Not handled ColorControl cluster attribute ID: " ChipLogFormatMEI, + ChipLogValueMEI(attributePath.mAttributeId)); + } + break; +#endif // ENABLE_DBUS_UI + default: + ChipLogDetail(NotSpecified, "Not handled cluster ID: " ChipLogFormatMEI, ChipLogValueMEI(attributePath.mClusterId)); } } +void emberAfColorControlClusterInitCallback(EndpointId endpoint) +{ + // Set the color mode to color temperature. + Clusters::ColorControl::Attributes::ColorMode::Set(endpoint, + Clusters::ColorControl::ColorMode::EMBER_ZCL_COLOR_MODE_COLOR_TEMPERATURE); + // Preserve the state of the color temperature attribute across reboots. + Clusters::ColorControl::Attributes::StartUpColorTemperatureMireds::SetNull(endpoint); +} + void ApplicationInit() { +#if ENABLE_DBUS_UI + sDBusInterface.Init(); +#endif #if CHIP_DEVICE_CONFIG_ENABLE_WIFI sWiFiNetworkCommissioningInstance.Init(); #endif + ledManager.Init(); } void ApplicationShutdown() {} @@ -58,7 +145,6 @@ int main(int argc, char * argv[]) { TizenServiceAppMain app; VerifyOrDie(app.Init(argc, argv) == 0); - VerifyOrDie(LightingMgr().Init() == CHIP_NO_ERROR); return app.RunMainLoop(); diff --git a/examples/lighting-app/tizen/tizen-manifest.xml b/examples/lighting-app/tizen/tizen-manifest.xml index 4cb6047b528173..d9e5771cb4faab 100644 --- a/examples/lighting-app/tizen/tizen-manifest.xml +++ b/examples/lighting-app/tizen/tizen-manifest.xml @@ -10,6 +10,7 @@ http://tizen.org/privilege/network.get http://tizen.org/privilege/network.set http://tizen.org/privilege/network.profile + http://tizen.org/privilege/peripheralio true true diff --git a/examples/lighting-app/tizen/xml/DBusLightApp.xml b/examples/lighting-app/tizen/xml/DBusLightApp.xml new file mode 100644 index 00000000000000..71ae99262b985b --- /dev/null +++ b/examples/lighting-app/tizen/xml/DBusLightApp.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/scripts/build/build/targets.py b/scripts/build/build/targets.py index 890895528b40dc..2160af0d1e0322 100755 --- a/scripts/build/build/targets.py +++ b/scripts/build/build/targets.py @@ -617,6 +617,7 @@ def BuildTizenTarget(): target.AppendModifier("no-wifi", enable_wifi=False) target.AppendModifier("asan", use_asan=True) target.AppendModifier("ubsan", use_ubsan=True) + target.AppendModifier('with-ui', with_ui=True) return target diff --git a/scripts/build/builders/tizen.py b/scripts/build/builders/tizen.py index 966b5da62207de..bc0a454b39222c 100644 --- a/scripts/build/builders/tizen.py +++ b/scripts/build/builders/tizen.py @@ -93,6 +93,7 @@ def __init__(self, use_asan: bool = False, use_tsan: bool = False, use_ubsan: bool = False, + with_ui: bool = False, ): super(TizenBuilder, self).__init__( root=os.path.join(root, app.value.source), @@ -128,6 +129,8 @@ def __init__(self, raise Exception("TSAN sanitizer not supported by Tizen toolchain") if use_ubsan: self.extra_gn_options.append('is_ubsan=true') + if with_ui: + self.extra_gn_options.append('chip_examples_enable_ui=true') def GnBuildArgs(self): # Make sure that required ENV variables are defined diff --git a/scripts/build/testdata/all_targets_linux_x64.txt b/scripts/build/testdata/all_targets_linux_x64.txt index f077397b63bf78..b5402ab140189a 100644 --- a/scripts/build/testdata/all_targets_linux_x64.txt +++ b/scripts/build/testdata/all_targets_linux_x64.txt @@ -21,6 +21,6 @@ nrf-{nrf5340dk,nrf52840dk,nrf52840dongle}-{all-clusters,all-clusters-minimal,loc nrf-native-posix-64-tests qpg-qpg6105-{lock,light,shell,persistent-storage} stm32-stm32wb5mm-dk-light -tizen-arm-{all-clusters,all-clusters-minimal,chip-tool,light,tests}[-no-ble][-no-thread][-no-wifi][-asan][-ubsan] +tizen-arm-{all-clusters,all-clusters-minimal,chip-tool,light,tests}[-no-ble][-no-thread][-no-wifi][-asan][-ubsan][-with-ui] telink-{tlsr9518adk80d,tlsr9528a}-{air-quality-sensor,all-clusters,all-clusters-minimal,bridge,contact-sensor,light,light-switch,lock,ota-requestor,pump,pump-controller,resource-monitoring,shell,smoke-co-alarm,temperature-measurement,thermostat,window-covering}[-ota][-dfu][-shell][-rpc][-factory-data][-4mb] openiotsdk-{shell,lock}[-mbedtls][-psa] diff --git a/src/app/clusters/color-control-server/color-control-server.cpp b/src/app/clusters/color-control-server/color-control-server.cpp index cc8c9ab935550b..39fc5f9cdcc710 100644 --- a/src/app/clusters/color-control-server/color-control-server.cpp +++ b/src/app/clusters/color-control-server/color-control-server.cpp @@ -1171,7 +1171,7 @@ bool ColorControlServer::computeNewHueValue(ColorControlServer::ColorHueTransiti } /** - * @brief Configures EnventControl callback when using HSV colors + * @brief Configures EventControl callback when using HSV colors * * @param endpoint */ @@ -2101,7 +2101,7 @@ uint16_t ColorControlServer::findNewColorValueFromStep(uint16_t oldValue, int16_ } /** - * @brief Configures EnventControl callback when using XY colors + * @brief Configures EventControl callback when using XY colors * * @param endpoint */ @@ -2486,7 +2486,7 @@ uint16_t ColorControlServer::getTemperatureCoupleToLevelMin(EndpointId endpoint) } /** - * @brief Configures EnventControl callback when using Temp colors + * @brief Configures EventControl callback when using Temp colors * * @param endpoint */ @@ -2505,7 +2505,7 @@ void ColorControlServer::startUpColorTempCommand(EndpointId endpoint) { // 07-5123-07 (i.e. ZCL 7) 5.2.2.2.1.22 StartUpColorTemperatureMireds Attribute // The StartUpColorTemperatureMireds attribute SHALL define the desired startup color - // temperature values a lamp SHAL use when it is supplied with power and this value SHALL + // temperature values a lamp SHALL use when it is supplied with power and this value SHALL // be reflected in the ColorTemperatureMireds attribute. In addition, the ColorMode and // EnhancedColorMode attributes SHALL be set to 0x02 (color temperature). The values of // the StartUpColorTemperatureMireds attribute are listed in the table below.