|
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 | + */ |
2 | 17 |
|
3 |
| -#include <app/util/af-event.h> |
4 |
| -#include <app/util/attribute-storage.h> |
| 18 | +#include <app/util/af.h> |
5 | 19 |
|
6 |
| -#include <app-common/zap-generated/attributes/Accessors.h> |
7 |
| -#include <app-common/zap-generated/callback.h> |
8 | 20 | #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> |
12 | 21 | #include <app/ConcreteAttributePath.h>
|
13 |
| -#include <app/ConcreteCommandPath.h> |
14 |
| -#include <app/util/error-mapping.h> |
15 | 22 | #include <lib/core/CHIPEncoding.h>
|
16 | 23 |
|
17 |
| -using namespace chip; |
18 | 24 | 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 |
20 | 50 |
|
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) |
23 | 53 | {
|
24 | 54 | if (size != 0)
|
25 | 55 | {
|
26 |
| - if (ThermostatUserInterfaceConfiguration::Attributes::TemperatureDisplayMode::Id == attributePath.mAttributeId) |
| 56 | + if (Attributes::TemperatureDisplayMode::Id == attributePath.mAttributeId) |
27 | 57 | {
|
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)) |
30 | 60 | {
|
31 |
| - return Protocols::InteractionModel::Status::Failure; |
| 61 | + return Status::Failure; |
32 | 62 | }
|
33 | 63 | }
|
34 |
| - else if (ThermostatUserInterfaceConfiguration::Attributes::KeypadLockout::Id == attributePath.mAttributeId) |
| 64 | + else if (Attributes::KeypadLockout::Id == attributePath.mAttributeId) |
35 | 65 | {
|
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)) |
41 | 70 | {
|
42 |
| - return Protocols::InteractionModel::Status::Failure; |
| 71 | + return Status::Failure; |
43 | 72 | }
|
44 | 73 | }
|
45 |
| - else if (ThermostatUserInterfaceConfiguration::Attributes::ScheduleProgrammingVisibility::Id == attributePath.mAttributeId) |
| 74 | + else if (Attributes::ScheduleProgrammingVisibility::Id == attributePath.mAttributeId) |
46 | 75 | {
|
47 |
| - uint8_t prog = chip::Encoding::Get8(value); |
| 76 | + auto prog = chip::Encoding::Get8(value); |
48 | 77 | if (prog > 1)
|
49 | 78 | {
|
50 |
| - return Protocols::InteractionModel::Status::Failure; |
| 79 | + return Status::Failure; |
51 | 80 | }
|
52 | 81 | }
|
53 | 82 | }
|
54 | 83 |
|
55 |
| - return Protocols::InteractionModel::Status::Success; |
| 84 | + return Status::Success; |
56 | 85 | }
|
0 commit comments