-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix termostat user interface value validation (#11058)
* add support for boundry checks for thermostat-user-interface-configuration * add impl for boundry checks for thermostat-user-interface-configuration in all-clsuter-app * add check for size and remove static cast to unit8 * add support for ProAttribute hook for thermostat user interface configuration * remove preattribute hooks in all-cluster-app/linux * regen all * fix esp32 and mbed builds
- Loading branch information
Showing
7 changed files
with
79 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...at-user-interface-configuration-server/thermostat-user-interface-configuration-server.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include <app/util/af.h> | ||
|
||
#include <app/util/af-event.h> | ||
#include <app/util/attribute-storage.h> | ||
|
||
#include <app-common/zap-generated/attribute-id.h> | ||
#include <app-common/zap-generated/attribute-type.h> | ||
#include <app-common/zap-generated/attributes/Accessors.h> | ||
#include <app-common/zap-generated/callback.h> | ||
#include <app-common/zap-generated/cluster-id.h> | ||
#include <app-common/zap-generated/cluster-objects.h> | ||
#include <app-common/zap-generated/command-id.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; | ||
|
||
Protocols::InteractionModel::Status MatterThermostatUserInterfaceConfigurationClusterServerPreAttributeChangedCallback( | ||
const app::ConcreteAttributePath & attributePath, EmberAfAttributeType attributeType, uint16_t size, uint8_t * value) | ||
{ | ||
if (size != 0) | ||
{ | ||
if (ThermostatUserInterfaceConfiguration::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)) | ||
{ | ||
return Protocols::InteractionModel::Status::Failure; | ||
} | ||
} | ||
else if (ThermostatUserInterfaceConfiguration::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)) | ||
{ | ||
return Protocols::InteractionModel::Status::Failure; | ||
} | ||
} | ||
else if (ThermostatUserInterfaceConfiguration::Attributes::ScheduleProgrammingVisibility::Id == attributePath.mAttributeId) | ||
{ | ||
uint8_t prog = chip::Encoding::Get8(value); | ||
if (prog > 1) | ||
{ | ||
return Protocols::InteractionModel::Status::Failure; | ||
} | ||
} | ||
} | ||
|
||
return Protocols::InteractionModel::Status::Success; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 9 additions & 1 deletion
10
zzz_generated/all-clusters-app/zap-generated/endpoint_config.h
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.