|
| 1 | +#include <app/util/af.h> |
| 2 | + |
| 3 | +#include <app/util/af-event.h> |
| 4 | +#include <app/util/attribute-storage.h> |
| 5 | + |
| 6 | +#include <app-common/zap-generated/attribute-id.h> |
| 7 | +#include <app-common/zap-generated/attribute-type.h> |
| 8 | +#include <app-common/zap-generated/attributes/Accessors.h> |
| 9 | +#include <app-common/zap-generated/callback.h> |
| 10 | +#include <app-common/zap-generated/cluster-id.h> |
| 11 | +#include <app-common/zap-generated/cluster-objects.h> |
| 12 | +#include <app-common/zap-generated/command-id.h> |
| 13 | +#include <app-common/zap-generated/enums.h> |
| 14 | +#include <app-common/zap-generated/ids/Attributes.h> |
| 15 | +#include <app/CommandHandler.h> |
| 16 | +#include <app/ConcreteAttributePath.h> |
| 17 | +#include <app/ConcreteCommandPath.h> |
| 18 | +#include <app/util/error-mapping.h> |
| 19 | +#include <lib/core/CHIPEncoding.h> |
| 20 | + |
| 21 | +using namespace chip; |
| 22 | +using namespace chip::app; |
| 23 | +using namespace chip::app::Clusters; |
| 24 | + |
| 25 | +Protocols::InteractionModel::Status MatterThermostatUserInterfaceConfigurationClusterServerPreAttributeChangedCallback( |
| 26 | + const app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value) |
| 27 | +{ |
| 28 | + if (size != 0) |
| 29 | + { |
| 30 | + if (ThermostatUserInterfaceConfiguration::Attributes::TemperatureDisplayMode::Id == attributePath.mAttributeId) |
| 31 | + { |
| 32 | + EmberAfTemperatureDisplayMode mode = static_cast<EmberAfTemperatureDisplayMode>(chip::Encoding::Get8(value)); |
| 33 | + if ((EMBER_ZCL_TEMPERATURE_DISPLAY_MODE_CELSIUS != mode) && (EMBER_ZCL_TEMPERATURE_DISPLAY_MODE_FAHRENHEIT != mode)) |
| 34 | + { |
| 35 | + return Protocols::InteractionModel::Status::Failure; |
| 36 | + } |
| 37 | + } |
| 38 | + else if (ThermostatUserInterfaceConfiguration::Attributes::KeypadLockout::Id == attributePath.mAttributeId) |
| 39 | + { |
| 40 | + EmberAfKeypadLockout lockout = static_cast<EmberAfKeypadLockout>(chip::Encoding::Get8(value)); |
| 41 | + if ((EMBER_ZCL_KEYPAD_LOCKOUT_NO_LOCKOUT != lockout) && (EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_ONE_LOCKOUT != lockout) && |
| 42 | + (EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_TWO_LOCKOUT != lockout) && |
| 43 | + (EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_THREE_LOCKOUT != lockout) && |
| 44 | + (EMBER_ZCL_KEYPAD_LOCKOUT_LEVEL_FOUR_LOCKOUT != lockout) && (EMBER_ZCL_KEYPAD_LOCKOUT_LEVELFIVE_LOCKOUT != lockout)) |
| 45 | + { |
| 46 | + return Protocols::InteractionModel::Status::Failure; |
| 47 | + } |
| 48 | + } |
| 49 | + else if (ThermostatUserInterfaceConfiguration::Attributes::ScheduleProgrammingVisibility::Id == attributePath.mAttributeId) |
| 50 | + { |
| 51 | + uint8_t prog = chip::Encoding::Get8(value); |
| 52 | + if (prog > 1) |
| 53 | + { |
| 54 | + return Protocols::InteractionModel::Status::Failure; |
| 55 | + } |
| 56 | + } |
| 57 | + } |
| 58 | + |
| 59 | + return Protocols::InteractionModel::Status::Success; |
| 60 | +} |
0 commit comments