From 35049651182a11ba9fc0a2ab312c67f98104c713 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 4 Nov 2021 10:20:44 -0400 Subject: [PATCH] Add a TestCluster response command that just returns a boolean. (#11397) Use this instead of relying on status codes in various tests. Fixes https://github.com/project-chip/connectedhomeip/issues/10555 --- .../test-cluster-server.cpp | 46 ++++++---- .../tests/suites/TestClusterComplexTypes.yaml | 48 +++++++++-- .../zcl/data-model/chip/test-cluster.xml | 72 ++++++++-------- .../data_model/controller-clusters.zap | 10 ++- .../java/zap-generated/CHIPClusters-JNI.cpp | 83 +++++++++++++++++-- .../chip/devicecontroller/ChipClusters.java | 18 ++-- .../devicecontroller/ClusterInfoMapping.java | 44 ++++++++-- .../python/chip/clusters/Objects.py | 16 ++++ .../CHIP/zap-generated/CHIPCallbackBridge.mm | 7 ++ .../CHIPCallbackBridge_internal.h | 10 +++ .../CHIP/zap-generated/CHIPClustersObjc.mm | 25 +++--- .../app-common/zap-generated/callback.h | 4 + .../zap-generated/cluster-objects.cpp | 34 ++++++++ .../zap-generated/cluster-objects.h | 28 +++++++ .../app-common/zap-generated/command-id.h | 1 + .../app-common/zap-generated/ids/Commands.h | 4 + .../zap-generated/cluster/Commands.h | 17 +++- .../chip-tool/zap-generated/test/Commands.h | 66 ++++++++++----- .../zap-generated/CHIPClientCallbacks.cpp | 13 +++ .../zap-generated/CHIPClientCallbacks.h | 1 + .../zap-generated/CHIPClustersInvoke.cpp | 15 ++-- .../zap-generated/IMClusterCommandHandler.cpp | 58 +++++++++++++ 22 files changed, 494 insertions(+), 126 deletions(-) diff --git a/src/app/clusters/test-cluster-server/test-cluster-server.cpp b/src/app/clusters/test-cluster-server/test-cluster-server.cpp index d4bf81190281ba..689969833e948d 100644 --- a/src/app/clusters/test-cluster-server/test-cluster-server.cpp +++ b/src/app/clusters/test-cluster-server/test-cluster-server.cpp @@ -283,20 +283,30 @@ bool emberAfTestClusterClusterTestAddArgumentsCallback(CommandHandler * apComman return true; } +static bool SendBooleanResponse(CommandHandler * commandObj, const ConcreteCommandPath & commandPath, bool value) +{ + Commands::BooleanResponse::Type response; + response.value = value; + CHIP_ERROR err = commandObj->AddResponseData(commandPath, response); + if (err != CHIP_NO_ERROR) + { + commandObj->AddStatus(commandPath, Protocols::InteractionModel::Status::Failure); + } + return true; +} + bool emberAfTestClusterClusterTestStructArgumentRequestCallback( app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::TestStructArgumentRequest::DecodableType & commandData) { - emberAfSendImmediateDefaultResponse(commandData.arg1.b ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE); - return true; + return SendBooleanResponse(commandObj, commandPath, commandData.arg1.b); } bool emberAfTestClusterClusterTestNestedStructArgumentRequestCallback( app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, const Commands::TestNestedStructArgumentRequest::DecodableType & commandData) { - emberAfSendImmediateDefaultResponse(commandData.arg1.c.b ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE); - return true; + return SendBooleanResponse(commandObj, commandPath, commandData.arg1.c.b); } bool emberAfTestClusterClusterTestListStructArgumentRequestCallback( @@ -314,11 +324,11 @@ bool emberAfTestClusterClusterTestListStructArgumentRequestCallback( if (CHIP_NO_ERROR != structIterator.GetStatus()) { - shouldReturnTrue = false; + emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + return true; } - emberAfSendImmediateDefaultResponse(shouldReturnTrue ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE); - return true; + return SendBooleanResponse(commandObj, commandPath, shouldReturnTrue); } bool emberAfTestClusterClusterTestListInt8UArgumentRequestCallback( @@ -336,11 +346,11 @@ bool emberAfTestClusterClusterTestListInt8UArgumentRequestCallback( if (CHIP_NO_ERROR != uint8Iterator.GetStatus()) { - shouldReturnTrue = false; + emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + return true; } - emberAfSendImmediateDefaultResponse(shouldReturnTrue ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE); - return true; + return SendBooleanResponse(commandObj, commandPath, shouldReturnTrue); } bool emberAfTestClusterClusterTestNestedStructListArgumentRequestCallback( @@ -358,11 +368,11 @@ bool emberAfTestClusterClusterTestNestedStructListArgumentRequestCallback( if (CHIP_NO_ERROR != structIterator.GetStatus()) { - shouldReturnTrue = false; + emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + return true; } - emberAfSendImmediateDefaultResponse(shouldReturnTrue ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE); - return true; + return SendBooleanResponse(commandObj, commandPath, shouldReturnTrue); } bool emberAfTestClusterClusterTestListNestedStructListArgumentRequestCallback( @@ -386,18 +396,18 @@ bool emberAfTestClusterClusterTestListNestedStructListArgumentRequestCallback( if (CHIP_NO_ERROR != subStructIterator.GetStatus()) { - shouldReturnTrue = false; - break; + emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + return true; } } if (CHIP_NO_ERROR != structIterator.GetStatus()) { - shouldReturnTrue = false; + emberAfSendImmediateDefaultResponse(EMBER_ZCL_STATUS_FAILURE); + return true; } - emberAfSendImmediateDefaultResponse(shouldReturnTrue ? EMBER_ZCL_STATUS_SUCCESS : EMBER_ZCL_STATUS_FAILURE); - return true; + return SendBooleanResponse(commandObj, commandPath, shouldReturnTrue); } bool emberAfTestClusterClusterTestListInt8UReverseRequestCallback( diff --git a/src/app/tests/suites/TestClusterComplexTypes.yaml b/src/app/tests/suites/TestClusterComplexTypes.yaml index 3eb1f6d4d81c9b..e8676697c43a84 100644 --- a/src/app/tests/suites/TestClusterComplexTypes.yaml +++ b/src/app/tests/suites/TestClusterComplexTypes.yaml @@ -35,6 +35,10 @@ tests: e: "char_string", f: 1, } + response: + values: + - name: "value" + value: true - label: "Send Test Command With Struct Argument and arg1.b is false" command: "testStructArgumentRequest" @@ -51,7 +55,9 @@ tests: f: 1, } response: - error: 1 + values: + - name: "value" + value: false - label: "Send Test Command With Nested Struct Argument and arg1.c.b is true" @@ -74,6 +80,10 @@ tests: f: 1, }, } + response: + values: + - name: "value" + value: true - label: "Send Test Command With Nested Struct Argument arg1.c.b is false" disabled: true @@ -96,7 +106,9 @@ tests: }, } response: - error: 1 + values: + - name: "value" + value: false - label: "Send Test Command With Nested Struct List Argument and all fields b @@ -147,6 +159,10 @@ tests: ], g: [0, 255], } + response: + values: + - name: "value" + value: false - label: "Send Test Command With Nested Struct List Argument and some fields b @@ -198,7 +214,9 @@ tests: g: [0, 255], } response: - error: 1 + values: + - name: "value" + value: false # Tests for List @@ -208,6 +226,10 @@ tests: values: - name: "arg1" value: [1, 2, 3, 4, 5, 6, 7, 8, 9] + response: + values: + - name: "value" + value: true - label: "Send Test Command With List of INT8U and one of them is set to 0" command: "testListInt8UArgumentRequest" @@ -216,7 +238,9 @@ tests: - name: "arg1" value: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0] response: - error: 1 + values: + - name: "value" + value: false - label: "Send Test Command With List of INT8U and get it reversed" command: "testListInt8UReverseRequest" @@ -255,6 +279,10 @@ tests: f: 1, }, ] + response: + values: + - name: "value" + value: true - label: "Send Test Command With List of Struct Argument and arg1.b of first @@ -283,7 +311,9 @@ tests: }, ] response: - error: 1 + values: + - name: "value" + value: false - label: "Send Test Command With List of Nested Struct List Argument and all @@ -336,6 +366,10 @@ tests: g: [0, 255], }, ] + response: + values: + - name: "value" + value: true - label: "Send Test Command With Nested Struct List Argument and some fields b @@ -389,7 +423,9 @@ tests: }, ] response: - error: 1 + values: + - name: "value" + value: false # Tests for Nullables and Optionals diff --git a/src/app/zap-templates/zcl/data-model/chip/test-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/test-cluster.xml index cf2ef210144b20..f9967fd5f1c3da 100644 --- a/src/app/zap-templates/zcl/data-model/chip/test-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/test-cluster.xml @@ -196,72 +196,58 @@ limitations under the License. - - + - Command that takes an argument which is struct + Command that takes an argument which is struct. The response echoes the + 'b' field of the single arg. - - + - Command that takes an argument which is nested struct + Command that takes an argument which is nested struct. The response + echoes the 'b' field of ar1.c. - - + - Command that takes an argument which is a list of struct + Command that takes an argument which is a list of structs. The response + returns false if there is some struct in the list whose 'b' field is + false, and true otherwise (including if the list is empty). - - + - Command that takes an argument which is a list of INT8U + Command that takes an argument which is a list of INT8U. The response + returns false if the list contains a 0 in it, true otherwise (including + if the list is empty). - - + - Command that takes an argument which is a Nested Struct List + Command that takes an argument which is a Nested Struct List. The + response returns false if there is some struct in arg1 (either directly + in arg1.c or in the arg1.d list) whose 'b' field is false, and true + otherwise. - - Command that takes an argument which is a list of Nested Struct List + Command that takes an argument which is a list of Nested Struct List. + The response returns false if there is some struct in arg1 (either + directly in as the 'c' field of an entry 'd' list of an entry) whose 'b' + field is false, and true otherwise (including if the list is empty). @@ -415,6 +401,14 @@ limitations under the License. optional="true"/> + + + Delivers a single boolean argument. What the argument means depends on + what we're responding to. + + + + Example test event diff --git a/src/controller/data_model/controller-clusters.zap b/src/controller/data_model/controller-clusters.zap index 8638b679fbbcdc..735732b7f995e9 100644 --- a/src/controller/data_model/controller-clusters.zap +++ b/src/controller/data_model/controller-clusters.zap @@ -1961,7 +1961,7 @@ "outgoing": 0 }, { - "name": "ApplyUpdateRequestResponse", + "name": "ApplyUpdateResponse", "code": 4, "mfgCode": null, "source": "server", @@ -11464,6 +11464,14 @@ "source": "server", "incoming": 1, "outgoing": 0 + }, + { + "name": "BooleanResponse", + "code": 8, + "mfgCode": null, + "source": "server", + "incoming": 1, + "outgoing": 0 } ], "attributes": [ diff --git a/src/controller/java/zap-generated/CHIPClusters-JNI.cpp b/src/controller/java/zap-generated/CHIPClusters-JNI.cpp index e33de57abe8ea1..b81db6da78a7c4 100644 --- a/src/controller/java/zap-generated/CHIPClusters-JNI.cpp +++ b/src/controller/java/zap-generated/CHIPClusters-JNI.cpp @@ -5005,6 +5005,74 @@ class CHIPTargetNavigatorClusterNavigateTargetResponseCallback jobject javaCallbackRef; }; +class CHIPTestClusterClusterBooleanResponseCallback : public Callback::Callback +{ +public: + CHIPTestClusterClusterBooleanResponseCallback(jobject javaCallback) : + Callback::Callback(CallbackFn, this) + { + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } + } + ~CHIPTestClusterClusterBooleanResponseCallback() + { + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); + }; + + static void CallbackFn(void * context, bool value) + { + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + jmethodID javaMethod; + CHIPTestClusterClusterBooleanResponseCallback * cppCallback = nullptr; + + VerifyOrExit(env != nullptr, err = CHIP_JNI_ERROR_NO_ENV); + + cppCallback = reinterpret_cast(context); + VerifyOrExit(cppCallback != nullptr, err = CHIP_JNI_ERROR_NULL_OBJECT); + + javaCallbackRef = cppCallback->javaCallbackRef; + VerifyOrExit(javaCallbackRef != nullptr, err = CHIP_NO_ERROR); + + err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Z)V", &javaMethod); + SuccessOrExit(err); + + env->CallVoidMethod(javaCallbackRef, javaMethod, static_cast(value)); + + exit: + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Error invoking Java callback: %" CHIP_ERROR_FORMAT, err.Format()); + } + if (cppCallback != nullptr) + { + cppCallback->Cancel(); + delete cppCallback; + } + } + +private: + jobject javaCallbackRef; +}; + class CHIPTestClusterClusterTestAddArgumentsResponseCallback : public Callback::Callback { @@ -15743,8 +15811,9 @@ JNI_METHOD(void, TestClusterCluster, testListInt8UArgumentRequest) CHIP_ERROR err = CHIP_NO_ERROR; TestClusterCluster * cppCluster; - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrExit(onSuccess.get() != nullptr, err = CHIP_ERROR_INCORRECT_STATE); @@ -15844,8 +15913,9 @@ JNI_METHOD(void, TestClusterCluster, testListStructArgumentRequest) JniByteArray dArr(env, d); JniUtfString eStr(env, e); - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrExit(onSuccess.get() != nullptr, err = CHIP_ERROR_INCORRECT_STATE); @@ -16043,8 +16113,9 @@ JNI_METHOD(void, TestClusterCluster, testStructArgumentRequest) JniByteArray dArr(env, d); JniUtfString eStr(env, e); - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback), + Platform::Delete); std::unique_ptr onFailure( Platform::New(callback), Platform::Delete); VerifyOrExit(onSuccess.get() != nullptr, err = CHIP_ERROR_INCORRECT_STATE); diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java index 6d5f0b7501c9ea..6f5df3b2596994 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java @@ -6056,7 +6056,7 @@ public void testEnumsRequest(TestEnumsResponseCallback callback, int arg1, int a testEnumsRequest(chipClusterPtr, callback, arg1, arg2); } - public void testListInt8UArgumentRequest(DefaultClusterCallback callback, int arg1) { + public void testListInt8UArgumentRequest(BooleanResponseCallback callback, int arg1) { testListInt8UArgumentRequest(chipClusterPtr, callback, arg1); } @@ -6066,7 +6066,7 @@ public void testListInt8UReverseRequest( } public void testListStructArgumentRequest( - DefaultClusterCallback callback, int a, boolean b, int c, byte[] d, String e, int f) { + BooleanResponseCallback callback, int a, boolean b, int c, byte[] d, String e, int f) { testListStructArgumentRequest(chipClusterPtr, callback, a, b, c, d, e, f); } @@ -6084,7 +6084,7 @@ public void testSpecific(TestSpecificResponseCallback callback) { } public void testStructArgumentRequest( - DefaultClusterCallback callback, int a, boolean b, int c, byte[] d, String e, int f) { + BooleanResponseCallback callback, int a, boolean b, int c, byte[] d, String e, int f) { testStructArgumentRequest(chipClusterPtr, callback, a, b, c, d, e, f); } @@ -6101,14 +6101,14 @@ private native void testEnumsRequest( long chipClusterPtr, TestEnumsResponseCallback callback, int arg1, int arg2); private native void testListInt8UArgumentRequest( - long chipClusterPtr, DefaultClusterCallback callback, int arg1); + long chipClusterPtr, BooleanResponseCallback callback, int arg1); private native void testListInt8UReverseRequest( long chipClusterPtr, TestListInt8UReverseResponseCallback callback, int arg1); private native void testListStructArgumentRequest( long chipClusterPtr, - DefaultClusterCallback callback, + BooleanResponseCallback callback, int a, boolean b, int c, @@ -6125,7 +6125,7 @@ private native void testNullableOptionalRequest( private native void testStructArgumentRequest( long chipClusterPtr, - DefaultClusterCallback callback, + BooleanResponseCallback callback, int a, boolean b, int c, @@ -6135,6 +6135,12 @@ private native void testStructArgumentRequest( private native void testUnknownCommand(long chipClusterPtr, DefaultClusterCallback callback); + public interface BooleanResponseCallback { + void onSuccess(boolean value); + + void onError(Exception error); + } + public interface TestAddArgumentsResponseCallback { void onSuccess(int returnValue); diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java b/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java index 7ff6abb55939eb..2ad04c000c40e8 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java @@ -1785,6 +1785,28 @@ public void onError(Exception error) { } } + public class DelegatedBooleanResponseCallback + implements ChipClusters.TestClusterCluster.BooleanResponseCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(boolean value) { + List responseValues = new ArrayList<>(); + responseValues.add(value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception error) { + callback.onFailure(error); + } + } + public class DelegatedTestAddArgumentsResponseCallback implements ChipClusters.TestClusterCluster.TestAddArgumentsResponseCallback, DelegatedClusterCallback { @@ -6738,7 +6760,8 @@ public Map getClusterMap() { Map testClustertestListInt8UArgumentRequestCommandParams = new LinkedHashMap(); CommandParameterInfo testClustertestListInt8UArgumentRequestCommandParameterInfo = - new CommandParameterInfo("TestCluster", ChipClusters.DefaultClusterCallback.class); + new CommandParameterInfo( + "TestCluster", ChipClusters.TestClusterCluster.BooleanResponseCallback.class); CommandParameterInfo testClustertestListInt8UArgumentRequestarg1CommandParameterInfo = new CommandParameterInfo("arg1", int.class); testClustertestListInt8UArgumentRequestCommandParams.put( @@ -6750,9 +6773,10 @@ public Map getClusterMap() { (cluster, callback, commandArguments) -> { ((ChipClusters.TestClusterCluster) cluster) .testListInt8UArgumentRequest( - (DefaultClusterCallback) callback, (Integer) commandArguments.get("arg1")); + (ChipClusters.TestClusterCluster.BooleanResponseCallback) callback, + (Integer) commandArguments.get("arg1")); }, - () -> new DelegatedDefaultClusterCallback(), + () -> new DelegatedBooleanResponseCallback(), testClustertestListInt8UArgumentRequestCommandParams); testClusterClusterCommandInfoMap.put( "testListInt8UArgumentRequest", testClustertestListInt8UArgumentRequestCommandInfo); @@ -6784,7 +6808,8 @@ public Map getClusterMap() { Map testClustertestListStructArgumentRequestCommandParams = new LinkedHashMap(); CommandParameterInfo testClustertestListStructArgumentRequestCommandParameterInfo = - new CommandParameterInfo("TestCluster", ChipClusters.DefaultClusterCallback.class); + new CommandParameterInfo( + "TestCluster", ChipClusters.TestClusterCluster.BooleanResponseCallback.class); CommandParameterInfo testClustertestListStructArgumentRequestaCommandParameterInfo = new CommandParameterInfo("a", int.class); testClustertestListStructArgumentRequestCommandParams.put( @@ -6821,7 +6846,7 @@ public Map getClusterMap() { (cluster, callback, commandArguments) -> { ((ChipClusters.TestClusterCluster) cluster) .testListStructArgumentRequest( - (DefaultClusterCallback) callback, + (ChipClusters.TestClusterCluster.BooleanResponseCallback) callback, (Integer) commandArguments.get("a"), (Boolean) commandArguments.get("b"), (Integer) commandArguments.get("c"), @@ -6829,7 +6854,7 @@ public Map getClusterMap() { (String) commandArguments.get("e"), (Integer) commandArguments.get("f")); }, - () -> new DelegatedDefaultClusterCallback(), + () -> new DelegatedBooleanResponseCallback(), testClustertestListStructArgumentRequestCommandParams); testClusterClusterCommandInfoMap.put( "testListStructArgumentRequest", testClustertestListStructArgumentRequestCommandInfo); @@ -6891,7 +6916,8 @@ public Map getClusterMap() { Map testClustertestStructArgumentRequestCommandParams = new LinkedHashMap(); CommandParameterInfo testClustertestStructArgumentRequestCommandParameterInfo = - new CommandParameterInfo("TestCluster", ChipClusters.DefaultClusterCallback.class); + new CommandParameterInfo( + "TestCluster", ChipClusters.TestClusterCluster.BooleanResponseCallback.class); CommandParameterInfo testClustertestStructArgumentRequestaCommandParameterInfo = new CommandParameterInfo("a", int.class); testClustertestStructArgumentRequestCommandParams.put( @@ -6928,7 +6954,7 @@ public Map getClusterMap() { (cluster, callback, commandArguments) -> { ((ChipClusters.TestClusterCluster) cluster) .testStructArgumentRequest( - (DefaultClusterCallback) callback, + (ChipClusters.TestClusterCluster.BooleanResponseCallback) callback, (Integer) commandArguments.get("a"), (Boolean) commandArguments.get("b"), (Integer) commandArguments.get("c"), @@ -6936,7 +6962,7 @@ public Map getClusterMap() { (String) commandArguments.get("e"), (Integer) commandArguments.get("f")); }, - () -> new DelegatedDefaultClusterCallback(), + () -> new DelegatedBooleanResponseCallback(), testClustertestStructArgumentRequestCommandParams); testClusterClusterCommandInfoMap.put( "testStructArgumentRequest", testClustertestStructArgumentRequestCommandInfo); diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 92851987639f81..c123dc32c29de7 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -21154,6 +21154,22 @@ def descriptor(cls) -> ClusterObjectDescriptor: arg1: 'TestCluster.Structs.NestedStruct' = None + @dataclass + class BooleanResponse(ClusterCommand): + cluster_id: typing.ClassVar[int] = 0x050F + command_id: typing.ClassVar[int] = 0x0008 + is_client: typing.ClassVar[bool] = False + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor( + Label="value", Tag=0, Type=bool), + ]) + + value: 'bool' = None + @dataclass class TestListStructArgumentRequest(ClusterCommand): cluster_id: typing.ClassVar[int] = 0x050F diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm index 43a87d5bae69d6..1aaae1a46030c8 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm @@ -1380,6 +1380,13 @@ }); }; +void CHIPTestClusterClusterBooleanResponseCallbackBridge::OnSuccessFn(void * context, bool value) +{ + DispatchSuccess(context, @ { + @"value" : [NSNumber numberWithBool:value], + }); +}; + void CHIPTestClusterClusterTestAddArgumentsResponseCallbackBridge::OnSuccessFn(void * context, uint8_t returnValue) { DispatchSuccess(context, @ { diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge_internal.h b/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge_internal.h index eb0577cd430ed5..5c72e998e9a791 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge_internal.h +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge_internal.h @@ -1321,6 +1321,16 @@ class CHIPTargetNavigatorClusterNavigateTargetResponseCallbackBridge static void OnSuccessFn(void * context, uint8_t status, chip::CharSpan data); }; +class CHIPTestClusterClusterBooleanResponseCallbackBridge : public CHIPCallbackBridge +{ +public: + CHIPTestClusterClusterBooleanResponseCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, CHIPActionBlock action, + bool keepAlive = false) : + CHIPCallbackBridge(queue, handler, action, OnSuccessFn, keepAlive){}; + + static void OnSuccessFn(void * context, bool value); +}; + class CHIPTestClusterClusterTestAddArgumentsResponseCallbackBridge : public CHIPCallbackBridge { diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm index 6630ad24e7763d..fb5505c154eda4 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm @@ -4785,9 +4785,10 @@ new CHIPTestClusterClusterTestEnumsResponseCallbackBridge( - (void)testListInt8UArgumentRequest:(uint8_t)arg1 responseHandler:(ResponseHandler)responseHandler { - new CHIPDefaultSuccessCallbackBridge(self.callbackQueue, responseHandler, ^(Cancelable * success, Cancelable * failure) { - return self.cppCluster.TestListInt8UArgumentRequest(success, failure, arg1); - }); + new CHIPTestClusterClusterBooleanResponseCallbackBridge( + self.callbackQueue, responseHandler, ^(Cancelable * success, Cancelable * failure) { + return self.cppCluster.TestListInt8UArgumentRequest(success, failure, arg1); + }); } - (void)testListInt8UReverseRequest:(uint8_t)arg1 responseHandler:(ResponseHandler)responseHandler @@ -4806,10 +4807,11 @@ - (void)testListStructArgumentRequest:(uint8_t)a f:(uint8_t)f responseHandler:(ResponseHandler)responseHandler { - new CHIPDefaultSuccessCallbackBridge(self.callbackQueue, responseHandler, ^(Cancelable * success, Cancelable * failure) { - return self.cppCluster.TestListStructArgumentRequest( - success, failure, a, b, static_cast(c), [self asByteSpan:d], [self asCharSpan:e], f); - }); + new CHIPTestClusterClusterBooleanResponseCallbackBridge( + self.callbackQueue, responseHandler, ^(Cancelable * success, Cancelable * failure) { + return self.cppCluster.TestListStructArgumentRequest( + success, failure, a, b, static_cast(c), [self asByteSpan:d], [self asCharSpan:e], f); + }); } - (void)testNotHandled:(ResponseHandler)responseHandler @@ -4843,10 +4845,11 @@ - (void)testStructArgumentRequest:(uint8_t)a f:(uint8_t)f responseHandler:(ResponseHandler)responseHandler { - new CHIPDefaultSuccessCallbackBridge(self.callbackQueue, responseHandler, ^(Cancelable * success, Cancelable * failure) { - return self.cppCluster.TestStructArgumentRequest( - success, failure, a, b, static_cast(c), [self asByteSpan:d], [self asCharSpan:e], f); - }); + new CHIPTestClusterClusterBooleanResponseCallbackBridge( + self.callbackQueue, responseHandler, ^(Cancelable * success, Cancelable * failure) { + return self.cppCluster.TestStructArgumentRequest( + success, failure, a, b, static_cast(c), [self asByteSpan:d], [self asCharSpan:e], f); + }); } - (void)testUnknownCommand:(ResponseHandler)responseHandler 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 46522b004b02f2..af73d161c0662a 100644 --- a/zzz_generated/app-common/app-common/zap-generated/callback.h +++ b/zzz_generated/app-common/app-common/zap-generated/callback.h @@ -14236,6 +14236,10 @@ bool emberAfTestClusterClusterTestComplexNullableOptionalResponseCallback( bool emberAfTestClusterClusterTestNestedStructArgumentRequestCallback( chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::TestCluster::Commands::TestNestedStructArgumentRequest::DecodableType & commandData); +/** + * @brief Test Cluster Cluster BooleanResponse Command callback (from server) + */ +bool emberAfTestClusterClusterBooleanResponseCallback(chip::EndpointId endpoint, chip::app::CommandSender * commandObj, bool value); /** * @brief Test Cluster Cluster TestListStructArgumentRequest Command callback (from client) */ diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp index 46f38bc92b2054..df34fcb629de25 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp @@ -16828,6 +16828,40 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) return CHIP_NO_ERROR; } } // namespace TestNestedStructArgumentRequest. +namespace BooleanResponse { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kValue)), value)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + ReturnErrorOnFailure(reader.EnterContainer(outer)); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kValue): + ReturnErrorOnFailure(DataModel::Decode(reader, value)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} +} // namespace BooleanResponse. namespace TestListStructArgumentRequest { CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const { 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 b8524f6d05da37..1efc11ba1fa800 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 @@ -23935,6 +23935,34 @@ struct DecodableType CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace TestNestedStructArgumentRequest +namespace BooleanResponse { +enum class Fields +{ + kValue = 0, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return Commands::BooleanResponse::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TestCluster::Id; } + + bool value; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return Commands::BooleanResponse::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::TestCluster::Id; } + + bool value; + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace BooleanResponse namespace TestListStructArgumentRequest { enum class Fields { diff --git a/zzz_generated/app-common/app-common/zap-generated/command-id.h b/zzz_generated/app-common/app-common/zap-generated/command-id.h index 8b9697b6ba324c..c1967eb7d95af4 100644 --- a/zzz_generated/app-common/app-common/zap-generated/command-id.h +++ b/zzz_generated/app-common/app-common/zap-generated/command-id.h @@ -463,6 +463,7 @@ #define ZCL_TEST_STRUCT_ARGUMENT_REQUEST_COMMAND_ID (0x07) #define ZCL_TEST_COMPLEX_NULLABLE_OPTIONAL_RESPONSE_COMMAND_ID (0x07) #define ZCL_TEST_NESTED_STRUCT_ARGUMENT_REQUEST_COMMAND_ID (0x08) +#define ZCL_BOOLEAN_RESPONSE_COMMAND_ID (0x08) #define ZCL_TEST_LIST_STRUCT_ARGUMENT_REQUEST_COMMAND_ID (0x09) #define ZCL_TEST_LIST_INT8_U_ARGUMENT_REQUEST_COMMAND_ID (0x0A) #define ZCL_TEST_NESTED_STRUCT_LIST_ARGUMENT_REQUEST_COMMAND_ID (0x0B) diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h b/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h index 182884edcdadee..51911eeac8d201 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h @@ -1664,6 +1664,10 @@ namespace TestNestedStructArgumentRequest { static constexpr CommandId Id = 0x00000008; } // namespace TestNestedStructArgumentRequest +namespace BooleanResponse { +static constexpr CommandId Id = 0x00000008; +} // namespace BooleanResponse + namespace TestListStructArgumentRequest { static constexpr CommandId Id = 0x00000009; } // namespace TestListStructArgumentRequest diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index baca930ef5aa3a..023e98f8a39e9e 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -2046,6 +2046,17 @@ static void OnTargetNavigatorNavigateTargetResponseSuccess( command->SetCommandExitStatus(CHIP_NO_ERROR); }; +static void +OnTestClusterBooleanResponseSuccess(void * context, + const chip::app::Clusters::TestCluster::Commands::BooleanResponse::DecodableType & data) +{ + ChipLogProgress(Zcl, "Received BooleanResponse:"); + ChipLogProgress(Zcl, " value: %d", data.value); + + ModelCommand * command = static_cast(context); + command->SetCommandExitStatus(CHIP_NO_ERROR); +}; + static void OnTestClusterTestAddArgumentsResponseSuccess( void * context, const chip::app::Clusters::TestCluster::Commands::TestAddArgumentsResponse::DecodableType & data) { @@ -19957,7 +19968,7 @@ class TestClusterTestListInt8UArgumentRequest : public ModelCommand chip::Controller::TestClusterCluster cluster; cluster.Associate(device, endpointId); - return cluster.InvokeCommand(mRequest, this, OnDefaultSuccess, OnDefaultFailure); + return cluster.InvokeCommand(mRequest, this, OnTestClusterBooleanResponseSuccess, OnDefaultFailure); } private: @@ -20007,7 +20018,7 @@ class TestClusterTestListStructArgumentRequest : public ModelCommand chip::Controller::TestClusterCluster cluster; cluster.Associate(device, endpointId); - return cluster.InvokeCommand(mRequest, this, OnDefaultSuccess, OnDefaultFailure); + return cluster.InvokeCommand(mRequest, this, OnTestClusterBooleanResponseSuccess, OnDefaultFailure); } private: @@ -20099,7 +20110,7 @@ class TestClusterTestStructArgumentRequest : public ModelCommand chip::Controller::TestClusterCluster cluster; cluster.Associate(device, endpointId); - return cluster.InvokeCommand(mRequest, this, OnDefaultSuccess, OnDefaultFailure); + return cluster.InvokeCommand(mRequest, this, OnTestClusterBooleanResponseSuccess, OnDefaultFailure); } private: diff --git a/zzz_generated/chip-tool/zap-generated/test/Commands.h b/zzz_generated/chip-tool/zap-generated/test/Commands.h index 9ddd24e1aa1078..31034f00937aa1 100644 --- a/zzz_generated/chip-tool/zap-generated/test/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/test/Commands.h @@ -26222,7 +26222,7 @@ class TestClusterComplexTypes : public TestCommand cluster.Associate(mDevice, 1); using requestType = chip::app::Clusters::TestCluster::Commands::TestStructArgumentRequest::Type; - using responseType = chip::app::DataModel::NullObjectType; + using responseType = chip::app::Clusters::TestCluster::Commands::BooleanResponse::DecodableType; chip::app::Clusters::TestCluster::Commands::TestStructArgumentRequest::Type request; @@ -26234,7 +26234,7 @@ class TestClusterComplexTypes : public TestCommand request.arg1.f = static_cast>(1); auto success = [](void * context, const responseType & data) { - (static_cast(context))->OnSuccessResponse_0(); + (static_cast(context))->OnSuccessResponse_0(data.value); }; auto failure = [](void * context, EmberAfStatus status) { @@ -26245,7 +26245,11 @@ class TestClusterComplexTypes : public TestCommand void OnFailureResponse_0(uint8_t status) { ThrowFailureResponse(); } - void OnSuccessResponse_0() { NextTest(); } + void OnSuccessResponse_0(bool value) + { + VerifyOrReturn(CheckValue("value", value, true)); + NextTest(); + } CHIP_ERROR TestSendTestCommandWithStructArgumentAndArg1bIsFalse_1() { @@ -26253,7 +26257,7 @@ class TestClusterComplexTypes : public TestCommand cluster.Associate(mDevice, 1); using requestType = chip::app::Clusters::TestCluster::Commands::TestStructArgumentRequest::Type; - using responseType = chip::app::DataModel::NullObjectType; + using responseType = chip::app::Clusters::TestCluster::Commands::BooleanResponse::DecodableType; chip::app::Clusters::TestCluster::Commands::TestStructArgumentRequest::Type request; @@ -26265,7 +26269,7 @@ class TestClusterComplexTypes : public TestCommand request.arg1.f = static_cast>(1); auto success = [](void * context, const responseType & data) { - (static_cast(context))->OnSuccessResponse_1(); + (static_cast(context))->OnSuccessResponse_1(data.value); }; auto failure = [](void * context, EmberAfStatus status) { @@ -26274,9 +26278,13 @@ class TestClusterComplexTypes : public TestCommand return cluster.InvokeCommand(request, this, success, failure); } - void OnFailureResponse_1(uint8_t status) { NextTest(); } + void OnFailureResponse_1(uint8_t status) { ThrowFailureResponse(); } - void OnSuccessResponse_1() { ThrowSuccessResponse(); } + void OnSuccessResponse_1(bool value) + { + VerifyOrReturn(CheckValue("value", value, false)); + NextTest(); + } CHIP_ERROR TestSendTestCommandWithListOfInt8uAndNoneOfThemIsSetTo0_2() { @@ -26284,7 +26292,7 @@ class TestClusterComplexTypes : public TestCommand cluster.Associate(mDevice, 1); using requestType = chip::app::Clusters::TestCluster::Commands::TestListInt8UArgumentRequest::Type; - using responseType = chip::app::DataModel::NullObjectType; + using responseType = chip::app::Clusters::TestCluster::Commands::BooleanResponse::DecodableType; chip::app::Clusters::TestCluster::Commands::TestListInt8UArgumentRequest::Type request; @@ -26301,7 +26309,7 @@ class TestClusterComplexTypes : public TestCommand request.arg1 = arg1List; auto success = [](void * context, const responseType & data) { - (static_cast(context))->OnSuccessResponse_2(); + (static_cast(context))->OnSuccessResponse_2(data.value); }; auto failure = [](void * context, EmberAfStatus status) { @@ -26312,7 +26320,11 @@ class TestClusterComplexTypes : public TestCommand void OnFailureResponse_2(uint8_t status) { ThrowFailureResponse(); } - void OnSuccessResponse_2() { NextTest(); } + void OnSuccessResponse_2(bool value) + { + VerifyOrReturn(CheckValue("value", value, true)); + NextTest(); + } CHIP_ERROR TestSendTestCommandWithListOfInt8uAndOneOfThemIsSetTo0_3() { @@ -26320,7 +26332,7 @@ class TestClusterComplexTypes : public TestCommand cluster.Associate(mDevice, 1); using requestType = chip::app::Clusters::TestCluster::Commands::TestListInt8UArgumentRequest::Type; - using responseType = chip::app::DataModel::NullObjectType; + using responseType = chip::app::Clusters::TestCluster::Commands::BooleanResponse::DecodableType; chip::app::Clusters::TestCluster::Commands::TestListInt8UArgumentRequest::Type request; @@ -26338,7 +26350,7 @@ class TestClusterComplexTypes : public TestCommand request.arg1 = arg1List; auto success = [](void * context, const responseType & data) { - (static_cast(context))->OnSuccessResponse_3(); + (static_cast(context))->OnSuccessResponse_3(data.value); }; auto failure = [](void * context, EmberAfStatus status) { @@ -26347,9 +26359,13 @@ class TestClusterComplexTypes : public TestCommand return cluster.InvokeCommand(request, this, success, failure); } - void OnFailureResponse_3(uint8_t status) { NextTest(); } + void OnFailureResponse_3(uint8_t status) { ThrowFailureResponse(); } - void OnSuccessResponse_3() { ThrowSuccessResponse(); } + void OnSuccessResponse_3(bool value) + { + VerifyOrReturn(CheckValue("value", value, false)); + NextTest(); + } CHIP_ERROR TestSendTestCommandWithListOfInt8uAndGetItReversed_4() { @@ -26397,7 +26413,7 @@ class TestClusterComplexTypes : public TestCommand cluster.Associate(mDevice, 1); using requestType = chip::app::Clusters::TestCluster::Commands::TestListStructArgumentRequest::Type; - using responseType = chip::app::DataModel::NullObjectType; + using responseType = chip::app::Clusters::TestCluster::Commands::BooleanResponse::DecodableType; chip::app::Clusters::TestCluster::Commands::TestListStructArgumentRequest::Type request; @@ -26420,7 +26436,7 @@ class TestClusterComplexTypes : public TestCommand request.arg1 = arg1List; auto success = [](void * context, const responseType & data) { - (static_cast(context))->OnSuccessResponse_5(); + (static_cast(context))->OnSuccessResponse_5(data.value); }; auto failure = [](void * context, EmberAfStatus status) { @@ -26431,7 +26447,11 @@ class TestClusterComplexTypes : public TestCommand void OnFailureResponse_5(uint8_t status) { ThrowFailureResponse(); } - void OnSuccessResponse_5() { NextTest(); } + void OnSuccessResponse_5(bool value) + { + VerifyOrReturn(CheckValue("value", value, true)); + NextTest(); + } CHIP_ERROR TestSendTestCommandWithListOfStructArgumentAndArg1bOfFirstItemIsFalse_6() { @@ -26439,7 +26459,7 @@ class TestClusterComplexTypes : public TestCommand cluster.Associate(mDevice, 1); using requestType = chip::app::Clusters::TestCluster::Commands::TestListStructArgumentRequest::Type; - using responseType = chip::app::DataModel::NullObjectType; + using responseType = chip::app::Clusters::TestCluster::Commands::BooleanResponse::DecodableType; chip::app::Clusters::TestCluster::Commands::TestListStructArgumentRequest::Type request; @@ -26462,7 +26482,7 @@ class TestClusterComplexTypes : public TestCommand request.arg1 = arg1List; auto success = [](void * context, const responseType & data) { - (static_cast(context))->OnSuccessResponse_6(); + (static_cast(context))->OnSuccessResponse_6(data.value); }; auto failure = [](void * context, EmberAfStatus status) { @@ -26471,9 +26491,13 @@ class TestClusterComplexTypes : public TestCommand return cluster.InvokeCommand(request, this, success, failure); } - void OnFailureResponse_6(uint8_t status) { NextTest(); } + void OnFailureResponse_6(uint8_t status) { ThrowFailureResponse(); } - void OnSuccessResponse_6() { ThrowSuccessResponse(); } + void OnSuccessResponse_6(bool value) + { + VerifyOrReturn(CheckValue("value", value, false)); + NextTest(); + } CHIP_ERROR TestSendTestCommandWithOptionalArgSet_7() { diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp index 0d5251c846b4b3..f3fcb1a93ea00d 100644 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp @@ -1869,6 +1869,19 @@ bool emberAfTargetNavigatorClusterNavigateTargetResponseCallback(EndpointId endp return true; } +bool emberAfTestClusterClusterBooleanResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, bool value) +{ + ChipLogProgress(Zcl, "BooleanResponse:"); + ChipLogProgress(Zcl, " value: %d", value); + + GET_CLUSTER_RESPONSE_CALLBACKS("TestClusterClusterBooleanResponseCallback"); + + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, value); + return true; +} + bool emberAfTestClusterClusterTestAddArgumentsResponseCallback(EndpointId endpoint, app::CommandSender * commandObj, uint8_t returnValue) { diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h index 66defcbe9cc818..21378c4acd0644 100644 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h @@ -142,6 +142,7 @@ typedef void (*TvChannelClusterChangeChannelResponseCallback)(void * context, /* TYPE WARNING: array array defaults to */ uint8_t * ChannelMatch, uint8_t ErrorType); typedef void (*TargetNavigatorClusterNavigateTargetResponseCallback)(void * context, uint8_t status, chip::CharSpan data); +typedef void (*TestClusterClusterBooleanResponseCallback)(void * context, bool value); typedef void (*TestClusterClusterTestAddArgumentsResponseCallback)(void * context, uint8_t returnValue); typedef void (*TestClusterClusterTestEnumsResponseCallback)(void * context, chip::VendorId arg1, uint8_t arg2); typedef void (*TestClusterClusterTestListInt8UReverseResponseCallback)(void * context, diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClustersInvoke.cpp b/zzz_generated/controller-clusters/zap-generated/CHIPClustersInvoke.cpp index 3549c92db7084d..65019b8a70d4ea 100644 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClustersInvoke.cpp +++ b/zzz_generated/controller-clusters/zap-generated/CHIPClustersInvoke.cpp @@ -895,9 +895,10 @@ template CHIP_ERROR ClusterBase::InvokeCommand( + chip::app::Clusters::TestCluster::Commands::BooleanResponse::DecodableType>( const chip::app::Clusters::TestCluster::Commands::TestListInt8UArgumentRequest::Type &, void *, - CommandResponseSuccessCallback, CommandResponseFailureCallback); + CommandResponseSuccessCallback, + CommandResponseFailureCallback); template CHIP_ERROR ClusterBase::InvokeCommand( + chip::app::Clusters::TestCluster::Commands::BooleanResponse::DecodableType>( const chip::app::Clusters::TestCluster::Commands::TestListStructArgumentRequest::Type &, void *, - CommandResponseSuccessCallback, CommandResponseFailureCallback); + CommandResponseSuccessCallback, + CommandResponseFailureCallback); template CHIP_ERROR ClusterBase::InvokeCommand( @@ -930,9 +932,10 @@ template CHIP_ERROR ClusterBase::InvokeCommand( + chip::app::Clusters::TestCluster::Commands::BooleanResponse::DecodableType>( const chip::app::Clusters::TestCluster::Commands::TestStructArgumentRequest::Type &, void *, - CommandResponseSuccessCallback, CommandResponseFailureCallback); + CommandResponseSuccessCallback, + CommandResponseFailureCallback); template CHIP_ERROR ClusterBase::InvokeCommand( diff --git a/zzz_generated/controller-clusters/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/controller-clusters/zap-generated/IMClusterCommandHandler.cpp index 85b5def7d37e00..e638e09ef8cd94 100644 --- a/zzz_generated/controller-clusters/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/controller-clusters/zap-generated/IMClusterCommandHandler.cpp @@ -5182,6 +5182,64 @@ void DispatchClientCommand(CommandSender * apCommandObj, const ConcreteCommandPa { switch (aCommandPath.mCommandId) { + case Commands::BooleanResponse::Id: { + expectArgumentCount = 1; + bool value; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(value); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + wasHandled = emberAfTestClusterClusterBooleanResponseCallback(aCommandPath.mEndpointId, apCommandObj, value); + } + break; + } case Commands::TestAddArgumentsResponse::Id: { expectArgumentCount = 1; uint8_t returnValue;