Skip to content

Commit 1139512

Browse files
vivien-applepull[bot]
authored andcommitted
Remove KeypadLockout, TemperatureDisplayMode weak enums (#25149)
1 parent f3de4c2 commit 1139512

File tree

3 files changed

+58
-49
lines changed

3 files changed

+58
-49
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,85 @@
1-
#include <app/util/af.h>
1+
/**
2+
*
3+
* Copyright (c) 2021-2023 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
217

3-
#include <app/util/af-event.h>
4-
#include <app/util/attribute-storage.h>
18+
#include <app/util/af.h>
519

6-
#include <app-common/zap-generated/attributes/Accessors.h>
7-
#include <app-common/zap-generated/callback.h>
820
#include <app-common/zap-generated/cluster-objects.h>
9-
#include <app-common/zap-generated/enums.h>
10-
#include <app-common/zap-generated/ids/Attributes.h>
11-
#include <app/CommandHandler.h>
1221
#include <app/ConcreteAttributePath.h>
13-
#include <app/ConcreteCommandPath.h>
14-
#include <app/util/error-mapping.h>
1522
#include <lib/core/CHIPEncoding.h>
1623

17-
using namespace chip;
1824
using namespace chip::app;
19-
using namespace chip::app::Clusters;
25+
using namespace chip::app::Clusters::ThermostatUserInterfaceConfiguration;
26+
using chip::Protocols::InteractionModel::Status;
27+
28+
namespace {
29+
//
30+
// Those types are defined as drafts in
31+
// src/app/zap-templates/zcl/data-model/draft/types/thermostat-user-interface-configuration.xml
32+
//
33+
enum class TemperatureDisplayMode : uint8_t
34+
{
35+
kCelsius = 0x0,
36+
kFahrenheit = 0x1,
37+
};
38+
39+
enum class KeypadLockout : uint8_t
40+
{
41+
kNoLockout = 0x0,
42+
kLevelOneLockout = 0x1,
43+
kLevelTwoLockout = 0x2,
44+
kLevelThreeLockout = 0x3,
45+
kLevelFourLockout = 0x4,
46+
kLevelFiveLockout = 0x5,
47+
};
48+
49+
} // namespace
2050

21-
Protocols::InteractionModel::Status MatterThermostatUserInterfaceConfigurationClusterServerPreAttributeChangedCallback(
22-
const app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value)
51+
Status MatterThermostatUserInterfaceConfigurationClusterServerPreAttributeChangedCallback(
52+
const ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value)
2353
{
2454
if (size != 0)
2555
{
26-
if (ThermostatUserInterfaceConfiguration::Attributes::TemperatureDisplayMode::Id == attributePath.mAttributeId)
56+
if (Attributes::TemperatureDisplayMode::Id == attributePath.mAttributeId)
2757
{
28-
EmberAfTemperatureDisplayMode mode = static_cast<EmberAfTemperatureDisplayMode>(chip::Encoding::Get8(value));
29-
if ((EMBER_ZCL_TEMPERATURE_DISPLAY_MODE_CELSIUS != mode) && (EMBER_ZCL_TEMPERATURE_DISPLAY_MODE_FAHRENHEIT != mode))
58+
auto mode = static_cast<TemperatureDisplayMode>(chip::Encoding::Get8(value));
59+
if ((TemperatureDisplayMode::kCelsius != mode) && (TemperatureDisplayMode::kFahrenheit != mode))
3060
{
31-
return Protocols::InteractionModel::Status::Failure;
61+
return Status::Failure;
3262
}
3363
}
34-
else if (ThermostatUserInterfaceConfiguration::Attributes::KeypadLockout::Id == attributePath.mAttributeId)
64+
else if (Attributes::KeypadLockout::Id == attributePath.mAttributeId)
3565
{
36-
EmberAfKeypadLockout lockout = static_cast<EmberAfKeypadLockout>(chip::Encoding::Get8(value));
37-
if ((EMBER_ZCL_KEYPAD_LOCKOUT_NO_LOCKOUT != lockout) && (EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_ONE_LOCKOUT != lockout) &&
38-
(EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_TWO_LOCKOUT != lockout) &&
39-
(EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_THREE_LOCKOUT != lockout) &&
40-
(EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_FOUR_LOCKOUT != lockout) && (EMBER_ZCL_KEYPAD_LOCKOUT_LEVELFIVE_LOCKOUT != lockout))
66+
auto lockout = static_cast<KeypadLockout>(chip::Encoding::Get8(value));
67+
if ((KeypadLockout::kNoLockout != lockout) && (KeypadLockout::kLevelOneLockout != lockout) &&
68+
(KeypadLockout::kLevelTwoLockout != lockout) && (KeypadLockout::kLevelThreeLockout != lockout) &&
69+
(KeypadLockout::kLevelFourLockout != lockout) && (KeypadLockout::kLevelFiveLockout != lockout))
4170
{
42-
return Protocols::InteractionModel::Status::Failure;
71+
return Status::Failure;
4372
}
4473
}
45-
else if (ThermostatUserInterfaceConfiguration::Attributes::ScheduleProgrammingVisibility::Id == attributePath.mAttributeId)
74+
else if (Attributes::ScheduleProgrammingVisibility::Id == attributePath.mAttributeId)
4675
{
47-
uint8_t prog = chip::Encoding::Get8(value);
76+
auto prog = chip::Encoding::Get8(value);
4877
if (prog > 1)
4978
{
50-
return Protocols::InteractionModel::Status::Failure;
79+
return Status::Failure;
5180
}
5281
}
5382
}
5483

55-
return Protocols::InteractionModel::Status::Success;
84+
return Status::Success;
5685
}

src/app/common/templates/config-data.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ WeakEnums:
1818
- IdentifyEffectVariant
1919
- IdentifyIdentifyType
2020
- InterfaceTypeEnum
21-
- KeypadLockout
2221
- LevelControlOptions
2322
- MoveMode
2423
- NetworkFaultEnum
@@ -28,7 +27,6 @@ WeakEnums:
2827
- SaturationMoveMode
2928
- SaturationStepMode
3029
- StepMode
31-
- TemperatureDisplayMode
3230

3331
DefineBitmaps:
3432
# Allow-list of bitmaps that we generates as #define as well as enum classes.

zzz_generated/app-common/app-common/zap-generated/enums.h

-18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)