Skip to content

Commit 8d9619d

Browse files
[Chef] Laundry dryer controls and tests (project-chip#43366)
* Add laundry dryer controls delegate * Include files in build * compile fix * compile debug * Add test for laundry dryer app * Clusters and initialisations for laundry dryer * Init laundry dryer controls * test debug * test debug * test debug * identify tests * laundry washer mode * Rename tests * Temperature controls cluster * Fix test bug * Fix test bug * Restyled by clang-format * Restyled by ruff * Restyled by autopep8 * fix lints * Fix error * Add static guards to allow initializers to be called only once --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent dee181d commit 8d9619d

9 files changed

Lines changed: 830 additions & 4 deletions

File tree

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
*
3+
* Copyright (c) 2026 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#include "chef-laundry-dryer-controls-delegate.h"
20+
#include <app/clusters/laundry-dryer-controls-server/laundry-dryer-controls-server.h>
21+
22+
#if MATTER_DM_LAUNDRY_DRYER_CONTROLS_CLUSTER_SERVER_ENDPOINT_COUNT > 0
23+
24+
namespace chip {
25+
namespace app {
26+
namespace Clusters {
27+
namespace LaundryDryerControls {
28+
namespace Chef {
29+
30+
CHIP_ERROR ChefDelegate::GetSupportedDrynessLevelAtIndex(size_t index, DrynessLevelEnum & supportedDryness)
31+
{
32+
if (index >= MATTER_ARRAY_SIZE(mSupportedDrynessLevels))
33+
{
34+
return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED;
35+
}
36+
supportedDryness = mSupportedDrynessLevels[index];
37+
return CHIP_NO_ERROR;
38+
}
39+
40+
void ChefDelegate::Register(EndpointId endpoint)
41+
{
42+
LaundryDryerControlsServer::SetDefaultDelegate(endpoint, this);
43+
}
44+
45+
} // namespace Chef
46+
} // namespace LaundryDryerControls
47+
} // namespace Clusters
48+
} // namespace app
49+
} // namespace chip
50+
51+
#endif // #if MATTER_DM_LAUNDRY_DRYER_CONTROLS_CLUSTER_SERVER_ENDPOINT_COUNT
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
*
3+
* Copyright (c) 2026 Project CHIP Authors
4+
* All rights reserved.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
#pragma once
20+
21+
#include <app-common/zap-generated/cluster-enums.h>
22+
#include <app/clusters/laundry-dryer-controls-server/laundry-dryer-controls-delegate.h>
23+
#include <app/util/config.h>
24+
#include <lib/core/CHIPError.h>
25+
#include <lib/support/CodeUtils.h>
26+
27+
#if MATTER_DM_LAUNDRY_DRYER_CONTROLS_CLUSTER_SERVER_ENDPOINT_COUNT > 0
28+
29+
namespace chip {
30+
namespace app {
31+
namespace Clusters {
32+
namespace LaundryDryerControls {
33+
namespace Chef {
34+
35+
/**
36+
* @brief The ChefDelegate class implements the LaundryDryerControls::Delegate.
37+
*/
38+
class ChefDelegate : public Delegate
39+
{
40+
public:
41+
ChefDelegate() = default;
42+
~ChefDelegate() override = default;
43+
44+
/**
45+
* @brief Get the supported dryness value at the given index in the list.
46+
* @param index The index of the supported dryness with 0 representing the first one.
47+
* @param supportedDryness The supported dryness at the given index
48+
* @return CHIP_ERROR_PROVIDER_LIST_EXHAUSTED if the index is out of range for the list of supported dryness.
49+
*/
50+
CHIP_ERROR GetSupportedDrynessLevelAtIndex(size_t index, DrynessLevelEnum & supportedDryness) override;
51+
52+
/**
53+
* @brief Register the delegate for the given endpoint.
54+
* @param endpoint The endpoint to register the delegate for.
55+
*/
56+
void Register(EndpointId endpoint);
57+
58+
private:
59+
const DrynessLevelEnum mSupportedDrynessLevels[3] = { DrynessLevelEnum::kLow, DrynessLevelEnum::kNormal,
60+
DrynessLevelEnum::kExtra };
61+
};
62+
63+
} // namespace Chef
64+
} // namespace LaundryDryerControls
65+
} // namespace Clusters
66+
} // namespace app
67+
} // namespace chip
68+
69+
#endif // #if MATTER_DM_LAUNDRY_DRYER_CONTROLS_CLUSTER_SERVER_ENDPOINT_COUNT

examples/chef/common/stubs.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ const Clusters::Descriptor::Structs::SemanticTagStruct::Type kEp2TagList[] = { P
182182
#include "microwave-oven-control/chef-microwave-oven-control.h"
183183
#endif // MATTER_DM_PLUGIN_MICROWAVE_OVEN_CONTROL_SERVER
184184

185+
#if MATTER_DM_LAUNDRY_DRYER_CONTROLS_CLUSTER_SERVER_ENDPOINT_COUNT > 0
186+
#include "laundry-dryer-controls/chef-laundry-dryer-controls-delegate.h"
187+
#endif // #if MATTER_DM_LAUNDRY_DRYER_CONTROLS_CLUSTER_SERVER_ENDPOINT_COUNT
188+
185189
Protocols::InteractionModel::Status emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId,
186190
const EmberAfAttributeMetadata * attributeMetadata,
187191
uint8_t * buffer, uint16_t maxReadLength)
@@ -597,11 +601,32 @@ void GenericSwitchInit()
597601
}
598602

599603
/**
604+
* This initializer is for the laundry dryer application rootnode_laundrydryer_01796fe396. To not have this initialiser affect
605+
* new laundry dryer chef apps, use a different endpoint.
606+
*/
607+
void LaundryDryerInit()
608+
{
609+
static bool called = false;
610+
VerifyOrDieWithMsg(!called, Zcl, "Error: LaundryDryerInit called more than once");
611+
called = true;
612+
#if MATTER_DM_LAUNDRY_DRYER_CONTROLS_CLUSTER_SERVER_ENDPOINT_COUNT > 0
613+
// Only initialises Laundry Dryer Controls. Other clusters are initialised through ember calls.
614+
if (DeviceTypes::EndpointHasDeviceType(1, Device::kLaundryDryerDeviceTypeId))
615+
{
616+
Platform::New<LaundryDryerControls::Chef::ChefDelegate>()->Register(1);
617+
}
618+
#endif // #if MATTER_DM_LAUNDRY_DRYER_CONTROLS_CLUSTER_SERVER_ENDPOINT_COUNT
619+
}
620+
621+
/*
600622
* This initializer is for the casting video player application rootnode_castingvideoplayer_contentapp_34699714e7. To not have this
601623
* initialiser affect new apps video player device types, use different endpoints.
602624
*/
603625
void CastingvideoplayerContentappInit()
604626
{
627+
static bool called = false;
628+
VerifyOrDieWithMsg(!called, Zcl, "Error: CastingvideoplayerContentappInit called more than once");
629+
called = true;
605630

606631
#if (MATTER_DM_CONTENT_LAUNCHER_CLUSTER_SERVER_ENDPOINT_COUNT > 0) && \
607632
(MATTER_DM_APPLICATION_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT > 0) && \
@@ -653,6 +678,7 @@ void ApplicationInit()
653678
RefrigeratorTemperatureControlledCabinetInit();
654679
OvenTemperatureControlledCabinetCooktopCookSurfaceInit();
655680
GenericSwitchInit();
681+
LaundryDryerInit();
656682
CastingvideoplayerContentappInit();
657683

658684
#ifdef MATTER_DM_PLUGIN_PUMP_CONFIGURATION_AND_CONTROL_SERVER

examples/chef/devices/rootnode_laundrydryer_01796fe396.matter

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,6 +1572,80 @@ cluster GroupKeyManagement = 63 {
15721572
fabric command access(invoke: administer) KeySetReadAllIndices(): KeySetReadAllIndicesResponse = 4;
15731573
}
15741574

1575+
/** This cluster provides a way to access options associated with the operation of
1576+
a laundry dryer device type. */
1577+
cluster LaundryDryerControls = 74 {
1578+
revision 1;
1579+
1580+
enum DrynessLevelEnum : enum8 {
1581+
kLow = 0;
1582+
kNormal = 1;
1583+
kExtra = 2;
1584+
kMax = 3;
1585+
}
1586+
1587+
readonly attribute DrynessLevelEnum supportedDrynessLevels[] = 0;
1588+
attribute nullable DrynessLevelEnum selectedDrynessLevel = 1;
1589+
readonly attribute command_id generatedCommandList[] = 65528;
1590+
readonly attribute command_id acceptedCommandList[] = 65529;
1591+
readonly attribute attrib_id attributeList[] = 65531;
1592+
readonly attribute bitmap32 featureMap = 65532;
1593+
readonly attribute int16u clusterRevision = 65533;
1594+
}
1595+
1596+
/** Attributes and commands for selecting a mode from a list of supported options. */
1597+
cluster LaundryWasherMode = 81 {
1598+
revision 3;
1599+
1600+
enum ModeTag : enum16 {
1601+
kAuto = 0;
1602+
kQuick = 1;
1603+
kQuiet = 2;
1604+
kLowNoise = 3;
1605+
kLowEnergy = 4;
1606+
kVacation = 5;
1607+
kMin = 6;
1608+
kMax = 7;
1609+
kNight = 8;
1610+
kDay = 9;
1611+
kNormal = 16384;
1612+
kDelicate = 16385;
1613+
kHeavy = 16386;
1614+
kWhites = 16387;
1615+
}
1616+
1617+
shared struct ModeTagStruct {
1618+
optional vendor_id mfgCode = 0;
1619+
enum16 value = 1;
1620+
}
1621+
1622+
shared struct ModeOptionStruct {
1623+
char_string<64> label = 0;
1624+
int8u mode = 1;
1625+
ModeTagStruct modeTags[] = 2;
1626+
}
1627+
1628+
readonly attribute ModeOptionStruct supportedModes[] = 0;
1629+
readonly attribute int8u currentMode = 1;
1630+
readonly attribute command_id generatedCommandList[] = 65528;
1631+
readonly attribute command_id acceptedCommandList[] = 65529;
1632+
readonly attribute attrib_id attributeList[] = 65531;
1633+
readonly attribute bitmap32 featureMap = 65532;
1634+
readonly attribute int16u clusterRevision = 65533;
1635+
1636+
request struct ChangeToModeRequest {
1637+
int8u newMode = 0;
1638+
}
1639+
1640+
response struct ChangeToModeResponse = 1 {
1641+
enum8 status = 0;
1642+
optional char_string<64> statusText = 1;
1643+
}
1644+
1645+
/** This command is used to change device modes. */
1646+
command ChangeToMode(ChangeToModeRequest): ChangeToModeResponse = 0;
1647+
}
1648+
15751649
/** Attributes and commands for configuring the temperature control, and reporting temperature. */
15761650
cluster TemperatureControl = 86 {
15771651
revision 1;
@@ -1932,6 +2006,28 @@ endpoint 1 {
19322006
callback attribute clusterRevision;
19332007
}
19342008

2009+
server cluster LaundryDryerControls {
2010+
callback attribute supportedDrynessLevels;
2011+
ram attribute selectedDrynessLevel;
2012+
callback attribute generatedCommandList;
2013+
callback attribute acceptedCommandList;
2014+
callback attribute attributeList;
2015+
ram attribute featureMap default = 0;
2016+
ram attribute clusterRevision default = 1;
2017+
}
2018+
2019+
server cluster LaundryWasherMode {
2020+
callback attribute supportedModes;
2021+
callback attribute currentMode;
2022+
callback attribute generatedCommandList;
2023+
callback attribute acceptedCommandList;
2024+
callback attribute attributeList;
2025+
callback attribute featureMap;
2026+
ram attribute clusterRevision default = 3;
2027+
2028+
handle command ChangeToMode;
2029+
}
2030+
19352031
server cluster TemperatureControl {
19362032
ram attribute selectedTemperatureLevel;
19372033
callback attribute supportedTemperatureLevels;

0 commit comments

Comments
 (0)