Skip to content

Commit 93d430b

Browse files
tersalrestyled-commitsCopilotbzbarsky-apple
authored
Migrate ValveConfigurationAndControl cluster. (project-chip#42366)
* Valve Configuration And Control code driven cluster migration * Minor code additions/removals * Remove trailing spaces * Fix unit test * Restyled by whitespace * Restyled by clang-format * Restyled by gn * Restyled by prettier-json * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix typos, removed switch braces and change order of Attributes in config file * Restyled by whitespace * Restyled by prettier-json * Fix compilation errors * Update src/app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-cluster.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Revert Delegate changes * Revert header changes in Delegate and app implementation * Update src/app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-cluster.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * changes to build files and unit tests * Regenerate with ZAP * Restyled by whitespace * Restyled by clang-format * Restyled by gn * Restyled by prettier-json * Resolve merge conflicts with ZAP generation * Regenerate with ZAP * Add SetLevel API back and fix tests * Restyled by clang-format * Add guards for TimeSync dependency * Fix compilation errors * Change event logic to avoid double reporting * Refactor OpenValve functions * Run ZAP generation * Restyled by clang-format * Address PR comments * Restyled by whitespace * Restyled by clang-format * Fix report on error * Avoid creating repeated events and reverted code to base functionality * Restyled by clang-format * Update testing files * Use AttributePersistence for Nullable types * Rename variable * Add initialization struct for values * Add initialization values to UnitTest * Rever ember changes for attributes * Restyled by whitespace * Restyled by clang-format * Restyled by prettier-json * Revert CamelCase file rename * Address PR comments * Apply suggestions from code review Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Apply suggestions from code review Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix compilation issues * Restyled by clang-format * Update Codegen files * Restyled by clang-format * Fix comments and remove unused parameter from function * Restyled by clang-format * Improve TODO comment * Restyled by clang-format * Add command testing and fix PR comments * Restyled by whitespace * Restyled by clang-format * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Fix typos * Fix unit test error caused by test framework change * Remove initialization from class and add default checks in unit tests * Revert removal of some attributes with specific default values defined * Add test files back * Restyled by clang-format * Regenerate zap files * Address PR comments * Restyled by clang-format * Update with PR comments * Regenerate ZAP files * Restyled by clang-format * Reorder struct initialization * Add comments for OpenValve function * Restyled by whitespace * Restyled by clang-format * Remove trailing semicolon and fix typos * Modify TimeSync description * Restyled by clang-format * Address PR comments * Use SetAttributeValue to attribute changes * Address PR comments * Restyled by whitespace * Restyled by clang-format * Add UT for invalida command values and more PR comments * Restyled by whitespace * Fix compilation errors in UT * Add comments linked to issues and description for command faults --------- Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent fbdbe29 commit 93d430b

30 files changed

Lines changed: 1591 additions & 1406 deletions

examples/all-clusters-app/all-clusters-common/all-clusters-app.matter

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8053,22 +8053,22 @@ endpoint 1 {
80538053
server cluster ValveConfigurationAndControl {
80548054
emits event ValveStateChanged;
80558055
emits event ValveFault;
8056-
ram attribute openDuration;
8057-
persist attribute defaultOpenDuration;
8058-
ram attribute autoCloseTime;
8056+
callback attribute openDuration;
8057+
callback attribute defaultOpenDuration;
8058+
callback attribute autoCloseTime;
80598059
callback attribute remainingDuration;
8060-
ram attribute currentState;
8061-
ram attribute targetState;
8062-
ram attribute currentLevel;
8063-
ram attribute targetLevel;
8064-
persist attribute defaultOpenLevel default = 100;
8065-
ram attribute valveFault default = 0;
8066-
ram attribute levelStep default = 1;
8060+
callback attribute currentState;
8061+
callback attribute targetState;
8062+
callback attribute currentLevel;
8063+
callback attribute targetLevel;
8064+
callback attribute defaultOpenLevel;
8065+
callback attribute valveFault;
8066+
callback attribute levelStep;
80678067
callback attribute generatedCommandList;
80688068
callback attribute acceptedCommandList;
80698069
callback attribute attributeList;
80708070
ram attribute featureMap default = 3;
8071-
ram attribute clusterRevision default = 1;
8071+
callback attribute clusterRevision;
80728072

80738073
handle command Open;
80748074
handle command Close;

examples/all-clusters-app/all-clusters-common/all-clusters-app.zap

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11751,7 +11751,7 @@
1175111751
"side": "server",
1175211752
"type": "elapsed_s",
1175311753
"included": 1,
11754-
"storageOption": "RAM",
11754+
"storageOption": "External",
1175511755
"singleton": 0,
1175611756
"bounded": 0,
1175711757
"defaultValue": null,
@@ -11767,7 +11767,7 @@
1176711767
"side": "server",
1176811768
"type": "elapsed_s",
1176911769
"included": 1,
11770-
"storageOption": "NVM",
11770+
"storageOption": "External",
1177111771
"singleton": 0,
1177211772
"bounded": 0,
1177311773
"defaultValue": null,
@@ -11783,7 +11783,7 @@
1178311783
"side": "server",
1178411784
"type": "epoch_us",
1178511785
"included": 1,
11786-
"storageOption": "RAM",
11786+
"storageOption": "External",
1178711787
"singleton": 0,
1178811788
"bounded": 0,
1178911789
"defaultValue": null,
@@ -11815,7 +11815,7 @@
1181511815
"side": "server",
1181611816
"type": "ValveStateEnum",
1181711817
"included": 1,
11818-
"storageOption": "RAM",
11818+
"storageOption": "External",
1181911819
"singleton": 0,
1182011820
"bounded": 0,
1182111821
"defaultValue": null,
@@ -11831,7 +11831,7 @@
1183111831
"side": "server",
1183211832
"type": "ValveStateEnum",
1183311833
"included": 1,
11834-
"storageOption": "RAM",
11834+
"storageOption": "External",
1183511835
"singleton": 0,
1183611836
"bounded": 0,
1183711837
"defaultValue": null,
@@ -11847,7 +11847,7 @@
1184711847
"side": "server",
1184811848
"type": "percent",
1184911849
"included": 1,
11850-
"storageOption": "RAM",
11850+
"storageOption": "External",
1185111851
"singleton": 0,
1185211852
"bounded": 0,
1185311853
"defaultValue": null,
@@ -11863,7 +11863,7 @@
1186311863
"side": "server",
1186411864
"type": "percent",
1186511865
"included": 1,
11866-
"storageOption": "RAM",
11866+
"storageOption": "External",
1186711867
"singleton": 0,
1186811868
"bounded": 0,
1186911869
"defaultValue": null,
@@ -11879,10 +11879,10 @@
1187911879
"side": "server",
1188011880
"type": "percent",
1188111881
"included": 1,
11882-
"storageOption": "NVM",
11882+
"storageOption": "External",
1188311883
"singleton": 0,
1188411884
"bounded": 0,
11885-
"defaultValue": "100",
11885+
"defaultValue": null,
1188611886
"reportable": 1,
1188711887
"minInterval": 1,
1188811888
"maxInterval": 65534,
@@ -11895,10 +11895,10 @@
1189511895
"side": "server",
1189611896
"type": "ValveFaultBitmap",
1189711897
"included": 1,
11898-
"storageOption": "RAM",
11898+
"storageOption": "External",
1189911899
"singleton": 0,
1190011900
"bounded": 0,
11901-
"defaultValue": "0",
11901+
"defaultValue": null,
1190211902
"reportable": 1,
1190311903
"minInterval": 1,
1190411904
"maxInterval": 65534,
@@ -11911,10 +11911,10 @@
1191111911
"side": "server",
1191211912
"type": "int8u",
1191311913
"included": 1,
11914-
"storageOption": "RAM",
11914+
"storageOption": "External",
1191511915
"singleton": 0,
1191611916
"bounded": 0,
11917-
"defaultValue": "1",
11917+
"defaultValue": null,
1191811918
"reportable": 1,
1191911919
"minInterval": 1,
1192011920
"maxInterval": 65534,
@@ -11991,10 +11991,10 @@
1199111991
"side": "server",
1199211992
"type": "int16u",
1199311993
"included": 1,
11994-
"storageOption": "RAM",
11994+
"storageOption": "External",
1199511995
"singleton": 0,
1199611996
"bounded": 0,
11997-
"defaultValue": "1",
11997+
"defaultValue": null,
1199811998
"reportable": 1,
1199911999
"minInterval": 1,
1200012000
"maxInterval": 65534,

examples/all-clusters-app/linux/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ source_set("chip-all-clusters-common") {
7979
"${chip_root}/src/app:attribute-persistence",
8080
"${chip_root}/src/app/clusters/identify-server",
8181
"${chip_root}/src/app/clusters/software-diagnostics-server:software-fault-listener",
82+
"${chip_root}/src/app/clusters/valve-configuration-and-control-server:valve-configuration-and-control-server",
8283
"${chip_root}/src/app/clusters/wifi-network-diagnostics-server:wifi-network-diagnostics-server",
8384
"${chip_root}/src/app/common:ids",
8485
"${chip_root}/src/app/common:metadata",

examples/all-clusters-app/linux/ValveControlDelegate.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
#include "ValveControlDelegate.h"
19-
#include <app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-cluster.h>
19+
#include <app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-server.h>
2020
#include <lib/support/logging/CHIPLogging.h>
2121

2222
using namespace chip;

examples/all-clusters-app/linux/main-common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
#include <app/clusters/thermostat-server/thermostat-server.h>
5252
#include <app/clusters/time-synchronization-server/time-synchronization-server.h>
5353
#include <app/clusters/unit-localization-server/unit-localization-server.h>
54-
#include <app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-cluster.h>
54+
#include <app/clusters/valve-configuration-and-control-server/valve-configuration-and-control-server.h>
5555
#include <app/server/Server.h>
5656
#include <app/util/attribute-storage.h>
5757
#include <data-model-providers/codegen/CodegenDataModelProvider.h>

examples/all-clusters-app/realtek/data_model/all-clusters-app.matter

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8784,22 +8784,22 @@ endpoint 1 {
87848784
server cluster ValveConfigurationAndControl {
87858785
emits event ValveStateChanged;
87868786
emits event ValveFault;
8787-
ram attribute openDuration;
8787+
callback attribute openDuration;
87888788
persist attribute defaultOpenDuration;
8789-
ram attribute autoCloseTime;
8789+
callback attribute autoCloseTime;
87908790
callback attribute remainingDuration;
8791-
ram attribute currentState;
8792-
ram attribute targetState;
8793-
ram attribute currentLevel;
8794-
ram attribute targetLevel;
8791+
callback attribute currentState;
8792+
callback attribute targetState;
8793+
callback attribute currentLevel;
8794+
callback attribute targetLevel;
87958795
persist attribute defaultOpenLevel default = 100;
8796-
ram attribute valveFault default = 0;
8796+
callback attribute valveFault;
87978797
ram attribute levelStep default = 1;
87988798
callback attribute generatedCommandList;
87998799
callback attribute acceptedCommandList;
88008800
callback attribute attributeList;
88018801
ram attribute featureMap default = 3;
8802-
ram attribute clusterRevision default = 1;
8802+
callback attribute clusterRevision;
88038803

88048804
handle command Open;
88058805
handle command Close;

examples/chef/devices/rootnode_watervalve_6bb39f1f67.matter

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,16 +1951,16 @@ endpoint 1 {
19511951
}
19521952

19531953
server cluster ValveConfigurationAndControl {
1954-
ram attribute openDuration;
1954+
callback attribute openDuration;
19551955
ram attribute defaultOpenDuration;
19561956
callback attribute remainingDuration;
1957-
ram attribute currentState;
1958-
ram attribute targetState;
1957+
callback attribute currentState;
1958+
callback attribute targetState;
19591959
callback attribute generatedCommandList;
19601960
callback attribute acceptedCommandList;
19611961
callback attribute attributeList;
19621962
ram attribute featureMap default = 0;
1963-
ram attribute clusterRevision default = 1;
1963+
callback attribute clusterRevision;
19641964

19651965
handle command Open;
19661966
handle command Close;

scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/CodeDrivenCallback.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ void MatterBooleanStateConfigurationClusterInitCallback(chip::EndpointId endpoin
125125

126126
void MatterBooleanStateConfigurationClusterShutdownCallback(chip::EndpointId endpointId, MatterClusterShutdownType shutdownType);
127127

128+
void MatterValveConfigurationAndControlClusterInitCallback(chip::EndpointId endpointId);
129+
130+
void MatterValveConfigurationAndControlClusterShutdownCallback(chip::EndpointId endpointId, MatterClusterShutdownType shutdownType);
131+
128132
void MatterElectricalPowerMeasurementClusterInitCallback(chip::EndpointId endpointId);
129133

130134
void MatterElectricalPowerMeasurementClusterShutdownCallback(chip::EndpointId endpointId, MatterClusterShutdownType shutdownType);

scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/CodeDrivenInitShutdown.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ void MatterClusterServerInitCallback(EndpointId endpoint, ClusterId clusterId)
103103
case app::Clusters::BooleanStateConfiguration::Id:
104104
MatterBooleanStateConfigurationClusterInitCallback(endpoint);
105105
break;
106+
case app::Clusters::ValveConfigurationAndControl::Id:
107+
MatterValveConfigurationAndControlClusterInitCallback(endpoint);
108+
break;
106109
case app::Clusters::ElectricalPowerMeasurement::Id:
107110
MatterElectricalPowerMeasurementClusterInitCallback(endpoint);
108111
break;
@@ -206,6 +209,9 @@ void MatterClusterServerShutdownCallback(EndpointId endpoint, ClusterId clusterI
206209
case app::Clusters::BooleanStateConfiguration::Id:
207210
MatterBooleanStateConfigurationClusterShutdownCallback(endpoint, shutdownType);
208211
break;
212+
case app::Clusters::ValveConfigurationAndControl::Id:
213+
MatterValveConfigurationAndControlClusterShutdownCallback(endpoint, shutdownType);
214+
break;
209215
case app::Clusters::ElectricalPowerMeasurement::Id:
210216
MatterElectricalPowerMeasurementClusterShutdownCallback(endpoint, shutdownType);
211217
break;

scripts/tools/zap/tests/outputs/all-clusters-app/app-templates/IMClusterCommandHandler.cpp

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,56 +1201,6 @@ Protocols::InteractionModel::Status DispatchServerCommand(CommandHandler * apCom
12011201

12021202
} // namespace UnitTesting
12031203

1204-
namespace ValveConfigurationAndControl {
1205-
1206-
Protocols::InteractionModel::Status DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath,
1207-
TLV::TLVReader & aDataTlv)
1208-
{
1209-
CHIP_ERROR TLVError = CHIP_NO_ERROR;
1210-
bool wasHandled = false;
1211-
{
1212-
switch (aCommandPath.mCommandId)
1213-
{
1214-
case Commands::Open::Id: {
1215-
Commands::Open::DecodableType commandData;
1216-
TLVError = DataModel::Decode(aDataTlv, commandData);
1217-
if (TLVError == CHIP_NO_ERROR)
1218-
{
1219-
wasHandled = emberAfValveConfigurationAndControlClusterOpenCallback(apCommandObj, aCommandPath, commandData);
1220-
}
1221-
break;
1222-
}
1223-
case Commands::Close::Id: {
1224-
Commands::Close::DecodableType commandData;
1225-
TLVError = DataModel::Decode(aDataTlv, commandData);
1226-
if (TLVError == CHIP_NO_ERROR)
1227-
{
1228-
wasHandled = emberAfValveConfigurationAndControlClusterCloseCallback(apCommandObj, aCommandPath, commandData);
1229-
}
1230-
break;
1231-
}
1232-
default: {
1233-
// Unrecognized command ID, error status will apply.
1234-
ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI,
1235-
ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId));
1236-
return Protocols::InteractionModel::Status::UnsupportedCommand;
1237-
}
1238-
}
1239-
}
1240-
1241-
if (CHIP_NO_ERROR != TLVError || !wasHandled)
1242-
{
1243-
ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format());
1244-
return Protocols::InteractionModel::Status::InvalidCommand;
1245-
}
1246-
1247-
// We use success as a marker that no special handling is required
1248-
// This is to avoid having a std::optional which uses slightly more code.
1249-
return Protocols::InteractionModel::Status::Success;
1250-
}
1251-
1252-
} // namespace ValveConfigurationAndControl
1253-
12541204
namespace WindowCovering {
12551205

12561206
Protocols::InteractionModel::Status DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath,
@@ -1399,9 +1349,6 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV:
13991349
case Clusters::UnitTesting::Id:
14001350
errorStatus = Clusters::UnitTesting::DispatchServerCommand(apCommandObj, aCommandPath, aReader);
14011351
break;
1402-
case Clusters::ValveConfigurationAndControl::Id:
1403-
errorStatus = Clusters::ValveConfigurationAndControl::DispatchServerCommand(apCommandObj, aCommandPath, aReader);
1404-
break;
14051352
case Clusters::WindowCovering::Id:
14061353
errorStatus = Clusters::WindowCovering::DispatchServerCommand(apCommandObj, aCommandPath, aReader);
14071354
break;

0 commit comments

Comments
 (0)