From 12588992dfa582b285f6fb8ac77be8da5446d0ae Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Mon, 8 Jan 2024 12:31:55 -0500 Subject: [PATCH] New unit testing cluster commands to support testing batch commands corner cases (#31138) * New unit testing cluster commands for batch testing * Restyled by whitespace * Restyled by clang-format * Address PR comments * Restyled by clang-format * Fixes for CI * Restyled by prettier-yaml * Fix Darwin codegen for adding new commands to UnitTesting. 1) Add missing isSupported check that was causing us to generate an implementation that did not have a corresponding declaration (which had the check). 2) Add missing isForCommandPayload to existing isSupported check, so implementation and declaration are doing the same check. 3) Mark newly-added things as provisional. * Rerun zap regen --------- Co-authored-by: Restyled.io Co-authored-by: Boris Zbarsky --- .../all-clusters-app.matter | 22 ++ .../all-clusters-common/all-clusters-app.zap | 28 +- .../all-clusters-minimal-app.matter | 20 ++ .../test-cluster-server.cpp | 87 ++++++ src/app/tests/suites/TestCluster.yaml | 25 +- .../zcl/data-model/chip/test-cluster.xml | 27 ++ .../data_model/controller-clusters.matter | 20 ++ .../chip/devicecontroller/ChipClusters.java | 80 ++++++ .../devicecontroller/ClusterIDMapping.java | 38 ++- .../devicecontroller/ClusterInfoMapping.java | 82 ++++++ .../cluster/clusters/UnitTestingCluster.kt | 118 ++++++++ .../zap-generated/CHIPInvokeCallbacks.cpp | 60 ++++ .../java/zap-generated/CHIPInvokeCallbacks.h | 15 + .../python/chip/clusters/CHIPClusters.py | 18 ++ .../python/chip/clusters/Objects.py | 56 ++++ .../templates/MTRCommandPayloadsObjc-src.zapt | 4 +- .../CHIP/templates/availability.yaml | 6 + .../CHIP/zap-generated/MTRBaseClusters.h | 12 + .../CHIP/zap-generated/MTRBaseClusters.mm | 48 ++++ .../CHIP/zap-generated/MTRClusterConstants.h | 3 + .../CHIP/zap-generated/MTRClusters.h | 2 + .../CHIP/zap-generated/MTRClusters.mm | 54 ++++ .../zap-generated/MTRCommandPayloadsObjc.h | 87 ++++++ .../zap-generated/MTRCommandPayloadsObjc.mm | 261 ++++++++++++++++++ .../MTRCommandPayloads_Internal.h | 18 ++ .../app-common/zap-generated/callback.h | 12 + .../zap-generated/cluster-objects.cpp | 122 ++++++++ .../zap-generated/cluster-objects.h | 123 +++++++++ .../app-common/zap-generated/ids/Commands.h | 12 + .../zap-generated/cluster/Commands.h | 84 ++++++ .../cluster/logging/DataModelLogger.cpp | 13 + .../cluster/logging/DataModelLogger.h | 2 + .../zap-generated/cluster/Commands.h | 151 ++++++++++ .../zap-generated/test/Commands.h | 7 +- 34 files changed, 1705 insertions(+), 12 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 c09d305dd7390b..b17ab915e55a98 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 @@ -6198,6 +6198,10 @@ internal cluster UnitTesting = 4294048773 { NestedStructList arg1[] = 0; } + response struct TestBatchHelperResponse = 12 { + octet_string<800> buffer = 0; + } + request struct TestListInt8UReverseRequestRequest { int8u arg1[] = 0; } @@ -6244,6 +6248,18 @@ internal cluster UnitTesting = 4294048773 { int8u arg1 = 0; } + request struct TestBatchHelperRequestRequest { + int16u sleepBeforeResponseTimeMs = 0; + int16u sizeOfResponseBuffer = 1; + int8u fillCharacter = 2; + } + + request struct TestSecondBatchHelperRequestRequest { + int16u sleepBeforeResponseTimeMs = 0; + int16u sizeOfResponseBuffer = 1; + int8u fillCharacter = 2; + } + /** Simple command without any parameters and without a specific response */ command Test(): DefaultSuccess = 0; /** Simple command without any parameters and without a specific response not handled by the server */ @@ -6309,6 +6325,10 @@ internal cluster UnitTesting = 4294048773 { command TestEmitTestEventRequest(TestEmitTestEventRequestRequest): TestEmitTestEventResponse = 20; /** Command that takes identical arguments to the fields of the TestFabricScopedEvent and logs the TestFabricScopedEvent to the buffer. Command returns an event ID as the response. */ command TestEmitTestFabricScopedEventRequest(TestEmitTestFabricScopedEventRequestRequest): TestEmitTestFabricScopedEventResponse = 21; + /** Command that responds after sleepBeforeResponseTimeMs with an octet_string the size requested with fillCharacter. */ + command TestBatchHelperRequest(TestBatchHelperRequestRequest): TestBatchHelperResponse = 22; + /** Second command that responds after sleepBeforeResponseTimeMs with an octet_string the size requested with fillCharacter. */ + command TestSecondBatchHelperRequest(TestSecondBatchHelperRequestRequest): TestBatchHelperResponse = 23; } /** The Fault Injection Cluster provide a means for a test harness to configure faults(for example triggering a fault in the system). */ @@ -8012,6 +8032,8 @@ endpoint 1 { handle command TestSimpleOptionalArgumentRequest; handle command TestEmitTestEventRequest; handle command TestEmitTestFabricScopedEventRequest; + handle command TestBatchHelperRequest; + handle command TestSecondBatchHelperRequest; } } endpoint 2 { diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 8f1d73386c7465..a5d06276bbc56e 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -17,6 +17,12 @@ } ], "package": [ + { + "pathRelativity": "relativeToZap", + "path": "../../../src/app/zap-templates/app-templates.json", + "type": "gen-templates-json", + "version": "chip-v1" + }, { "pathRelativity": "relativeToZap", "path": "../../../src/app/zap-templates/zcl/zcl-with-test-extensions.json", @@ -24,12 +30,6 @@ "category": "matter", "version": 1, "description": "Matter SDK ZCL data with some extensions" - }, - { - "pathRelativity": "relativeToZap", - "path": "../../../src/app/zap-templates/app-templates.json", - "type": "gen-templates-json", - "version": "chip-v1" } ], "endpointTypes": [ @@ -19318,6 +19318,22 @@ "source": "client", "isIncoming": 1, "isEnabled": 1 + }, + { + "name": "TestBatchHelperRequest", + "code": 22, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TestSecondBatchHelperRequest", + "code": 23, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 } ], "attributes": [ diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter index 42daa8ddac3aa8..601b3e82450bd2 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.matter @@ -5601,6 +5601,10 @@ internal cluster UnitTesting = 4294048773 { NestedStructList arg1[] = 0; } + response struct TestBatchHelperResponse = 12 { + octet_string<800> buffer = 0; + } + request struct TestListInt8UReverseRequestRequest { int8u arg1[] = 0; } @@ -5647,6 +5651,18 @@ internal cluster UnitTesting = 4294048773 { int8u arg1 = 0; } + request struct TestBatchHelperRequestRequest { + int16u sleepBeforeResponseTimeMs = 0; + int16u sizeOfResponseBuffer = 1; + int8u fillCharacter = 2; + } + + request struct TestSecondBatchHelperRequestRequest { + int16u sleepBeforeResponseTimeMs = 0; + int16u sizeOfResponseBuffer = 1; + int8u fillCharacter = 2; + } + /** Simple command without any parameters and without a specific response */ command Test(): DefaultSuccess = 0; /** Simple command without any parameters and without a specific response not handled by the server */ @@ -5712,6 +5728,10 @@ internal cluster UnitTesting = 4294048773 { command TestEmitTestEventRequest(TestEmitTestEventRequestRequest): TestEmitTestEventResponse = 20; /** Command that takes identical arguments to the fields of the TestFabricScopedEvent and logs the TestFabricScopedEvent to the buffer. Command returns an event ID as the response. */ command TestEmitTestFabricScopedEventRequest(TestEmitTestFabricScopedEventRequestRequest): TestEmitTestFabricScopedEventResponse = 21; + /** Command that responds after sleepBeforeResponseTimeMs with an octet_string the size requested with fillCharacter. */ + command TestBatchHelperRequest(TestBatchHelperRequestRequest): TestBatchHelperResponse = 22; + /** Second command that responds after sleepBeforeResponseTimeMs with an octet_string the size requested with fillCharacter. */ + command TestSecondBatchHelperRequest(TestSecondBatchHelperRequestRequest): TestBatchHelperResponse = 23; } endpoint 0 { 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 30d1fb4a6edaa1..de41c286f15f2d 100644 --- a/src/app/clusters/test-cluster-server/test-cluster-server.cpp +++ b/src/app/clusters/test-cluster-server/test-cluster-server.cpp @@ -55,6 +55,9 @@ constexpr uint8_t kFabricSensitiveCharLength = 128; // The maximum length of the fabric sensitive integer list within the TestFabricScoped struct. constexpr uint8_t kFabricSensitiveIntListLength = 8; +// The maximum buffer size allowed in TestBatchHelperResponse +constexpr uint16_t kTestBatchHelperResponseBufferMax = 800; + namespace { class OctetStringData @@ -103,6 +106,14 @@ class TestAttrAccess : public AttributeAccessInterface CHIP_ERROR WriteListFabricScopedAttribute(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder); }; +struct AsyncBatchCommandsWorkData +{ + CommandHandler::Handle asyncCommandHandle; + ConcreteCommandPath commandPath = ConcreteCommandPath(0, 0, 0); + uint16_t sizeOfResponseBuffer; + uint8_t fillCharacter; +}; + TestAttrAccess gAttrAccess; uint8_t gListUint8Data[kAttributeListLength]; size_t gListUint8DataLen = kAttributeListLength; @@ -137,6 +148,36 @@ SimpleEnum gSimpleEnums[kAttributeListLength]; size_t gSimpleEnumCount = 0; Structs::NullablesAndOptionalsStruct::Type gNullablesAndOptionalsStruct; +void AsyncBatchCommandWork(AsyncBatchCommandsWorkData * asyncWorkData) +{ + auto commandHandleRef = std::move(asyncWorkData->asyncCommandHandle); + auto commandHandle = commandHandleRef.Get(); + if (commandHandle == nullptr) + { + // Very weird that we are even in here, what set this to nullptr? + Platform::Delete(asyncWorkData); + return; + } + + uint8_t buffer[kTestBatchHelperResponseBufferMax]; + memset(buffer, asyncWorkData->fillCharacter, asyncWorkData->sizeOfResponseBuffer); + Commands::TestBatchHelperResponse::Type response; + response.buffer = ByteSpan(buffer, asyncWorkData->sizeOfResponseBuffer); + commandHandle->AddResponse(asyncWorkData->commandPath, response); + Platform::Delete(asyncWorkData); +} + +static void timerCallback(System::Layer *, void * callbackContext) +{ + AsyncBatchCommandWork(reinterpret_cast(callbackContext)); +} + +static void scheduleTimerCallbackMs(AsyncBatchCommandsWorkData * asyncWorkData, uint32_t delayMs) +{ + DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Milliseconds32(delayMs), timerCallback, + reinterpret_cast(asyncWorkData)); +} + CHIP_ERROR TestAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) { switch (aPath.mAttributeId) @@ -994,6 +1035,52 @@ bool emberAfUnitTestingClusterTestSimpleOptionalArgumentRequestCallback( return true; } +// TestBatchHelperRequest and TestSecondBatchHelperRequest do the same thing. +// The reason there are two identical commands is because batch command requires +// command paths in the same batch to be unique. These command allow for +// client to control order of the response and control size of CommandDataIB +// being sent back to help test some corner cases. +bool TestBatchHelperCommon(CommandHandler * commandObj, const ConcreteCommandPath & commandPath, const uint16_t sleepTimeMs, + const uint16_t sizeOfResponseBuffer, const uint8_t fillCharacter) +{ + if (sizeOfResponseBuffer > kTestBatchHelperResponseBufferMax) + { + commandObj->AddStatus(commandPath, Protocols::InteractionModel::Status::ConstraintError); + return true; + } + + AsyncBatchCommandsWorkData * asyncWorkData = Platform::New(); + if (asyncWorkData == nullptr) + { + commandObj->AddStatus(commandPath, Protocols::InteractionModel::Status::Busy); + return true; + } + + asyncWorkData->asyncCommandHandle = commandObj; + asyncWorkData->commandPath = commandPath; + asyncWorkData->sizeOfResponseBuffer = sizeOfResponseBuffer; + asyncWorkData->fillCharacter = fillCharacter; + + scheduleTimerCallbackMs(asyncWorkData, sleepTimeMs); + + return true; +} + +bool emberAfUnitTestingClusterTestBatchHelperRequestCallback(CommandHandler * commandObj, const ConcreteCommandPath & commandPath, + const Commands::TestBatchHelperRequest::DecodableType & commandData) +{ + return TestBatchHelperCommon(commandObj, commandPath, commandData.sleepBeforeResponseTimeMs, commandData.sizeOfResponseBuffer, + commandData.fillCharacter); +} + +bool emberAfUnitTestingClusterTestSecondBatchHelperRequestCallback( + CommandHandler * commandObj, const ConcreteCommandPath & commandPath, + const Commands::TestSecondBatchHelperRequest::DecodableType & commandData) +{ + return TestBatchHelperCommon(commandObj, commandPath, commandData.sleepBeforeResponseTimeMs, commandData.sizeOfResponseBuffer, + commandData.fillCharacter); +} + // ----------------------------------------------------------------------------- // Plugin initialization diff --git a/src/app/tests/suites/TestCluster.yaml b/src/app/tests/suites/TestCluster.yaml index e89a892dd32ee5..c6e8dc0946970c 100644 --- a/src/app/tests/suites/TestCluster.yaml +++ b/src/app/tests/suites/TestCluster.yaml @@ -3855,13 +3855,34 @@ tests: attribute: "AcceptedCommandList" response: value: - [0, 1, 2, 4, 7, 8, 9, 10, 11, 12, 13, 14, 15, 17, 18, 19, 20, 21] + [ + 0, + 1, + 2, + 4, + 7, + 8, + 9, + 10, + 11, + 12, + 13, + 14, + 15, + 17, + 18, + 19, + 20, + 21, + 22, + 23, + ] - label: "read GeneratedCommandList attribute" command: "readAttribute" attribute: "GeneratedCommandList" response: - value: [0, 1, 4, 5, 6, 8, 9, 10, 11] + value: [0, 1, 4, 5, 6, 8, 9, 10, 11, 12] # Struct-typed attribute - label: "Write struct-typed attribute" 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 6e81b67b5c46e9..f043c49074ec0e 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 @@ -440,6 +440,26 @@ limitations under the License. + + + Command that responds after sleepBeforeResponseTimeMs with an octet_string the size requested with fillCharacter. + + + + + + + + + Second command that responds after sleepBeforeResponseTimeMs with an octet_string the size requested with fillCharacter. + + + + + + Simple response for TestWithResponse with a simple return value @@ -566,6 +586,13 @@ limitations under the License. + + + Response to TestBatchHelperRequest or TestSecondBatchHelperRequest. Buffer in response is filled as directed in the Request. + + + + Example test event diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index 380270d146601a..70cef4b39d5675 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -8693,6 +8693,10 @@ internal cluster UnitTesting = 4294048773 { NestedStructList arg1[] = 0; } + response struct TestBatchHelperResponse = 12 { + octet_string<800> buffer = 0; + } + request struct TestListInt8UReverseRequestRequest { int8u arg1[] = 0; } @@ -8739,6 +8743,18 @@ internal cluster UnitTesting = 4294048773 { int8u arg1 = 0; } + request struct TestBatchHelperRequestRequest { + int16u sleepBeforeResponseTimeMs = 0; + int16u sizeOfResponseBuffer = 1; + int8u fillCharacter = 2; + } + + request struct TestSecondBatchHelperRequestRequest { + int16u sleepBeforeResponseTimeMs = 0; + int16u sizeOfResponseBuffer = 1; + int8u fillCharacter = 2; + } + /** Simple command without any parameters and without a specific response */ command Test(): DefaultSuccess = 0; /** Simple command without any parameters and without a specific response not handled by the server */ @@ -8804,6 +8820,10 @@ internal cluster UnitTesting = 4294048773 { command TestEmitTestEventRequest(TestEmitTestEventRequestRequest): TestEmitTestEventResponse = 20; /** Command that takes identical arguments to the fields of the TestFabricScopedEvent and logs the TestFabricScopedEvent to the buffer. Command returns an event ID as the response. */ command TestEmitTestFabricScopedEventRequest(TestEmitTestFabricScopedEventRequestRequest): TestEmitTestFabricScopedEventResponse = 21; + /** Command that responds after sleepBeforeResponseTimeMs with an octet_string the size requested with fillCharacter. */ + command TestBatchHelperRequest(TestBatchHelperRequestRequest): TestBatchHelperResponse = 22; + /** Second command that responds after sleepBeforeResponseTimeMs with an octet_string the size requested with fillCharacter. */ + command TestSecondBatchHelperRequest(TestSecondBatchHelperRequestRequest): TestBatchHelperResponse = 23; } /** The Fault Injection Cluster provide a means for a test harness to configure faults(for example triggering a fault in the system). */ diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java index d9b1143464b577..eb221bfec1730b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java @@ -58464,6 +58464,82 @@ public void onResponse(StructType invokeStructValue) { }}, commandId, value, timedInvokeTimeoutMs); } + public void testBatchHelperRequest(TestBatchHelperResponseCallback callback, Integer sleepBeforeResponseTimeMs, Integer sizeOfResponseBuffer, Integer fillCharacter) { + testBatchHelperRequest(callback, sleepBeforeResponseTimeMs, sizeOfResponseBuffer, fillCharacter, 0); + } + + public void testBatchHelperRequest(TestBatchHelperResponseCallback callback, Integer sleepBeforeResponseTimeMs, Integer sizeOfResponseBuffer, Integer fillCharacter, int timedInvokeTimeoutMs) { + final long commandId = 22L; + + ArrayList elements = new ArrayList<>(); + final long sleepBeforeResponseTimeMsFieldID = 0L; + BaseTLVType sleepBeforeResponseTimeMstlvValue = new UIntType(sleepBeforeResponseTimeMs); + elements.add(new StructElement(sleepBeforeResponseTimeMsFieldID, sleepBeforeResponseTimeMstlvValue)); + + final long sizeOfResponseBufferFieldID = 1L; + BaseTLVType sizeOfResponseBuffertlvValue = new UIntType(sizeOfResponseBuffer); + elements.add(new StructElement(sizeOfResponseBufferFieldID, sizeOfResponseBuffertlvValue)); + + final long fillCharacterFieldID = 2L; + BaseTLVType fillCharactertlvValue = new UIntType(fillCharacter); + elements.add(new StructElement(fillCharacterFieldID, fillCharactertlvValue)); + + StructType value = new StructType(elements); + invoke(new InvokeCallbackImpl(callback) { + @Override + public void onResponse(StructType invokeStructValue) { + final long bufferFieldID = 0L; + byte[] buffer = null; + for (StructElement element: invokeStructValue.value()) { + if (element.contextTagNum() == bufferFieldID) { + if (element.value(BaseTLVType.class).type() == TLVType.ByteArray) { + ByteArrayType castingValue = element.value(ByteArrayType.class); + buffer = castingValue.value(byte[].class); + } + } + } + callback.onSuccess(buffer); + }}, commandId, value, timedInvokeTimeoutMs); + } + + public void testSecondBatchHelperRequest(TestBatchHelperResponseCallback callback, Integer sleepBeforeResponseTimeMs, Integer sizeOfResponseBuffer, Integer fillCharacter) { + testSecondBatchHelperRequest(callback, sleepBeforeResponseTimeMs, sizeOfResponseBuffer, fillCharacter, 0); + } + + public void testSecondBatchHelperRequest(TestBatchHelperResponseCallback callback, Integer sleepBeforeResponseTimeMs, Integer sizeOfResponseBuffer, Integer fillCharacter, int timedInvokeTimeoutMs) { + final long commandId = 23L; + + ArrayList elements = new ArrayList<>(); + final long sleepBeforeResponseTimeMsFieldID = 0L; + BaseTLVType sleepBeforeResponseTimeMstlvValue = new UIntType(sleepBeforeResponseTimeMs); + elements.add(new StructElement(sleepBeforeResponseTimeMsFieldID, sleepBeforeResponseTimeMstlvValue)); + + final long sizeOfResponseBufferFieldID = 1L; + BaseTLVType sizeOfResponseBuffertlvValue = new UIntType(sizeOfResponseBuffer); + elements.add(new StructElement(sizeOfResponseBufferFieldID, sizeOfResponseBuffertlvValue)); + + final long fillCharacterFieldID = 2L; + BaseTLVType fillCharactertlvValue = new UIntType(fillCharacter); + elements.add(new StructElement(fillCharacterFieldID, fillCharactertlvValue)); + + StructType value = new StructType(elements); + invoke(new InvokeCallbackImpl(callback) { + @Override + public void onResponse(StructType invokeStructValue) { + final long bufferFieldID = 0L; + byte[] buffer = null; + for (StructElement element: invokeStructValue.value()) { + if (element.contextTagNum() == bufferFieldID) { + if (element.value(BaseTLVType.class).type() == TLVType.ByteArray) { + ByteArrayType castingValue = element.value(ByteArrayType.class); + buffer = castingValue.value(byte[].class); + } + } + } + callback.onSuccess(buffer); + }}, commandId, value, timedInvokeTimeoutMs); + } + public interface TestSpecificResponseCallback extends BaseClusterCallback { void onSuccess(Integer returnValue); } @@ -58512,6 +58588,10 @@ public interface TestEmitTestFabricScopedEventResponseCallback extends BaseClust void onSuccess(Long value); } + public interface TestBatchHelperResponseCallback extends BaseClusterCallback { + void onSuccess(byte[] buffer); + } + public interface ListInt8uAttributeCallback extends BaseAttributeCallback { void onSuccess(List value); } diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java index e432edea9dc9c3..77021a240507ed 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java @@ -16053,7 +16053,9 @@ public enum Command { TimedInvokeRequest(18L), TestSimpleOptionalArgumentRequest(19L), TestEmitTestEventRequest(20L), - TestEmitTestFabricScopedEventRequest(21L),; + TestEmitTestFabricScopedEventRequest(21L), + TestBatchHelperRequest(22L), + TestSecondBatchHelperRequest(23L),; private final long id; Command(long id) { this.id = id; @@ -16360,6 +16362,40 @@ public static TestEmitTestFabricScopedEventRequestCommandField value(int id) thr } throw new NoSuchFieldError(); } + }public enum TestBatchHelperRequestCommandField {SleepBeforeResponseTimeMs(0),SizeOfResponseBuffer(1),FillCharacter(2),; + private final int id; + TestBatchHelperRequestCommandField(int id) { + this.id = id; + } + + public int getID() { + return id; + } + public static TestBatchHelperRequestCommandField value(int id) throws NoSuchFieldError { + for (TestBatchHelperRequestCommandField field : TestBatchHelperRequestCommandField.values()) { + if (field.getID() == id) { + return field; + } + } + throw new NoSuchFieldError(); + } + }public enum TestSecondBatchHelperRequestCommandField {SleepBeforeResponseTimeMs(0),SizeOfResponseBuffer(1),FillCharacter(2),; + private final int id; + TestSecondBatchHelperRequestCommandField(int id) { + this.id = id; + } + + public int getID() { + return id; + } + public static TestSecondBatchHelperRequestCommandField value(int id) throws NoSuchFieldError { + for (TestSecondBatchHelperRequestCommandField field : TestSecondBatchHelperRequestCommandField.values()) { + if (field.getID() == id) { + return field; + } + } + throw new NoSuchFieldError(); + } }@Override public String getAttributeName(long id) throws NoSuchFieldError { return Attribute.value(id).toString(); diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java index 187400cba467b4..a0a05852bd9c69 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java @@ -18312,6 +18312,28 @@ public void onError(Exception error) { callback.onFailure(error); } } + + public static class DelegatedUnitTestingClusterTestBatchHelperResponseCallback implements ChipClusters.UnitTestingCluster.TestBatchHelperResponseCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(byte[] buffer) { + Map responseValues = new LinkedHashMap<>(); + + CommandResponseInfo bufferResponseValue = new CommandResponseInfo("buffer", "byte[]"); + responseValues.put(bufferResponseValue, buffer); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception error) { + callback.onFailure(error); + } + } public static class DelegatedUnitTestingClusterListInt8uAttributeCallback implements ChipClusters.UnitTestingCluster.ListInt8uAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override @@ -26190,6 +26212,66 @@ public Map> getCommandMap() { ); unitTestingClusterInteractionInfoMap.put("testEmitTestFabricScopedEventRequest", unitTestingtestEmitTestFabricScopedEventRequestInteractionInfo); + Map unitTestingtestBatchHelperRequestCommandParams = new LinkedHashMap(); + + CommandParameterInfo unitTestingtestBatchHelperRequestsleepBeforeResponseTimeMsCommandParameterInfo = new CommandParameterInfo("sleepBeforeResponseTimeMs", Integer.class, Integer.class); + unitTestingtestBatchHelperRequestCommandParams.put("sleepBeforeResponseTimeMs",unitTestingtestBatchHelperRequestsleepBeforeResponseTimeMsCommandParameterInfo); + + CommandParameterInfo unitTestingtestBatchHelperRequestsizeOfResponseBufferCommandParameterInfo = new CommandParameterInfo("sizeOfResponseBuffer", Integer.class, Integer.class); + unitTestingtestBatchHelperRequestCommandParams.put("sizeOfResponseBuffer",unitTestingtestBatchHelperRequestsizeOfResponseBufferCommandParameterInfo); + + CommandParameterInfo unitTestingtestBatchHelperRequestfillCharacterCommandParameterInfo = new CommandParameterInfo("fillCharacter", Integer.class, Integer.class); + unitTestingtestBatchHelperRequestCommandParams.put("fillCharacter",unitTestingtestBatchHelperRequestfillCharacterCommandParameterInfo); + InteractionInfo unitTestingtestBatchHelperRequestInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.UnitTestingCluster) cluster) + .testBatchHelperRequest((ChipClusters.UnitTestingCluster.TestBatchHelperResponseCallback) callback + , (Integer) + commandArguments.get("sleepBeforeResponseTimeMs") + + , (Integer) + commandArguments.get("sizeOfResponseBuffer") + + , (Integer) + commandArguments.get("fillCharacter") + + ); + }, + () -> new DelegatedUnitTestingClusterTestBatchHelperResponseCallback(), + unitTestingtestBatchHelperRequestCommandParams + ); + unitTestingClusterInteractionInfoMap.put("testBatchHelperRequest", unitTestingtestBatchHelperRequestInteractionInfo); + + Map unitTestingtestSecondBatchHelperRequestCommandParams = new LinkedHashMap(); + + CommandParameterInfo unitTestingtestSecondBatchHelperRequestsleepBeforeResponseTimeMsCommandParameterInfo = new CommandParameterInfo("sleepBeforeResponseTimeMs", Integer.class, Integer.class); + unitTestingtestSecondBatchHelperRequestCommandParams.put("sleepBeforeResponseTimeMs",unitTestingtestSecondBatchHelperRequestsleepBeforeResponseTimeMsCommandParameterInfo); + + CommandParameterInfo unitTestingtestSecondBatchHelperRequestsizeOfResponseBufferCommandParameterInfo = new CommandParameterInfo("sizeOfResponseBuffer", Integer.class, Integer.class); + unitTestingtestSecondBatchHelperRequestCommandParams.put("sizeOfResponseBuffer",unitTestingtestSecondBatchHelperRequestsizeOfResponseBufferCommandParameterInfo); + + CommandParameterInfo unitTestingtestSecondBatchHelperRequestfillCharacterCommandParameterInfo = new CommandParameterInfo("fillCharacter", Integer.class, Integer.class); + unitTestingtestSecondBatchHelperRequestCommandParams.put("fillCharacter",unitTestingtestSecondBatchHelperRequestfillCharacterCommandParameterInfo); + InteractionInfo unitTestingtestSecondBatchHelperRequestInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.UnitTestingCluster) cluster) + .testSecondBatchHelperRequest((ChipClusters.UnitTestingCluster.TestBatchHelperResponseCallback) callback + , (Integer) + commandArguments.get("sleepBeforeResponseTimeMs") + + , (Integer) + commandArguments.get("sizeOfResponseBuffer") + + , (Integer) + commandArguments.get("fillCharacter") + + ); + }, + () -> new DelegatedUnitTestingClusterTestBatchHelperResponseCallback(), + unitTestingtestSecondBatchHelperRequestCommandParams + ); + unitTestingClusterInteractionInfoMap.put("testSecondBatchHelperRequest", unitTestingtestSecondBatchHelperRequestInteractionInfo); + commandMap.put("unitTesting", unitTestingClusterInteractionInfoMap); Map faultInjectionClusterInteractionInfoMap = new LinkedHashMap<>(); diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt index 94fe39115cd7a2..468d4e4b310802 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt @@ -119,6 +119,8 @@ class UnitTestingCluster(private val controller: MatterController, private val e class TestEmitTestFabricScopedEventResponse(val value: ULong) + class TestBatchHelperResponse(val buffer: ByteArray) + class ListInt8uAttribute(val value: List) sealed class ListInt8uAttributeSubscriptionState { @@ -2217,6 +2219,122 @@ class UnitTestingCluster(private val controller: MatterController, private val e return TestEmitTestFabricScopedEventResponse(value_decoded) } + suspend fun testBatchHelperRequest( + sleepBeforeResponseTimeMs: UShort, + sizeOfResponseBuffer: UShort, + fillCharacter: UByte, + timedInvokeTimeout: Duration? = null + ): TestBatchHelperResponse { + val commandId: UInt = 22u + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ: Int = 0 + tlvWriter.put( + ContextSpecificTag(TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ), + sleepBeforeResponseTimeMs + ) + + val TAG_SIZE_OF_RESPONSE_BUFFER_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_SIZE_OF_RESPONSE_BUFFER_REQ), sizeOfResponseBuffer) + + val TAG_FILL_CHARACTER_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_FILL_CHARACTER_REQ), fillCharacter) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timedInvokeTimeout + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_BUFFER: Int = 0 + var buffer_decoded: ByteArray? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_BUFFER)) { + buffer_decoded = tlvReader.getByteArray(tag) + } else { + tlvReader.skipElement() + } + } + + if (buffer_decoded == null) { + throw IllegalStateException("buffer not found in TLV") + } + + tlvReader.exitContainer() + + return TestBatchHelperResponse(buffer_decoded) + } + + suspend fun testSecondBatchHelperRequest( + sleepBeforeResponseTimeMs: UShort, + sizeOfResponseBuffer: UShort, + fillCharacter: UByte, + timedInvokeTimeout: Duration? = null + ): TestBatchHelperResponse { + val commandId: UInt = 23u + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ: Int = 0 + tlvWriter.put( + ContextSpecificTag(TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ), + sleepBeforeResponseTimeMs + ) + + val TAG_SIZE_OF_RESPONSE_BUFFER_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_SIZE_OF_RESPONSE_BUFFER_REQ), sizeOfResponseBuffer) + + val TAG_FILL_CHARACTER_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_FILL_CHARACTER_REQ), fillCharacter) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timedInvokeTimeout + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + + val tlvReader = TlvReader(response.payload) + tlvReader.enterStructure(AnonymousTag) + val TAG_BUFFER: Int = 0 + var buffer_decoded: ByteArray? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_BUFFER)) { + buffer_decoded = tlvReader.getByteArray(tag) + } else { + tlvReader.skipElement() + } + } + + if (buffer_decoded == null) { + throw IllegalStateException("buffer not found in TLV") + } + + tlvReader.exitContainer() + + return TestBatchHelperResponse(buffer_decoded) + } + suspend fun readBooleanAttribute(): Boolean { val ATTRIBUTE_ID: UInt = 0u diff --git a/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp b/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp index c8b5c50edc55e8..8c3deacae5abaf 100644 --- a/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp +++ b/src/controller/java/zap-generated/CHIPInvokeCallbacks.cpp @@ -8330,6 +8330,66 @@ void CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback::Callba env->CallVoidMethod(javaCallbackRef, javaMethod, value); } +CHIPUnitTestingClusterTestBatchHelperResponseCallback::CHIPUnitTestingClusterTestBatchHelperResponseCallback(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"); + } +} + +CHIPUnitTestingClusterTestBatchHelperResponseCallback::~CHIPUnitTestingClusterTestBatchHelperResponseCallback() +{ + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +}; + +void CHIPUnitTestingClusterTestBatchHelperResponseCallback::CallbackFn( + void * context, const chip::app::Clusters::UnitTesting::Commands::TestBatchHelperResponse::DecodableType & dataResponse) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + jmethodID javaMethod; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Error invoking Java callback: no JNIEnv")); + + std::unique_ptr + cppCallback(reinterpret_cast(context), + chip::Platform::Delete); + VerifyOrReturn(cppCallback != nullptr, ChipLogError(Zcl, "Error invoking Java callback: failed to cast native callback")); + + javaCallbackRef = cppCallback->javaCallbackRef; + // Java callback is allowed to be null, exit early if this is the case. + VerifyOrReturn(javaCallbackRef != nullptr); + + err = JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "([B)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); + + jobject buffer; + jbyteArray bufferByteArray = env->NewByteArray(static_cast(dataResponse.buffer.size())); + env->SetByteArrayRegion(bufferByteArray, 0, static_cast(dataResponse.buffer.size()), + reinterpret_cast(dataResponse.buffer.data())); + buffer = bufferByteArray; + + env->CallVoidMethod(javaCallbackRef, javaMethod, buffer); +} CHIPSampleMeiClusterAddArgumentsResponseCallback::CHIPSampleMeiClusterAddArgumentsResponseCallback(jobject javaCallback) : Callback::Callback(CallbackFn, this) { diff --git a/src/controller/java/zap-generated/CHIPInvokeCallbacks.h b/src/controller/java/zap-generated/CHIPInvokeCallbacks.h index 23b691e07a332b..1a0c0dd4d2ef50 100644 --- a/src/controller/java/zap-generated/CHIPInvokeCallbacks.h +++ b/src/controller/java/zap-generated/CHIPInvokeCallbacks.h @@ -1126,6 +1126,21 @@ class CHIPUnitTestingClusterTestEmitTestFabricScopedEventResponseCallback jobject javaCallbackRef; }; +class CHIPUnitTestingClusterTestBatchHelperResponseCallback + : public Callback::Callback +{ +public: + CHIPUnitTestingClusterTestBatchHelperResponseCallback(jobject javaCallback); + + ~CHIPUnitTestingClusterTestBatchHelperResponseCallback(); + + static void CallbackFn(void * context, + const chip::app::Clusters::UnitTesting::Commands::TestBatchHelperResponse::DecodableType & data); + +private: + jobject javaCallbackRef; +}; + class CHIPSampleMeiClusterAddArgumentsResponseCallback : public Callback::Callback { diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index 57d6c97e833340..59c67cbe244eb2 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -13126,6 +13126,24 @@ class ChipClusters: "arg1": "int", }, }, + 0x00000016: { + "commandId": 0x00000016, + "commandName": "TestBatchHelperRequest", + "args": { + "sleepBeforeResponseTimeMs": "int", + "sizeOfResponseBuffer": "int", + "fillCharacter": "int", + }, + }, + 0x00000017: { + "commandId": 0x00000017, + "commandName": "TestSecondBatchHelperRequest", + "args": { + "sleepBeforeResponseTimeMs": "int", + "sizeOfResponseBuffer": "int", + "fillCharacter": "int", + }, + }, }, "attributes": { 0x00000000: { diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index c5874b2aaec964..ac7aeca1cab875 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -45541,6 +45541,22 @@ def descriptor(cls) -> ClusterObjectDescriptor: arg1: 'typing.List[UnitTesting.Structs.NestedStructList]' = field(default_factory=lambda: []) + @dataclass + class TestBatchHelperResponse(ClusterCommand): + cluster_id: typing.ClassVar[int] = 0xFFF1FC05 + command_id: typing.ClassVar[int] = 0x0000000C + is_client: typing.ClassVar[bool] = False + response_type: typing.ClassVar[str] = None + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="buffer", Tag=0, Type=bytes), + ]) + + buffer: 'bytes' = b"" + @dataclass class TestListInt8UReverseRequest(ClusterCommand): cluster_id: typing.ClassVar[int] = 0xFFF1FC05 @@ -45714,6 +45730,46 @@ def descriptor(cls) -> ClusterObjectDescriptor: arg1: 'uint' = 0 + @dataclass + class TestBatchHelperRequest(ClusterCommand): + cluster_id: typing.ClassVar[int] = 0xFFF1FC05 + command_id: typing.ClassVar[int] = 0x00000016 + is_client: typing.ClassVar[bool] = True + response_type: typing.ClassVar[str] = 'TestBatchHelperResponse' + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="sleepBeforeResponseTimeMs", Tag=0, Type=uint), + ClusterObjectFieldDescriptor(Label="sizeOfResponseBuffer", Tag=1, Type=uint), + ClusterObjectFieldDescriptor(Label="fillCharacter", Tag=2, Type=uint), + ]) + + sleepBeforeResponseTimeMs: 'uint' = 0 + sizeOfResponseBuffer: 'uint' = 0 + fillCharacter: 'uint' = 0 + + @dataclass + class TestSecondBatchHelperRequest(ClusterCommand): + cluster_id: typing.ClassVar[int] = 0xFFF1FC05 + command_id: typing.ClassVar[int] = 0x00000017 + is_client: typing.ClassVar[bool] = True + response_type: typing.ClassVar[str] = 'TestBatchHelperResponse' + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="sleepBeforeResponseTimeMs", Tag=0, Type=uint), + ClusterObjectFieldDescriptor(Label="sizeOfResponseBuffer", Tag=1, Type=uint), + ClusterObjectFieldDescriptor(Label="fillCharacter", Tag=2, Type=uint), + ]) + + sleepBeforeResponseTimeMs: 'uint' = 0 + sizeOfResponseBuffer: 'uint' = 0 + fillCharacter: 'uint' = 0 + class Attributes: @dataclass class Boolean(ClusterAttributeDescriptor): diff --git a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt index aa7fe84de732d2..c58c75f77d9d38 100644 --- a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt @@ -198,6 +198,7 @@ NS_ASSUME_NONNULL_BEGIN {{/if}} {{/inline}} {{#*inline "oldNameImpl"}} +{{#if (isSupported cluster command=command isForCommandPayload=true)}} @implementation MTR{{cluster}}Cluster{{command}}Params {{#zcl_command_arguments}} @@ -213,8 +214,9 @@ NS_ASSUME_NONNULL_BEGIN @dynamic timedInvokeTimeoutMs; {{/if}} @end +{{/if}} {{/inline}} -{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true) isForCommandPayload=true)}} {{> completeImpl cluster=(asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true) includeRenamedProperties=false}} diff --git a/src/darwin/Framework/CHIP/templates/availability.yaml b/src/darwin/Framework/CHIP/templates/availability.yaml index 0911dd0118fe3e..ae0d02274db63b 100644 --- a/src/darwin/Framework/CHIP/templates/availability.yaml +++ b/src/darwin/Framework/CHIP/templates/availability.yaml @@ -8313,6 +8313,12 @@ - ActivateAudioTrack - ActivateTextTrack - DeactivateTextTrack + UnitTesting: + # Ideally none of UnitTesting would be exposed as public API, but + # for now just start doing that for new additions to it. + - TestBatchHelperResponse + - TestBatchHelperRequest + - TestSecondBatchHelperRequest command fields: NetworkCommissioning: # Targeting Spring 2024 Matter release diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index ffa6767035e2b3..1ae4424f2229fb 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -14764,6 +14764,18 @@ MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) * Command that takes identical arguments to the fields of the TestFabricScopedEvent and logs the TestFabricScopedEvent to the buffer. Command returns an event ID as the response. */ - (void)testEmitTestFabricScopedEventRequestWithParams:(MTRUnitTestingClusterTestEmitTestFabricScopedEventRequestParams *)params completion:(void (^)(MTRUnitTestingClusterTestEmitTestFabricScopedEventResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +/** + * Command TestBatchHelperRequest + * + * Command that responds after sleepBeforeResponseTimeMs with an octet_string the size requested with fillCharacter. + */ +- (void)testBatchHelperRequestWithParams:(MTRUnitTestingClusterTestBatchHelperRequestParams *)params completion:(void (^)(MTRUnitTestingClusterTestBatchHelperResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +/** + * Command TestSecondBatchHelperRequest + * + * Second command that responds after sleepBeforeResponseTimeMs with an octet_string the size requested with fillCharacter. + */ +- (void)testSecondBatchHelperRequestWithParams:(MTRUnitTestingClusterTestSecondBatchHelperRequestParams *)params completion:(void (^)(MTRUnitTestingClusterTestBatchHelperResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; - (void)readAttributeBooleanWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); - (void)writeAttributeBooleanWithValue:(NSNumber * _Nonnull)value completion:(MTRStatusCompletion)completion MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm index 19b00a2c799aaa..1050bcbbc044ca 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm @@ -109665,6 +109665,54 @@ - (void)testEmitTestFabricScopedEventRequestWithParams:(MTRUnitTestingClusterTes queue:self.callbackQueue completion:responseHandler]; } +- (void)testBatchHelperRequestWithParams:(MTRUnitTestingClusterTestBatchHelperRequestParams *)params completion:(void (^)(MTRUnitTestingClusterTestBatchHelperResponseParams * _Nullable data, NSError * _Nullable error))completion +{ + if (params == nil) { + params = [[MTRUnitTestingClusterTestBatchHelperRequestParams + alloc] init]; + } + + auto responseHandler = ^(id _Nullable response, NSError * _Nullable error) { + completion(response, error); + }; + + auto * timedInvokeTimeoutMs = params.timedInvokeTimeoutMs; + + using RequestType = UnitTesting::Commands::TestBatchHelperRequest::Type; + [self.device _invokeKnownCommandWithEndpointID:@(self.endpoint) + clusterID:@(RequestType::GetClusterId()) + commandID:@(RequestType::GetCommandId()) + commandPayload:params + timedInvokeTimeout:timedInvokeTimeoutMs + serverSideProcessingTimeout:params.serverSideProcessingTimeout + responseClass:MTRUnitTestingClusterTestBatchHelperResponseParams.class + queue:self.callbackQueue + completion:responseHandler]; +} +- (void)testSecondBatchHelperRequestWithParams:(MTRUnitTestingClusterTestSecondBatchHelperRequestParams *)params completion:(void (^)(MTRUnitTestingClusterTestBatchHelperResponseParams * _Nullable data, NSError * _Nullable error))completion +{ + if (params == nil) { + params = [[MTRUnitTestingClusterTestSecondBatchHelperRequestParams + alloc] init]; + } + + auto responseHandler = ^(id _Nullable response, NSError * _Nullable error) { + completion(response, error); + }; + + auto * timedInvokeTimeoutMs = params.timedInvokeTimeoutMs; + + using RequestType = UnitTesting::Commands::TestSecondBatchHelperRequest::Type; + [self.device _invokeKnownCommandWithEndpointID:@(self.endpoint) + clusterID:@(RequestType::GetClusterId()) + commandID:@(RequestType::GetCommandId()) + commandPayload:params + timedInvokeTimeout:timedInvokeTimeoutMs + serverSideProcessingTimeout:params.serverSideProcessingTimeout + responseClass:MTRUnitTestingClusterTestBatchHelperResponseParams.class + queue:self.callbackQueue + completion:responseHandler]; +} - (void)readAttributeBooleanWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h index 8e618740b0b6da..4cf0aa3990a7dd 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h @@ -6918,6 +6918,7 @@ typedef NS_ENUM(uint32_t, MTRCommandIDType) { MTRCommandIDTypeClusterUnitTestingCommandTestNestedStructListArgumentRequestID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x0000000B, MTRCommandIDTypeClusterUnitTestingCommandTestEmitTestFabricScopedEventResponseID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x0000000B, MTRCommandIDTypeClusterUnitTestingCommandTestListNestedStructListArgumentRequestID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x0000000C, + MTRCommandIDTypeClusterUnitTestingCommandTestBatchHelperResponseID MTR_PROVISIONALLY_AVAILABLE = 0x0000000C, MTRCommandIDTypeClusterUnitTestingCommandTestListInt8UReverseRequestID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x0000000D, MTRCommandIDTypeClusterUnitTestingCommandTestEnumsRequestID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x0000000E, MTRCommandIDTypeClusterUnitTestingCommandTestNullableOptionalRequestID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x0000000F, @@ -6927,6 +6928,8 @@ typedef NS_ENUM(uint32_t, MTRCommandIDType) { MTRCommandIDTypeClusterUnitTestingCommandTestSimpleOptionalArgumentRequestID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000013, MTRCommandIDTypeClusterUnitTestingCommandTestEmitTestEventRequestID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000014, MTRCommandIDTypeClusterUnitTestingCommandTestEmitTestFabricScopedEventRequestID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000015, + MTRCommandIDTypeClusterUnitTestingCommandTestBatchHelperRequestID MTR_PROVISIONALLY_AVAILABLE = 0x00000016, + MTRCommandIDTypeClusterUnitTestingCommandTestSecondBatchHelperRequestID MTR_PROVISIONALLY_AVAILABLE = 0x00000017, // Cluster SampleMEI commands MTRCommandIDTypeClusterSampleMEICommandPingID MTR_PROVISIONALLY_AVAILABLE = 0x00000000, diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h index 7e3c9eb87cf9c7..b377db1108216e 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h @@ -6730,6 +6730,8 @@ MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) MTR_AVAILABLE(ios(17.4), macos(14.4), watchos(10.4), tvos(17.4)); - (void)testEmitTestEventRequestWithParams:(MTRUnitTestingClusterTestEmitTestEventRequestParams *)params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRUnitTestingClusterTestEmitTestEventResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); - (void)testEmitTestFabricScopedEventRequestWithParams:(MTRUnitTestingClusterTestEmitTestFabricScopedEventRequestParams *)params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRUnitTestingClusterTestEmitTestFabricScopedEventResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +- (void)testBatchHelperRequestWithParams:(MTRUnitTestingClusterTestBatchHelperRequestParams *)params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRUnitTestingClusterTestBatchHelperResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)testSecondBatchHelperRequestWithParams:(MTRUnitTestingClusterTestSecondBatchHelperRequestParams *)params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRUnitTestingClusterTestBatchHelperResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; - (NSDictionary * _Nullable)readAttributeBooleanWithParams:(MTRReadParams * _Nullable)params MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); - (void)writeAttributeBooleanWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm index 0ab55d5776856e..f8bb88a0ef0152 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm @@ -19977,6 +19977,60 @@ - (void)testEmitTestFabricScopedEventRequestWithParams:(MTRUnitTestingClusterTes completion:responseHandler]; } +- (void)testBatchHelperRequestWithParams:(MTRUnitTestingClusterTestBatchHelperRequestParams *)params expectedValues:(NSArray *> * _Nullable)expectedValues expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRUnitTestingClusterTestBatchHelperResponseParams * _Nullable data, NSError * _Nullable error))completion +{ + if (params == nil) { + params = [[MTRUnitTestingClusterTestBatchHelperRequestParams + alloc] init]; + } + + auto responseHandler = ^(id _Nullable response, NSError * _Nullable error) { + completion(response, error); + }; + + auto * timedInvokeTimeoutMs = params.timedInvokeTimeoutMs; + + using RequestType = UnitTesting::Commands::TestBatchHelperRequest::Type; + [self.device _invokeKnownCommandWithEndpointID:@(self.endpoint) + clusterID:@(RequestType::GetClusterId()) + commandID:@(RequestType::GetCommandId()) + commandPayload:params + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + timedInvokeTimeout:timedInvokeTimeoutMs + serverSideProcessingTimeout:params.serverSideProcessingTimeout + responseClass:MTRUnitTestingClusterTestBatchHelperResponseParams.class + queue:self.callbackQueue + completion:responseHandler]; +} + +- (void)testSecondBatchHelperRequestWithParams:(MTRUnitTestingClusterTestSecondBatchHelperRequestParams *)params expectedValues:(NSArray *> * _Nullable)expectedValues expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRUnitTestingClusterTestBatchHelperResponseParams * _Nullable data, NSError * _Nullable error))completion +{ + if (params == nil) { + params = [[MTRUnitTestingClusterTestSecondBatchHelperRequestParams + alloc] init]; + } + + auto responseHandler = ^(id _Nullable response, NSError * _Nullable error) { + completion(response, error); + }; + + auto * timedInvokeTimeoutMs = params.timedInvokeTimeoutMs; + + using RequestType = UnitTesting::Commands::TestSecondBatchHelperRequest::Type; + [self.device _invokeKnownCommandWithEndpointID:@(self.endpoint) + clusterID:@(RequestType::GetClusterId()) + commandID:@(RequestType::GetCommandId()) + commandPayload:params + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + timedInvokeTimeout:timedInvokeTimeoutMs + serverSideProcessingTimeout:params.serverSideProcessingTimeout + responseClass:MTRUnitTestingClusterTestBatchHelperResponseParams.class + queue:self.callbackQueue + completion:responseHandler]; +} + - (NSDictionary * _Nullable)readAttributeBooleanWithParams:(MTRReadParams * _Nullable)params { return [self.device readAttributeWithEndpointID:@(self.endpoint) clusterID:@(MTRClusterIDTypeUnitTestingID) attributeID:@(MTRAttributeIDTypeClusterUnitTestingAttributeBooleanID) params:params]; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h index f540aa11163f6d..a3177639b26409 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h @@ -11959,6 +11959,25 @@ MTR_DEPRECATED("Please use MTRUnitTestingClusterTestListNestedStructListArgument @property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout; @end +MTR_PROVISIONALLY_AVAILABLE +@interface MTRUnitTestingClusterTestBatchHelperResponseParams : NSObject + +@property (nonatomic, copy) NSData * _Nonnull buffer MTR_PROVISIONALLY_AVAILABLE; + +/** + * Initialize an MTRUnitTestingClusterTestBatchHelperResponseParams with a response-value dictionary + * of the sort that MTRDeviceResponseHandler would receive. + * + * Will return nil and hand out an error if the response-value dictionary is not + * a command data response or is not the right command response. + * + * Will return nil and hand out an error if the data response does not match the known + * schema for this command. + */ +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error MTR_PROVISIONALLY_AVAILABLE; +@end + MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @interface MTRUnitTestingClusterTestListInt8UReverseRequestParams : NSObject @@ -12551,6 +12570,74 @@ MTR_DEPRECATED("Please use MTRUnitTestingClusterTestEmitTestFabricScopedEventReq @property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout; @end +MTR_PROVISIONALLY_AVAILABLE +@interface MTRUnitTestingClusterTestBatchHelperRequestParams : NSObject + +@property (nonatomic, copy) NSNumber * _Nonnull sleepBeforeResponseTimeMs MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy) NSNumber * _Nonnull sizeOfResponseBuffer MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy) NSNumber * _Nonnull fillCharacter MTR_PROVISIONALLY_AVAILABLE; +/** + * Controls whether the command is a timed command (using Timed Invoke). + * + * If nil (the default value), a regular invoke is done for commands that do + * not require a timed invoke and a timed invoke with some default timed request + * timeout is done for commands that require a timed invoke. + * + * If not nil, a timed invoke is done, with the provided value used as the timed + * request timeout. The value should be chosen small enough to provide the + * desired security properties but large enough that it will allow a round-trip + * from the sever to the client (for the status response and actual invoke + * request) within the timeout window. + * + */ +@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; + +/** + * Controls how much time, in seconds, we will allow for the server to process the command. + * + * The command will then time out if that much time, plus an allowance for retransmits due to network failures, passes. + * + * If nil, the framework will try to select an appropriate timeout value itself. + */ +@property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout; +@end + +MTR_PROVISIONALLY_AVAILABLE +@interface MTRUnitTestingClusterTestSecondBatchHelperRequestParams : NSObject + +@property (nonatomic, copy) NSNumber * _Nonnull sleepBeforeResponseTimeMs MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy) NSNumber * _Nonnull sizeOfResponseBuffer MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy) NSNumber * _Nonnull fillCharacter MTR_PROVISIONALLY_AVAILABLE; +/** + * Controls whether the command is a timed command (using Timed Invoke). + * + * If nil (the default value), a regular invoke is done for commands that do + * not require a timed invoke and a timed invoke with some default timed request + * timeout is done for commands that require a timed invoke. + * + * If not nil, a timed invoke is done, with the provided value used as the timed + * request timeout. The value should be chosen small enough to provide the + * desired security properties but large enough that it will allow a round-trip + * from the sever to the client (for the status response and actual invoke + * request) within the timeout window. + * + */ +@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; + +/** + * Controls how much time, in seconds, we will allow for the server to process the command. + * + * The command will then time out if that much time, plus an allowance for retransmits due to network failures, passes. + * + * If nil, the framework will try to select an appropriate timeout value itself. + */ +@property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout; +@end + MTR_PROVISIONALLY_AVAILABLE @interface MTRSampleMEIClusterPingParams : NSObject /** diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm index 35c71e8afd4c3f..368ac07c4a2ac3 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm @@ -32513,6 +32513,85 @@ @implementation MTRTestClusterClusterTestListNestedStructListArgumentRequestPara @dynamic timedInvokeTimeoutMs; @dynamic serverSideProcessingTimeout; @end +@implementation MTRUnitTestingClusterTestBatchHelperResponseParams +- (instancetype)init +{ + if (self = [super init]) { + + _buffer = [NSData data]; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone; +{ + auto other = [[MTRUnitTestingClusterTestBatchHelperResponseParams alloc] init]; + + other.buffer = self.buffer; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: buffer:%@; >", NSStringFromClass([self class]), [_buffer base64EncodedStringWithOptions:0]]; + return descriptionString; +} + +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::UnitTesting::Commands::TestBatchHelperResponse::DecodableType; + chip::System::PacketBufferHandle buffer = [MTRBaseDevice _responseDataForCommand:responseValue + clusterID:DecodableType::GetClusterId() + commandID:DecodableType::GetCommandId() + error:error]; + if (buffer.IsNull()) { + return nil; + } + + chip::TLV::TLVReader reader; + reader.Init(buffer->Start(), buffer->DataLength()); + + CHIP_ERROR err = reader.Next(chip::TLV::AnonymousTag()); + if (err == CHIP_NO_ERROR) { + DecodableType decodedStruct; + err = chip::app::DataModel::Decode(reader, decodedStruct); + if (err == CHIP_NO_ERROR) { + err = [self _setFieldsFromDecodableStruct:decodedStruct]; + if (err == CHIP_NO_ERROR) { + return self; + } + } + } + + NSString * errorStr = [NSString stringWithFormat:@"Command payload decoding failed: %s", err.AsString()]; + MTR_LOG_ERROR("%s", errorStr.UTF8String); + if (error != nil) { + NSDictionary * userInfo = @{ NSLocalizedFailureReasonErrorKey : NSLocalizedString(errorStr, nil) }; + *error = [NSError errorWithDomain:MTRErrorDomain code:MTRErrorCodeSchemaMismatch userInfo:userInfo]; + } + return nil; +} + +@end + +@implementation MTRUnitTestingClusterTestBatchHelperResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct:(const chip::app::Clusters::UnitTesting::Commands::TestBatchHelperResponse::DecodableType &)decodableStruct +{ + { + self.buffer = AsData(decodableStruct.buffer); + } + return CHIP_NO_ERROR; +} + +@end + @implementation MTRUnitTestingClusterTestListInt8UReverseRequestParams - (instancetype)init { @@ -33556,6 +33635,188 @@ @implementation MTRTestClusterClusterTestEmitTestFabricScopedEventRequestParams @dynamic timedInvokeTimeoutMs; @dynamic serverSideProcessingTimeout; @end +@implementation MTRUnitTestingClusterTestBatchHelperRequestParams +- (instancetype)init +{ + if (self = [super init]) { + + _sleepBeforeResponseTimeMs = @(0); + + _sizeOfResponseBuffer = @(0); + + _fillCharacter = @(0); + _timedInvokeTimeoutMs = nil; + _serverSideProcessingTimeout = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone; +{ + auto other = [[MTRUnitTestingClusterTestBatchHelperRequestParams alloc] init]; + + other.sleepBeforeResponseTimeMs = self.sleepBeforeResponseTimeMs; + other.sizeOfResponseBuffer = self.sizeOfResponseBuffer; + other.fillCharacter = self.fillCharacter; + other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; + other.serverSideProcessingTimeout = self.serverSideProcessingTimeout; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: sleepBeforeResponseTimeMs:%@; sizeOfResponseBuffer:%@; fillCharacter:%@; >", NSStringFromClass([self class]), _sleepBeforeResponseTimeMs, _sizeOfResponseBuffer, _fillCharacter]; + return descriptionString; +} + +@end + +@implementation MTRUnitTestingClusterTestBatchHelperRequestParams (InternalMethods) + +- (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader +{ + chip::app::Clusters::UnitTesting::Commands::TestBatchHelperRequest::Type encodableStruct; + ListFreer listFreer; + { + encodableStruct.sleepBeforeResponseTimeMs = self.sleepBeforeResponseTimeMs.unsignedShortValue; + } + { + encodableStruct.sizeOfResponseBuffer = self.sizeOfResponseBuffer.unsignedShortValue; + } + { + encodableStruct.fillCharacter = self.fillCharacter.unsignedCharValue; + } + + auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); + if (buffer.IsNull()) { + return CHIP_ERROR_NO_MEMORY; + } + + chip::System::PacketBufferTLVWriter writer; + // Commands never need chained buffers, since they cannot be chunked. + writer.Init(std::move(buffer), /* useChainedBuffers = */ false); + + ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::AnonymousTag(), encodableStruct)); + + ReturnErrorOnFailure(writer.Finalize(&buffer)); + + reader.Init(std::move(buffer)); + return reader.Next(chip::TLV::kTLVType_Structure, chip::TLV::AnonymousTag()); +} + +- (NSDictionary * _Nullable)_encodeAsDataValue:(NSError * __autoreleasing *)error +{ + chip::System::PacketBufferTLVReader reader; + CHIP_ERROR err = [self _encodeToTLVReader:reader]; + if (err != CHIP_NO_ERROR) { + if (error) { + *error = [MTRError errorForCHIPErrorCode:err]; + } + return nil; + } + + auto decodedObj = MTRDecodeDataValueDictionaryFromCHIPTLV(&reader); + if (decodedObj == nil) { + if (error) { + *error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE]; + } + } + return decodedObj; +} +@end + +@implementation MTRUnitTestingClusterTestSecondBatchHelperRequestParams +- (instancetype)init +{ + if (self = [super init]) { + + _sleepBeforeResponseTimeMs = @(0); + + _sizeOfResponseBuffer = @(0); + + _fillCharacter = @(0); + _timedInvokeTimeoutMs = nil; + _serverSideProcessingTimeout = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone; +{ + auto other = [[MTRUnitTestingClusterTestSecondBatchHelperRequestParams alloc] init]; + + other.sleepBeforeResponseTimeMs = self.sleepBeforeResponseTimeMs; + other.sizeOfResponseBuffer = self.sizeOfResponseBuffer; + other.fillCharacter = self.fillCharacter; + other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; + other.serverSideProcessingTimeout = self.serverSideProcessingTimeout; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: sleepBeforeResponseTimeMs:%@; sizeOfResponseBuffer:%@; fillCharacter:%@; >", NSStringFromClass([self class]), _sleepBeforeResponseTimeMs, _sizeOfResponseBuffer, _fillCharacter]; + return descriptionString; +} + +@end + +@implementation MTRUnitTestingClusterTestSecondBatchHelperRequestParams (InternalMethods) + +- (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader +{ + chip::app::Clusters::UnitTesting::Commands::TestSecondBatchHelperRequest::Type encodableStruct; + ListFreer listFreer; + { + encodableStruct.sleepBeforeResponseTimeMs = self.sleepBeforeResponseTimeMs.unsignedShortValue; + } + { + encodableStruct.sizeOfResponseBuffer = self.sizeOfResponseBuffer.unsignedShortValue; + } + { + encodableStruct.fillCharacter = self.fillCharacter.unsignedCharValue; + } + + auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); + if (buffer.IsNull()) { + return CHIP_ERROR_NO_MEMORY; + } + + chip::System::PacketBufferTLVWriter writer; + // Commands never need chained buffers, since they cannot be chunked. + writer.Init(std::move(buffer), /* useChainedBuffers = */ false); + + ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::AnonymousTag(), encodableStruct)); + + ReturnErrorOnFailure(writer.Finalize(&buffer)); + + reader.Init(std::move(buffer)); + return reader.Next(chip::TLV::kTLVType_Structure, chip::TLV::AnonymousTag()); +} + +- (NSDictionary * _Nullable)_encodeAsDataValue:(NSError * __autoreleasing *)error +{ + chip::System::PacketBufferTLVReader reader; + CHIP_ERROR err = [self _encodeToTLVReader:reader]; + if (err != CHIP_NO_ERROR) { + if (error) { + *error = [MTRError errorForCHIPErrorCode:err]; + } + return nil; + } + + auto decodedObj = MTRDecodeDataValueDictionaryFromCHIPTLV(&reader); + if (decodedObj == nil) { + if (error) { + *error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE]; + } + } + return decodedObj; +} +@end + @implementation MTRSampleMEIClusterPingParams - (instancetype)init { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h index 24ef38c1031cc6..eaf1bf2b744f8c 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h @@ -2014,6 +2014,12 @@ NS_ASSUME_NONNULL_BEGIN @end +@interface MTRUnitTestingClusterTestBatchHelperResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct:(const chip::app::Clusters::UnitTesting::Commands::TestBatchHelperResponse::DecodableType &)decodableStruct; + +@end + @interface MTRUnitTestingClusterTestListInt8UReverseRequestParams (InternalMethods) - (NSDictionary * _Nullable)_encodeAsDataValue:(NSError * __autoreleasing *)error; @@ -2068,6 +2074,18 @@ NS_ASSUME_NONNULL_BEGIN @end +@interface MTRUnitTestingClusterTestBatchHelperRequestParams (InternalMethods) + +- (NSDictionary * _Nullable)_encodeAsDataValue:(NSError * __autoreleasing *)error; + +@end + +@interface MTRUnitTestingClusterTestSecondBatchHelperRequestParams (InternalMethods) + +- (NSDictionary * _Nullable)_encodeAsDataValue:(NSError * __autoreleasing *)error; + +@end + @interface MTRSampleMEIClusterPingParams (InternalMethods) - (NSDictionary * _Nullable)_encodeAsDataValue:(NSError * __autoreleasing *)error; 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 439ed6b63ab082..61c909519685e1 100644 --- a/zzz_generated/app-common/app-common/zap-generated/callback.h +++ b/zzz_generated/app-common/app-common/zap-generated/callback.h @@ -10980,6 +10980,18 @@ bool emberAfUnitTestingClusterTestEmitTestEventRequestCallback( bool emberAfUnitTestingClusterTestEmitTestFabricScopedEventRequestCallback( chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::UnitTesting::Commands::TestEmitTestFabricScopedEventRequest::DecodableType & commandData); +/** + * @brief Unit Testing Cluster TestBatchHelperRequest Command callback (from client) + */ +bool emberAfUnitTestingClusterTestBatchHelperRequestCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::UnitTesting::Commands::TestBatchHelperRequest::DecodableType & commandData); +/** + * @brief Unit Testing Cluster TestSecondBatchHelperRequest Command callback (from client) + */ +bool emberAfUnitTestingClusterTestSecondBatchHelperRequestCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::UnitTesting::Commands::TestSecondBatchHelperRequest::DecodableType & commandData); /** * @brief Fault Injection Cluster FailAtFault 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 7d25bcce933bb4..e3798e4613005c 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 @@ -27154,6 +27154,40 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } } } // namespace TestListNestedStructListArgumentRequest. +namespace TestBatchHelperResponse { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; + encoder.Encode(to_underlying(Fields::kBuffer), buffer); + return encoder.Finalize(); +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + detail::StructDecodeIterator __iterator(reader); + while (true) + { + auto __element = __iterator.Next(); + if (std::holds_alternative(__element)) + { + return std::get(__element); + } + + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t __context_tag = std::get(__element); + + if (__context_tag == to_underlying(Fields::kBuffer)) + { + err = DataModel::Decode(reader, buffer); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} +} // namespace TestBatchHelperResponse. namespace TestListInt8UReverseRequest { CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const { @@ -27516,6 +27550,94 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } } } // namespace TestEmitTestFabricScopedEventRequest. +namespace TestBatchHelperRequest { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; + encoder.Encode(to_underlying(Fields::kSleepBeforeResponseTimeMs), sleepBeforeResponseTimeMs); + encoder.Encode(to_underlying(Fields::kSizeOfResponseBuffer), sizeOfResponseBuffer); + encoder.Encode(to_underlying(Fields::kFillCharacter), fillCharacter); + return encoder.Finalize(); +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + detail::StructDecodeIterator __iterator(reader); + while (true) + { + auto __element = __iterator.Next(); + if (std::holds_alternative(__element)) + { + return std::get(__element); + } + + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t __context_tag = std::get(__element); + + if (__context_tag == to_underlying(Fields::kSleepBeforeResponseTimeMs)) + { + err = DataModel::Decode(reader, sleepBeforeResponseTimeMs); + } + else if (__context_tag == to_underlying(Fields::kSizeOfResponseBuffer)) + { + err = DataModel::Decode(reader, sizeOfResponseBuffer); + } + else if (__context_tag == to_underlying(Fields::kFillCharacter)) + { + err = DataModel::Decode(reader, fillCharacter); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} +} // namespace TestBatchHelperRequest. +namespace TestSecondBatchHelperRequest { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; + encoder.Encode(to_underlying(Fields::kSleepBeforeResponseTimeMs), sleepBeforeResponseTimeMs); + encoder.Encode(to_underlying(Fields::kSizeOfResponseBuffer), sizeOfResponseBuffer); + encoder.Encode(to_underlying(Fields::kFillCharacter), fillCharacter); + return encoder.Finalize(); +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + detail::StructDecodeIterator __iterator(reader); + while (true) + { + auto __element = __iterator.Next(); + if (std::holds_alternative(__element)) + { + return std::get(__element); + } + + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t __context_tag = std::get(__element); + + if (__context_tag == to_underlying(Fields::kSleepBeforeResponseTimeMs)) + { + err = DataModel::Decode(reader, sleepBeforeResponseTimeMs); + } + else if (__context_tag == to_underlying(Fields::kSizeOfResponseBuffer)) + { + err = DataModel::Decode(reader, sizeOfResponseBuffer); + } + else if (__context_tag == to_underlying(Fields::kFillCharacter)) + { + err = DataModel::Decode(reader, fillCharacter); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} +} // namespace TestSecondBatchHelperRequest. } // namespace Commands namespace Attributes { 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 c292a11f999cd8..cb176c39ba7394 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 @@ -39687,6 +39687,11 @@ struct Type; struct DecodableType; } // namespace TestListNestedStructListArgumentRequest +namespace TestBatchHelperResponse { +struct Type; +struct DecodableType; +} // namespace TestBatchHelperResponse + namespace TestListInt8UReverseRequest { struct Type; struct DecodableType; @@ -39732,6 +39737,16 @@ struct Type; struct DecodableType; } // namespace TestEmitTestFabricScopedEventRequest +namespace TestBatchHelperRequest { +struct Type; +struct DecodableType; +} // namespace TestBatchHelperRequest + +namespace TestSecondBatchHelperRequest { +struct Type; +struct DecodableType; +} // namespace TestSecondBatchHelperRequest + } // namespace Commands namespace Commands { @@ -40645,6 +40660,38 @@ struct DecodableType CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace TestListNestedStructListArgumentRequest +namespace TestBatchHelperResponse { +enum class Fields : uint8_t +{ + kBuffer = 0, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return Commands::TestBatchHelperResponse::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::UnitTesting::Id; } + + chip::ByteSpan buffer; + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; + + using ResponseType = DataModel::NullObjectType; + + static constexpr bool MustUseTimedInvoke() { return false; } +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return Commands::TestBatchHelperResponse::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::UnitTesting::Id; } + + chip::ByteSpan buffer; + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace TestBatchHelperResponse namespace TestListInt8UReverseRequest { enum class Fields : uint8_t { @@ -40971,6 +41018,82 @@ struct DecodableType CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace TestEmitTestFabricScopedEventRequest +namespace TestBatchHelperRequest { +enum class Fields : uint8_t +{ + kSleepBeforeResponseTimeMs = 0, + kSizeOfResponseBuffer = 1, + kFillCharacter = 2, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return Commands::TestBatchHelperRequest::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::UnitTesting::Id; } + + uint16_t sleepBeforeResponseTimeMs = static_cast(0); + uint16_t sizeOfResponseBuffer = static_cast(0); + uint8_t fillCharacter = static_cast(0); + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; + + using ResponseType = Clusters::UnitTesting::Commands::TestBatchHelperResponse::DecodableType; + + static constexpr bool MustUseTimedInvoke() { return false; } +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return Commands::TestBatchHelperRequest::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::UnitTesting::Id; } + + uint16_t sleepBeforeResponseTimeMs = static_cast(0); + uint16_t sizeOfResponseBuffer = static_cast(0); + uint8_t fillCharacter = static_cast(0); + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace TestBatchHelperRequest +namespace TestSecondBatchHelperRequest { +enum class Fields : uint8_t +{ + kSleepBeforeResponseTimeMs = 0, + kSizeOfResponseBuffer = 1, + kFillCharacter = 2, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return Commands::TestSecondBatchHelperRequest::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::UnitTesting::Id; } + + uint16_t sleepBeforeResponseTimeMs = static_cast(0); + uint16_t sizeOfResponseBuffer = static_cast(0); + uint8_t fillCharacter = static_cast(0); + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; + + using ResponseType = Clusters::UnitTesting::Commands::TestBatchHelperResponse::DecodableType; + + static constexpr bool MustUseTimedInvoke() { return false; } +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return Commands::TestSecondBatchHelperRequest::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::UnitTesting::Id; } + + uint16_t sleepBeforeResponseTimeMs = static_cast(0); + uint16_t sizeOfResponseBuffer = static_cast(0); + uint8_t fillCharacter = static_cast(0); + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace TestSecondBatchHelperRequest } // namespace Commands namespace Attributes { 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 d903540c90f79f..e5d62e248f7cdc 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 @@ -1740,6 +1740,10 @@ namespace TestListNestedStructListArgumentRequest { static constexpr CommandId Id = 0x0000000C; } // namespace TestListNestedStructListArgumentRequest +namespace TestBatchHelperResponse { +static constexpr CommandId Id = 0x0000000C; +} // namespace TestBatchHelperResponse + namespace TestListInt8UReverseRequest { static constexpr CommandId Id = 0x0000000D; } // namespace TestListInt8UReverseRequest @@ -1776,6 +1780,14 @@ namespace TestEmitTestFabricScopedEventRequest { static constexpr CommandId Id = 0x00000015; } // namespace TestEmitTestFabricScopedEventRequest +namespace TestBatchHelperRequest { +static constexpr CommandId Id = 0x00000016; +} // namespace TestBatchHelperRequest + +namespace TestSecondBatchHelperRequest { +static constexpr CommandId Id = 0x00000017; +} // namespace TestSecondBatchHelperRequest + } // namespace Commands } // namespace UnitTesting diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index 1c9302b99b360c..24be99ebdc010a 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -12795,6 +12795,8 @@ class ElectricalMeasurementGetMeasurementProfileCommand : public ClusterCommand | * TestSimpleOptionalArgumentRequest | 0x13 | | * TestEmitTestEventRequest | 0x14 | | * TestEmitTestFabricScopedEventRequest | 0x15 | +| * TestBatchHelperRequest | 0x16 | +| * TestSecondBatchHelperRequest | 0x17 | |------------------------------------------------------------------------------| | Attributes: | | | * Boolean | 0x0000 | @@ -13775,6 +13777,86 @@ class UnitTestingTestEmitTestFabricScopedEventRequest : public ClusterCommand chip::app::Clusters::UnitTesting::Commands::TestEmitTestFabricScopedEventRequest::Type mRequest; }; +/* + * Command TestBatchHelperRequest + */ +class UnitTestingTestBatchHelperRequest : public ClusterCommand +{ +public: + UnitTestingTestBatchHelperRequest(CredentialIssuerCommands * credsIssuerConfig) : + ClusterCommand("test-batch-helper-request", credsIssuerConfig) + { + AddArgument("SleepBeforeResponseTimeMs", 0, UINT16_MAX, &mRequest.sleepBeforeResponseTimeMs); + AddArgument("SizeOfResponseBuffer", 0, UINT16_MAX, &mRequest.sizeOfResponseBuffer); + AddArgument("FillCharacter", 0, UINT8_MAX, &mRequest.fillCharacter); + ClusterCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; + constexpr chip::CommandId commandId = chip::app::Clusters::UnitTesting::Commands::TestBatchHelperRequest::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") command (0x%08" PRIX32 ") on endpoint %u", clusterId, + commandId, endpointIds.at(0)); + return ClusterCommand::SendCommand(device, endpointIds.at(0), clusterId, commandId, mRequest); + } + + CHIP_ERROR SendGroupCommand(chip::GroupId groupId, chip::FabricIndex fabricIndex) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; + constexpr chip::CommandId commandId = chip::app::Clusters::UnitTesting::Commands::TestBatchHelperRequest::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") command (0x%08" PRIX32 ") on Group %u", clusterId, commandId, + groupId); + + return ClusterCommand::SendGroupCommand(groupId, fabricIndex, clusterId, commandId, mRequest); + } + +private: + chip::app::Clusters::UnitTesting::Commands::TestBatchHelperRequest::Type mRequest; +}; + +/* + * Command TestSecondBatchHelperRequest + */ +class UnitTestingTestSecondBatchHelperRequest : public ClusterCommand +{ +public: + UnitTestingTestSecondBatchHelperRequest(CredentialIssuerCommands * credsIssuerConfig) : + ClusterCommand("test-second-batch-helper-request", credsIssuerConfig) + { + AddArgument("SleepBeforeResponseTimeMs", 0, UINT16_MAX, &mRequest.sleepBeforeResponseTimeMs); + AddArgument("SizeOfResponseBuffer", 0, UINT16_MAX, &mRequest.sizeOfResponseBuffer); + AddArgument("FillCharacter", 0, UINT8_MAX, &mRequest.fillCharacter); + ClusterCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; + constexpr chip::CommandId commandId = chip::app::Clusters::UnitTesting::Commands::TestSecondBatchHelperRequest::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") command (0x%08" PRIX32 ") on endpoint %u", clusterId, + commandId, endpointIds.at(0)); + return ClusterCommand::SendCommand(device, endpointIds.at(0), clusterId, commandId, mRequest); + } + + CHIP_ERROR SendGroupCommand(chip::GroupId groupId, chip::FabricIndex fabricIndex) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; + constexpr chip::CommandId commandId = chip::app::Clusters::UnitTesting::Commands::TestSecondBatchHelperRequest::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") command (0x%08" PRIX32 ") on Group %u", clusterId, commandId, + groupId); + + return ClusterCommand::SendGroupCommand(groupId, fabricIndex, clusterId, commandId, mRequest); + } + +private: + chip::app::Clusters::UnitTesting::Commands::TestSecondBatchHelperRequest::Type mRequest; +}; + /*----------------------------------------------------------------------------*\ | Cluster FaultInjection | 0xFFF1FC06 | |------------------------------------------------------------------------------| @@ -24899,6 +24981,8 @@ void registerClusterUnitTesting(Commands & commands, CredentialIssuerCommands * make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // + make_unique(credsIssuerConfig), // + make_unique(credsIssuerConfig), // // // Attributes // 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 6089c40e02e3fd..8f0584c156f190 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -7302,6 +7302,14 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, DataModelLogger::LogString(indent, "}"); return CHIP_NO_ERROR; } +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const UnitTesting::Commands::TestBatchHelperResponse::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + ReturnErrorOnFailure(DataModelLogger::LogValue("buffer", indent + 1, value.buffer)); + DataModelLogger::LogString(indent, "}"); + return CHIP_NO_ERROR; +} CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const SampleMei::Commands::AddArgumentsResponse::DecodableType & value) { @@ -17455,6 +17463,11 @@ CHIP_ERROR DataModelLogger::LogCommand(const chip::app::ConcreteCommandPath & pa ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("TestEmitTestFabricScopedEventResponse", 1, value); } + case UnitTesting::Commands::TestBatchHelperResponse::Id: { + UnitTesting::Commands::TestBatchHelperResponse::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("TestBatchHelperResponse", 1, value); + } } break; } diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h index 8828a11491c5d3..007d791c07066b 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h @@ -737,5 +737,7 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::UnitTesting::Commands::TestEmitTestFabricScopedEventResponse::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::UnitTesting::Commands::TestBatchHelperResponse::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::SampleMei::Commands::AddArgumentsResponse::DecodableType & value); diff --git a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h index 61c9dc61e9bd56..bdfa874c995304 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -160860,6 +160860,8 @@ class SubscribeAttributeElectricalMeasurementClusterRevision : public SubscribeA | * TestSimpleOptionalArgumentRequest | 0x13 | | * TestEmitTestEventRequest | 0x14 | | * TestEmitTestFabricScopedEventRequest | 0x15 | +| * TestBatchHelperRequest | 0x16 | +| * TestSecondBatchHelperRequest | 0x17 | |------------------------------------------------------------------------------| | Attributes: | | | * Boolean | 0x0000 | @@ -162549,6 +162551,149 @@ class UnitTestingTestEmitTestFabricScopedEventRequest : public ClusterCommand { chip::app::Clusters::UnitTesting::Commands::TestEmitTestFabricScopedEventRequest::Type mRequest; }; +#if MTR_ENABLE_PROVISIONAL +/* + * Command TestBatchHelperRequest + */ +class UnitTestingTestBatchHelperRequest : public ClusterCommand { +public: + UnitTestingTestBatchHelperRequest() + : ClusterCommand("test-batch-helper-request") + { +#if MTR_ENABLE_PROVISIONAL + AddArgument("SleepBeforeResponseTimeMs", 0, UINT16_MAX, &mRequest.sleepBeforeResponseTimeMs); +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + AddArgument("SizeOfResponseBuffer", 0, UINT16_MAX, &mRequest.sizeOfResponseBuffer); +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + AddArgument("FillCharacter", 0, UINT8_MAX, &mRequest.fillCharacter); +#endif // MTR_ENABLE_PROVISIONAL + ClusterCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; + constexpr chip::CommandId commandId = chip::app::Clusters::UnitTesting::Commands::TestBatchHelperRequest::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") command (0x%08" PRIX32 ") on endpoint %u", clusterId, commandId, endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRUnitTestingClusterTestBatchHelperRequestParams alloc] init]; + params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; +#if MTR_ENABLE_PROVISIONAL + params.sleepBeforeResponseTimeMs = [NSNumber numberWithUnsignedShort:mRequest.sleepBeforeResponseTimeMs]; +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + params.sizeOfResponseBuffer = [NSNumber numberWithUnsignedShort:mRequest.sizeOfResponseBuffer]; +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + params.fillCharacter = [NSNumber numberWithUnsignedChar:mRequest.fillCharacter]; +#endif // MTR_ENABLE_PROVISIONAL + uint16_t repeatCount = mRepeatCount.ValueOr(1); + uint16_t __block responsesNeeded = repeatCount; + while (repeatCount--) { + [cluster testBatchHelperRequestWithParams:params completion: + ^(MTRUnitTestingClusterTestBatchHelperResponseParams * _Nullable values, NSError * _Nullable error) { + NSLog(@"Values: %@", values); + if (error == nil) { + constexpr chip::CommandId responseId = chip::app::Clusters::UnitTesting::Commands::TestBatchHelperResponse::Id; + RemoteDataModelLogger::LogCommandAsJSON(@(endpointId), @(clusterId), @(responseId), values); + } + responsesNeeded--; + if (error != nil) { + mError = error; + LogNSError("Error", error); + constexpr chip::CommandId responseId = chip::app::Clusters::UnitTesting::Commands::TestBatchHelperResponse::Id; + RemoteDataModelLogger::LogCommandErrorAsJSON(@(endpointId), @(clusterId), @(responseId), error); + } + if (responsesNeeded == 0) { + SetCommandExitStatus(mError); + } + }]; + } + return CHIP_NO_ERROR; + } + +private: + chip::app::Clusters::UnitTesting::Commands::TestBatchHelperRequest::Type mRequest; +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL +/* + * Command TestSecondBatchHelperRequest + */ +class UnitTestingTestSecondBatchHelperRequest : public ClusterCommand { +public: + UnitTestingTestSecondBatchHelperRequest() + : ClusterCommand("test-second-batch-helper-request") + { +#if MTR_ENABLE_PROVISIONAL + AddArgument("SleepBeforeResponseTimeMs", 0, UINT16_MAX, &mRequest.sleepBeforeResponseTimeMs); +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + AddArgument("SizeOfResponseBuffer", 0, UINT16_MAX, &mRequest.sizeOfResponseBuffer); +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + AddArgument("FillCharacter", 0, UINT8_MAX, &mRequest.fillCharacter); +#endif // MTR_ENABLE_PROVISIONAL + ClusterCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; + constexpr chip::CommandId commandId = chip::app::Clusters::UnitTesting::Commands::TestSecondBatchHelperRequest::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") command (0x%08" PRIX32 ") on endpoint %u", clusterId, commandId, endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRUnitTestingClusterTestSecondBatchHelperRequestParams alloc] init]; + params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; +#if MTR_ENABLE_PROVISIONAL + params.sleepBeforeResponseTimeMs = [NSNumber numberWithUnsignedShort:mRequest.sleepBeforeResponseTimeMs]; +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + params.sizeOfResponseBuffer = [NSNumber numberWithUnsignedShort:mRequest.sizeOfResponseBuffer]; +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + params.fillCharacter = [NSNumber numberWithUnsignedChar:mRequest.fillCharacter]; +#endif // MTR_ENABLE_PROVISIONAL + uint16_t repeatCount = mRepeatCount.ValueOr(1); + uint16_t __block responsesNeeded = repeatCount; + while (repeatCount--) { + [cluster testSecondBatchHelperRequestWithParams:params completion: + ^(MTRUnitTestingClusterTestBatchHelperResponseParams * _Nullable values, NSError * _Nullable error) { + NSLog(@"Values: %@", values); + if (error == nil) { + constexpr chip::CommandId responseId = chip::app::Clusters::UnitTesting::Commands::TestBatchHelperResponse::Id; + RemoteDataModelLogger::LogCommandAsJSON(@(endpointId), @(clusterId), @(responseId), values); + } + responsesNeeded--; + if (error != nil) { + mError = error; + LogNSError("Error", error); + constexpr chip::CommandId responseId = chip::app::Clusters::UnitTesting::Commands::TestBatchHelperResponse::Id; + RemoteDataModelLogger::LogCommandErrorAsJSON(@(endpointId), @(clusterId), @(responseId), error); + } + if (responsesNeeded == 0) { + SetCommandExitStatus(mError); + } + }]; + } + return CHIP_NO_ERROR; + } + +private: + chip::app::Clusters::UnitTesting::Commands::TestSecondBatchHelperRequest::Type mRequest; +}; + +#endif // MTR_ENABLE_PROVISIONAL + /* * Attribute Boolean */ @@ -181084,6 +181229,12 @@ void registerClusterUnitTesting(Commands & commands) make_unique(), // make_unique(), // make_unique(), // +#if MTR_ENABLE_PROVISIONAL + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL make_unique(Id), // make_unique(Id), // make_unique(Id), // diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index d67b62285f449e..5a739fd0e02d9f 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -143224,7 +143224,7 @@ class TestCluster : public TestCommandBridge { { id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(18))); + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(20))); VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); VerifyOrReturn(CheckValue("", actualValue[1], 1UL)); VerifyOrReturn(CheckValue("", actualValue[2], 2UL)); @@ -143243,6 +143243,8 @@ class TestCluster : public TestCommandBridge { VerifyOrReturn(CheckValue("", actualValue[15], 19UL)); VerifyOrReturn(CheckValue("", actualValue[16], 20UL)); VerifyOrReturn(CheckValue("", actualValue[17], 21UL)); + VerifyOrReturn(CheckValue("", actualValue[18], 22UL)); + VerifyOrReturn(CheckValue("", actualValue[19], 23UL)); } NextTest(); @@ -143269,7 +143271,7 @@ class TestCluster : public TestCommandBridge { { id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(9))); + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(10))); VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); VerifyOrReturn(CheckValue("", actualValue[1], 1UL)); VerifyOrReturn(CheckValue("", actualValue[2], 4UL)); @@ -143279,6 +143281,7 @@ class TestCluster : public TestCommandBridge { VerifyOrReturn(CheckValue("", actualValue[6], 9UL)); VerifyOrReturn(CheckValue("", actualValue[7], 10UL)); VerifyOrReturn(CheckValue("", actualValue[8], 11UL)); + VerifyOrReturn(CheckValue("", actualValue[9], 12UL)); } NextTest();