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