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

Add the Pre-Attribute checking for laundry washer controls cluster #28618

Merged
merged 10 commits into from
Aug 25, 2023
2 changes: 1 addition & 1 deletion examples/all-clusters-app/linux/main-common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void ApplicationShutdown()
using namespace chip::app::Clusters::LaundryWasherControls;
void emberAfLaundryWasherControlsClusterInitCallback(EndpointId endpoint)
{
LaundryWasherControlsServer::SetDefaultDelegate(1, &LaundryWasherControlDelegate::getLaundryWasherControlDelegate());
LaundryWasherControlsServer::SetDefaultDelegate(endpoint, &LaundryWasherControlDelegate::getLaundryWasherControlDelegate());
}

void emberAfLowPowerClusterInitCallback(EndpointId endpoint)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,53 @@ void MatterLaundryWasherControlsPluginServerInitCallback()
LaundryWasherControlsServer & laundryWasherControlsServer = LaundryWasherControlsServer::Instance();
registerAttributeAccessOverride(&laundryWasherControlsServer);
}

Status MatterLaundryWasherControlsClusterServerPreAttributeChangedCallback(const chip::app::ConcreteAttributePath & attributePath,
crlonxp marked this conversation as resolved.
Show resolved Hide resolved
EmberAfAttributeType attributeType, uint16_t size,
uint8_t * value)
{
Delegate * delegate = GetDelegate(attributePath.mEndpointId);
if (delegate == nullptr)
{
return Status::Success;
crlonxp marked this conversation as resolved.
Show resolved Hide resolved
}
switch (attributePath.mAttributeId)
{
case Attributes::SpinSpeedCurrent::Id: {
if (NumericAttributeTraits<uint8_t>::IsNullValue(*value))
{
return Status::Success;
}
char buffer[LaundryWasherControlsServer::kMaxSpinSpeedLength];
MutableCharSpan spinSpeed(buffer);
auto err = delegate->GetSpinSpeedAtIndex((*value), spinSpeed);
crlonxp marked this conversation as resolved.
Show resolved Hide resolved
if (err == CHIP_NO_ERROR)
{
return Status::Success;
}
else
{
return Status::ConstraintError;
}
}
case Attributes::NumberOfRinses::Id: {
for (uint8_t i = 0; true; i++)
crlonxp marked this conversation as resolved.
Show resolved Hide resolved
{
NumberOfRinsesEnum supportedRinse;
auto err = delegate->GetSupportedRinseAtIndex(i, supportedRinse);
if (err != CHIP_NO_ERROR)
{
// Can't find the attribute to be written in the supported list (CHIP_ERROR_PROVIDER_LIST_EXHAUSTED)
// Or can't get the correct supported list
return Status::InvalidInState;
}
if (supportedRinse == static_cast<NumberOfRinsesEnum>(*value))
{
// The written attribute is one of the supported item
return Status::Success;
}
}
}
}
return Status::Success;
}
1 change: 1 addition & 0 deletions src/app/common/templates/config-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,4 @@ ClustersWithPreAttributeChangeFunctions:
- Mode Select
- Fan Control
- Thermostat
- Laundry Washer Controls