From 6e61284bba63d709cfbe782aee2b6aa4c5cb599a Mon Sep 17 00:00:00 2001 From: mideayanghui Date: Thu, 13 Jul 2023 16:12:31 +0800 Subject: [PATCH 01/20] OperationalState attribute simply to Enum --- .../zcl/data-model/chip/operational-state-cluster.xml | 2 +- .../zcl/data-model/chip/operational-state-rvc-cluster.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/zap-templates/zcl/data-model/chip/operational-state-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/operational-state-cluster.xml index e454bbee517ae3..c70cc003b0aacc 100644 --- a/src/app/zap-templates/zcl/data-model/chip/operational-state-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/operational-state-cluster.xml @@ -63,7 +63,7 @@ limitations under the License. CurrentPhase CountdownTime OperationalStateList - OperationalState + OperationalState OperationalError diff --git a/src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster.xml index 94c10eb297a5d3..7b652169c34dc2 100644 --- a/src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster.xml @@ -51,7 +51,7 @@ limitations under the License. CurrentPhase CountdownTime OperationalStateList - OperationalState + OperationalState OperationalError From e36a5d2e1044c769fbd4234d6b7901c2176061e8 Mon Sep 17 00:00:00 2001 From: mideayanghui Date: Fri, 14 Jul 2023 14:03:35 +0800 Subject: [PATCH 02/20] temporary remove some test step in TestOperationalState --- .../tests/suites/TestOperationalState.yaml | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/src/app/tests/suites/TestOperationalState.yaml b/src/app/tests/suites/TestOperationalState.yaml index 62ad14ddab3bbf..a7079a560c218e 100644 --- a/src/app/tests/suites/TestOperationalState.yaml +++ b/src/app/tests/suites/TestOperationalState.yaml @@ -64,12 +64,6 @@ tests: response: value: { ErrorStateID: 0 } - - label: "Read current Operational State" - command: "readAttribute" - attribute: "OperationalState" - response: - value: { OperationalStateID: 0 } - - label: "Start Command" command: "Start" response: @@ -77,12 +71,6 @@ tests: - name: "CommandResponseState" value: { ErrorStateID: 0 } - - label: "Read current Operational State" - command: "readAttribute" - attribute: "OperationalState" - response: - value: { OperationalStateID: 1 } - - label: "Pause Command" command: "Pause" response: @@ -90,12 +78,6 @@ tests: - name: "CommandResponseState" value: { ErrorStateID: 0 } - - label: "Read current Operational State" - command: "readAttribute" - attribute: "OperationalState" - response: - value: { OperationalStateID: 2 } - - label: "Resume Command" command: "Resume" response: @@ -103,12 +85,6 @@ tests: - name: "CommandResponseState" value: { ErrorStateID: 0 } - - label: "Read current Operational State" - command: "readAttribute" - attribute: "OperationalState" - response: - value: { OperationalStateID: 1 } - - label: "Stop Command" command: "Stop" response: @@ -116,8 +92,3 @@ tests: - name: "CommandResponseState" value: { ErrorStateID: 0 } - - label: "Read current Operational State" - command: "readAttribute" - attribute: "OperationalState" - response: - value: { OperationalStateID: 0 } From d756399bbccdd2a5e7dec05b7d00246344c8fa02 Mon Sep 17 00:00:00 2001 From: mideayanghui Date: Fri, 14 Jul 2023 14:44:40 +0800 Subject: [PATCH 03/20] zap regen all --- .../all-clusters-app.matter | 2 +- .../data_model/controller-clusters.matter | 4 +- .../devicecontroller/ClusterReadMapping.java | 22 +++++ .../CHIPAttributeTLVValueDecoder.cpp | 86 ++---------------- .../chip/devicecontroller/ChipClusters.java | 38 ++++++++ .../python/chip/clusters/CHIPClusters.py | 4 +- .../python/chip/clusters/Objects.py | 16 ++-- .../zap-generated/cluster-objects.h | 16 ++-- .../zap-generated/cluster/Commands.h | 8 +- .../cluster/logging/DataModelLogger.cpp | 4 +- .../chip-tool/zap-generated/test/Commands.h | 87 +++---------------- 11 files changed, 106 insertions(+), 181 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index a0991594cef32f..d5644a9359625c 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -2692,7 +2692,7 @@ server cluster OperationalState = 96 { readonly attribute nullable int8u currentPhase = 1; readonly attribute nullable elapsed_s countdownTime = 2; readonly attribute OperationalStateStruct operationalStateList[] = 3; - readonly attribute OperationalStateStruct operationalState = 4; + readonly attribute enum8 operationalState = 4; readonly attribute ErrorStateStruct operationalError = 5; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index c1316f2683d275..82cb01408da254 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -3354,7 +3354,7 @@ client cluster OperationalState = 96 { readonly attribute nullable int8u currentPhase = 1; readonly attribute optional nullable elapsed_s countdownTime = 2; readonly attribute OperationalStateStruct operationalStateList[] = 3; - readonly attribute OperationalStateStruct operationalState = 4; + readonly attribute enum8 operationalState = 4; readonly attribute ErrorStateStruct operationalError = 5; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -3421,7 +3421,7 @@ client cluster RvcOperationalState = 97 { readonly attribute nullable int8u currentPhase = 1; readonly attribute optional nullable elapsed_s countdownTime = 2; readonly attribute OperationalStateStruct operationalStateList[] = 3; - readonly attribute OperationalStateStruct operationalState = 4; + readonly attribute enum8 operationalState = 4; readonly attribute ErrorStateStruct operationalError = 5; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java index a4e3c7438bedbb..85c49e835d5a9b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java @@ -7432,6 +7432,17 @@ private static Map readOperationalStateInteractionInfo( readOperationalStateOperationalStateListCommandParams ); result.put("readOperationalStateListAttribute", readOperationalStateOperationalStateListAttributeInteractionInfo); + Map readOperationalStateOperationalStateCommandParams = new LinkedHashMap(); + InteractionInfo readOperationalStateOperationalStateAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.OperationalStateCluster) cluster).readOperationalStateAttribute( + (ChipClusters.IntegerAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), + readOperationalStateOperationalStateCommandParams + ); + result.put("readOperationalStateAttribute", readOperationalStateOperationalStateAttributeInteractionInfo); Map readOperationalStateGeneratedCommandListCommandParams = new LinkedHashMap(); InteractionInfo readOperationalStateGeneratedCommandListAttributeInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { @@ -7546,6 +7557,17 @@ private static Map readRvcOperationalStateInteractionIn readRvcOperationalStateOperationalStateListCommandParams ); result.put("readOperationalStateListAttribute", readRvcOperationalStateOperationalStateListAttributeInteractionInfo); + Map readRvcOperationalStateOperationalStateCommandParams = new LinkedHashMap(); + InteractionInfo readRvcOperationalStateOperationalStateAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.RvcOperationalStateCluster) cluster).readOperationalStateAttribute( + (ChipClusters.IntegerAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), + readRvcOperationalStateOperationalStateCommandParams + ); + result.put("readOperationalStateAttribute", readRvcOperationalStateOperationalStateAttributeInteractionInfo); Map readRvcOperationalStateGeneratedCommandListCommandParams = new LinkedHashMap(); InteractionInfo readRvcOperationalStateGeneratedCommandListAttributeInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { diff --git a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp index f1813681f553ba..f4f88992cbb98b 100644 --- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp @@ -15134,45 +15134,10 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - jobject value_operationalStateID; - std::string value_operationalStateIDClassName = "java/lang/Integer"; - std::string value_operationalStateIDCtorSignature = "(I)V"; - chip::JniReferences::GetInstance().CreateBoxedObject(value_operationalStateIDClassName.c_str(), - value_operationalStateIDCtorSignature.c_str(), - cppValue.operationalStateID, value_operationalStateID); - jobject value_operationalStateLabel; - if (!cppValue.operationalStateLabel.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, value_operationalStateLabel); - } - else - { - jobject value_operationalStateLabelInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.operationalStateLabel.Value(), - value_operationalStateLabelInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(value_operationalStateLabelInsideOptional, - value_operationalStateLabel); - } - - jclass operationalStateStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$OperationalStateClusterOperationalStateStruct", - operationalStateStructStructClass_0); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$OperationalStateClusterOperationalStateStruct"); - return nullptr; - } - jmethodID operationalStateStructStructCtor_0 = - env->GetMethodID(operationalStateStructStructClass_0, "", "(Ljava/lang/Integer;Ljava/util/Optional;)V"); - if (operationalStateStructStructCtor_0 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$OperationalStateClusterOperationalStateStruct constructor"); - return nullptr; - } - - value = env->NewObject(operationalStateStructStructClass_0, operationalStateStructStructCtor_0, - value_operationalStateID, value_operationalStateLabel); + std::string valueClassName = "java/lang/Integer"; + std::string valueCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + cppValue, value); return value; } case Attributes::OperationalError::Id: { @@ -15511,45 +15476,10 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } jobject value; - jobject value_operationalStateID; - std::string value_operationalStateIDClassName = "java/lang/Integer"; - std::string value_operationalStateIDCtorSignature = "(I)V"; - chip::JniReferences::GetInstance().CreateBoxedObject(value_operationalStateIDClassName.c_str(), - value_operationalStateIDCtorSignature.c_str(), - cppValue.operationalStateID, value_operationalStateID); - jobject value_operationalStateLabel; - if (!cppValue.operationalStateLabel.HasValue()) - { - chip::JniReferences::GetInstance().CreateOptional(nullptr, value_operationalStateLabel); - } - else - { - jobject value_operationalStateLabelInsideOptional; - LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.operationalStateLabel.Value(), - value_operationalStateLabelInsideOptional)); - chip::JniReferences::GetInstance().CreateOptional(value_operationalStateLabelInsideOptional, - value_operationalStateLabel); - } - - jclass operationalStateStructStructClass_0; - err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipStructs$RvcOperationalStateClusterOperationalStateStruct", - operationalStateStructStructClass_0); - if (err != CHIP_NO_ERROR) - { - ChipLogError(Zcl, "Could not find class ChipStructs$RvcOperationalStateClusterOperationalStateStruct"); - return nullptr; - } - jmethodID operationalStateStructStructCtor_0 = - env->GetMethodID(operationalStateStructStructClass_0, "", "(Ljava/lang/Integer;Ljava/util/Optional;)V"); - if (operationalStateStructStructCtor_0 == nullptr) - { - ChipLogError(Zcl, "Could not find ChipStructs$RvcOperationalStateClusterOperationalStateStruct constructor"); - return nullptr; - } - - value = env->NewObject(operationalStateStructStructClass_0, operationalStateStructStructCtor_0, - value_operationalStateID, value_operationalStateLabel); + std::string valueClassName = "java/lang/Integer"; + std::string valueCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + cppValue, value); return value; } case Attributes::OperationalError::Id: { diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java index 2faf941fc46051..b12d5d9f86e5c3 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java @@ -16904,6 +16904,18 @@ public void subscribeOperationalStateListAttribute( subscribeOperationalStateListAttribute(chipClusterPtr, callback, minInterval, maxInterval); } + public void readOperationalStateAttribute( + IntegerAttributeCallback callback + ) { + readOperationalStateAttribute(chipClusterPtr, callback); + } + public void subscribeOperationalStateAttribute( + IntegerAttributeCallback callback +, + int minInterval, int maxInterval) { + subscribeOperationalStateAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + public void readGeneratedCommandListAttribute( GeneratedCommandListAttributeCallback callback ) { @@ -17004,6 +17016,13 @@ private native void subscribeOperationalStateListAttribute(long chipClusterPtr, OperationalStateListAttributeCallback callback , int minInterval, int maxInterval); + private native void readOperationalStateAttribute(long chipClusterPtr, + IntegerAttributeCallback callback + ); + private native void subscribeOperationalStateAttribute(long chipClusterPtr, + IntegerAttributeCallback callback +, int minInterval, int maxInterval); + private native void readGeneratedCommandListAttribute(long chipClusterPtr, GeneratedCommandListAttributeCallback callback ); @@ -17208,6 +17227,18 @@ public void subscribeOperationalStateListAttribute( subscribeOperationalStateListAttribute(chipClusterPtr, callback, minInterval, maxInterval); } + public void readOperationalStateAttribute( + IntegerAttributeCallback callback + ) { + readOperationalStateAttribute(chipClusterPtr, callback); + } + public void subscribeOperationalStateAttribute( + IntegerAttributeCallback callback +, + int minInterval, int maxInterval) { + subscribeOperationalStateAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + public void readGeneratedCommandListAttribute( GeneratedCommandListAttributeCallback callback ) { @@ -17308,6 +17339,13 @@ private native void subscribeOperationalStateListAttribute(long chipClusterPtr, OperationalStateListAttributeCallback callback , int minInterval, int maxInterval); + private native void readOperationalStateAttribute(long chipClusterPtr, + IntegerAttributeCallback callback + ); + private native void subscribeOperationalStateAttribute(long chipClusterPtr, + IntegerAttributeCallback callback +, int minInterval, int maxInterval); + private native void readGeneratedCommandListAttribute(long chipClusterPtr, GeneratedCommandListAttributeCallback callback ); diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index 56122c414e5143..8346243254abab 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -5280,7 +5280,7 @@ class ChipClusters: 0x00000004: { "attributeName": "OperationalState", "attributeId": 0x00000004, - "type": "", + "type": "int", "reportable": True, }, 0x00000005: { @@ -5384,7 +5384,7 @@ class ChipClusters: 0x00000004: { "attributeName": "OperationalState", "attributeId": 0x00000004, - "type": "", + "type": "int", "reportable": True, }, 0x00000005: { diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index b02ced42ad05ad..a61b4eaa3408df 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -18256,7 +18256,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="currentPhase", Tag=0x00000001, Type=typing.Union[Nullable, uint]), ClusterObjectFieldDescriptor(Label="countdownTime", Tag=0x00000002, Type=typing.Union[None, Nullable, uint]), ClusterObjectFieldDescriptor(Label="operationalStateList", Tag=0x00000003, Type=typing.List[OperationalState.Structs.OperationalStateStruct]), - ClusterObjectFieldDescriptor(Label="operationalState", Tag=0x00000004, Type=OperationalState.Structs.OperationalStateStruct), + ClusterObjectFieldDescriptor(Label="operationalState", Tag=0x00000004, Type=uint), ClusterObjectFieldDescriptor(Label="operationalError", Tag=0x00000005, Type=OperationalState.Structs.ErrorStateStruct), ClusterObjectFieldDescriptor(Label="generatedCommandList", Tag=0x0000FFF8, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="acceptedCommandList", Tag=0x0000FFF9, Type=typing.List[uint]), @@ -18270,7 +18270,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: currentPhase: 'typing.Union[Nullable, uint]' = None countdownTime: 'typing.Union[None, Nullable, uint]' = None operationalStateList: 'typing.List[OperationalState.Structs.OperationalStateStruct]' = None - operationalState: 'OperationalState.Structs.OperationalStateStruct' = None + operationalState: 'uint' = None operationalError: 'OperationalState.Structs.ErrorStateStruct' = None generatedCommandList: 'typing.List[uint]' = None acceptedCommandList: 'typing.List[uint]' = None @@ -18477,9 +18477,9 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=OperationalState.Structs.OperationalStateStruct) + return ClusterObjectFieldDescriptor(Type=uint) - value: 'OperationalState.Structs.OperationalStateStruct' = field(default_factory=lambda: OperationalState.Structs.OperationalStateStruct()) + value: 'uint' = 0 @dataclass class OperationalError(ClusterAttributeDescriptor): @@ -18649,7 +18649,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="currentPhase", Tag=0x00000001, Type=typing.Union[Nullable, uint]), ClusterObjectFieldDescriptor(Label="countdownTime", Tag=0x00000002, Type=typing.Union[None, Nullable, uint]), ClusterObjectFieldDescriptor(Label="operationalStateList", Tag=0x00000003, Type=typing.List[RvcOperationalState.Structs.OperationalStateStruct]), - ClusterObjectFieldDescriptor(Label="operationalState", Tag=0x00000004, Type=RvcOperationalState.Structs.OperationalStateStruct), + ClusterObjectFieldDescriptor(Label="operationalState", Tag=0x00000004, Type=uint), ClusterObjectFieldDescriptor(Label="operationalError", Tag=0x00000005, Type=RvcOperationalState.Structs.ErrorStateStruct), ClusterObjectFieldDescriptor(Label="generatedCommandList", Tag=0x0000FFF8, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="acceptedCommandList", Tag=0x0000FFF9, Type=typing.List[uint]), @@ -18663,7 +18663,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: currentPhase: 'typing.Union[Nullable, uint]' = None countdownTime: 'typing.Union[None, Nullable, uint]' = None operationalStateList: 'typing.List[RvcOperationalState.Structs.OperationalStateStruct]' = None - operationalState: 'RvcOperationalState.Structs.OperationalStateStruct' = None + operationalState: 'uint' = None operationalError: 'RvcOperationalState.Structs.ErrorStateStruct' = None generatedCommandList: 'typing.List[uint]' = None acceptedCommandList: 'typing.List[uint]' = None @@ -18873,9 +18873,9 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=RvcOperationalState.Structs.OperationalStateStruct) + return ClusterObjectFieldDescriptor(Type=uint) - value: 'RvcOperationalState.Structs.OperationalStateStruct' = field(default_factory=lambda: RvcOperationalState.Structs.OperationalStateStruct()) + value: 'uint' = 0 @dataclass class OperationalError(ClusterAttributeDescriptor): diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index bc65d932345fc3..6262c1ee5e48cd 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -16933,9 +16933,9 @@ struct TypeInfo namespace OperationalState { struct TypeInfo { - using Type = chip::app::Clusters::OperationalState::Structs::OperationalStateStruct::Type; - using DecodableType = chip::app::Clusters::OperationalState::Structs::OperationalStateStruct::DecodableType; - using DecodableArgType = const chip::app::Clusters::OperationalState::Structs::OperationalStateStruct::DecodableType &; + using Type = uint8_t; + using DecodableType = uint8_t; + using DecodableArgType = uint8_t; static constexpr ClusterId GetClusterId() { return Clusters::OperationalState::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::OperationalState::Id; } @@ -17003,7 +17003,7 @@ struct TypeInfo Attributes::CurrentPhase::TypeInfo::DecodableType currentPhase; Attributes::CountdownTime::TypeInfo::DecodableType countdownTime; Attributes::OperationalStateList::TypeInfo::DecodableType operationalStateList; - Attributes::OperationalState::TypeInfo::DecodableType operationalState; + Attributes::OperationalState::TypeInfo::DecodableType operationalState = static_cast(0); Attributes::OperationalError::TypeInfo::DecodableType operationalError; Attributes::GeneratedCommandList::TypeInfo::DecodableType generatedCommandList; Attributes::AcceptedCommandList::TypeInfo::DecodableType acceptedCommandList; @@ -17327,9 +17327,9 @@ struct TypeInfo namespace OperationalState { struct TypeInfo { - using Type = chip::app::Clusters::RvcOperationalState::Structs::OperationalStateStruct::Type; - using DecodableType = chip::app::Clusters::RvcOperationalState::Structs::OperationalStateStruct::DecodableType; - using DecodableArgType = const chip::app::Clusters::RvcOperationalState::Structs::OperationalStateStruct::DecodableType &; + using Type = uint8_t; + using DecodableType = uint8_t; + using DecodableArgType = uint8_t; static constexpr ClusterId GetClusterId() { return Clusters::RvcOperationalState::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::OperationalState::Id; } @@ -17397,7 +17397,7 @@ struct TypeInfo Attributes::CurrentPhase::TypeInfo::DecodableType currentPhase; Attributes::CountdownTime::TypeInfo::DecodableType countdownTime; Attributes::OperationalStateList::TypeInfo::DecodableType operationalStateList; - Attributes::OperationalState::TypeInfo::DecodableType operationalState; + Attributes::OperationalState::TypeInfo::DecodableType operationalState = static_cast(0); Attributes::OperationalError::TypeInfo::DecodableType operationalError; Attributes::GeneratedCommandList::TypeInfo::DecodableType generatedCommandList; Attributes::AcceptedCommandList::TypeInfo::DecodableType acceptedCommandList; diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index b6bec09fa1783a..cda82b13b152e2 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -15596,8 +15596,8 @@ void registerClusterOperationalState(Commands & commands, CredentialIssuerComman chip::app::DataModel::List>>( Id, "operational-state-list", Attributes::OperationalStateList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>( - Id, "operational-state", Attributes::OperationalState::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>(Id, "operational-state", 0, UINT8_MAX, Attributes::OperationalState::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>( Id, "operational-error", Attributes::OperationalError::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>>( @@ -15682,8 +15682,8 @@ void registerClusterRvcOperationalState(Commands & commands, CredentialIssuerCom chip::app::DataModel::List>>( Id, "operational-state-list", Attributes::OperationalStateList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>( - Id, "operational-state", Attributes::OperationalState::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>(Id, "operational-state", 0, UINT8_MAX, Attributes::OperationalState::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>( Id, "operational-error", Attributes::OperationalError::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>>( diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp index 2db93696bc282c..3a436daf038631 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -8967,7 +8967,7 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP return DataModelLogger::LogValue("OperationalStateList", 1, value); } case OperationalState::Attributes::OperationalState::Id: { - chip::app::Clusters::OperationalState::Structs::OperationalStateStruct::DecodableType value; + uint8_t value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("OperationalState", 1, value); } @@ -9035,7 +9035,7 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP return DataModelLogger::LogValue("OperationalStateList", 1, value); } case RvcOperationalState::Attributes::OperationalState::Id: { - chip::app::Clusters::RvcOperationalState::Structs::OperationalStateStruct::DecodableType value; + uint8_t value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("OperationalState", 1, value); } diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index feda117830052c..965226c5c88e4b 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -91348,7 +91348,7 @@ class TestOperationalStateSuite : public TestCommand { public: TestOperationalStateSuite(CredentialIssuerCommands * credsIssuerConfig) : - TestCommand("TestOperationalState", 15, credsIssuerConfig) + TestCommand("TestOperationalState", 10, credsIssuerConfig) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); AddArgument("cluster", &mCluster); @@ -91443,14 +91443,6 @@ class TestOperationalStateSuite : public TestCommand } break; case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::Clusters::OperationalState::Structs::OperationalStateStruct::DecodableType value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("operationalState.operationalStateID", value.operationalStateID, 0U)); - } - break; - case 7: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { chip::app::Clusters::OperationalState::Commands::OperationalCommandResponse::DecodableType value; @@ -91458,15 +91450,7 @@ class TestOperationalStateSuite : public TestCommand VerifyOrReturn(CheckValue("commandResponseState.errorStateID", value.commandResponseState.errorStateID, 0U)); } break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::Clusters::OperationalState::Structs::OperationalStateStruct::DecodableType value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("operationalState.operationalStateID", value.operationalStateID, 1U)); - } - break; - case 9: + case 7: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { chip::app::Clusters::OperationalState::Commands::OperationalCommandResponse::DecodableType value; @@ -91474,15 +91458,7 @@ class TestOperationalStateSuite : public TestCommand VerifyOrReturn(CheckValue("commandResponseState.errorStateID", value.commandResponseState.errorStateID, 0U)); } break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::Clusters::OperationalState::Structs::OperationalStateStruct::DecodableType value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("operationalState.operationalStateID", value.operationalStateID, 2U)); - } - break; - case 11: + case 8: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { chip::app::Clusters::OperationalState::Commands::OperationalCommandResponse::DecodableType value; @@ -91490,15 +91466,7 @@ class TestOperationalStateSuite : public TestCommand VerifyOrReturn(CheckValue("commandResponseState.errorStateID", value.commandResponseState.errorStateID, 0U)); } break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::Clusters::OperationalState::Structs::OperationalStateStruct::DecodableType value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("operationalState.operationalStateID", value.operationalStateID, 1U)); - } - break; - case 13: + case 9: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { chip::app::Clusters::OperationalState::Commands::OperationalCommandResponse::DecodableType value; @@ -91506,14 +91474,6 @@ class TestOperationalStateSuite : public TestCommand VerifyOrReturn(CheckValue("commandResponseState.errorStateID", value.commandResponseState.errorStateID, 0U)); } break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - { - chip::app::Clusters::OperationalState::Structs::OperationalStateStruct::DecodableType value; - VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("operationalState.operationalStateID", value.operationalStateID, 0U)); - } - break; default: LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); } @@ -91562,12 +91522,7 @@ class TestOperationalStateSuite : public TestCommand OperationalState::Attributes::OperationalError::Id, true, chip::NullOptional); } case 6: { - LogStep(6, "Read current Operational State"); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, - OperationalState::Attributes::OperationalState::Id, true, chip::NullOptional); - } - case 7: { - LogStep(7, "Start Command"); + LogStep(6, "Start Command"); ListFreer listFreer; chip::app::Clusters::OperationalState::Commands::Start::Type value; return SendCommand(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, OperationalState::Commands::Start::Id, value, @@ -91575,13 +91530,8 @@ class TestOperationalStateSuite : public TestCommand ); } - case 8: { - LogStep(8, "Read current Operational State"); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, - OperationalState::Attributes::OperationalState::Id, true, chip::NullOptional); - } - case 9: { - LogStep(9, "Pause Command"); + case 7: { + LogStep(7, "Pause Command"); ListFreer listFreer; chip::app::Clusters::OperationalState::Commands::Pause::Type value; return SendCommand(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, OperationalState::Commands::Pause::Id, value, @@ -91589,13 +91539,8 @@ class TestOperationalStateSuite : public TestCommand ); } - case 10: { - LogStep(10, "Read current Operational State"); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, - OperationalState::Attributes::OperationalState::Id, true, chip::NullOptional); - } - case 11: { - LogStep(11, "Resume Command"); + case 8: { + LogStep(8, "Resume Command"); ListFreer listFreer; chip::app::Clusters::OperationalState::Commands::Resume::Type value; return SendCommand(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, OperationalState::Commands::Resume::Id, value, @@ -91603,13 +91548,8 @@ class TestOperationalStateSuite : public TestCommand ); } - case 12: { - LogStep(12, "Read current Operational State"); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, - OperationalState::Attributes::OperationalState::Id, true, chip::NullOptional); - } - case 13: { - LogStep(13, "Stop Command"); + case 9: { + LogStep(9, "Stop Command"); ListFreer listFreer; chip::app::Clusters::OperationalState::Commands::Stop::Type value; return SendCommand(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, OperationalState::Commands::Stop::Id, value, @@ -91617,11 +91557,6 @@ class TestOperationalStateSuite : public TestCommand ); } - case 14: { - LogStep(14, "Read current Operational State"); - return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, - OperationalState::Attributes::OperationalState::Id, true, chip::NullOptional); - } } return CHIP_NO_ERROR; } From 1c1ac2869b9ff07af45c8cccacdf27abc2dbe8ea Mon Sep 17 00:00:00 2001 From: mideayanghui Date: Fri, 14 Jul 2023 14:47:56 +0800 Subject: [PATCH 04/20] modify the code related of the OperationalState attribute type --- .../include/operational-state-delegate-impl.h | 10 ++++----- .../src/operational-state-delegate-impl.cpp | 12 +++++----- .../src/operational-state-delegates.cpp | 2 +- .../operational-state-delegate.h | 6 ++--- .../operational-state-server.cpp | 22 +++++++++---------- 5 files changed, 26 insertions(+), 26 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h b/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h index d3fa6bd913dd14..ca225fbcebcf3c 100644 --- a/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h +++ b/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h @@ -35,10 +35,10 @@ class OperationalStateDelegate : public Delegate public: /** * Get current operational state. - * @param op The GenericOperationalState to fill with the current operational state value. + * @param op The uint8_t to fill with the current operational state value. * @return void. */ - void GetCurrentOperationalState(GenericOperationalState & op) override; + void GetCurrentOperationalState(uint8_t & op) override; /** * Get the list of supported operational states. @@ -86,7 +86,7 @@ class OperationalStateDelegate : public Delegate * Set current operational state. * @param opState The operational state that should now be the current one. */ - CHIP_ERROR SetOperationalState(const GenericOperationalState & opState) override; + CHIP_ERROR SetOperationalState(const uint8_t & opState) override; /** * Set operational phase. @@ -125,7 +125,7 @@ class OperationalStateDelegate : public Delegate */ void HandleStopStateCallback(GenericOperationalError & err) override; - OperationalStateDelegate(GenericOperationalState aOperationalState, GenericOperationalError aOperationalError, + OperationalStateDelegate(uint8_t aOperationalState, GenericOperationalError aOperationalError, Span aOperationalStateList, Span aOperationalPhaseList, app::DataModel::Nullable aPhase = DataModel::Nullable(), @@ -137,7 +137,7 @@ class OperationalStateDelegate : public Delegate ~OperationalStateDelegate() = default; private: - GenericOperationalState mOperationalState; + uint8_t mOperationalState; GenericOperationalError mOperationalError; app::DataModel::List mOperationalStateList; Span mOperationalPhaseList; diff --git a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp index ce6c5945497e76..05376fe5df14c0 100644 --- a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp @@ -24,7 +24,7 @@ namespace OperationalState { using chip::Protocols::InteractionModel::Status; -CHIP_ERROR OperationalStateDelegate::SetOperationalState(const GenericOperationalState & opState) +CHIP_ERROR OperationalStateDelegate::SetOperationalState(const uint8_t & opState) { mOperationalState = opState; return CHIP_NO_ERROR; @@ -42,7 +42,7 @@ CHIP_ERROR OperationalStateDelegate::SetCountdownTime(const app::DataModel::Null return CHIP_NO_ERROR; } -void OperationalStateDelegate::GetCurrentOperationalState(GenericOperationalState & op) +void OperationalStateDelegate::GetCurrentOperationalState(uint8_t & op) { op = mOperationalState; } @@ -91,28 +91,28 @@ CHIP_ERROR OperationalStateDelegate::GetOperationalPhaseAtIndex(size_t index, Ge void OperationalStateDelegate::HandlePauseStateCallback(GenericOperationalError & err) { // placeholder implementation - mOperationalState.Set(to_underlying(OperationalStateEnum::kPaused)); + mOperationalState = to_underlying(OperationalStateEnum::kPaused); err.Set(to_underlying(ErrorStateEnum::kNoError)); } void OperationalStateDelegate::HandleResumeStateCallback(GenericOperationalError & err) { // placeholder implementation - mOperationalState.Set(to_underlying(OperationalStateEnum::kRunning)); + mOperationalState = to_underlying(OperationalStateEnum::kRunning); err.Set(to_underlying(ErrorStateEnum::kNoError)); } void OperationalStateDelegate::HandleStartStateCallback(GenericOperationalError & err) { // placeholder implementation - mOperationalState.Set(to_underlying(OperationalStateEnum::kRunning)); + mOperationalState = to_underlying(OperationalStateEnum::kRunning); err.Set(to_underlying(ErrorStateEnum::kNoError)); } void OperationalStateDelegate::HandleStopStateCallback(GenericOperationalError & err) { // placeholder implementation - mOperationalState.Set(to_underlying(OperationalStateEnum::kStopped)); + mOperationalState = to_underlying(OperationalStateEnum::kStopped); err.Set(to_underlying(ErrorStateEnum::kNoError)); } diff --git a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegates.cpp b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegates.cpp index 32bf09a4592b3c..9d4a5cec4b111e 100644 --- a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegates.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegates.cpp @@ -77,7 +77,7 @@ static const GenericOperationalPhase opPhaseList[] = { * Operational State Delegate * Note: User Define */ -static OperationalStateDelegate opStateDelegate(GenericOperationalState(to_underlying(OperationalStateEnum::kStopped)), +static OperationalStateDelegate opStateDelegate(to_underlying(OperationalStateEnum::kStopped), GenericOperationalError(to_underlying(ErrorStateEnum::kNoError)), Span(opStateList), Span(opPhaseList)); diff --git a/src/app/clusters/operational-state-server/operational-state-delegate.h b/src/app/clusters/operational-state-server/operational-state-delegate.h index 217a99c02b400d..7a3576e87fd2a1 100644 --- a/src/app/clusters/operational-state-server/operational-state-delegate.h +++ b/src/app/clusters/operational-state-server/operational-state-delegate.h @@ -213,10 +213,10 @@ class Delegate public: /** * Get the current operational state. - * @param op The GenericOperationalState to fill with the current operational state value. + * @param op The uint8_t to fill with the current operational state value. * @return void. */ - virtual void GetCurrentOperationalState(GenericOperationalState & op) = 0; + virtual void GetCurrentOperationalState(uint8_t & op) = 0; /** * Get the list of supported operational states. @@ -258,7 +258,7 @@ class Delegate * Set current operational state. * @param opState The operational state that should now be the current one. */ - virtual CHIP_ERROR SetOperationalState(const GenericOperationalState & opState) = 0; + virtual CHIP_ERROR SetOperationalState(const uint8_t & opState) = 0; /** * Set operational error. diff --git a/src/app/clusters/operational-state-server/operational-state-server.cpp b/src/app/clusters/operational-state-server/operational-state-server.cpp index 79bb3d157388b9..a7f51ee3902004 100644 --- a/src/app/clusters/operational-state-server/operational-state-server.cpp +++ b/src/app/clusters/operational-state-server/operational-state-server.cpp @@ -106,12 +106,12 @@ void OperationalStateServer::HandlePauseState(HandlerContext & ctx, const Comman Commands::OperationalCommandResponse::Type response; Delegate * delegate = OperationalState::GetOperationalStateDelegate(mEndpointId, mClusterId); GenericOperationalError err(to_underlying(ErrorStateEnum::kNoError)); - GenericOperationalState opState; + uint8_t opState; VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure)); delegate->GetCurrentOperationalState(opState); - if (opState.operationalStateID != to_underlying(OperationalStateEnum::kPaused)) + if (opState != to_underlying(OperationalStateEnum::kPaused)) { delegate->HandlePauseStateCallback(err); } @@ -126,18 +126,18 @@ void OperationalStateServer::HandleResumeState(HandlerContext & ctx, const Comma Commands::OperationalCommandResponse::Type response; Delegate * delegate = OperationalState::GetOperationalStateDelegate(mEndpointId, mClusterId); GenericOperationalError err(to_underlying(ErrorStateEnum::kNoError)); - GenericOperationalState opState; + uint8_t opState; VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure)); delegate->GetCurrentOperationalState(opState); - if (opState.operationalStateID != to_underlying(OperationalStateEnum::kPaused) && - opState.operationalStateID != to_underlying(OperationalStateEnum::kRunning)) + if (opState != to_underlying(OperationalStateEnum::kPaused) && + opState != to_underlying(OperationalStateEnum::kRunning)) { err.Set(to_underlying(ErrorStateEnum::kCommandInvalidInState)); } - else if (opState.operationalStateID == to_underlying(OperationalStateEnum::kPaused)) + else if (opState == to_underlying(OperationalStateEnum::kPaused)) { delegate->HandleResumeStateCallback(err); } @@ -152,13 +152,13 @@ void OperationalStateServer::HandleStartState(HandlerContext & ctx, const Comman Commands::OperationalCommandResponse::Type response; Delegate * delegate = OperationalState::GetOperationalStateDelegate(mEndpointId, mClusterId); GenericOperationalError err(to_underlying(ErrorStateEnum::kNoError)); - GenericOperationalState opState; + uint8_t opState; VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure)); delegate->GetCurrentOperationalState(opState); - if (opState.operationalStateID != to_underlying(OperationalStateEnum::kRunning)) + if (opState != to_underlying(OperationalStateEnum::kRunning)) { delegate->HandleStartStateCallback(err); } @@ -173,13 +173,13 @@ void OperationalStateServer::HandleStopState(HandlerContext & ctx, const Command Commands::OperationalCommandResponse::Type response; Delegate * delegate = OperationalState::GetOperationalStateDelegate(mEndpointId, mClusterId); GenericOperationalError err(to_underlying(ErrorStateEnum::kNoError)); - GenericOperationalState opState; + uint8_t opState; VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure)); delegate->GetCurrentOperationalState(opState); - if (opState.operationalStateID != to_underlying(OperationalStateEnum::kStopped)) + if (opState != to_underlying(OperationalStateEnum::kStopped)) { delegate->HandleStopStateCallback(err); } @@ -243,7 +243,7 @@ CHIP_ERROR OperationalStateServer::Read(const ConcreteReadAttributePath & aPath, case OperationalState::Attributes::OperationalState::Id: { Delegate * delegate = OperationalState::GetOperationalStateDelegate(mEndpointId, mClusterId); - GenericOperationalState opState; + uint8_t opState; VerifyOrReturnError(delegate != nullptr, CHIP_ERROR_INCORRECT_STATE, ChipLogError(Zcl, "Delegate is nullptr")); delegate->GetCurrentOperationalState(opState); return aEncoder.Encode(opState); From 34152ce9057767e1da3bf3d117bcb72d79f10f26 Mon Sep 17 00:00:00 2001 From: mideayanghui Date: Fri, 14 Jul 2023 15:06:34 +0800 Subject: [PATCH 05/20] update OperationalState type to Enum in TestOperationalState.yaml --- .../tests/suites/TestOperationalState.yaml | 29 +++++++ .../chip-tool/zap-generated/test/Commands.h | 87 ++++++++++++++++--- 2 files changed, 105 insertions(+), 11 deletions(-) diff --git a/src/app/tests/suites/TestOperationalState.yaml b/src/app/tests/suites/TestOperationalState.yaml index a7079a560c218e..bd949b48905984 100644 --- a/src/app/tests/suites/TestOperationalState.yaml +++ b/src/app/tests/suites/TestOperationalState.yaml @@ -64,6 +64,12 @@ tests: response: value: { ErrorStateID: 0 } + - label: "Read current Operational State" + command: "readAttribute" + attribute: "OperationalState" + response: + value: 0 + - label: "Start Command" command: "Start" response: @@ -71,6 +77,12 @@ tests: - name: "CommandResponseState" value: { ErrorStateID: 0 } + - label: "Read current Operational State" + command: "readAttribute" + attribute: "OperationalState" + response: + value: 1 + - label: "Pause Command" command: "Pause" response: @@ -78,6 +90,12 @@ tests: - name: "CommandResponseState" value: { ErrorStateID: 0 } + - label: "Read current Operational State" + command: "readAttribute" + attribute: "OperationalState" + response: + value: 2 + - label: "Resume Command" command: "Resume" response: @@ -85,6 +103,12 @@ tests: - name: "CommandResponseState" value: { ErrorStateID: 0 } + - label: "Read current Operational State" + command: "readAttribute" + attribute: "OperationalState" + response: + value: 1 + - label: "Stop Command" command: "Stop" response: @@ -92,3 +116,8 @@ tests: - name: "CommandResponseState" value: { ErrorStateID: 0 } + - label: "Read current Operational State" + command: "readAttribute" + attribute: "OperationalState" + response: + value: 0 diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 965226c5c88e4b..4b9a147612d739 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -91348,7 +91348,7 @@ class TestOperationalStateSuite : public TestCommand { public: TestOperationalStateSuite(CredentialIssuerCommands * credsIssuerConfig) : - TestCommand("TestOperationalState", 10, credsIssuerConfig) + TestCommand("TestOperationalState", 15, credsIssuerConfig) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); AddArgument("cluster", &mCluster); @@ -91445,9 +91445,9 @@ class TestOperationalStateSuite : public TestCommand case 6: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { - chip::app::Clusters::OperationalState::Commands::OperationalCommandResponse::DecodableType value; + uint8_t value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("commandResponseState.errorStateID", value.commandResponseState.errorStateID, 0U)); + VerifyOrReturn(CheckValue("operationalState", value, 0U)); } break; case 7: @@ -91459,6 +91459,14 @@ class TestOperationalStateSuite : public TestCommand } break; case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + uint8_t value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValue("operationalState", value, 1U)); + } + break; + case 9: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { chip::app::Clusters::OperationalState::Commands::OperationalCommandResponse::DecodableType value; @@ -91466,7 +91474,31 @@ class TestOperationalStateSuite : public TestCommand VerifyOrReturn(CheckValue("commandResponseState.errorStateID", value.commandResponseState.errorStateID, 0U)); } break; - case 9: + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + uint8_t value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValue("operationalState", value, 2U)); + } + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + chip::app::Clusters::OperationalState::Commands::OperationalCommandResponse::DecodableType value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValue("commandResponseState.errorStateID", value.commandResponseState.errorStateID, 0U)); + } + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + uint8_t value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValue("operationalState", value, 1U)); + } + break; + case 13: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { chip::app::Clusters::OperationalState::Commands::OperationalCommandResponse::DecodableType value; @@ -91474,6 +91506,14 @@ class TestOperationalStateSuite : public TestCommand VerifyOrReturn(CheckValue("commandResponseState.errorStateID", value.commandResponseState.errorStateID, 0U)); } break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + { + uint8_t value; + VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); + VerifyOrReturn(CheckValue("operationalState", value, 0U)); + } + break; default: LogErrorOnFailure(ContinueOnChipMainThread(CHIP_ERROR_INVALID_ARGUMENT)); } @@ -91522,7 +91562,12 @@ class TestOperationalStateSuite : public TestCommand OperationalState::Attributes::OperationalError::Id, true, chip::NullOptional); } case 6: { - LogStep(6, "Start Command"); + LogStep(6, "Read current Operational State"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, + OperationalState::Attributes::OperationalState::Id, true, chip::NullOptional); + } + case 7: { + LogStep(7, "Start Command"); ListFreer listFreer; chip::app::Clusters::OperationalState::Commands::Start::Type value; return SendCommand(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, OperationalState::Commands::Start::Id, value, @@ -91530,8 +91575,13 @@ class TestOperationalStateSuite : public TestCommand ); } - case 7: { - LogStep(7, "Pause Command"); + case 8: { + LogStep(8, "Read current Operational State"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, + OperationalState::Attributes::OperationalState::Id, true, chip::NullOptional); + } + case 9: { + LogStep(9, "Pause Command"); ListFreer listFreer; chip::app::Clusters::OperationalState::Commands::Pause::Type value; return SendCommand(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, OperationalState::Commands::Pause::Id, value, @@ -91539,8 +91589,13 @@ class TestOperationalStateSuite : public TestCommand ); } - case 8: { - LogStep(8, "Resume Command"); + case 10: { + LogStep(10, "Read current Operational State"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, + OperationalState::Attributes::OperationalState::Id, true, chip::NullOptional); + } + case 11: { + LogStep(11, "Resume Command"); ListFreer listFreer; chip::app::Clusters::OperationalState::Commands::Resume::Type value; return SendCommand(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, OperationalState::Commands::Resume::Id, value, @@ -91548,8 +91603,13 @@ class TestOperationalStateSuite : public TestCommand ); } - case 9: { - LogStep(9, "Stop Command"); + case 12: { + LogStep(12, "Read current Operational State"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, + OperationalState::Attributes::OperationalState::Id, true, chip::NullOptional); + } + case 13: { + LogStep(13, "Stop Command"); ListFreer listFreer; chip::app::Clusters::OperationalState::Commands::Stop::Type value; return SendCommand(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, OperationalState::Commands::Stop::Id, value, @@ -91557,6 +91617,11 @@ class TestOperationalStateSuite : public TestCommand ); } + case 14: { + LogStep(14, "Read current Operational State"); + return ReadAttribute(kIdentityAlpha, GetEndpoint(1), OperationalState::Id, + OperationalState::Attributes::OperationalState::Id, true, chip::NullOptional); + } } return CHIP_NO_ERROR; } From 726b34bc6d66e4175e9c8e197cad949649e7e089 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 14 Jul 2023 07:12:18 +0000 Subject: [PATCH 06/20] Restyled by clang-format --- .../operational-state-server/operational-state-server.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/app/clusters/operational-state-server/operational-state-server.cpp b/src/app/clusters/operational-state-server/operational-state-server.cpp index a7f51ee3902004..ce518275e4239e 100644 --- a/src/app/clusters/operational-state-server/operational-state-server.cpp +++ b/src/app/clusters/operational-state-server/operational-state-server.cpp @@ -132,8 +132,7 @@ void OperationalStateServer::HandleResumeState(HandlerContext & ctx, const Comma delegate->GetCurrentOperationalState(opState); - if (opState != to_underlying(OperationalStateEnum::kPaused) && - opState != to_underlying(OperationalStateEnum::kRunning)) + if (opState != to_underlying(OperationalStateEnum::kPaused) && opState != to_underlying(OperationalStateEnum::kRunning)) { err.Set(to_underlying(ErrorStateEnum::kCommandInvalidInState)); } From 66a6920311aaec4ea9497dc939d735cfc41fefab Mon Sep 17 00:00:00 2001 From: mideayanghui Date: Sat, 15 Jul 2023 10:09:26 +0800 Subject: [PATCH 07/20] modify the api of GetCurrentOperationalState in class Delegate --- .../include/operational-state-delegate-impl.h | 7 +++---- .../src/operational-state-delegate-impl.cpp | 4 ++-- .../operational-state-delegate.h | 5 ++--- .../operational-state-server.cpp | 18 +++++------------- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h b/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h index ca225fbcebcf3c..8404cac55056c7 100644 --- a/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h +++ b/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h @@ -34,11 +34,10 @@ class OperationalStateDelegate : public Delegate public: /** - * Get current operational state. - * @param op The uint8_t to fill with the current operational state value. - * @return void. + * Get the current operational state. + * @return The current operational state value */ - void GetCurrentOperationalState(uint8_t & op) override; + uint8_t GetCurrentOperationalState() override; /** * Get the list of supported operational states. diff --git a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp index 05376fe5df14c0..402fa3909237cd 100644 --- a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp @@ -42,9 +42,9 @@ CHIP_ERROR OperationalStateDelegate::SetCountdownTime(const app::DataModel::Null return CHIP_NO_ERROR; } -void OperationalStateDelegate::GetCurrentOperationalState(uint8_t & op) +uint8_t OperationalStateDelegate::GetCurrentOperationalState() { - op = mOperationalState; + return mOperationalState; } CHIP_ERROR OperationalStateDelegate::SetOperationalError(const GenericOperationalError & opErrState) diff --git a/src/app/clusters/operational-state-server/operational-state-delegate.h b/src/app/clusters/operational-state-server/operational-state-delegate.h index 7a3576e87fd2a1..db10219ed597f9 100644 --- a/src/app/clusters/operational-state-server/operational-state-delegate.h +++ b/src/app/clusters/operational-state-server/operational-state-delegate.h @@ -213,10 +213,9 @@ class Delegate public: /** * Get the current operational state. - * @param op The uint8_t to fill with the current operational state value. - * @return void. + * @return The current operational state value */ - virtual void GetCurrentOperationalState(uint8_t & op) = 0; + virtual uint8_t GetCurrentOperationalState() = 0; /** * Get the list of supported operational states. diff --git a/src/app/clusters/operational-state-server/operational-state-server.cpp b/src/app/clusters/operational-state-server/operational-state-server.cpp index ce518275e4239e..ad909a4e9a2af3 100644 --- a/src/app/clusters/operational-state-server/operational-state-server.cpp +++ b/src/app/clusters/operational-state-server/operational-state-server.cpp @@ -106,10 +106,9 @@ void OperationalStateServer::HandlePauseState(HandlerContext & ctx, const Comman Commands::OperationalCommandResponse::Type response; Delegate * delegate = OperationalState::GetOperationalStateDelegate(mEndpointId, mClusterId); GenericOperationalError err(to_underlying(ErrorStateEnum::kNoError)); - uint8_t opState; VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure)); - delegate->GetCurrentOperationalState(opState); + uint8_t opState = delegate->GetCurrentOperationalState(); if (opState != to_underlying(OperationalStateEnum::kPaused)) { @@ -126,11 +125,9 @@ void OperationalStateServer::HandleResumeState(HandlerContext & ctx, const Comma Commands::OperationalCommandResponse::Type response; Delegate * delegate = OperationalState::GetOperationalStateDelegate(mEndpointId, mClusterId); GenericOperationalError err(to_underlying(ErrorStateEnum::kNoError)); - uint8_t opState; VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure)); - - delegate->GetCurrentOperationalState(opState); + uint8_t opState = delegate->GetCurrentOperationalState(); if (opState != to_underlying(OperationalStateEnum::kPaused) && opState != to_underlying(OperationalStateEnum::kRunning)) { @@ -151,11 +148,9 @@ void OperationalStateServer::HandleStartState(HandlerContext & ctx, const Comman Commands::OperationalCommandResponse::Type response; Delegate * delegate = OperationalState::GetOperationalStateDelegate(mEndpointId, mClusterId); GenericOperationalError err(to_underlying(ErrorStateEnum::kNoError)); - uint8_t opState; VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure)); - - delegate->GetCurrentOperationalState(opState); + uint8_t opState = delegate->GetCurrentOperationalState(); if (opState != to_underlying(OperationalStateEnum::kRunning)) { @@ -172,11 +167,9 @@ void OperationalStateServer::HandleStopState(HandlerContext & ctx, const Command Commands::OperationalCommandResponse::Type response; Delegate * delegate = OperationalState::GetOperationalStateDelegate(mEndpointId, mClusterId); GenericOperationalError err(to_underlying(ErrorStateEnum::kNoError)); - uint8_t opState; VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure)); - - delegate->GetCurrentOperationalState(opState); + uint8_t opState = delegate->GetCurrentOperationalState(); if (opState != to_underlying(OperationalStateEnum::kStopped)) { @@ -242,9 +235,8 @@ CHIP_ERROR OperationalStateServer::Read(const ConcreteReadAttributePath & aPath, case OperationalState::Attributes::OperationalState::Id: { Delegate * delegate = OperationalState::GetOperationalStateDelegate(mEndpointId, mClusterId); - uint8_t opState; VerifyOrReturnError(delegate != nullptr, CHIP_ERROR_INCORRECT_STATE, ChipLogError(Zcl, "Delegate is nullptr")); - delegate->GetCurrentOperationalState(opState); + uint8_t opState = delegate->GetCurrentOperationalState(); return aEncoder.Encode(opState); } break; From c25b4ba92a1ff76501cda22b760ebf3df467a3de Mon Sep 17 00:00:00 2001 From: mideayanghui Date: Sat, 15 Jul 2023 10:12:21 +0800 Subject: [PATCH 08/20] modify the api of SetOperationalState in class Delegate --- .../include/operational-state-delegate-impl.h | 2 +- .../all-clusters-common/src/operational-state-delegate-impl.cpp | 2 +- .../operational-state-server/operational-state-delegate.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h b/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h index 8404cac55056c7..935fdb626bfd14 100644 --- a/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h +++ b/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h @@ -85,7 +85,7 @@ class OperationalStateDelegate : public Delegate * Set current operational state. * @param opState The operational state that should now be the current one. */ - CHIP_ERROR SetOperationalState(const uint8_t & opState) override; + CHIP_ERROR SetOperationalState(uint8_t opState) override; /** * Set operational phase. diff --git a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp index 402fa3909237cd..7501e386db00b7 100644 --- a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp @@ -24,7 +24,7 @@ namespace OperationalState { using chip::Protocols::InteractionModel::Status; -CHIP_ERROR OperationalStateDelegate::SetOperationalState(const uint8_t & opState) +CHIP_ERROR OperationalStateDelegate::SetOperationalState(uint8_t opState) { mOperationalState = opState; return CHIP_NO_ERROR; diff --git a/src/app/clusters/operational-state-server/operational-state-delegate.h b/src/app/clusters/operational-state-server/operational-state-delegate.h index db10219ed597f9..6fd29bd7d48480 100644 --- a/src/app/clusters/operational-state-server/operational-state-delegate.h +++ b/src/app/clusters/operational-state-server/operational-state-delegate.h @@ -257,7 +257,7 @@ class Delegate * Set current operational state. * @param opState The operational state that should now be the current one. */ - virtual CHIP_ERROR SetOperationalState(const uint8_t & opState) = 0; + virtual CHIP_ERROR SetOperationalState(uint8_t opState) = 0; /** * Set operational error. From 2abaa8d6c031c0ba6be5e70719ccacfefc158e9b Mon Sep 17 00:00:00 2001 From: mideayanghui Date: Sat, 15 Jul 2023 10:58:27 +0800 Subject: [PATCH 09/20] optimize the Operational State cluster definition --- .../zcl/data-model/chip/operational-state-cluster.xml | 2 +- .../zcl/data-model/chip/operational-state-rvc-cluster.xml | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/zap-templates/zcl/data-model/chip/operational-state-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/operational-state-cluster.xml index c70cc003b0aacc..0a4c0172ea2625 100644 --- a/src/app/zap-templates/zcl/data-model/chip/operational-state-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/operational-state-cluster.xml @@ -63,7 +63,7 @@ limitations under the License. CurrentPhase CountdownTime OperationalStateList - OperationalState + OperationalState OperationalError diff --git a/src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster.xml index 7b652169c34dc2..e1943cb98644a0 100644 --- a/src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster.xml @@ -51,6 +51,11 @@ limitations under the License. CurrentPhase CountdownTime OperationalStateList + + OperationalState OperationalError From 10fad3103efac8bfdfe8c486a2452a1082f02e3b Mon Sep 17 00:00:00 2001 From: mideayanghui Date: Sat, 15 Jul 2023 10:59:04 +0800 Subject: [PATCH 10/20] zap regen all --- .../all-clusters-common/all-clusters-app.matter | 2 +- src/controller/data_model/controller-clusters.matter | 2 +- .../zap-generated/CHIPAttributeTLVValueDecoder.cpp | 2 +- src/controller/python/chip/clusters/Objects.py | 8 ++++---- .../app-common/zap-generated/cluster-objects.h | 9 +++++---- .../chip-tool/zap-generated/cluster/Commands.h | 5 +++-- .../zap-generated/cluster/logging/DataModelLogger.cpp | 2 +- zzz_generated/chip-tool/zap-generated/test/Commands.h | 10 +++++----- 8 files changed, 21 insertions(+), 19 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index d5644a9359625c..7430b037d79e12 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -2692,7 +2692,7 @@ server cluster OperationalState = 96 { readonly attribute nullable int8u currentPhase = 1; readonly attribute nullable elapsed_s countdownTime = 2; readonly attribute OperationalStateStruct operationalStateList[] = 3; - readonly attribute enum8 operationalState = 4; + readonly attribute OperationalStateEnum operationalState = 4; readonly attribute ErrorStateStruct operationalError = 5; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index 82cb01408da254..db6f89b02be15c 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -3354,7 +3354,7 @@ client cluster OperationalState = 96 { readonly attribute nullable int8u currentPhase = 1; readonly attribute optional nullable elapsed_s countdownTime = 2; readonly attribute OperationalStateStruct operationalStateList[] = 3; - readonly attribute enum8 operationalState = 4; + readonly attribute OperationalStateEnum operationalState = 4; readonly attribute ErrorStateStruct operationalError = 5; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; diff --git a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp index f4f88992cbb98b..b3f8a26e4332be 100644 --- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp @@ -15137,7 +15137,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR std::string valueClassName = "java/lang/Integer"; std::string valueCtorSignature = "(I)V"; chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), - cppValue, value); + static_cast(cppValue), value); return value; } case Attributes::OperationalError::Id: { diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index a61b4eaa3408df..aa2c6e474d06c9 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -18256,7 +18256,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="currentPhase", Tag=0x00000001, Type=typing.Union[Nullable, uint]), ClusterObjectFieldDescriptor(Label="countdownTime", Tag=0x00000002, Type=typing.Union[None, Nullable, uint]), ClusterObjectFieldDescriptor(Label="operationalStateList", Tag=0x00000003, Type=typing.List[OperationalState.Structs.OperationalStateStruct]), - ClusterObjectFieldDescriptor(Label="operationalState", Tag=0x00000004, Type=uint), + ClusterObjectFieldDescriptor(Label="operationalState", Tag=0x00000004, Type=OperationalState.Enums.OperationalStateEnum), ClusterObjectFieldDescriptor(Label="operationalError", Tag=0x00000005, Type=OperationalState.Structs.ErrorStateStruct), ClusterObjectFieldDescriptor(Label="generatedCommandList", Tag=0x0000FFF8, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="acceptedCommandList", Tag=0x0000FFF9, Type=typing.List[uint]), @@ -18270,7 +18270,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: currentPhase: 'typing.Union[Nullable, uint]' = None countdownTime: 'typing.Union[None, Nullable, uint]' = None operationalStateList: 'typing.List[OperationalState.Structs.OperationalStateStruct]' = None - operationalState: 'uint' = None + operationalState: 'OperationalState.Enums.OperationalStateEnum' = None operationalError: 'OperationalState.Structs.ErrorStateStruct' = None generatedCommandList: 'typing.List[uint]' = None acceptedCommandList: 'typing.List[uint]' = None @@ -18477,9 +18477,9 @@ def attribute_id(cls) -> int: @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=uint) + return ClusterObjectFieldDescriptor(Type=OperationalState.Enums.OperationalStateEnum) - value: 'uint' = 0 + value: 'OperationalState.Enums.OperationalStateEnum' = 0 @dataclass class OperationalError(ClusterAttributeDescriptor): diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index 6262c1ee5e48cd..34cc96f868bcc7 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -16933,9 +16933,9 @@ struct TypeInfo namespace OperationalState { struct TypeInfo { - using Type = uint8_t; - using DecodableType = uint8_t; - using DecodableArgType = uint8_t; + using Type = chip::app::Clusters::OperationalState::OperationalStateEnum; + using DecodableType = chip::app::Clusters::OperationalState::OperationalStateEnum; + using DecodableArgType = chip::app::Clusters::OperationalState::OperationalStateEnum; static constexpr ClusterId GetClusterId() { return Clusters::OperationalState::Id; } static constexpr AttributeId GetAttributeId() { return Attributes::OperationalState::Id; } @@ -17003,7 +17003,8 @@ struct TypeInfo Attributes::CurrentPhase::TypeInfo::DecodableType currentPhase; Attributes::CountdownTime::TypeInfo::DecodableType countdownTime; Attributes::OperationalStateList::TypeInfo::DecodableType operationalStateList; - Attributes::OperationalState::TypeInfo::DecodableType operationalState = static_cast(0); + Attributes::OperationalState::TypeInfo::DecodableType operationalState = + static_cast(0); Attributes::OperationalError::TypeInfo::DecodableType operationalError; Attributes::GeneratedCommandList::TypeInfo::DecodableType generatedCommandList; Attributes::AcceptedCommandList::TypeInfo::DecodableType acceptedCommandList; diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index cda82b13b152e2..c88a81c1ec38c7 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -15596,8 +15596,9 @@ void registerClusterOperationalState(Commands & commands, CredentialIssuerComman chip::app::DataModel::List>>( Id, "operational-state-list", Attributes::OperationalStateList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // - make_unique>(Id, "operational-state", 0, UINT8_MAX, Attributes::OperationalState::Id, - WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>( + Id, "operational-state", 0, UINT8_MAX, Attributes::OperationalState::Id, WriteCommandType::kForceWrite, + credsIssuerConfig), // make_unique>( Id, "operational-error", Attributes::OperationalError::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>>( diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp index 3a436daf038631..940b02f8c55ae8 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -8967,7 +8967,7 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP return DataModelLogger::LogValue("OperationalStateList", 1, value); } case OperationalState::Attributes::OperationalState::Id: { - uint8_t value; + chip::app::Clusters::OperationalState::OperationalStateEnum value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("OperationalState", 1, value); } diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 9dbfe7e83bab66..7ec8b02994c977 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -89985,7 +89985,7 @@ class TestOperationalStateSuite : public TestCommand case 6: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { - uint8_t value; + chip::app::Clusters::OperationalState::OperationalStateEnum value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); VerifyOrReturn(CheckValue("operationalState", value, 0U)); } @@ -90001,7 +90001,7 @@ class TestOperationalStateSuite : public TestCommand case 8: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { - uint8_t value; + chip::app::Clusters::OperationalState::OperationalStateEnum value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); VerifyOrReturn(CheckValue("operationalState", value, 1U)); } @@ -90017,7 +90017,7 @@ class TestOperationalStateSuite : public TestCommand case 10: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { - uint8_t value; + chip::app::Clusters::OperationalState::OperationalStateEnum value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); VerifyOrReturn(CheckValue("operationalState", value, 2U)); } @@ -90033,7 +90033,7 @@ class TestOperationalStateSuite : public TestCommand case 12: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { - uint8_t value; + chip::app::Clusters::OperationalState::OperationalStateEnum value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); VerifyOrReturn(CheckValue("operationalState", value, 1U)); } @@ -90049,7 +90049,7 @@ class TestOperationalStateSuite : public TestCommand case 14: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { - uint8_t value; + chip::app::Clusters::OperationalState::OperationalStateEnum value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); VerifyOrReturn(CheckValue("operationalState", value, 0U)); } From 14085d2ab6d2707d62415664cb507559b52c16e8 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sat, 15 Jul 2023 03:03:07 +0000 Subject: [PATCH 11/20] Restyled by clang-format --- .../operational-state-server.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/clusters/operational-state-server/operational-state-server.cpp b/src/app/clusters/operational-state-server/operational-state-server.cpp index ad909a4e9a2af3..ec54a41f2b7b60 100644 --- a/src/app/clusters/operational-state-server/operational-state-server.cpp +++ b/src/app/clusters/operational-state-server/operational-state-server.cpp @@ -108,7 +108,7 @@ void OperationalStateServer::HandlePauseState(HandlerContext & ctx, const Comman GenericOperationalError err(to_underlying(ErrorStateEnum::kNoError)); VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure)); - uint8_t opState = delegate->GetCurrentOperationalState(); + uint8_t opState = delegate->GetCurrentOperationalState(); if (opState != to_underlying(OperationalStateEnum::kPaused)) { @@ -127,7 +127,7 @@ void OperationalStateServer::HandleResumeState(HandlerContext & ctx, const Comma GenericOperationalError err(to_underlying(ErrorStateEnum::kNoError)); VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure)); - uint8_t opState = delegate->GetCurrentOperationalState(); + uint8_t opState = delegate->GetCurrentOperationalState(); if (opState != to_underlying(OperationalStateEnum::kPaused) && opState != to_underlying(OperationalStateEnum::kRunning)) { @@ -150,7 +150,7 @@ void OperationalStateServer::HandleStartState(HandlerContext & ctx, const Comman GenericOperationalError err(to_underlying(ErrorStateEnum::kNoError)); VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure)); - uint8_t opState = delegate->GetCurrentOperationalState(); + uint8_t opState = delegate->GetCurrentOperationalState(); if (opState != to_underlying(OperationalStateEnum::kRunning)) { @@ -169,7 +169,7 @@ void OperationalStateServer::HandleStopState(HandlerContext & ctx, const Command GenericOperationalError err(to_underlying(ErrorStateEnum::kNoError)); VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure)); - uint8_t opState = delegate->GetCurrentOperationalState(); + uint8_t opState = delegate->GetCurrentOperationalState(); if (opState != to_underlying(OperationalStateEnum::kStopped)) { @@ -236,7 +236,7 @@ CHIP_ERROR OperationalStateServer::Read(const ConcreteReadAttributePath & aPath, Delegate * delegate = OperationalState::GetOperationalStateDelegate(mEndpointId, mClusterId); VerifyOrReturnError(delegate != nullptr, CHIP_ERROR_INCORRECT_STATE, ChipLogError(Zcl, "Delegate is nullptr")); - uint8_t opState = delegate->GetCurrentOperationalState(); + uint8_t opState = delegate->GetCurrentOperationalState(); return aEncoder.Encode(opState); } break; From f15219f85d71f2736128626e515017684fd40c05 Mon Sep 17 00:00:00 2001 From: mideayanghui Date: Sat, 15 Jul 2023 14:30:57 +0800 Subject: [PATCH 12/20] modify the note for RVC Operational State cluster definition --- .../zcl/data-model/chip/operational-state-rvc-cluster.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster.xml index e1943cb98644a0..4943d0a8fd61a3 100644 --- a/src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/operational-state-rvc-cluster.xml @@ -53,8 +53,9 @@ limitations under the License. OperationalStateList OperationalState OperationalError From fa84e160f4caf3ab78b7e01102bb6387d87a2460 Mon Sep 17 00:00:00 2001 From: mideayanghui Date: Sat, 15 Jul 2023 16:08:40 +0800 Subject: [PATCH 13/20] Add OperationalError event api for operational state cluster --- .../operational-state-server.cpp | 24 +++++++++++++++++++ .../operational-state-server.h | 9 +++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/app/clusters/operational-state-server/operational-state-server.cpp b/src/app/clusters/operational-state-server/operational-state-server.cpp index ec54a41f2b7b60..47fab8c7fee63d 100644 --- a/src/app/clusters/operational-state-server/operational-state-server.cpp +++ b/src/app/clusters/operational-state-server/operational-state-server.cpp @@ -29,7 +29,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -294,3 +296,25 @@ CHIP_ERROR OperationalStateServer::Read(const ConcreteReadAttributePath & aPath, } return CHIP_NO_ERROR; } + +void OperationalStateServer::OnOperationalErrorDetect(const Structs::ErrorStateStruct::Type & aError) +{ + ChipLogDetail(Zcl, "OperationalStateServer: OnOperationalErrorDetect"); + MatterReportingAttributeChangeCallback(mEndpointId, mClusterId, + OperationalState::Attributes::OperationalState::Id); + + EventNumber eventNumber; + Events::OperationalError::Type event { aError }; + EventLogger eventData(event); + ConcreteEventPath path(mEndpointId, mClusterId, event.GetEventId()); + EventManagement & logMgmt = chip::app::EventManagement::GetInstance(); + EventOptions eventOptions; + eventOptions.mPath = path; + eventOptions.mPriority = event.GetPriorityLevel(); + + CHIP_ERROR err = logMgmt.LogEvent(&eventData, eventOptions, eventNumber); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "OperationalStateServer: Failed to record OperationalError event: %" CHIP_ERROR_FORMAT, err.Format()); + } +} diff --git a/src/app/clusters/operational-state-server/operational-state-server.h b/src/app/clusters/operational-state-server/operational-state-server.h index 247ef3779ffd7a..d2609565c4db22 100644 --- a/src/app/clusters/operational-state-server/operational-state-server.h +++ b/src/app/clusters/operational-state-server/operational-state-server.h @@ -60,11 +60,17 @@ class OperationalStateServer : public CommandHandlerInterface, public AttributeA */ void Shutdown(); + /** + * @brief Called when the Node detects a OperationalError has been raised. + * @param aError OperationalError which detects + */ + void OnOperationalErrorDetect(const Structs::ErrorStateStruct::Type & aError); + /** * Creates an operational state cluster instance. The Init() function needs to be called for this instance to be registered and * called by the interaction model at the appropriate times. * @param aEndpointId The endpoint on which this cluster exists. This must match the zap configuration. - * @param aClusterId The ID of the ModeSelect aliased cluster to be instantiated. + * @param aClusterId The ID of the operational state aliased cluster to be instantiated. */ OperationalStateServer(EndpointId aEndpointId, ClusterId aClusterId) : CommandHandlerInterface(MakeOptional(aEndpointId), aClusterId), @@ -113,7 +119,6 @@ class OperationalStateServer : public CommandHandlerInterface, public AttributeA EndpointId mEndpointId; ClusterId mClusterId; }; - } // namespace OperationalState } // namespace Clusters } // namespace app From 1a2701272c5a4e493e4cdea5a4d733d4a44d5ac4 Mon Sep 17 00:00:00 2001 From: mideayanghui Date: Sat, 15 Jul 2023 17:14:47 +0800 Subject: [PATCH 14/20] fix build error --- .../operational-state-server/operational-state-server.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/clusters/operational-state-server/operational-state-server.cpp b/src/app/clusters/operational-state-server/operational-state-server.cpp index 47fab8c7fee63d..134217e1e85c61 100644 --- a/src/app/clusters/operational-state-server/operational-state-server.cpp +++ b/src/app/clusters/operational-state-server/operational-state-server.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include From aae5a7e2ca148c97e591b2233e344b3ab93945e7 Mon Sep 17 00:00:00 2001 From: mideayanghui Date: Sat, 15 Jul 2023 17:38:20 +0800 Subject: [PATCH 15/20] Add OperationCompletion event api for operational state cluster --- .../operational-state-server.cpp | 21 +++++++++++++++++++ .../operational-state-server.h | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/src/app/clusters/operational-state-server/operational-state-server.cpp b/src/app/clusters/operational-state-server/operational-state-server.cpp index 134217e1e85c61..9fb5e0950cb8d2 100644 --- a/src/app/clusters/operational-state-server/operational-state-server.cpp +++ b/src/app/clusters/operational-state-server/operational-state-server.cpp @@ -319,3 +319,24 @@ void OperationalStateServer::OnOperationalErrorDetect(const Structs::ErrorStateS ChipLogError(Zcl, "OperationalStateServer: Failed to record OperationalError event: %" CHIP_ERROR_FORMAT, err.Format()); } } + +void OperationalStateServer::OnOperationCompletionDetect(const Events::OperationCompletion::Type & aEvent); +{ + ChipLogDetail(Zcl, "OperationalStateServer: OnOperationCompletionDetect"); + MatterReportingAttributeChangeCallback(mEndpointId, mClusterId, + OperationalState::Attributes::OperationalState::Id); + + EventNumber eventNumber; + EventLogger eventData(aEvent); + ConcreteEventPath path(mEndpointId, mClusterId, aEvent.GetEventId()); + EventManagement & logMgmt = chip::app::EventManagement::GetInstance(); + EventOptions eventOptions; + eventOptions.mPath = path; + eventOptions.mPriority = aEvent.GetPriorityLevel(); + + CHIP_ERROR err = logMgmt.LogEvent(&eventData, eventOptions, eventNumber); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "OperationalStateServer: Failed to record OnOperationCompletionDetect event: %" CHIP_ERROR_FORMAT, err.Format()); + } +} diff --git a/src/app/clusters/operational-state-server/operational-state-server.h b/src/app/clusters/operational-state-server/operational-state-server.h index d2609565c4db22..796fa4cc3640e4 100644 --- a/src/app/clusters/operational-state-server/operational-state-server.h +++ b/src/app/clusters/operational-state-server/operational-state-server.h @@ -66,6 +66,12 @@ class OperationalStateServer : public CommandHandlerInterface, public AttributeA */ void OnOperationalErrorDetect(const Structs::ErrorStateStruct::Type & aError); + /** + * @brief Called when the Node detects a OperationCompletion has been raised. + * @param aEvent OperationCompletion event + */ + void OnOperationCompletionDetect(const Events::OperationCompletion::Type & aEvent); + /** * Creates an operational state cluster instance. The Init() function needs to be called for this instance to be registered and * called by the interaction model at the appropriate times. From d688c6965ef95f95baf596742642d07933a97cce Mon Sep 17 00:00:00 2001 From: mideayanghui Date: Sat, 15 Jul 2023 17:49:33 +0800 Subject: [PATCH 16/20] fix build error --- .../operational-state-server/operational-state-server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/clusters/operational-state-server/operational-state-server.cpp b/src/app/clusters/operational-state-server/operational-state-server.cpp index 9fb5e0950cb8d2..9a1959c7b6f251 100644 --- a/src/app/clusters/operational-state-server/operational-state-server.cpp +++ b/src/app/clusters/operational-state-server/operational-state-server.cpp @@ -320,7 +320,7 @@ void OperationalStateServer::OnOperationalErrorDetect(const Structs::ErrorStateS } } -void OperationalStateServer::OnOperationCompletionDetect(const Events::OperationCompletion::Type & aEvent); +void OperationalStateServer::OnOperationCompletionDetect(const Events::OperationCompletion::Type & aEvent) { ChipLogDetail(Zcl, "OperationalStateServer: OnOperationCompletionDetect"); MatterReportingAttributeChangeCallback(mEndpointId, mClusterId, From bd5ff29b5cc621ee4f54b7ffd8d0242729f96759 Mon Sep 17 00:00:00 2001 From: mideayanghui Date: Sat, 15 Jul 2023 17:05:48 +0800 Subject: [PATCH 17/20] Add RVC Operational State Cluster Implementation --- src/app/common/templates/config-data.yaml | 1 + src/app/util/util.cpp | 1 + src/app/zap_cluster_list.json | 1 + 3 files changed, 3 insertions(+) diff --git a/src/app/common/templates/config-data.yaml b/src/app/common/templates/config-data.yaml index d9b620e173f4ef..f11a9b165a563a 100644 --- a/src/app/common/templates/config-data.yaml +++ b/src/app/common/templates/config-data.yaml @@ -25,6 +25,7 @@ CommandHandlerInterfaceOnlyClusters: - NetworkCommissioning - Scenes - OperationalState + - RvcOperationalState # We need a more configurable way of deciding which clusters have which init functions.... # See https://github.com/project-chip/connectedhomeip/issues/4369 diff --git a/src/app/util/util.cpp b/src/app/util/util.cpp index 7ae0d174062133..cc57f9e5ebcfb0 100644 --- a/src/app/util/util.cpp +++ b/src/app/util/util.cpp @@ -160,6 +160,7 @@ void MatterPm25ConcentrationMeasurementPluginServerInitCallback() {} void MatterRadonConcentrationMeasurementPluginServerInitCallback() {} void MatterTotalVolatileOrganicCompoundsConcentrationMeasurementPluginServerInitCallback() {} void MatterOperationalStatePluginServerInitCallback() {} +void MatterRvcOperationalStatePluginServerInitCallback() {} // **************************************** // Print out information about each cluster // **************************************** diff --git a/src/app/zap_cluster_list.json b/src/app/zap_cluster_list.json index ca9592bd5a7daf..f71213593bd794 100644 --- a/src/app/zap_cluster_list.json +++ b/src/app/zap_cluster_list.json @@ -241,6 +241,7 @@ "ON_OFF_SWITCH_CONFIGURATION_CLUSTER": [], "OPERATIONAL_CREDENTIALS_CLUSTER": ["operational-credentials-server"], "OPERATIONAL_STATE_CLUSTER": ["operational-state-server"], + "OPERATIONAL_STATE_RVC_CLUSTER": ["operational-state-server"], "OTA_BOOTLOAD_CLUSTER": [], "OTA_SOFTWARE_UPDATE_PROVIDER_CLUSTER": ["ota-provider"], "OTA_SOFTWARE_UPDATE_REQUESTOR_CLUSTER": ["ota-requestor"], From 98f417459882d89ff0abec7b9b42872f5e8f066e Mon Sep 17 00:00:00 2001 From: mideayanghui Date: Sat, 15 Jul 2023 17:07:20 +0800 Subject: [PATCH 18/20] enable RVC operational state cluster in all-cluster-app and zap regen all --- .../all-clusters-app.matter | 80 +++++ .../all-clusters-common/all-clusters-app.zap | 306 +++++++++++++++++- .../app-common/zap-generated/callback.h | 24 -- 3 files changed, 385 insertions(+), 25 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index 7430b037d79e12..271bd60c8d641e 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -2711,6 +2711,69 @@ server cluster OperationalState = 96 { command Resume(): OperationalCommandResponse = 3; } +/** This cluster supports remotely monitoring and, where supported, changing the operational state of a Robotic Vacuum. */ +server cluster RvcOperationalState = 97 { + enum ErrorStateEnum : ENUM8 { + kFailedToFindChargingDock = 64; + kStuck = 65; + kDustBinMissing = 66; + kDustBinFull = 67; + kWaterTankEmpty = 68; + kWaterTankMissing = 69; + kWaterTankLidOpen = 70; + kMopCleaningPadMissing = 71; + } + + enum OperationalStateEnum : ENUM8 { + kSeekingCharger = 64; + kCharging = 65; + kDocked = 66; + } + + struct ErrorStateStruct { + enum8 errorStateID = 0; + optional char_string<64> errorStateLabel = 1; + optional char_string<64> errorStateDetails = 2; + } + + struct OperationalStateStruct { + enum8 operationalStateID = 0; + optional char_string<64> operationalStateLabel = 1; + } + + critical event OperationalError = 0 { + ErrorStateStruct errorState = 0; + } + + info event OperationCompletion = 1 { + ENUM8 completionErrorCode = 0; + optional nullable elapsed_s totalOperationalTime = 1; + optional nullable elapsed_s pausedTime = 2; + } + + readonly attribute nullable CHAR_STRING phaseList[] = 0; + readonly attribute nullable int8u currentPhase = 1; + readonly attribute nullable elapsed_s countdownTime = 2; + readonly attribute OperationalStateStruct operationalStateList[] = 3; + readonly attribute enum8 operationalState = 4; + readonly attribute ErrorStateStruct operationalError = 5; + readonly attribute command_id generatedCommandList[] = 65528; + readonly attribute command_id acceptedCommandList[] = 65529; + readonly attribute event_id eventList[] = 65530; + readonly attribute attrib_id attributeList[] = 65531; + readonly attribute bitmap32 featureMap = 65532; + readonly attribute int16u clusterRevision = 65533; + + response struct OperationalCommandResponse = 4 { + ErrorStateStruct commandResponseState = 0; + } + + command Pause(): OperationalCommandResponse = 0; + command Stop(): OperationalCommandResponse = 1; + command Start(): OperationalCommandResponse = 2; + command Resume(): OperationalCommandResponse = 3; +} + /** Attributes and commands for monitoring HEPA filters in a device */ server cluster HepaFilterMonitoring = 113 { enum ChangeIndicationEnum : ENUM8 { @@ -6712,6 +6775,23 @@ endpoint 1 { ram attribute clusterRevision default = 1; } + server cluster RvcOperationalState { + emits event OperationalError; + emits event OperationCompletion; + callback attribute phaseList; + callback attribute currentPhase default = 0; + callback attribute countdownTime default = 0; + callback attribute operationalStateList default = 0; + callback attribute operationalState default = 0; + callback attribute operationalError default = 0; + callback attribute generatedCommandList default = 0; + callback attribute acceptedCommandList default = 0; + callback attribute eventList default = 0; + callback attribute attributeList default = 0; + ram attribute featureMap default = 0; + ram attribute clusterRevision default = 1; + } + server cluster HepaFilterMonitoring { ram attribute condition; ram attribute degradationDirection; diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index e78ffef66e0cc4..2cce834b1569bf 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -14498,7 +14498,7 @@ "code": 4, "mfgCode": null, "side": "server", - "type": "OperationalStateStruct", + "type": "OperationalStateEnum", "included": 1, "storageOption": "External", "singleton": 0, @@ -14639,6 +14639,310 @@ } ] }, + { + "name": "RVC Operational State", + "code": 97, + "mfgCode": null, + "define": "OPERATIONAL_STATE_RVC_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "Pause", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Stop", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Start", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, + { + "name": "Resume", + "code": 3, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], + "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ] + }, + { + "name": "RVC Operational State", + "code": 97, + "mfgCode": null, + "define": "OPERATIONAL_STATE_RVC_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [ + { + "name": "OperationalCommandResponse", + "code": 4, + "mfgCode": null, + "source": "server", + "incoming": 0, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "PhaseList", + "code": 0, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CurrentPhase", + "code": 1, + "mfgCode": null, + "side": "server", + "type": "int8u", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "CountdownTime", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "elapsed_s", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OperationalStateList", + "code": 3, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OperationalState", + "code": 4, + "mfgCode": null, + "side": "server", + "type": "enum8", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "OperationalError", + "code": 5, + "mfgCode": null, + "side": "server", + "type": "ErrorStateStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "type": "bitmap32", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "type": "int16u", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "1", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + } + ], + "events": [ + { + "name": "OperationalError", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + }, + { + "name": "OperationCompletion", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 + } + ] + }, { "name": "HEPA Filter Monitoring", "code": 113, diff --git a/zzz_generated/app-common/app-common/zap-generated/callback.h b/zzz_generated/app-common/app-common/zap-generated/callback.h index 64302ebb7c50e0..6c0a7df9379a2d 100644 --- a/zzz_generated/app-common/app-common/zap-generated/callback.h +++ b/zzz_generated/app-common/app-common/zap-generated/callback.h @@ -11855,30 +11855,6 @@ bool emberAfDishwasherAlarmClusterResetCallback( bool emberAfDishwasherAlarmClusterModifyEnabledAlarmsCallback( chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::DishwasherAlarm::Commands::ModifyEnabledAlarms::DecodableType & commandData); -/** - * @brief RVC Operational State Cluster Pause Command callback (from client) - */ -bool emberAfRvcOperationalStateClusterPauseCallback( - chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, - const chip::app::Clusters::RvcOperationalState::Commands::Pause::DecodableType & commandData); -/** - * @brief RVC Operational State Cluster Stop Command callback (from client) - */ -bool emberAfRvcOperationalStateClusterStopCallback( - chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, - const chip::app::Clusters::RvcOperationalState::Commands::Stop::DecodableType & commandData); -/** - * @brief RVC Operational State Cluster Start Command callback (from client) - */ -bool emberAfRvcOperationalStateClusterStartCallback( - chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, - const chip::app::Clusters::RvcOperationalState::Commands::Start::DecodableType & commandData); -/** - * @brief RVC Operational State Cluster Resume Command callback (from client) - */ -bool emberAfRvcOperationalStateClusterResumeCallback( - chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, - const chip::app::Clusters::RvcOperationalState::Commands::Resume::DecodableType & commandData); /** * @brief HEPA Filter Monitoring Cluster ResetCondition Command callback (from client) */ From ff12b560870c23e75f3949c4592d49a55af20c20 Mon Sep 17 00:00:00 2001 From: mideayanghui Date: Sat, 15 Jul 2023 18:12:39 +0800 Subject: [PATCH 19/20] Add RVC operational state server in all-cluster-app --- .../src/operational-state-delegates.cpp | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegates.cpp b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegates.cpp index 9d4a5cec4b111e..e056a7d4b3f62d 100644 --- a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegates.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegates.cpp @@ -82,6 +82,29 @@ static OperationalStateDelegate opStateDelegate(to_underlying(OperationalStateEn Span(opStateList), Span(opPhaseList)); +/** + * RVC Operational State List + * Note: User Define + */ +static const GenericOperationalState rvcOpStateList[] = { + GenericOperationalState(to_underlying(OperationalStateEnum::kStopped)), + GenericOperationalState(to_underlying(OperationalStateEnum::kRunning)), + GenericOperationalState(to_underlying(OperationalStateEnum::kPaused)), + GenericOperationalState(to_underlying(OperationalStateEnum::kError)), + GenericOperationalState(to_underlying(Clusters::RvcOperationalState::OperationalStateEnum::kSeekingCharger)), + GenericOperationalState(to_underlying(Clusters::RvcOperationalState::OperationalStateEnum::kCharging)), + GenericOperationalState(to_underlying(Clusters::RvcOperationalState::OperationalStateEnum::kDocked)), +}; + +/** + * RVC Operational State Delegate + * Note: User Define + */ +static OperationalStateDelegate rvcOpStateDelegate(to_underlying(OperationalStateEnum::kStopped), + GenericOperationalError(to_underlying(ErrorStateEnum::kNoError)), + Span(rvcOpStateList), + Span(opPhaseList)); + /** * Enquiry Table of Operational State Cluster and alias Cluter Delegate corresponding to endpointId and clusterId * Note: User Define @@ -89,6 +112,7 @@ static OperationalStateDelegate opStateDelegate(to_underlying(OperationalStateEn constexpr DelegatesEnquiryTable kDelegatesEnquiryTable[] = { // EndpointId, ClusterId, Delegate { Clusters::OperationalState::kDemoEndpointId, Clusters::OperationalState::Id, &opStateDelegate }, + { Clusters::OperationalState::kDemoEndpointId, Clusters::RvcOperationalState::Id, &rvcOpStateDelegate }, }; /** @@ -130,4 +154,13 @@ void MatterOperationalStateServerInit() static Clusters::OperationalState::OperationalStateServer operationalstateServer(Clusters::OperationalState::kDemoEndpointId, Clusters::OperationalState::Id); operationalstateServer.Init(); + operationalstateServer.OnOperationalErrorDetect(Clusters::OperationalState::GenericOperationalError(chip::to_underlying(Clusters::OperationalState::ErrorStateEnum::kUnableToStartOrResume))); + + operationalstateServer.OnOperationCompletionDetect(Clusters::OperationalState::GenericOperationCompletion(chip::to_underlying(Clusters::OperationalState::ErrorStateEnum::kNoError))); + + static Clusters::OperationalState::OperationalStateServer rvcOperationalstateServer(Clusters::OperationalState::kDemoEndpointId, + Clusters::RvcOperationalState::Id); + rvcOperationalstateServer.Init(); + rvcOperationalstateServer.OnOperationalErrorDetect(Clusters::OperationalState::GenericOperationalError(chip::to_underlying(Clusters::RvcOperationalState::ErrorStateEnum::kFailedToFindChargingDock))); + rvcOperationalstateServer.OnOperationCompletionDetect(Clusters::OperationalState::GenericOperationCompletion(chip::to_underlying(Clusters::OperationalState::ErrorStateEnum::kNoError))); } From 3e41b30a47c1f91e85bbcef4183172d883800d29 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Sat, 15 Jul 2023 10:17:17 +0000 Subject: [PATCH 20/20] Restyled by clang-format --- .../src/operational-state-delegates.cpp | 20 +++++++++++-------- .../operational-state-server.cpp | 11 +++++----- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegates.cpp b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegates.cpp index e056a7d4b3f62d..d5f09feefb8e14 100644 --- a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegates.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegates.cpp @@ -101,9 +101,9 @@ static const GenericOperationalState rvcOpStateList[] = { * Note: User Define */ static OperationalStateDelegate rvcOpStateDelegate(to_underlying(OperationalStateEnum::kStopped), - GenericOperationalError(to_underlying(ErrorStateEnum::kNoError)), - Span(rvcOpStateList), - Span(opPhaseList)); + GenericOperationalError(to_underlying(ErrorStateEnum::kNoError)), + Span(rvcOpStateList), + Span(opPhaseList)); /** * Enquiry Table of Operational State Cluster and alias Cluter Delegate corresponding to endpointId and clusterId @@ -154,13 +154,17 @@ void MatterOperationalStateServerInit() static Clusters::OperationalState::OperationalStateServer operationalstateServer(Clusters::OperationalState::kDemoEndpointId, Clusters::OperationalState::Id); operationalstateServer.Init(); - operationalstateServer.OnOperationalErrorDetect(Clusters::OperationalState::GenericOperationalError(chip::to_underlying(Clusters::OperationalState::ErrorStateEnum::kUnableToStartOrResume))); + operationalstateServer.OnOperationalErrorDetect(Clusters::OperationalState::GenericOperationalError( + chip::to_underlying(Clusters::OperationalState::ErrorStateEnum::kUnableToStartOrResume))); - operationalstateServer.OnOperationCompletionDetect(Clusters::OperationalState::GenericOperationCompletion(chip::to_underlying(Clusters::OperationalState::ErrorStateEnum::kNoError))); + operationalstateServer.OnOperationCompletionDetect(Clusters::OperationalState::GenericOperationCompletion( + chip::to_underlying(Clusters::OperationalState::ErrorStateEnum::kNoError))); static Clusters::OperationalState::OperationalStateServer rvcOperationalstateServer(Clusters::OperationalState::kDemoEndpointId, - Clusters::RvcOperationalState::Id); + Clusters::RvcOperationalState::Id); rvcOperationalstateServer.Init(); - rvcOperationalstateServer.OnOperationalErrorDetect(Clusters::OperationalState::GenericOperationalError(chip::to_underlying(Clusters::RvcOperationalState::ErrorStateEnum::kFailedToFindChargingDock))); - rvcOperationalstateServer.OnOperationCompletionDetect(Clusters::OperationalState::GenericOperationCompletion(chip::to_underlying(Clusters::OperationalState::ErrorStateEnum::kNoError))); + rvcOperationalstateServer.OnOperationalErrorDetect(Clusters::OperationalState::GenericOperationalError( + chip::to_underlying(Clusters::RvcOperationalState::ErrorStateEnum::kFailedToFindChargingDock))); + rvcOperationalstateServer.OnOperationCompletionDetect(Clusters::OperationalState::GenericOperationCompletion( + chip::to_underlying(Clusters::OperationalState::ErrorStateEnum::kNoError))); } diff --git a/src/app/clusters/operational-state-server/operational-state-server.cpp b/src/app/clusters/operational-state-server/operational-state-server.cpp index 9a1959c7b6f251..b3fd2d89523f00 100644 --- a/src/app/clusters/operational-state-server/operational-state-server.cpp +++ b/src/app/clusters/operational-state-server/operational-state-server.cpp @@ -301,11 +301,10 @@ CHIP_ERROR OperationalStateServer::Read(const ConcreteReadAttributePath & aPath, void OperationalStateServer::OnOperationalErrorDetect(const Structs::ErrorStateStruct::Type & aError) { ChipLogDetail(Zcl, "OperationalStateServer: OnOperationalErrorDetect"); - MatterReportingAttributeChangeCallback(mEndpointId, mClusterId, - OperationalState::Attributes::OperationalState::Id); + MatterReportingAttributeChangeCallback(mEndpointId, mClusterId, OperationalState::Attributes::OperationalState::Id); EventNumber eventNumber; - Events::OperationalError::Type event { aError }; + Events::OperationalError::Type event{ aError }; EventLogger eventData(event); ConcreteEventPath path(mEndpointId, mClusterId, event.GetEventId()); EventManagement & logMgmt = chip::app::EventManagement::GetInstance(); @@ -323,8 +322,7 @@ void OperationalStateServer::OnOperationalErrorDetect(const Structs::ErrorStateS void OperationalStateServer::OnOperationCompletionDetect(const Events::OperationCompletion::Type & aEvent) { ChipLogDetail(Zcl, "OperationalStateServer: OnOperationCompletionDetect"); - MatterReportingAttributeChangeCallback(mEndpointId, mClusterId, - OperationalState::Attributes::OperationalState::Id); + MatterReportingAttributeChangeCallback(mEndpointId, mClusterId, OperationalState::Attributes::OperationalState::Id); EventNumber eventNumber; EventLogger eventData(aEvent); @@ -337,6 +335,7 @@ void OperationalStateServer::OnOperationCompletionDetect(const Events::Operation CHIP_ERROR err = logMgmt.LogEvent(&eventData, eventOptions, eventNumber); if (err != CHIP_NO_ERROR) { - ChipLogError(Zcl, "OperationalStateServer: Failed to record OnOperationCompletionDetect event: %" CHIP_ERROR_FORMAT, err.Format()); + ChipLogError(Zcl, "OperationalStateServer: Failed to record OnOperationCompletionDetect event: %" CHIP_ERROR_FORMAT, + err.Format()); } }