From 212078689f338b64dd16bdef18f39a90da035f28 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Fri, 17 Feb 2023 21:19:16 +0100 Subject: [PATCH] Remove KeypadLockout, TemperatureDisplayMode weak enums (#25149) --- ...at-user-interface-configuration-server.cpp | 87 ++++++++++++------- src/app/common/templates/config-data.yaml | 2 - .../app-common/zap-generated/enums.h | 18 ---- 3 files changed, 58 insertions(+), 49 deletions(-) diff --git a/src/app/clusters/thermostat-user-interface-configuration-server/thermostat-user-interface-configuration-server.cpp b/src/app/clusters/thermostat-user-interface-configuration-server/thermostat-user-interface-configuration-server.cpp index 3bc24f0b994dad..af13619a85365c 100644 --- a/src/app/clusters/thermostat-user-interface-configuration-server/thermostat-user-interface-configuration-server.cpp +++ b/src/app/clusters/thermostat-user-interface-configuration-server/thermostat-user-interface-configuration-server.cpp @@ -1,56 +1,85 @@ -#include +/** + * + * Copyright (c) 2021-2023 Project CHIP Authors + * + * 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 -#include -#include -#include #include -#include -#include #include -using namespace chip; using namespace chip::app; -using namespace chip::app::Clusters; +using namespace chip::app::Clusters::ThermostatUserInterfaceConfiguration; +using chip::Protocols::InteractionModel::Status; + +namespace { +// +// Those types are defined as drafts in +// src/app/zap-templates/zcl/data-model/draft/types/thermostat-user-interface-configuration.xml +// +enum class TemperatureDisplayMode : uint8_t +{ + kCelsius = 0x0, + kFahrenheit = 0x1, +}; + +enum class KeypadLockout : uint8_t +{ + kNoLockout = 0x0, + kLevelOneLockout = 0x1, + kLevelTwoLockout = 0x2, + kLevelThreeLockout = 0x3, + kLevelFourLockout = 0x4, + kLevelFiveLockout = 0x5, +}; + +} // namespace -Protocols::InteractionModel::Status MatterThermostatUserInterfaceConfigurationClusterServerPreAttributeChangedCallback( - const app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value) +Status MatterThermostatUserInterfaceConfigurationClusterServerPreAttributeChangedCallback( + const ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value) { if (size != 0) { - if (ThermostatUserInterfaceConfiguration::Attributes::TemperatureDisplayMode::Id == attributePath.mAttributeId) + if (Attributes::TemperatureDisplayMode::Id == attributePath.mAttributeId) { - EmberAfTemperatureDisplayMode mode = static_cast(chip::Encoding::Get8(value)); - if ((EMBER_ZCL_TEMPERATURE_DISPLAY_MODE_CELSIUS != mode) && (EMBER_ZCL_TEMPERATURE_DISPLAY_MODE_FAHRENHEIT != mode)) + auto mode = static_cast(chip::Encoding::Get8(value)); + if ((TemperatureDisplayMode::kCelsius != mode) && (TemperatureDisplayMode::kFahrenheit != mode)) { - return Protocols::InteractionModel::Status::Failure; + return Status::Failure; } } - else if (ThermostatUserInterfaceConfiguration::Attributes::KeypadLockout::Id == attributePath.mAttributeId) + else if (Attributes::KeypadLockout::Id == attributePath.mAttributeId) { - EmberAfKeypadLockout lockout = static_cast(chip::Encoding::Get8(value)); - if ((EMBER_ZCL_KEYPAD_LOCKOUT_NO_LOCKOUT != lockout) && (EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_ONE_LOCKOUT != lockout) && - (EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_TWO_LOCKOUT != lockout) && - (EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_THREE_LOCKOUT != lockout) && - (EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_FOUR_LOCKOUT != lockout) && (EMBER_ZCL_KEYPAD_LOCKOUT_LEVELFIVE_LOCKOUT != lockout)) + auto lockout = static_cast(chip::Encoding::Get8(value)); + if ((KeypadLockout::kNoLockout != lockout) && (KeypadLockout::kLevelOneLockout != lockout) && + (KeypadLockout::kLevelTwoLockout != lockout) && (KeypadLockout::kLevelThreeLockout != lockout) && + (KeypadLockout::kLevelFourLockout != lockout) && (KeypadLockout::kLevelFiveLockout != lockout)) { - return Protocols::InteractionModel::Status::Failure; + return Status::Failure; } } - else if (ThermostatUserInterfaceConfiguration::Attributes::ScheduleProgrammingVisibility::Id == attributePath.mAttributeId) + else if (Attributes::ScheduleProgrammingVisibility::Id == attributePath.mAttributeId) { - uint8_t prog = chip::Encoding::Get8(value); + auto prog = chip::Encoding::Get8(value); if (prog > 1) { - return Protocols::InteractionModel::Status::Failure; + return Status::Failure; } } } - return Protocols::InteractionModel::Status::Success; + return Status::Success; } diff --git a/src/app/common/templates/config-data.yaml b/src/app/common/templates/config-data.yaml index 94be6cc89003f7..4c2e9e8d4db42c 100644 --- a/src/app/common/templates/config-data.yaml +++ b/src/app/common/templates/config-data.yaml @@ -18,7 +18,6 @@ WeakEnums: - IdentifyEffectVariant - IdentifyIdentifyType - InterfaceTypeEnum - - KeypadLockout - LevelControlOptions - MoveMode - NetworkFaultEnum @@ -28,7 +27,6 @@ WeakEnums: - SaturationMoveMode - SaturationStepMode - StepMode - - TemperatureDisplayMode DefineBitmaps: # Allow-list of bitmaps that we generates as #define as well as enum classes. diff --git a/zzz_generated/app-common/app-common/zap-generated/enums.h b/zzz_generated/app-common/app-common/zap-generated/enums.h index ef52e0b548568c..8debcf5eab5547 100644 --- a/zzz_generated/app-common/app-common/zap-generated/enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/enums.h @@ -156,17 +156,6 @@ enum EmberAfInterfaceTypeEnum : uint8_t EMBER_ZCL_INTERFACE_TYPE_ENUM_THREAD = 4, }; -// Enum for KeypadLockout -enum EmberAfKeypadLockout : uint8_t -{ - EMBER_ZCL_KEYPAD_LOCKOUT_NO_LOCKOUT = 0, - EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_ONE_LOCKOUT = 1, - EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_TWO_LOCKOUT = 2, - EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_THREE_LOCKOUT = 3, - EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_FOUR_LOCKOUT = 4, - EMBER_ZCL_KEYPAD_LOCKOUT_LEVELFIVE_LOCKOUT = 5, -}; - // Enum for MoveMode enum EmberAfMoveMode : uint8_t { @@ -244,13 +233,6 @@ enum EmberAfStepMode : uint8_t EMBER_ZCL_STEP_MODE_DOWN = 1, }; -// Enum for TemperatureDisplayMode -enum EmberAfTemperatureDisplayMode : uint8_t -{ - EMBER_ZCL_TEMPERATURE_DISPLAY_MODE_CELSIUS = 0, - EMBER_ZCL_TEMPERATURE_DISPLAY_MODE_FAHRENHEIT = 1, -}; - #define EMBER_AF_BARRIER_CONTROL_CAPABILITIES_PARTIAL_BARRIER (1) #define EMBER_AF_BARRIER_CONTROL_CAPABILITIES_PARTIAL_BARRIER_OFFSET (0) #define EMBER_AF_BARRIER_CONTROL_SAFETY_STATUS_REMOTE_LOCKOUT (1)