Skip to content

Commit

Permalink
Remove KeypadLockout, TemperatureDisplayMode weak enums (#25149)
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple authored and pull[bot] committed Aug 25, 2023
1 parent 27f1a67 commit 1233952
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 49 deletions.
Original file line number Diff line number Diff line change
@@ -1,56 +1,85 @@
#include <app/util/af.h>
/**
*
* 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 <app/util/af-event.h>
#include <app/util/attribute-storage.h>
#include <app/util/af.h>

#include <app-common/zap-generated/attributes/Accessors.h>
#include <app-common/zap-generated/callback.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/enums.h>
#include <app-common/zap-generated/ids/Attributes.h>
#include <app/CommandHandler.h>
#include <app/ConcreteAttributePath.h>
#include <app/ConcreteCommandPath.h>
#include <app/util/error-mapping.h>
#include <lib/core/CHIPEncoding.h>

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<EmberAfTemperatureDisplayMode>(chip::Encoding::Get8(value));
if ((EMBER_ZCL_TEMPERATURE_DISPLAY_MODE_CELSIUS != mode) && (EMBER_ZCL_TEMPERATURE_DISPLAY_MODE_FAHRENHEIT != mode))
auto mode = static_cast<TemperatureDisplayMode>(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<EmberAfKeypadLockout>(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<KeypadLockout>(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;
}
2 changes: 0 additions & 2 deletions src/app/common/templates/config-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ WeakEnums:
- IdentifyEffectVariant
- IdentifyIdentifyType
- InterfaceTypeEnum
- KeypadLockout
- LevelControlOptions
- MoveMode
- NetworkFaultEnum
Expand All @@ -28,7 +27,6 @@ WeakEnums:
- SaturationMoveMode
- SaturationStepMode
- StepMode
- TemperatureDisplayMode

DefineBitmaps:
# Allow-list of bitmaps that we generates as #define as well as enum classes.
Expand Down
18 changes: 0 additions & 18 deletions zzz_generated/app-common/app-common/zap-generated/enums.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1233952

Please sign in to comment.