Skip to content

Commit 5d75611

Browse files
andy31415andreilitvinzaid-googlebzbarsky-applesoares-sergio
authored
Convert Boolean State Configuration to code driven (project-chip#41849)
* Rename boolean state configuration cluster, prepare for code driven cluster conversion. * Restyle * Initial changes - code compiles but has no functionality yet. * Start with some implementation logic. Not usable yet, however a start. Need to figure out API still. The interaction between alarms is odd. * Significant update to implementat: all implemented EXCEPT startup... * Startup values. Cluster should be more complete now... * Restyle * Update callback only attributes for boolean state configuration cluster. * Restyle * Fix return value for invalid state. * Another logic bug fix. * Start adding tests. * More tests. * More tests - we now test accepted commands too. * Fix include path. * Undo addition of extra file. * OOps ... replace a max with a min. * Fix another typo. * Restyle. * Remove redundant using namespace. * Zap regen. * Update based on LLM feedback. * Minor edits. * Fix cast error and add a comment. * Update the global attribute validation and make use of it for attribute list. * Update ValidateGlobalAttributes and make use of them. * Clean up comments for global attribute validation. * Update src/app/clusters/boolean-state-configuration-server/boolean-state-configuration-cluster.cpp Co-authored-by: Zaid Omer <[email protected]> * Use a single attribute member in the constructor to define the real enabled optional attributes. * Restyle * Update src/app/clusters/boolean-state-configuration-server/boolean-state-configuration-cluster.cpp Co-authored-by: Boris Zbarsky <[email protected]> * Remove some chip prefixes. * For events, replace `Emit` with `Generate` * Update src/app/clusters/boolean-state-configuration-server/boolean-state-configuration-cluster.cpp Co-authored-by: Sergio Soares <[email protected]> * Zap regen, update headers. * Fix extra using argument. * Add more tests for sensitivity level clamping and logic. * zap regen (to restyle) * Fix a bit of a test logic. * Some comment updates. * One more comment updated. * Fix exclusions for SafeAttributePersistenceProvider. * Update src/app/clusters/boolean-state-configuration-server/CodegenIntegration.h Co-authored-by: Copilot <[email protected]> * Update src/app/clusters/boolean-state-configuration-server/app_config_dependent_sources.cmake Co-authored-by: Copilot <[email protected]> * Add extra validation based on code review. * Restyled by clang-format * Add persistence for mEnabledAlarms. * Tests update and it works. * Remove useless variable. * Replace With to Add for alarms supported, since these are cummulative. Otherwise LLMs get confused. * Use a return safely ignored macro. * Decided to use 'temporary' because this does not feel right. * Add support to writing to the sensor fault attribute (which was NOT done in previous code...) * Only report sensor fault if that attribute is desirable. * Keep backwards compatibility naming. * Add a default value to variables, so that tidy stops complaining. * More defaults set. * Updated based on code review: - added getters - added delegate call to notify of attributes changed. * Fix includes. * Restyled by clang-format * Update src/app/clusters/boolean-state-configuration-server/boolean-state-configuration-cluster.h Co-authored-by: Copilot <[email protected]> * Add readme and update with some API docs. * Remove duplicated text. --------- Co-authored-by: Andrei Litvin <[email protected]> Co-authored-by: Zaid Omer <[email protected]> Co-authored-by: Boris Zbarsky <[email protected]> Co-authored-by: Sergio Soares <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Restyled.io <[email protected]>
1 parent 63c8f9f commit 5d75611

31 files changed

+1290
-778
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8610,16 +8610,16 @@ endpoint 1 {
86108610
callback attribute currentSensitivityLevel;
86118611
ram attribute supportedSensitivityLevels default = 3;
86128612
ram attribute defaultSensitivityLevel default = 2;
8613-
ram attribute alarmsActive;
8614-
ram attribute alarmsSuppressed;
8615-
persist attribute alarmsEnabled;
8613+
callback attribute alarmsActive;
8614+
callback attribute alarmsSuppressed;
8615+
callback attribute alarmsEnabled;
86168616
ram attribute alarmsSupported default = 0x03;
8617-
ram attribute sensorFault default = 0;
8617+
callback attribute sensorFault;
86188618
callback attribute generatedCommandList;
86198619
callback attribute acceptedCommandList;
86208620
callback attribute attributeList;
86218621
ram attribute featureMap default = 0x0F;
8622-
ram attribute clusterRevision default = 1;
8622+
callback attribute clusterRevision;
86238623

86248624
handle command SuppressAlarm;
86258625
handle command EnableDisableAlarm;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8791,16 +8791,16 @@ endpoint 1 {
87918791
callback attribute currentSensitivityLevel;
87928792
ram attribute supportedSensitivityLevels default = 3;
87938793
ram attribute defaultSensitivityLevel default = 2;
8794-
ram attribute alarmsActive;
8795-
ram attribute alarmsSuppressed;
8796-
persist attribute alarmsEnabled;
8794+
callback attribute alarmsActive;
8795+
callback attribute alarmsSuppressed;
8796+
callback attribute alarmsEnabled;
87978797
ram attribute alarmsSupported default = 0x03;
8798-
ram attribute sensorFault default = 0;
8798+
callback attribute sensorFault;
87998799
callback attribute generatedCommandList;
88008800
callback attribute acceptedCommandList;
88018801
callback attribute attributeList;
88028802
ram attribute featureMap default = 0x0F;
8803-
ram attribute clusterRevision default = 1;
8803+
callback attribute clusterRevision;
88048804

88058805
handle command SuppressAlarm;
88068806
handle command EnableDisableAlarm;

examples/chef/devices/rootnode_rainsensor_a7aa5d7738.matter

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1968,7 +1968,7 @@ endpoint 1 {
19681968
callback attribute acceptedCommandList;
19691969
callback attribute attributeList;
19701970
ram attribute featureMap default = 0;
1971-
ram attribute clusterRevision default = 1;
1971+
callback attribute clusterRevision;
19721972
}
19731973
}
19741974

examples/chef/devices/rootnode_waterfreezedetector_dd94a13a16.matter

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1968,7 +1968,7 @@ endpoint 1 {
19681968
callback attribute acceptedCommandList;
19691969
callback attribute attributeList;
19701970
ram attribute featureMap default = 0;
1971-
ram attribute clusterRevision default = 1;
1971+
callback attribute clusterRevision;
19721972
}
19731973
}
19741974

examples/chef/devices/rootnode_waterleakdetector_0b067acfa3.matter

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2066,7 +2066,7 @@ endpoint 1 {
20662066
callback attribute acceptedCommandList;
20672067
callback attribute attributeList;
20682068
ram attribute featureMap default = 0;
2069-
ram attribute clusterRevision default = 1;
2069+
callback attribute clusterRevision;
20702070
}
20712071
}
20722072

examples/water-leak-detector-app/water-leak-detector-common/water-leak-detector-app.matter

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1959,7 +1959,7 @@ endpoint 1 {
19591959
callback attribute acceptedCommandList;
19601960
callback attribute attributeList;
19611961
ram attribute featureMap default = 0;
1962-
ram attribute clusterRevision default = 1;
1962+
callback attribute clusterRevision;
19631963
}
19641964
}
19651965

scripts/attribute_persistence_provider_exclusions.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ src/app/persistence/AttributePersistenceProvider.h
2323
src/app/server/Server.cpp
2424

2525
# Cluster server implementations that currently use SafeAttributePersistenceProvider
26-
src/app/clusters/boolean-state-configuration-server/boolean-state-configuration-server.cpp
26+
src/app/clusters/boolean-state-configuration-server/boolean-state-configuration-cluster.cpp
27+
src/app/clusters/boolean-state-configuration-server/tests/TestBooleanStateConfigurationCluster.cpp
2728
src/app/clusters/camera-av-settings-user-level-management-server/camera-av-settings-user-level-management-server.h
2829
src/app/clusters/camera-av-stream-management-server/camera-av-stream-management-server.h
2930
src/app/clusters/chime-server/chime-server.cpp

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
@@ -102,3 +102,7 @@ void MatterUserLabelClusterShutdownCallback(chip::EndpointId endpointId);
102102
void MatterBooleanStateClusterInitCallback(chip::EndpointId endpointId);
103103

104104
void MatterBooleanStateClusterShutdownCallback(chip::EndpointId endpointId);
105+
106+
void MatterBooleanStateConfigurationClusterInitCallback(chip::EndpointId endpointId);
107+
108+
void MatterBooleanStateConfigurationClusterShutdownCallback(chip::EndpointId endpointId);

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
@@ -87,6 +87,9 @@ void MatterClusterServerInitCallback(EndpointId endpoint, ClusterId clusterId)
8787
case app::Clusters::BooleanState::Id:
8888
MatterBooleanStateClusterInitCallback(endpoint);
8989
break;
90+
case app::Clusters::BooleanStateConfiguration::Id:
91+
MatterBooleanStateConfigurationClusterInitCallback(endpoint);
92+
break;
9093
}
9194
}
9295

@@ -154,5 +157,8 @@ void MatterClusterServerShutdownCallback(EndpointId endpoint, ClusterId clusterI
154157
case app::Clusters::BooleanState::Id:
155158
MatterBooleanStateClusterShutdownCallback(endpoint);
156159
break;
160+
case app::Clusters::BooleanStateConfiguration::Id:
161+
MatterBooleanStateConfigurationClusterShutdownCallback(endpoint);
162+
break;
157163
}
158164
}

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

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -37,57 +37,6 @@ namespace app {
3737

3838
namespace Clusters {
3939

40-
namespace BooleanStateConfiguration {
41-
42-
Protocols::InteractionModel::Status DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath,
43-
TLV::TLVReader & aDataTlv)
44-
{
45-
CHIP_ERROR TLVError = CHIP_NO_ERROR;
46-
bool wasHandled = false;
47-
{
48-
switch (aCommandPath.mCommandId)
49-
{
50-
case Commands::SuppressAlarm::Id: {
51-
Commands::SuppressAlarm::DecodableType commandData;
52-
TLVError = DataModel::Decode(aDataTlv, commandData);
53-
if (TLVError == CHIP_NO_ERROR)
54-
{
55-
wasHandled = emberAfBooleanStateConfigurationClusterSuppressAlarmCallback(apCommandObj, aCommandPath, commandData);
56-
}
57-
break;
58-
}
59-
case Commands::EnableDisableAlarm::Id: {
60-
Commands::EnableDisableAlarm::DecodableType commandData;
61-
TLVError = DataModel::Decode(aDataTlv, commandData);
62-
if (TLVError == CHIP_NO_ERROR)
63-
{
64-
wasHandled =
65-
emberAfBooleanStateConfigurationClusterEnableDisableAlarmCallback(apCommandObj, aCommandPath, commandData);
66-
}
67-
break;
68-
}
69-
default: {
70-
// Unrecognized command ID, error status will apply.
71-
ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI,
72-
ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId));
73-
return Protocols::InteractionModel::Status::UnsupportedCommand;
74-
}
75-
}
76-
}
77-
78-
if (CHIP_NO_ERROR != TLVError || !wasHandled)
79-
{
80-
ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format());
81-
return Protocols::InteractionModel::Status::InvalidCommand;
82-
}
83-
84-
// We use success as a marker that no special handling is required
85-
// This is to avoid having a std::optional which uses slightly more code.
86-
return Protocols::InteractionModel::Status::Success;
87-
}
88-
89-
} // namespace BooleanStateConfiguration
90-
9140
namespace ColorControl {
9241

9342
Protocols::InteractionModel::Status DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath,
@@ -1405,9 +1354,6 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV:
14051354

14061355
switch (aCommandPath.mClusterId)
14071356
{
1408-
case Clusters::BooleanStateConfiguration::Id:
1409-
errorStatus = Clusters::BooleanStateConfiguration::DispatchServerCommand(apCommandObj, aCommandPath, aReader);
1410-
break;
14111357
case Clusters::ColorControl::Id:
14121358
errorStatus = Clusters::ColorControl::DispatchServerCommand(apCommandObj, aCommandPath, aReader);
14131359
break;

0 commit comments

Comments
 (0)