Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle Bugfix termostat user interface value validation #11059

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions examples/all-clusters-app/linux/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@
* limitations under the License.
*/

#include <app-common/zap-generated/callback.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/Command.h>
#include <app/ConcreteAttributePath.h>
#include <app/clusters/identify-server/identify-server.h>
#include <app/util/af.h>

#include "AppMain.h"

using namespace chip;

bool emberAfBasicClusterMfgSpecificPingCallback(chip::app::Command * commandObj)
{
emberAfSendDefaultResponse(emberAfCurrentCommand(), EMBER_ZCL_STATUS_SUCCESS);
Expand All @@ -42,6 +47,22 @@ Identify gIdentify1 = {
EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED,
};

Protocols::InteractionModel::Status MatterPreAttributeChangeCallback(const app::ConcreteAttributePath & attributePath, uint8_t mask,
uint8_t type, uint16_t size, uint8_t * value)
{
Protocols::InteractionModel::Status status = Protocols::InteractionModel::Status::Success;
if (attributePath.mClusterId == app::Clusters::Thermostat::Id)
{
status = MatterThermostatClusterServerPreAttributeChangedCallback(attributePath, type, size, value);
}
else if (attributePath.mClusterId == app::Clusters::ThermostatUserInterfaceConfiguration::Id)
{
status =
MatterThermostatUserInterfaceConfigurationClusterServerPreAttributeChangedCallback(attributePath, type, size, value);
}
return status;
}

int main(int argc, char * argv[])
{
VerifyOrDie(ChipLinuxAppInit(argc, argv) == 0);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#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 (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 = static_cast<uint8_t>(chip::Encoding::Get8(value));
if (prog > 1)
{
return Protocols::InteractionModel::Status::Failure;
}
}
return Protocols::InteractionModel::Status::Success;
}
2 changes: 1 addition & 1 deletion src/app/zap_cluster_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
'THERMOSTAT_CLUSTER': ['thermostat-server'],
'THREAD_NETWORK_DIAGNOSTICS_CLUSTER': ['thread_network_diagnostics_server'],
'WINDOW_COVERING_CLUSTER': ['window-covering-server'],
'THERMOSTAT_UI_CONFIG_CLUSTER': [],
'THERMOSTAT_UI_CONFIG_CLUSTER': ['thermostat-user-interface-configuration-server'],
'WIFI_NETWORK_DIAGNOSTICS_CLUSTER': ['wifi_network_diagnostics_server'],
'WAKE_ON_LAN_CLUSTER': [],
'ZLL_COMMISSIONING_CLUSTER': []
Expand Down