From 1417952eaad1c8f1aa94b5657f303880d441ed3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Josefsen?= <69624991+ReneJosefsen@users.noreply.github.com> Date: Wed, 6 Jul 2022 04:42:52 +0200 Subject: [PATCH] [Pump-server] Add unsupported operation mode handling in pump server (#20154) * Updated pump server to handle unsupported operation modes * Remove empty states and adjusted default * remove whitespaces Co-authored-by: Mathias K. Garbus --- .../pump-configuration-and-control-server.cpp | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/app/clusters/pump-configuration-and-control-server/pump-configuration-and-control-server.cpp b/src/app/clusters/pump-configuration-and-control-server/pump-configuration-and-control-server.cpp index 1e4e4fb69d881d..7855faa9d4a27f 100644 --- a/src/app/clusters/pump-configuration-and-control-server/pump-configuration-and-control-server.cpp +++ b/src/app/clusters/pump-configuration-and-control-server/pump-configuration-and-control-server.cpp @@ -354,9 +354,9 @@ chip::Protocols::InteractionModel::Status MatterPumpConfigurationAndControlClust { case Attributes::ControlMode::Id: { PumpControlMode controlMode; - NumericAttributeTraits::StorageType storage; - memcpy(&storage, value, size); - controlMode = NumericAttributeTraits::StorageToWorking(storage); + NumericAttributeTraits::StorageType tmp; + memcpy(&tmp, value, size); + controlMode = NumericAttributeTraits::StorageToWorking(tmp); switch (controlMode) { case PumpControlMode::kConstantFlow: @@ -389,8 +389,31 @@ chip::Protocols::InteractionModel::Status MatterPumpConfigurationAndControlClust } } break; + case Attributes::OperationMode::Id: - // TODO: Implement checks on the Operation Mode values + PumpOperationMode operationMode; + NumericAttributeTraits::StorageType tmp; + memcpy(&tmp, value, size); + operationMode = NumericAttributeTraits::StorageToWorking(tmp); + + switch (operationMode) + { + case PumpOperationMode::kMinimum: + if (!IsFeatureSupported(attributePath.mEndpointId, Attributes::MinConstSpeed::Get, Attributes::MaxConstSpeed::Get)) + { + status = Protocols::InteractionModel::Status::ConstraintError; + } + break; + case PumpOperationMode::kMaximum: + if (!IsFeatureSupported(attributePath.mEndpointId, Attributes::MinConstSpeed::Get, Attributes::MaxConstSpeed::Get)) + { + status = Protocols::InteractionModel::Status::ConstraintError; + } + break; + default: + status = Protocols::InteractionModel::Status::Success; + } + break; default: status = Protocols::InteractionModel::Status::Success;