From 6441b46ead4268ce2656dc4e27ea7782e11395aa Mon Sep 17 00:00:00 2001 From: mideayanghui <106149377+mideayanghui@users.noreply.github.com> Date: Mon, 17 Jul 2023 19:13:02 +0800 Subject: [PATCH] [OPSTATE] Fix: change in type for OperationalState attribute (#27958) * OperationalState attribute simply to Enum * temporary remove some test step in TestOperationalState * zap regen all * modify the code related of the OperationalState attribute type * update OperationalState type to Enum in TestOperationalState.yaml * Restyled by clang-format * modify the api of GetCurrentOperationalState in class Delegate * modify the api of SetOperationalState in class Delegate * optimize the Operational State cluster definition * zap regen all * Restyled by clang-format * modify the note for RVC Operational State cluster definition --------- Co-authored-by: Restyled.io --- .../all-clusters-app.matter | 2 +- .../include/operational-state-delegate-impl.h | 13 ++- .../src/operational-state-delegate-impl.cpp | 14 +-- .../src/operational-state-delegates.cpp | 2 +- .../operational-state-delegate.h | 7 +- .../operational-state-server.cpp | 29 +++---- .../tests/suites/TestOperationalState.yaml | 10 +-- .../chip/operational-state-cluster.xml | 2 +- .../chip/operational-state-rvc-cluster.xml | 8 +- .../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 | 17 ++-- .../zap-generated/cluster/Commands.h | 9 +- .../cluster/logging/DataModelLogger.cpp | 4 +- .../chip-tool/zap-generated/test/Commands.h | 20 ++--- 19 files changed, 147 insertions(+), 160 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..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 OperationalStateStruct 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/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..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 @@ -34,11 +34,10 @@ class OperationalStateDelegate : public Delegate public: /** - * Get current operational state. - * @param op The GenericOperationalState to fill with the current operational state value. - * @return void. + * Get the current operational state. + * @return The current operational state value */ - void GetCurrentOperationalState(GenericOperationalState & op) override; + uint8_t GetCurrentOperationalState() override; /** * Get the list of supported operational states. @@ -86,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 GenericOperationalState & opState) override; + CHIP_ERROR SetOperationalState(uint8_t opState) override; /** * Set operational phase. @@ -125,7 +124,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 +136,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..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 GenericOperationalState & opState) +CHIP_ERROR OperationalStateDelegate::SetOperationalState(uint8_t opState) { mOperationalState = opState; return CHIP_NO_ERROR; @@ -42,9 +42,9 @@ CHIP_ERROR OperationalStateDelegate::SetCountdownTime(const app::DataModel::Null return CHIP_NO_ERROR; } -void OperationalStateDelegate::GetCurrentOperationalState(GenericOperationalState & op) +uint8_t OperationalStateDelegate::GetCurrentOperationalState() { - op = mOperationalState; + return mOperationalState; } CHIP_ERROR OperationalStateDelegate::SetOperationalError(const GenericOperationalError & opErrState) @@ -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..6fd29bd7d48480 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 GenericOperationalState to fill with the current operational state value. - * @return void. + * @return The current operational state value */ - virtual void GetCurrentOperationalState(GenericOperationalState & op) = 0; + virtual uint8_t GetCurrentOperationalState() = 0; /** * Get the list of supported operational states. @@ -258,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 GenericOperationalState & opState) = 0; + virtual CHIP_ERROR SetOperationalState(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..ec54a41f2b7b60 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,11 @@ 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; VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure)); - delegate->GetCurrentOperationalState(opState); + uint8_t opState = delegate->GetCurrentOperationalState(); - if (opState.operationalStateID != to_underlying(OperationalStateEnum::kPaused)) + if (opState != to_underlying(OperationalStateEnum::kPaused)) { delegate->HandlePauseStateCallback(err); } @@ -126,18 +125,15 @@ 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; VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure)); + uint8_t opState = delegate->GetCurrentOperationalState(); - 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 +148,11 @@ 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; VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure)); + uint8_t opState = delegate->GetCurrentOperationalState(); - delegate->GetCurrentOperationalState(opState); - - if (opState.operationalStateID != to_underlying(OperationalStateEnum::kRunning)) + if (opState != to_underlying(OperationalStateEnum::kRunning)) { delegate->HandleStartStateCallback(err); } @@ -173,13 +167,11 @@ 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; VerifyOrReturn(delegate != nullptr, ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure)); + uint8_t opState = delegate->GetCurrentOperationalState(); - delegate->GetCurrentOperationalState(opState); - - if (opState.operationalStateID != to_underlying(OperationalStateEnum::kStopped)) + if (opState != to_underlying(OperationalStateEnum::kStopped)) { delegate->HandleStopStateCallback(err); } @@ -243,9 +235,8 @@ CHIP_ERROR OperationalStateServer::Read(const ConcreteReadAttributePath & aPath, case OperationalState::Attributes::OperationalState::Id: { Delegate * delegate = OperationalState::GetOperationalStateDelegate(mEndpointId, mClusterId); - GenericOperationalState 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; diff --git a/src/app/tests/suites/TestOperationalState.yaml b/src/app/tests/suites/TestOperationalState.yaml index 62ad14ddab3bbf..bd949b48905984 100644 --- a/src/app/tests/suites/TestOperationalState.yaml +++ b/src/app/tests/suites/TestOperationalState.yaml @@ -68,7 +68,7 @@ tests: command: "readAttribute" attribute: "OperationalState" response: - value: { OperationalStateID: 0 } + value: 0 - label: "Start Command" command: "Start" @@ -81,7 +81,7 @@ tests: command: "readAttribute" attribute: "OperationalState" response: - value: { OperationalStateID: 1 } + value: 1 - label: "Pause Command" command: "Pause" @@ -94,7 +94,7 @@ tests: command: "readAttribute" attribute: "OperationalState" response: - value: { OperationalStateID: 2 } + value: 2 - label: "Resume Command" command: "Resume" @@ -107,7 +107,7 @@ tests: command: "readAttribute" attribute: "OperationalState" response: - value: { OperationalStateID: 1 } + value: 1 - label: "Stop Command" command: "Stop" @@ -120,4 +120,4 @@ tests: command: "readAttribute" attribute: "OperationalState" response: - value: { OperationalStateID: 0 } + value: 0 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..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 94c10eb297a5d3..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 @@ -51,7 +51,13 @@ limitations under the License. CurrentPhase CountdownTime OperationalStateList - OperationalState + + + OperationalState OperationalError diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index c1316f2683d275..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 OperationalStateStruct operationalState = 4; + readonly attribute OperationalStateEnum 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..b3f8a26e4332be 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(), + static_cast(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..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=OperationalState.Structs.OperationalStateStruct), + 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: 'OperationalState.Structs.OperationalStateStruct' = 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=OperationalState.Structs.OperationalStateStruct) + return ClusterObjectFieldDescriptor(Type=OperationalState.Enums.OperationalStateEnum) - value: 'OperationalState.Structs.OperationalStateStruct' = field(default_factory=lambda: OperationalState.Structs.OperationalStateStruct()) + value: 'OperationalState.Enums.OperationalStateEnum' = 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..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 = 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 = 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; + 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 +17328,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 +17398,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..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", 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 +15683,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..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: { - chip::app::Clusters::OperationalState::Structs::OperationalStateStruct::DecodableType value; + chip::app::Clusters::OperationalState::OperationalStateEnum 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 1c16f25acd0fc8..7ec8b02994c977 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -89985,9 +89985,9 @@ class TestOperationalStateSuite : public TestCommand case 6: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { - chip::app::Clusters::OperationalState::Structs::OperationalStateStruct::DecodableType value; + chip::app::Clusters::OperationalState::OperationalStateEnum value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("operationalState.operationalStateID", value.operationalStateID, 0U)); + VerifyOrReturn(CheckValue("operationalState", value, 0U)); } break; case 7: @@ -90001,9 +90001,9 @@ class TestOperationalStateSuite : public TestCommand case 8: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { - chip::app::Clusters::OperationalState::Structs::OperationalStateStruct::DecodableType value; + chip::app::Clusters::OperationalState::OperationalStateEnum value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("operationalState.operationalStateID", value.operationalStateID, 1U)); + VerifyOrReturn(CheckValue("operationalState", value, 1U)); } break; case 9: @@ -90017,9 +90017,9 @@ class TestOperationalStateSuite : public TestCommand case 10: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { - chip::app::Clusters::OperationalState::Structs::OperationalStateStruct::DecodableType value; + chip::app::Clusters::OperationalState::OperationalStateEnum value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("operationalState.operationalStateID", value.operationalStateID, 2U)); + VerifyOrReturn(CheckValue("operationalState", value, 2U)); } break; case 11: @@ -90033,9 +90033,9 @@ class TestOperationalStateSuite : public TestCommand case 12: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { - chip::app::Clusters::OperationalState::Structs::OperationalStateStruct::DecodableType value; + chip::app::Clusters::OperationalState::OperationalStateEnum value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("operationalState.operationalStateID", value.operationalStateID, 1U)); + VerifyOrReturn(CheckValue("operationalState", value, 1U)); } break; case 13: @@ -90049,9 +90049,9 @@ class TestOperationalStateSuite : public TestCommand case 14: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); { - chip::app::Clusters::OperationalState::Structs::OperationalStateStruct::DecodableType value; + chip::app::Clusters::OperationalState::OperationalStateEnum value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); - VerifyOrReturn(CheckValue("operationalState.operationalStateID", value.operationalStateID, 0U)); + VerifyOrReturn(CheckValue("operationalState", value, 0U)); } break; default: