From b64bcce0eba7a3d60bd480361b81b062632d9a00 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 31 Jul 2024 22:29:18 -0400 Subject: [PATCH] Add some bits to exercise global structs/enums to Unit Testing cluster. (#34540) * Adds things to the Unit Testing cluster XML. * This requires those things to be enabled in all-clusters-app, all-clusters-minimal-app, and one of the chef contact sensors to pass CI. * That requires an implementation in test-cluster-server * At which point might as well add a YAML test to exercise it all. --- .../all-clusters-app.matter | 25 + .../all-clusters-common/all-clusters-app.zap | 80 ++ .../all-clusters-minimal-app.matter | 25 + .../all-clusters-minimal-app.zap | 80 ++ .../rootnode_contactsensor_27f76aeaf5.matter | 25 + .../rootnode_contactsensor_27f76aeaf5.zap | 80 ++ .../test-cluster-server.cpp | 66 ++ src/app/tests/suites/TestCluster.yaml | 75 +- .../zcl/data-model/chip/test-cluster.xml | 29 + .../zcl/zcl-with-test-extensions.json | 4 +- src/app/zap-templates/zcl/zcl.json | 4 +- .../data_model/controller-clusters.matter | 19 + .../chip/devicecontroller/ChipClusters.java | 201 ++++ .../chip/devicecontroller/ChipStructs.java | 114 ++- .../devicecontroller/ClusterIDMapping.java | 22 + .../devicecontroller/ClusterInfoMapping.java | 109 +++ .../devicecontroller/ClusterReadMapping.java | 22 + .../devicecontroller/ClusterWriteMapping.java | 44 + .../chip/devicecontroller/cluster/files.gni | 1 + .../structs/UnitTestingClusterNestedStruct.kt | 18 +- .../structs/UnitTestingClusterSimpleStruct.kt | 16 +- .../UnitTestingClusterTestGlobalStruct.kt | 92 ++ .../cluster/clusters/UnitTestingCluster.kt | 866 +++++++++++++++--- .../java/matter/controller/cluster/files.gni | 1 + .../structs/UnitTestingClusterNestedStruct.kt | 18 +- .../structs/UnitTestingClusterSimpleStruct.kt | 16 +- .../UnitTestingClusterTestGlobalStruct.kt | 92 ++ .../cluster/ChipClusterEventStructTest.kt | 25 +- .../cluster/ChipClusterStructTest.kt | 120 ++- .../CHIPAttributeTLVValueDecoder.cpp | 336 ++++++- .../CHIPEventTLVValueDecoder.cpp | 47 +- .../python/chip/clusters/CHIPClusters.py | 36 + .../python/chip/clusters/Objects.py | 112 +++ .../CHIP/templates/availability.yaml | 37 +- .../MTRAttributeSpecifiedCheck.mm | 12 + .../MTRAttributeTLVValueDecoder.mm | 122 +++ .../CHIP/zap-generated/MTRBaseClusters.h | 39 + .../CHIP/zap-generated/MTRBaseClusters.mm | 344 +++++++ .../CHIP/zap-generated/MTRClusterConstants.h | 6 + .../CHIP/zap-generated/MTRClusterNames.mm | 16 + .../CHIP/zap-generated/MTRClusters.h | 17 + .../CHIP/zap-generated/MTRClusters.mm | 91 ++ .../zap-generated/MTRCommandPayloadsObjc.h | 53 ++ .../zap-generated/MTRCommandPayloadsObjc.mm | 314 +++++++ .../MTRCommandPayloads_Internal.h | 12 + .../zap-generated/MTREventTLVValueDecoder.mm | 10 + .../CHIP/zap-generated/MTRStructsObjc.h | 2 + .../CHIP/zap-generated/MTRStructsObjc.mm | 10 +- .../zap-generated/attributes/Accessors.cpp | 139 +++ .../zap-generated/attributes/Accessors.h | 23 + .../app-common/zap-generated/callback.h | 6 + .../zap-generated/cluster-objects.cpp | 96 ++ .../zap-generated/cluster-objects.h | 139 ++- .../app-common/zap-generated/ids/Attributes.h | 16 + .../app-common/zap-generated/ids/Commands.h | 8 + .../zap-generated/cluster/Commands.h | 64 ++ .../cluster/ComplexArgumentParser.cpp | 92 +- .../cluster/ComplexArgumentParser.h | 10 +- .../cluster/logging/DataModelLogger.cpp | 116 ++- .../cluster/logging/DataModelLogger.h | 8 +- .../zap-generated/cluster/Commands.h | 815 +++++++++++++++- 61 files changed, 5155 insertions(+), 282 deletions(-) create mode 100644 src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestGlobalStruct.kt create mode 100644 src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestGlobalStruct.kt 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 3dd2b0f99fb439..f69ed20583379c 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 @@ -6949,6 +6949,7 @@ internal cluster UnitTesting = 4294048773 { SimpleBitmap f = 5; single g = 6; double h = 7; + optional TestGlobalEnum i = 8; } fabric_scoped struct TestFabricScoped { @@ -6981,6 +6982,7 @@ internal cluster UnitTesting = 4294048773 { int8u a = 0; boolean b = 1; SimpleStruct c = 2; + optional TestGlobalStruct d = 3; } struct NestedStructList { @@ -7066,6 +7068,8 @@ internal cluster UnitTesting = 4294048773 { timedwrite attribute boolean timedWriteBoolean = 48; attribute boolean generalErrorBoolean = 49; attribute boolean clusterErrorBoolean = 50; + attribute TestGlobalEnum globalEnum = 51; + attribute TestGlobalStruct globalStruct = 52; attribute optional boolean unsupported = 255; attribute nullable boolean nullableBoolean = 16384; attribute nullable Bitmap8MaskMap nullableBitmap8 = 16385; @@ -7101,6 +7105,8 @@ internal cluster UnitTesting = 4294048773 { attribute nullable int16u nullableRangeRestrictedInt16u = 16424; attribute nullable int16s nullableRangeRestrictedInt16s = 16425; attribute optional int8u writeOnlyInt8u = 16426; + attribute nullable TestGlobalEnum nullableGlobalEnum = 16435; + attribute nullable TestGlobalStruct nullableGlobalStruct = 16436; attribute int8u meiInt8u = 4294070017; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -7252,6 +7258,11 @@ internal cluster UnitTesting = 4294048773 { SimpleEnum arg2 = 1; } + response struct GlobalEchoResponse = 14 { + TestGlobalStruct field1 = 0; + TestGlobalEnum field2 = 1; + } + request struct TestNullableOptionalRequestRequest { optional nullable int8u arg1 = 0; } @@ -7305,6 +7316,11 @@ internal cluster UnitTesting = 4294048773 { octet_string payload = 0; } + request struct GlobalEchoRequestRequest { + TestGlobalStruct field1 = 0; + TestGlobalEnum field2 = 1; + } + request struct TestDifferentVendorMeiRequestRequest { int8u arg1 = 0; } @@ -7388,6 +7404,9 @@ internal cluster UnitTesting = 4294048773 { the string back. If the string is large then it would require a session that supports large payloads. */ command StringEchoRequest(StringEchoRequestRequest): StringEchoResponse = 24; + /** Command that takes arguments that are global structs/enums and the + response just echoes them back. */ + command GlobalEchoRequest(GlobalEchoRequestRequest): GlobalEchoResponse = 25; /** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */ command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962; } @@ -9283,6 +9302,8 @@ endpoint 1 { ram attribute timedWriteBoolean; callback attribute generalErrorBoolean; callback attribute clusterErrorBoolean; + ram attribute globalEnum; + callback attribute globalStruct; ram attribute nullableBoolean default = false; ram attribute nullableBitmap8 default = 0; ram attribute nullableBitmap16 default = 0; @@ -9317,6 +9338,8 @@ endpoint 1 { ram attribute nullableRangeRestrictedInt16u default = 200; ram attribute nullableRangeRestrictedInt16s default = -100; callback attribute writeOnlyInt8u default = 0; + ram attribute nullableGlobalEnum; + callback attribute nullableGlobalStruct; ram attribute featureMap default = 0; ram attribute clusterRevision default = 1; ram attribute meiInt8u default = 0; @@ -9342,6 +9365,7 @@ endpoint 1 { handle command TestListInt8UReverseRequest; handle command StringEchoResponse; handle command TestEnumsRequest; + handle command GlobalEchoResponse; handle command TestNullableOptionalRequest; handle command SimpleStructEchoRequest; handle command TimedInvokeRequest; @@ -9351,6 +9375,7 @@ endpoint 1 { handle command TestBatchHelperRequest; handle command TestSecondBatchHelperRequest; handle command StringEchoRequest; + handle command GlobalEchoRequest; handle command TestDifferentVendorMeiRequest; handle command TestDifferentVendorMeiResponse; } 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 a052433002d237..7b3ccf977dbc2b 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 @@ -22341,6 +22341,14 @@ "isIncoming": 1, "isEnabled": 1 }, + { + "name": "GlobalEchoResponse", + "code": 14, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, { "name": "TestNullableOptionalRequest", "code": 15, @@ -22413,6 +22421,14 @@ "isIncoming": 1, "isEnabled": 1 }, + { + "name": "GlobalEchoRequest", + "code": 25, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, { "name": "TestDifferentVendorMeiRequest", "code": 4294049962, @@ -23183,6 +23199,38 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "global_enum", + "code": 51, + "mfgCode": null, + "side": "server", + "type": "TestGlobalEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "global_struct", + "code": 52, + "mfgCode": null, + "side": "server", + "type": "TestGlobalStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "nullable_boolean", "code": 16384, @@ -23727,6 +23775,38 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "nullable_global_enum", + "code": 16435, + "mfgCode": null, + "side": "server", + "type": "TestGlobalEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_global_struct", + "code": 16436, + "mfgCode": null, + "side": "server", + "type": "TestGlobalStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "FeatureMap", "code": 65532, 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 4bf0d15e54f799..7db7a1c97c61b0 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 @@ -5540,6 +5540,7 @@ internal cluster UnitTesting = 4294048773 { SimpleBitmap f = 5; single g = 6; double h = 7; + optional TestGlobalEnum i = 8; } fabric_scoped struct TestFabricScoped { @@ -5572,6 +5573,7 @@ internal cluster UnitTesting = 4294048773 { int8u a = 0; boolean b = 1; SimpleStruct c = 2; + optional TestGlobalStruct d = 3; } struct NestedStructList { @@ -5657,6 +5659,8 @@ internal cluster UnitTesting = 4294048773 { timedwrite attribute boolean timedWriteBoolean = 48; attribute boolean generalErrorBoolean = 49; attribute boolean clusterErrorBoolean = 50; + attribute TestGlobalEnum globalEnum = 51; + attribute TestGlobalStruct globalStruct = 52; attribute optional boolean unsupported = 255; attribute nullable boolean nullableBoolean = 16384; attribute nullable Bitmap8MaskMap nullableBitmap8 = 16385; @@ -5692,6 +5696,8 @@ internal cluster UnitTesting = 4294048773 { attribute nullable int16u nullableRangeRestrictedInt16u = 16424; attribute nullable int16s nullableRangeRestrictedInt16s = 16425; attribute optional int8u writeOnlyInt8u = 16426; + attribute nullable TestGlobalEnum nullableGlobalEnum = 16435; + attribute nullable TestGlobalStruct nullableGlobalStruct = 16436; attribute int8u meiInt8u = 4294070017; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -5843,6 +5849,11 @@ internal cluster UnitTesting = 4294048773 { SimpleEnum arg2 = 1; } + response struct GlobalEchoResponse = 14 { + TestGlobalStruct field1 = 0; + TestGlobalEnum field2 = 1; + } + request struct TestNullableOptionalRequestRequest { optional nullable int8u arg1 = 0; } @@ -5896,6 +5907,11 @@ internal cluster UnitTesting = 4294048773 { octet_string payload = 0; } + request struct GlobalEchoRequestRequest { + TestGlobalStruct field1 = 0; + TestGlobalEnum field2 = 1; + } + request struct TestDifferentVendorMeiRequestRequest { int8u arg1 = 0; } @@ -5979,6 +5995,9 @@ internal cluster UnitTesting = 4294048773 { the string back. If the string is large then it would require a session that supports large payloads. */ command StringEchoRequest(StringEchoRequestRequest): StringEchoResponse = 24; + /** Command that takes arguments that are global structs/enums and the + response just echoes them back. */ + command GlobalEchoRequest(GlobalEchoRequestRequest): GlobalEchoResponse = 25; /** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */ command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962; } @@ -6840,6 +6859,8 @@ endpoint 1 { ram attribute timedWriteBoolean; callback attribute generalErrorBoolean; callback attribute clusterErrorBoolean; + ram attribute globalEnum; + callback attribute globalStruct; ram attribute nullableBoolean default = false; ram attribute nullableBitmap8 default = 0; ram attribute nullableBitmap16 default = 0; @@ -6874,6 +6895,8 @@ endpoint 1 { ram attribute nullableRangeRestrictedInt16u default = 200; ram attribute nullableRangeRestrictedInt16s default = -100; callback attribute writeOnlyInt8u default = 0; + ram attribute nullableGlobalEnum; + callback attribute nullableGlobalStruct; ram attribute featureMap default = 0; ram attribute clusterRevision default = 1; ram attribute meiInt8u default = 0; @@ -6899,6 +6922,7 @@ endpoint 1 { handle command TestListInt8UReverseRequest; handle command StringEchoResponse; handle command TestEnumsRequest; + handle command GlobalEchoResponse; handle command TestNullableOptionalRequest; handle command SimpleStructEchoRequest; handle command TimedInvokeRequest; @@ -6908,6 +6932,7 @@ endpoint 1 { handle command TestBatchHelperRequest; handle command TestSecondBatchHelperRequest; handle command StringEchoRequest; + handle command GlobalEchoRequest; handle command TestDifferentVendorMeiRequest; handle command TestDifferentVendorMeiResponse; } diff --git a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap index 57f2c0412fca55..560e95a7ec180a 100644 --- a/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap +++ b/examples/all-clusters-minimal-app/all-clusters-common/all-clusters-minimal-app.zap @@ -9081,6 +9081,14 @@ "isIncoming": 1, "isEnabled": 1 }, + { + "name": "GlobalEchoResponse", + "code": 14, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, { "name": "TestNullableOptionalRequest", "code": 15, @@ -9153,6 +9161,14 @@ "isIncoming": 1, "isEnabled": 1 }, + { + "name": "GlobalEchoRequest", + "code": 25, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, { "name": "TestDifferentVendorMeiRequest", "code": 4294049962, @@ -9923,6 +9939,38 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "global_enum", + "code": 51, + "mfgCode": null, + "side": "server", + "type": "TestGlobalEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "global_struct", + "code": 52, + "mfgCode": null, + "side": "server", + "type": "TestGlobalStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "nullable_boolean", "code": 16384, @@ -10467,6 +10515,38 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "nullable_global_enum", + "code": 16435, + "mfgCode": null, + "side": "server", + "type": "TestGlobalEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_global_struct", + "code": 16436, + "mfgCode": null, + "side": "server", + "type": "TestGlobalStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "FeatureMap", "code": 65532, diff --git a/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.matter b/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.matter index 5735b2cf936ff4..6e7ce6b18132ea 100644 --- a/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.matter +++ b/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.matter @@ -1570,6 +1570,7 @@ internal cluster UnitTesting = 4294048773 { SimpleBitmap f = 5; single g = 6; double h = 7; + optional TestGlobalEnum i = 8; } fabric_scoped struct TestFabricScoped { @@ -1602,6 +1603,7 @@ internal cluster UnitTesting = 4294048773 { int8u a = 0; boolean b = 1; SimpleStruct c = 2; + optional TestGlobalStruct d = 3; } struct NestedStructList { @@ -1687,6 +1689,8 @@ internal cluster UnitTesting = 4294048773 { timedwrite attribute boolean timedWriteBoolean = 48; attribute boolean generalErrorBoolean = 49; attribute boolean clusterErrorBoolean = 50; + attribute TestGlobalEnum globalEnum = 51; + attribute TestGlobalStruct globalStruct = 52; attribute optional boolean unsupported = 255; attribute nullable boolean nullableBoolean = 16384; attribute nullable Bitmap8MaskMap nullableBitmap8 = 16385; @@ -1722,6 +1726,8 @@ internal cluster UnitTesting = 4294048773 { attribute nullable int16u nullableRangeRestrictedInt16u = 16424; attribute nullable int16s nullableRangeRestrictedInt16s = 16425; attribute optional int8u writeOnlyInt8u = 16426; + attribute nullable TestGlobalEnum nullableGlobalEnum = 16435; + attribute nullable TestGlobalStruct nullableGlobalStruct = 16436; attribute int8u meiInt8u = 4294070017; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -1873,6 +1879,11 @@ internal cluster UnitTesting = 4294048773 { SimpleEnum arg2 = 1; } + response struct GlobalEchoResponse = 14 { + TestGlobalStruct field1 = 0; + TestGlobalEnum field2 = 1; + } + request struct TestNullableOptionalRequestRequest { optional nullable int8u arg1 = 0; } @@ -1926,6 +1937,11 @@ internal cluster UnitTesting = 4294048773 { octet_string payload = 0; } + request struct GlobalEchoRequestRequest { + TestGlobalStruct field1 = 0; + TestGlobalEnum field2 = 1; + } + request struct TestDifferentVendorMeiRequestRequest { int8u arg1 = 0; } @@ -2009,6 +2025,9 @@ internal cluster UnitTesting = 4294048773 { the string back. If the string is large then it would require a session that supports large payloads. */ command StringEchoRequest(StringEchoRequestRequest): StringEchoResponse = 24; + /** Command that takes arguments that are global structs/enums and the + response just echoes them back. */ + command GlobalEchoRequest(GlobalEchoRequestRequest): GlobalEchoResponse = 25; /** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */ command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962; } @@ -2332,6 +2351,8 @@ endpoint 1 { ram attribute timedWriteBoolean; callback attribute generalErrorBoolean; callback attribute clusterErrorBoolean; + ram attribute globalEnum; + callback attribute globalStruct; ram attribute nullableBoolean default = false; ram attribute nullableBitmap8 default = 0; ram attribute nullableBitmap16 default = 0; @@ -2366,6 +2387,8 @@ endpoint 1 { ram attribute nullableRangeRestrictedInt16u default = 200; ram attribute nullableRangeRestrictedInt16s default = -100; callback attribute writeOnlyInt8u default = 0; + ram attribute nullableGlobalEnum; + callback attribute nullableGlobalStruct; ram attribute featureMap default = 0; ram attribute clusterRevision default = 1; ram attribute meiInt8u default = 0; @@ -2390,6 +2413,7 @@ endpoint 1 { handle command TestListNestedStructListArgumentRequest; handle command TestListInt8UReverseRequest; handle command TestEnumsRequest; + handle command GlobalEchoResponse; handle command TestNullableOptionalRequest; handle command SimpleStructEchoRequest; handle command TimedInvokeRequest; @@ -2398,6 +2422,7 @@ endpoint 1 { handle command TestEmitTestFabricScopedEventRequest; handle command TestBatchHelperRequest; handle command TestSecondBatchHelperRequest; + handle command GlobalEchoRequest; handle command TestDifferentVendorMeiRequest; handle command TestDifferentVendorMeiResponse; } diff --git a/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.zap b/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.zap index 590dea9f9f3c8e..02a553e03f9cd1 100644 --- a/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.zap +++ b/examples/chef/devices/rootnode_contactsensor_27f76aeaf5.zap @@ -3252,6 +3252,14 @@ "isIncoming": 1, "isEnabled": 1 }, + { + "name": "GlobalEchoResponse", + "code": 14, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + }, { "name": "TestNullableOptionalRequest", "code": 15, @@ -3316,6 +3324,14 @@ "isIncoming": 1, "isEnabled": 1 }, + { + "name": "GlobalEchoRequest", + "code": 25, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, { "name": "TestDifferentVendorMeiRequest", "code": 4294049962, @@ -4086,6 +4102,38 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "global_enum", + "code": 51, + "mfgCode": null, + "side": "server", + "type": "TestGlobalEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "global_struct", + "code": 52, + "mfgCode": null, + "side": "server", + "type": "TestGlobalStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "nullable_boolean", "code": 16384, @@ -4630,6 +4678,38 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "nullable_global_enum", + "code": 16435, + "mfgCode": null, + "side": "server", + "type": "TestGlobalEnum", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "nullable_global_struct", + "code": 16436, + "mfgCode": null, + "side": "server", + "type": "TestGlobalStruct", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "FeatureMap", "code": 65532, 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 4b6fc979336ab3..9bd925780524eb 100644 --- a/src/app/clusters/test-cluster-server/test-cluster-server.cpp +++ b/src/app/clusters/test-cluster-server/test-cluster-server.cpp @@ -101,8 +101,12 @@ class TestAttrAccess : public AttributeAccessInterface AttributeValueDecoder & aDecoder); CHIP_ERROR ReadStructAttribute(AttributeValueEncoder & aEncoder); CHIP_ERROR WriteStructAttribute(AttributeValueDecoder & aDecoder); + CHIP_ERROR ReadGlobalStruct(AttributeValueEncoder & aEncoder); + CHIP_ERROR WriteGlobalStruct(AttributeValueDecoder & aDecoder); CHIP_ERROR ReadNullableStruct(AttributeValueEncoder & aEncoder); CHIP_ERROR WriteNullableStruct(AttributeValueDecoder & aDecoder); + CHIP_ERROR ReadNullableGlobalStruct(AttributeValueEncoder & aEncoder); + CHIP_ERROR WriteNullableGlobalStruct(AttributeValueDecoder & aDecoder); CHIP_ERROR ReadListFabricScopedAttribute(AttributeValueEncoder & aEncoder); CHIP_ERROR WriteListFabricScopedAttribute(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder); }; @@ -126,7 +130,9 @@ size_t gListLongOctetStringLen = kAttributeListLength; Structs::TestListStructOctet::Type listStructOctetStringData[kAttributeListLength]; OctetStringData gStructAttributeByteSpanData; Structs::SimpleStruct::Type gStructAttributeValue; +Globals::Structs::TestGlobalStruct::Type gGlobalStructAttributeValue; NullableStruct::TypeInfo::Type gNullableStructAttributeValue; +DataModel::Nullable gNullableGlobalStructAttributeValue; chip::app::Clusters::UnitTesting::Structs::TestFabricScoped::Type gListFabricScopedAttributeValue[kAttributeListLength]; uint8_t gListFabricScoped_fabricSensitiveInt8uList[kAttributeListLength][kFabricSensitiveIntListLength]; @@ -198,6 +204,9 @@ CHIP_ERROR TestAttrAccess::Read(const ConcreteReadAttributePath & aPath, Attribu case StructAttr::Id: { return ReadStructAttribute(aEncoder); } + case GlobalStruct::Id: { + return ReadGlobalStruct(aEncoder); + } case ListLongOctetString::Id: { return ReadListLongOctetStringAttribute(aEncoder); } @@ -207,6 +216,9 @@ CHIP_ERROR TestAttrAccess::Read(const ConcreteReadAttributePath & aPath, Attribu case NullableStruct::Id: { return ReadNullableStruct(aEncoder); } + case NullableGlobalStruct::Id: { + return ReadNullableGlobalStruct(aEncoder); + } case GeneralErrorBoolean::Id: { return StatusIB(Protocols::InteractionModel::Status::InvalidDataType).ToChipError(); } @@ -249,9 +261,15 @@ CHIP_ERROR TestAttrAccess::Write(const ConcreteDataAttributePath & aPath, Attrib case StructAttr::Id: { return WriteStructAttribute(aDecoder); } + case GlobalStruct::Id: { + return WriteGlobalStruct(aDecoder); + } case NullableStruct::Id: { return WriteNullableStruct(aDecoder); } + case NullableGlobalStruct::Id: { + return WriteNullableGlobalStruct(aDecoder); + } case GeneralErrorBoolean::Id: { return StatusIB(Protocols::InteractionModel::Status::InvalidDataType).ToChipError(); } @@ -276,6 +294,26 @@ CHIP_ERROR TestAttrAccess::WriteNullableStruct(AttributeValueDecoder & aDecoder) return aDecoder.Decode(gNullableStructAttributeValue); } +CHIP_ERROR TestAttrAccess::ReadNullableGlobalStruct(AttributeValueEncoder & aEncoder) +{ + return aEncoder.Encode(gNullableGlobalStructAttributeValue); +} + +CHIP_ERROR TestAttrAccess::WriteNullableGlobalStruct(AttributeValueDecoder & aDecoder) +{ + Attributes::NullableGlobalStruct::TypeInfo::DecodableType temp; + ReturnErrorOnFailure(aDecoder.Decode(temp)); + + if (!temp.IsNull()) + { + // We don't support a nonempty charspan here for now. + VerifyOrReturnError(temp.Value().name.empty(), CHIP_ERROR_BUFFER_TOO_SMALL); + } + + gNullableGlobalStructAttributeValue = temp; + return CHIP_NO_ERROR; +} + CHIP_ERROR TestAttrAccess::ReadListInt8uAttribute(AttributeValueEncoder & aEncoder) { return aEncoder.EncodeList([](const auto & encoder) -> CHIP_ERROR { @@ -588,6 +626,23 @@ CHIP_ERROR TestAttrAccess::WriteStructAttribute(AttributeValueDecoder & aDecoder return CHIP_NO_ERROR; } +CHIP_ERROR TestAttrAccess::ReadGlobalStruct(AttributeValueEncoder & aEncoder) +{ + return aEncoder.Encode(gGlobalStructAttributeValue); +} + +CHIP_ERROR TestAttrAccess::WriteGlobalStruct(AttributeValueDecoder & aDecoder) +{ + // We don't support a nonempty charspan here for now. + Attributes::GlobalStruct::TypeInfo::DecodableType temp; + ReturnErrorOnFailure(aDecoder.Decode(temp)); + + VerifyOrReturnError(temp.name.empty(), CHIP_ERROR_BUFFER_TOO_SMALL); + + gGlobalStructAttributeValue = temp; + return CHIP_NO_ERROR; +} + CHIP_ERROR TestAttrAccess::ReadListFabricScopedAttribute(AttributeValueEncoder & aEncoder) { return aEncoder.EncodeList([](const auto & encoder) -> CHIP_ERROR { @@ -1114,6 +1169,17 @@ bool emberAfUnitTestingClusterTestSecondBatchHelperRequestCallback( commandData.fillCharacter); } +bool emberAfUnitTestingClusterGlobalEchoRequestCallback(CommandHandler * commandObj, const ConcreteCommandPath & commandPath, + const Commands::GlobalEchoRequest::DecodableType & commandData) +{ + Commands::GlobalEchoResponse::Type response; + response.field1 = commandData.field1; + response.field2 = commandData.field2; + + commandObj->AddResponse(commandPath, response); + return true; +} + // ----------------------------------------------------------------------------- // Plugin initialization diff --git a/src/app/tests/suites/TestCluster.yaml b/src/app/tests/suites/TestCluster.yaml index 308240a0dd537d..d2ff0cb2d0f27e 100644 --- a/src/app/tests/suites/TestCluster.yaml +++ b/src/app/tests/suites/TestCluster.yaml @@ -3912,6 +3912,7 @@ tests: 22, 23, 24, + 25, 4294049962, ] @@ -3919,7 +3920,7 @@ tests: command: "readAttribute" attribute: "GeneratedCommandList" response: - value: [0, 1, 4, 5, 6, 8, 9, 10, 11, 12, 13, 4294049979] + value: [0, 1, 4, 5, 6, 8, 9, 10, 11, 12, 13, 14, 4294049979] - label: "Validate presence of MEI attribute" command: "readAttribute" @@ -3960,3 +3961,75 @@ tests: g: 1.5, h: 3.14159265358979, } + + # Globals testing + - label: "Write global-struct-typed attribute" + command: "writeAttribute" + attribute: "global_struct" + arguments: + value: + { + Name: "", + MyBitmap: 0x02, + MyEnum: TestGlobalEnum.SomeOtherValue, + } + + - label: "Read global-struct-typed attribute" + command: "readAttribute" + attribute: "global_struct" + response: + value: { + # Purposefully using non-symbolic values to make sure things work right. + Name: "", + MyBitmap: 0x02, + MyEnum: 1, + } + + - label: "Write nullable global-struct-typed attribute" + command: "writeAttribute" + attribute: "nullable_global_struct" + arguments: + value: { Name: "", MyBitmap: 0x01, MyEnum: TestGlobalEnum.SomeValue } + + - label: "Read nullable global-struct-typed attribute" + command: "readAttribute" + attribute: "nullable_global_struct" + response: + value: { Name: "", MyBitmap: 0x01, MyEnum: 0 } + + - label: "Write nullable global-struct-typed attribute as null" + command: "writeAttribute" + attribute: "nullable_global_struct" + arguments: + value: null + + - label: "Read nullable global-struct-typed attribute a second time" + command: "readAttribute" + attribute: "nullable_global_struct" + response: + value: null + + - label: "Send a command with global types" + command: "GlobalEchoRequest" + arguments: + values: + - name: "field1" + value: + { + Name: "", + MyBitmap: 0x02, + MyEnum: TestGlobalEnum.FinalValue, + } + - name: "field2" + value: TestGlobalEnum.SomeOtherValue + response: + values: + - name: "field1" + value: + { + Name: "", + MyBitmap: 0x02, + MyEnum: TestGlobalEnum.FinalValue, + } + - name: "field2" + value: TestGlobalEnum.SomeOtherValue 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 f010838f933b03..c289ee9f1c4338 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 @@ -58,6 +58,7 @@ limitations under the License. + @@ -65,6 +66,7 @@ limitations under the License. + @@ -198,6 +200,9 @@ limitations under the License. cluster_error_boolean + global_enum + global_struct + nullable_boolean nullable_bitmap8 nullable_bitmap16 @@ -232,8 +237,14 @@ limitations under the License. nullable_range_restricted_int16u nullable_range_restricted_int16s + write_only_int8u + nullable_global_enum + nullable_global_struct + mei_int8u @@ -474,6 +485,16 @@ limitations under the License. + + + Command that takes arguments that are global structs/enums and the + response just echoes them back. + + + + + @@ -622,6 +643,14 @@ limitations under the License. + + + Response to GlobalEchoRequest. + + + + + Response to TestDifferentVendorMeiRequest, which is a command having a different MEI vendor ID than the cluster. diff --git a/src/app/zap-templates/zcl/zcl-with-test-extensions.json b/src/app/zap-templates/zcl/zcl-with-test-extensions.json index 4c5a59200e7d49..44de496f06f544 100644 --- a/src/app/zap-templates/zcl/zcl-with-test-extensions.json +++ b/src/app/zap-templates/zcl/zcl-with-test-extensions.json @@ -299,7 +299,9 @@ "struct_attr", "nullable_struct", "general_error_boolean", - "cluster_error_boolean" + "cluster_error_boolean", + "global_struct", + "nullable_global_struct" ], "Thread Border Router Management": [ "BorderRouterName", diff --git a/src/app/zap-templates/zcl/zcl.json b/src/app/zap-templates/zcl/zcl.json index 777847fb7f06ad..a72b44ee03084a 100644 --- a/src/app/zap-templates/zcl/zcl.json +++ b/src/app/zap-templates/zcl/zcl.json @@ -297,7 +297,9 @@ "struct_attr", "nullable_struct", "general_error_boolean", - "cluster_error_boolean" + "cluster_error_boolean", + "global_struct", + "nullable_global_struct" ], "Thread Border Router Management": [ "BorderRouterName", diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index 24a9e2fb45c2b0..c0e1f7cb0f2eb7 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -9747,6 +9747,7 @@ internal cluster UnitTesting = 4294048773 { SimpleBitmap f = 5; single g = 6; double h = 7; + optional TestGlobalEnum i = 8; } fabric_scoped struct TestFabricScoped { @@ -9779,6 +9780,7 @@ internal cluster UnitTesting = 4294048773 { int8u a = 0; boolean b = 1; SimpleStruct c = 2; + optional TestGlobalStruct d = 3; } struct NestedStructList { @@ -9864,6 +9866,8 @@ internal cluster UnitTesting = 4294048773 { timedwrite attribute boolean timedWriteBoolean = 48; attribute boolean generalErrorBoolean = 49; attribute boolean clusterErrorBoolean = 50; + attribute TestGlobalEnum globalEnum = 51; + attribute TestGlobalStruct globalStruct = 52; attribute optional boolean unsupported = 255; attribute nullable boolean nullableBoolean = 16384; attribute nullable Bitmap8MaskMap nullableBitmap8 = 16385; @@ -9899,6 +9903,8 @@ internal cluster UnitTesting = 4294048773 { attribute nullable int16u nullableRangeRestrictedInt16u = 16424; attribute nullable int16s nullableRangeRestrictedInt16s = 16425; attribute optional int8u writeOnlyInt8u = 16426; + attribute nullable TestGlobalEnum nullableGlobalEnum = 16435; + attribute nullable TestGlobalStruct nullableGlobalStruct = 16436; attribute int8u meiInt8u = 4294070017; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -10050,6 +10056,11 @@ internal cluster UnitTesting = 4294048773 { SimpleEnum arg2 = 1; } + response struct GlobalEchoResponse = 14 { + TestGlobalStruct field1 = 0; + TestGlobalEnum field2 = 1; + } + request struct TestNullableOptionalRequestRequest { optional nullable int8u arg1 = 0; } @@ -10103,6 +10114,11 @@ internal cluster UnitTesting = 4294048773 { octet_string payload = 0; } + request struct GlobalEchoRequestRequest { + TestGlobalStruct field1 = 0; + TestGlobalEnum field2 = 1; + } + request struct TestDifferentVendorMeiRequestRequest { int8u arg1 = 0; } @@ -10186,6 +10202,9 @@ internal cluster UnitTesting = 4294048773 { the string back. If the string is large then it would require a session that supports large payloads. */ command StringEchoRequest(StringEchoRequestRequest): StringEchoResponse = 24; + /** Command that takes arguments that are global structs/enums and the + response just echoes them back. */ + command GlobalEchoRequest(GlobalEchoRequestRequest): GlobalEchoResponse = 25; /** Command having a different MEI vendor ID than the cluster. Also emits TestDifferentVendorMeiEvent. */ command TestDifferentVendorMeiRequest(TestDifferentVendorMeiRequestRequest): TestDifferentVendorMeiResponse = 4294049962; } diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java index f7fc1ea6955305..e8ba5badd39616 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java @@ -65210,6 +65210,8 @@ public static class UnitTestingCluster extends BaseChipCluster { private static final long TIMED_WRITE_BOOLEAN_ATTRIBUTE_ID = 48L; private static final long GENERAL_ERROR_BOOLEAN_ATTRIBUTE_ID = 49L; private static final long CLUSTER_ERROR_BOOLEAN_ATTRIBUTE_ID = 50L; + private static final long GLOBAL_ENUM_ATTRIBUTE_ID = 51L; + private static final long GLOBAL_STRUCT_ATTRIBUTE_ID = 52L; private static final long UNSUPPORTED_ATTRIBUTE_ID = 255L; private static final long NULLABLE_BOOLEAN_ATTRIBUTE_ID = 16384L; private static final long NULLABLE_BITMAP8_ATTRIBUTE_ID = 16385L; @@ -65245,6 +65247,8 @@ public static class UnitTestingCluster extends BaseChipCluster { private static final long NULLABLE_RANGE_RESTRICTED_INT16U_ATTRIBUTE_ID = 16424L; private static final long NULLABLE_RANGE_RESTRICTED_INT16S_ATTRIBUTE_ID = 16425L; private static final long WRITE_ONLY_INT8U_ATTRIBUTE_ID = 16426L; + private static final long NULLABLE_GLOBAL_ENUM_ATTRIBUTE_ID = 16435L; + private static final long NULLABLE_GLOBAL_STRUCT_ATTRIBUTE_ID = 16436L; private static final long MEI_INT8U_ATTRIBUTE_ID = 4294070017L; private static final long GENERATED_COMMAND_LIST_ATTRIBUTE_ID = 65528L; private static final long ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID = 65529L; @@ -66288,6 +66292,47 @@ public void onResponse(StructType invokeStructValue) { }}, commandId, commandArgs, timedInvokeTimeoutMs); } + public void globalEchoRequest(GlobalEchoResponseCallback callback, ChipStructs.UnitTestingClusterTestGlobalStruct field1, Integer field2) { + globalEchoRequest(callback, field1, field2, 0); + } + + public void globalEchoRequest(GlobalEchoResponseCallback callback, ChipStructs.UnitTestingClusterTestGlobalStruct field1, Integer field2, int timedInvokeTimeoutMs) { + final long commandId = 25L; + + ArrayList elements = new ArrayList<>(); + final long field1FieldID = 0L; + BaseTLVType field1tlvValue = field1.encodeTlv(); + elements.add(new StructElement(field1FieldID, field1tlvValue)); + + final long field2FieldID = 1L; + BaseTLVType field2tlvValue = new UIntType(field2); + elements.add(new StructElement(field2FieldID, field2tlvValue)); + + StructType commandArgs = new StructType(elements); + invoke(new InvokeCallbackImpl(callback) { + @Override + public void onResponse(StructType invokeStructValue) { + final long field1FieldID = 0L; + ChipStructs.UnitTestingClusterTestGlobalStruct field1 = null; + final long field2FieldID = 1L; + Integer field2 = null; + for (StructElement element: invokeStructValue.value()) { + if (element.contextTagNum() == field1FieldID) { + if (element.value(BaseTLVType.class).type() == TLVType.Struct) { + StructType castingValue = element.value(StructType.class); + field1 = ChipStructs.UnitTestingClusterTestGlobalStruct.decodeTlv(castingValue); + } + } else if (element.contextTagNum() == field2FieldID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + field2 = castingValue.value(Integer.class); + } + } + } + callback.onSuccess(field1, field2); + }}, commandId, commandArgs, timedInvokeTimeoutMs); + } + public void testDifferentVendorMeiRequest(TestDifferentVendorMeiResponseCallback callback, Integer arg1) { testDifferentVendorMeiRequest(callback, arg1, 0); } @@ -66381,6 +66426,10 @@ public interface StringEchoResponseCallback extends BaseClusterCallback { void onSuccess(byte[] payload); } + public interface GlobalEchoResponseCallback extends BaseClusterCallback { + void onSuccess(ChipStructs.UnitTestingClusterTestGlobalStruct field1, Integer field2); + } + public interface TestDifferentVendorMeiResponseCallback extends BaseClusterCallback { void onSuccess(Integer arg1, Long eventNumber); } @@ -66413,6 +66462,10 @@ public interface ListFabricScopedAttributeCallback extends BaseAttributeCallback void onSuccess(List value); } + public interface GlobalStructAttributeCallback extends BaseAttributeCallback { + void onSuccess(ChipStructs.UnitTestingClusterTestGlobalStruct value); + } + public interface NullableBooleanAttributeCallback extends BaseAttributeCallback { void onSuccess(@Nullable Boolean value); } @@ -66545,6 +66598,14 @@ public interface NullableRangeRestrictedInt16sAttributeCallback extends BaseAttr void onSuccess(@Nullable Integer value); } + public interface NullableGlobalEnumAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable Integer value); + } + + public interface NullableGlobalStructAttributeCallback extends BaseAttributeCallback { + void onSuccess(@Nullable ChipStructs.UnitTestingClusterTestGlobalStruct value); + } + public interface GeneratedCommandListAttributeCallback extends BaseAttributeCallback { void onSuccess(List value); } @@ -68207,6 +68268,76 @@ public void onSuccess(byte[] tlv) { }, CLUSTER_ERROR_BOOLEAN_ATTRIBUTE_ID, minInterval, maxInterval); } + public void readGlobalEnumAttribute( + IntegerAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GLOBAL_ENUM_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, GLOBAL_ENUM_ATTRIBUTE_ID, true); + } + + public void writeGlobalEnumAttribute(DefaultClusterCallback callback, Integer value) { + writeGlobalEnumAttribute(callback, value, 0); + } + + public void writeGlobalEnumAttribute(DefaultClusterCallback callback, Integer value, int timedWriteTimeoutMs) { + BaseTLVType tlvValue = new UIntType(value); + writeAttribute(new WriteAttributesCallbackImpl(callback), GLOBAL_ENUM_ATTRIBUTE_ID, tlvValue, timedWriteTimeoutMs); + } + + public void subscribeGlobalEnumAttribute( + IntegerAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GLOBAL_ENUM_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, GLOBAL_ENUM_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readGlobalStructAttribute( + GlobalStructAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GLOBAL_STRUCT_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + ChipStructs.UnitTestingClusterTestGlobalStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, GLOBAL_STRUCT_ATTRIBUTE_ID, true); + } + + public void writeGlobalStructAttribute(DefaultClusterCallback callback, ChipStructs.UnitTestingClusterTestGlobalStruct value) { + writeGlobalStructAttribute(callback, value, 0); + } + + public void writeGlobalStructAttribute(DefaultClusterCallback callback, ChipStructs.UnitTestingClusterTestGlobalStruct value, int timedWriteTimeoutMs) { + BaseTLVType tlvValue = value.encodeTlv(); + writeAttribute(new WriteAttributesCallbackImpl(callback), GLOBAL_STRUCT_ATTRIBUTE_ID, tlvValue, timedWriteTimeoutMs); + } + + public void subscribeGlobalStructAttribute( + GlobalStructAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GLOBAL_STRUCT_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + ChipStructs.UnitTestingClusterTestGlobalStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, GLOBAL_STRUCT_ATTRIBUTE_ID, minInterval, maxInterval); + } + public void readUnsupportedAttribute( BooleanAttributeCallback callback) { ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, UNSUPPORTED_ATTRIBUTE_ID); @@ -69432,6 +69563,76 @@ public void onSuccess(byte[] tlv) { }, WRITE_ONLY_INT8U_ATTRIBUTE_ID, minInterval, maxInterval); } + public void readNullableGlobalEnumAttribute( + NullableGlobalEnumAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, NULLABLE_GLOBAL_ENUM_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, NULLABLE_GLOBAL_ENUM_ATTRIBUTE_ID, true); + } + + public void writeNullableGlobalEnumAttribute(DefaultClusterCallback callback, Integer value) { + writeNullableGlobalEnumAttribute(callback, value, 0); + } + + public void writeNullableGlobalEnumAttribute(DefaultClusterCallback callback, Integer value, int timedWriteTimeoutMs) { + BaseTLVType tlvValue = value != null ? new UIntType(value) : new NullType(); + writeAttribute(new WriteAttributesCallbackImpl(callback), NULLABLE_GLOBAL_ENUM_ATTRIBUTE_ID, tlvValue, timedWriteTimeoutMs); + } + + public void subscribeNullableGlobalEnumAttribute( + NullableGlobalEnumAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, NULLABLE_GLOBAL_ENUM_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, NULLABLE_GLOBAL_ENUM_ATTRIBUTE_ID, minInterval, maxInterval); + } + + public void readNullableGlobalStructAttribute( + NullableGlobalStructAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, NULLABLE_GLOBAL_STRUCT_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.UnitTestingClusterTestGlobalStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, NULLABLE_GLOBAL_STRUCT_ATTRIBUTE_ID, true); + } + + public void writeNullableGlobalStructAttribute(DefaultClusterCallback callback, ChipStructs.UnitTestingClusterTestGlobalStruct value) { + writeNullableGlobalStructAttribute(callback, value, 0); + } + + public void writeNullableGlobalStructAttribute(DefaultClusterCallback callback, ChipStructs.UnitTestingClusterTestGlobalStruct value, int timedWriteTimeoutMs) { + BaseTLVType tlvValue = value != null ? value.encodeTlv() : new NullType(); + writeAttribute(new WriteAttributesCallbackImpl(callback), NULLABLE_GLOBAL_STRUCT_ATTRIBUTE_ID, tlvValue, timedWriteTimeoutMs); + } + + public void subscribeNullableGlobalStructAttribute( + NullableGlobalStructAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, NULLABLE_GLOBAL_STRUCT_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + @Nullable ChipStructs.UnitTestingClusterTestGlobalStruct value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, NULLABLE_GLOBAL_STRUCT_ATTRIBUTE_ID, minInterval, maxInterval); + } + public void readMeiInt8uAttribute( IntegerAttributeCallback callback) { ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, MEI_INT8U_ATTRIBUTE_ID); diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java b/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java index df78372f96c945..5ab4c29beb623b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java @@ -12899,6 +12899,7 @@ public static class UnitTestingClusterSimpleStruct { public Integer f; public Float g; public Double h; + public Optional i; private static final long A_ID = 0L; private static final long B_ID = 1L; private static final long C_ID = 2L; @@ -12907,6 +12908,7 @@ public static class UnitTestingClusterSimpleStruct { private static final long F_ID = 5L; private static final long G_ID = 6L; private static final long H_ID = 7L; + private static final long I_ID = 8L; public UnitTestingClusterSimpleStruct( Integer a, @@ -12916,7 +12918,8 @@ public UnitTestingClusterSimpleStruct( String e, Integer f, Float g, - Double h + Double h, + Optional i ) { this.a = a; this.b = b; @@ -12926,6 +12929,7 @@ public UnitTestingClusterSimpleStruct( this.f = f; this.g = g; this.h = h; + this.i = i; } public StructType encodeTlv() { @@ -12938,6 +12942,7 @@ public StructType encodeTlv() { values.add(new StructElement(F_ID, new UIntType(f))); values.add(new StructElement(G_ID, new FloatType(g))); values.add(new StructElement(H_ID, new DoubleType(h))); + values.add(new StructElement(I_ID, i.map((nonOptionali) -> new UIntType(nonOptionali)).orElse(new EmptyType()))); return new StructType(values); } @@ -12954,6 +12959,7 @@ public static UnitTestingClusterSimpleStruct decodeTlv(BaseTLVType tlvValue) { Integer f = null; Float g = null; Double h = null; + Optional i = Optional.empty(); for (StructElement element: ((StructType)tlvValue).value()) { if (element.contextTagNum() == A_ID) { if (element.value(BaseTLVType.class).type() == TLVType.UInt) { @@ -12995,6 +13001,11 @@ public static UnitTestingClusterSimpleStruct decodeTlv(BaseTLVType tlvValue) { DoubleType castingValue = element.value(DoubleType.class); h = castingValue.value(Double.class); } + } else if (element.contextTagNum() == I_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + i = Optional.of(castingValue.value(Integer.class)); + } } } return new UnitTestingClusterSimpleStruct( @@ -13005,7 +13016,8 @@ public static UnitTestingClusterSimpleStruct decodeTlv(BaseTLVType tlvValue) { e, f, g, - h + h, + i ); } @@ -13037,6 +13049,9 @@ public String toString() { output.append("\th: "); output.append(h); output.append("\n"); + output.append("\ti: "); + output.append(i); + output.append("\n"); output.append("}\n"); return output.toString(); } @@ -13407,18 +13422,22 @@ public static class UnitTestingClusterNestedStruct { public Integer a; public Boolean b; public ChipStructs.UnitTestingClusterSimpleStruct c; + public Optional d; private static final long A_ID = 0L; private static final long B_ID = 1L; private static final long C_ID = 2L; + private static final long D_ID = 3L; public UnitTestingClusterNestedStruct( Integer a, Boolean b, - ChipStructs.UnitTestingClusterSimpleStruct c + ChipStructs.UnitTestingClusterSimpleStruct c, + Optional d ) { this.a = a; this.b = b; this.c = c; + this.d = d; } public StructType encodeTlv() { @@ -13426,6 +13445,7 @@ public StructType encodeTlv() { values.add(new StructElement(A_ID, new UIntType(a))); values.add(new StructElement(B_ID, new BooleanType(b))); values.add(new StructElement(C_ID, c.encodeTlv())); + values.add(new StructElement(D_ID, d.map((nonOptionald) -> nonOptionald.encodeTlv()).orElse(new EmptyType()))); return new StructType(values); } @@ -13437,6 +13457,7 @@ public static UnitTestingClusterNestedStruct decodeTlv(BaseTLVType tlvValue) { Integer a = null; Boolean b = null; ChipStructs.UnitTestingClusterSimpleStruct c = null; + Optional d = Optional.empty(); for (StructElement element: ((StructType)tlvValue).value()) { if (element.contextTagNum() == A_ID) { if (element.value(BaseTLVType.class).type() == TLVType.UInt) { @@ -13453,12 +13474,18 @@ public static UnitTestingClusterNestedStruct decodeTlv(BaseTLVType tlvValue) { StructType castingValue = element.value(StructType.class); c = ChipStructs.UnitTestingClusterSimpleStruct.decodeTlv(castingValue); } + } else if (element.contextTagNum() == D_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.Struct) { + StructType castingValue = element.value(StructType.class); + d = Optional.of(ChipStructs.UnitTestingClusterTestGlobalStruct.decodeTlv(castingValue)); + } } } return new UnitTestingClusterNestedStruct( a, b, - c + c, + d ); } @@ -13475,6 +13502,9 @@ public String toString() { output.append("\tc: "); output.append(c); output.append("\n"); + output.append("\td: "); + output.append(d); + output.append("\n"); output.append("}\n"); return output.toString(); } @@ -13722,4 +13752,80 @@ public String toString() { return output.toString(); } } +public static class UnitTestingClusterTestGlobalStruct { + public String name; + public @Nullable Long myBitmap; + public @Nullable Optional myEnum; + private static final long NAME_ID = 0L; + private static final long MY_BITMAP_ID = 1L; + private static final long MY_ENUM_ID = 2L; + + public UnitTestingClusterTestGlobalStruct( + String name, + @Nullable Long myBitmap, + @Nullable Optional myEnum + ) { + this.name = name; + this.myBitmap = myBitmap; + this.myEnum = myEnum; + } + + public StructType encodeTlv() { + ArrayList values = new ArrayList<>(); + values.add(new StructElement(NAME_ID, new StringType(name))); + values.add(new StructElement(MY_BITMAP_ID, myBitmap != null ? new UIntType(myBitmap) : new NullType())); + values.add(new StructElement(MY_ENUM_ID, myEnum != null ? myEnum.map((nonOptionalmyEnum) -> new UIntType(nonOptionalmyEnum)).orElse(new EmptyType()) : new NullType())); + + return new StructType(values); + } + + public static UnitTestingClusterTestGlobalStruct decodeTlv(BaseTLVType tlvValue) { + if (tlvValue == null || tlvValue.type() != TLVType.Struct) { + return null; + } + String name = null; + @Nullable Long myBitmap = null; + @Nullable Optional myEnum = null; + for (StructElement element: ((StructType)tlvValue).value()) { + if (element.contextTagNum() == NAME_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.String) { + StringType castingValue = element.value(StringType.class); + name = castingValue.value(String.class); + } + } else if (element.contextTagNum() == MY_BITMAP_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + myBitmap = castingValue.value(Long.class); + } + } else if (element.contextTagNum() == MY_ENUM_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + myEnum = Optional.of(castingValue.value(Integer.class)); + } + } + } + return new UnitTestingClusterTestGlobalStruct( + name, + myBitmap, + myEnum + ); + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("UnitTestingClusterTestGlobalStruct {\n"); + output.append("\tname: "); + output.append(name); + output.append("\n"); + output.append("\tmyBitmap: "); + output.append(myBitmap); + output.append("\n"); + output.append("\tmyEnum: "); + output.append(myEnum); + output.append("\n"); + output.append("}\n"); + return output.toString(); + } +} } diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java index 37936a56fba6a6..bad71209a40272 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java @@ -17755,6 +17755,8 @@ public enum Attribute { TimedWriteBoolean(48L), GeneralErrorBoolean(49L), ClusterErrorBoolean(50L), + GlobalEnum(51L), + GlobalStruct(52L), Unsupported(255L), NullableBoolean(16384L), NullableBitmap8(16385L), @@ -17790,6 +17792,8 @@ public enum Attribute { NullableRangeRestrictedInt16u(16424L), NullableRangeRestrictedInt16s(16425L), WriteOnlyInt8u(16426L), + NullableGlobalEnum(16435L), + NullableGlobalStruct(16436L), MeiInt8u(4294070017L), GeneratedCommandList(65528L), AcceptedCommandList(65529L), @@ -17865,6 +17869,7 @@ public enum Command { TestBatchHelperRequest(22L), TestSecondBatchHelperRequest(23L), StringEchoRequest(24L), + GlobalEchoRequest(25L), TestDifferentVendorMeiRequest(4294049962L),; private final long id; Command(long id) { @@ -18223,6 +18228,23 @@ public static StringEchoRequestCommandField value(int id) throws NoSuchFieldErro } throw new NoSuchFieldError(); } + }public enum GlobalEchoRequestCommandField {Field1(0),Field2(1),; + private final int id; + GlobalEchoRequestCommandField(int id) { + this.id = id; + } + + public int getID() { + return id; + } + public static GlobalEchoRequestCommandField value(int id) throws NoSuchFieldError { + for (GlobalEchoRequestCommandField field : GlobalEchoRequestCommandField.values()) { + if (field.getID() == id) { + return field; + } + } + throw new NoSuchFieldError(); + } }public enum TestDifferentVendorMeiRequestCommandField {Arg1(0),; private final int id; TestDifferentVendorMeiRequestCommandField(int id) { diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java index 2ba2e50bb11ee8..1d398ff42e2c9d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java @@ -20908,6 +20908,30 @@ public void onError(Exception error) { } } + public static class DelegatedUnitTestingClusterGlobalEchoResponseCallback implements ChipClusters.UnitTestingCluster.GlobalEchoResponseCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(ChipStructs.UnitTestingClusterTestGlobalStruct field1, Integer field2) { + Map responseValues = new LinkedHashMap<>(); + + // field1: Struct TestGlobalStruct + // Conversion from this type to Java is not properly implemented yet + CommandResponseInfo field2ResponseValue = new CommandResponseInfo("field2", "Integer"); + responseValues.put(field2ResponseValue, field2); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception error) { + callback.onFailure(error); + } + } + public static class DelegatedUnitTestingClusterTestDifferentVendorMeiResponseCallback implements ChipClusters.UnitTestingCluster.TestDifferentVendorMeiResponseCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override @@ -21078,6 +21102,27 @@ public void onError(Exception ex) { } } + public static class DelegatedUnitTestingClusterGlobalStructAttributeCallback implements ChipClusters.UnitTestingCluster.GlobalStructAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(ChipStructs.UnitTestingClusterTestGlobalStruct value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "ChipStructs.UnitTestingClusterTestGlobalStruct"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + public static class DelegatedUnitTestingClusterNullableBooleanAttributeCallback implements ChipClusters.UnitTestingCluster.NullableBooleanAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override @@ -21771,6 +21816,48 @@ public void onError(Exception ex) { } } + public static class DelegatedUnitTestingClusterNullableGlobalEnumAttributeCallback implements ChipClusters.UnitTestingCluster.NullableGlobalEnumAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable Integer value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "Integer"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + + public static class DelegatedUnitTestingClusterNullableGlobalStructAttributeCallback implements ChipClusters.UnitTestingCluster.NullableGlobalStructAttributeCallback, DelegatedClusterCallback { + private ClusterCommandCallback callback; + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess(@Nullable ChipStructs.UnitTestingClusterTestGlobalStruct value) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = new CommandResponseInfo("value", "ChipStructs.UnitTestingClusterTestGlobalStruct"); + responseValues.put(commandResponseInfo, value); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + public static class DelegatedUnitTestingClusterGeneratedCommandListAttributeCallback implements ChipClusters.UnitTestingCluster.GeneratedCommandListAttributeCallback, DelegatedClusterCallback { private ClusterCommandCallback callback; @Override @@ -29576,6 +29663,28 @@ public Map> getCommandMap() { ); unitTestingClusterInteractionInfoMap.put("stringEchoRequest", unitTestingstringEchoRequestInteractionInfo); + Map unitTestingglobalEchoRequestCommandParams = new LinkedHashMap(); + + + CommandParameterInfo unitTestingglobalEchoRequestfield2CommandParameterInfo = new CommandParameterInfo("field2", Integer.class, Integer.class); + unitTestingglobalEchoRequestCommandParams.put("field2",unitTestingglobalEchoRequestfield2CommandParameterInfo); + InteractionInfo unitTestingglobalEchoRequestInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.UnitTestingCluster) cluster) + .globalEchoRequest((ChipClusters.UnitTestingCluster.GlobalEchoResponseCallback) callback + , (ChipStructs.UnitTestingClusterTestGlobalStruct) + commandArguments.get("field1") + + , (Integer) + commandArguments.get("field2") + + ); + }, + () -> new DelegatedUnitTestingClusterGlobalEchoResponseCallback(), + unitTestingglobalEchoRequestCommandParams + ); + unitTestingClusterInteractionInfoMap.put("globalEchoRequest", unitTestingglobalEchoRequestInteractionInfo); + Map unitTestingtestDifferentVendorMeiRequestCommandParams = new LinkedHashMap(); CommandParameterInfo unitTestingtestDifferentVendorMeiRequestarg1CommandParameterInfo = new CommandParameterInfo("arg1", Integer.class, Integer.class); diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java index 417ecce949fdc9..32d3d4f1a51756 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java @@ -20846,6 +20846,17 @@ private static Map readUnitTestingInteractionInfo() { readUnitTestingClusterErrorBooleanCommandParams ); result.put("readClusterErrorBooleanAttribute", readUnitTestingClusterErrorBooleanAttributeInteractionInfo); + Map readUnitTestingGlobalEnumCommandParams = new LinkedHashMap(); + InteractionInfo readUnitTestingGlobalEnumAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.UnitTestingCluster) cluster).readGlobalEnumAttribute( + (ChipClusters.IntegerAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), + readUnitTestingGlobalEnumCommandParams + ); + result.put("readGlobalEnumAttribute", readUnitTestingGlobalEnumAttributeInteractionInfo); Map readUnitTestingUnsupportedCommandParams = new LinkedHashMap(); InteractionInfo readUnitTestingUnsupportedAttributeInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { @@ -21220,6 +21231,17 @@ private static Map readUnitTestingInteractionInfo() { readUnitTestingWriteOnlyInt8uCommandParams ); result.put("readWriteOnlyInt8uAttribute", readUnitTestingWriteOnlyInt8uAttributeInteractionInfo); + Map readUnitTestingNullableGlobalEnumCommandParams = new LinkedHashMap(); + InteractionInfo readUnitTestingNullableGlobalEnumAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.UnitTestingCluster) cluster).readNullableGlobalEnumAttribute( + (ChipClusters.UnitTestingCluster.NullableGlobalEnumAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedUnitTestingClusterNullableGlobalEnumAttributeCallback(), + readUnitTestingNullableGlobalEnumCommandParams + ); + result.put("readNullableGlobalEnumAttribute", readUnitTestingNullableGlobalEnumAttributeInteractionInfo); Map readUnitTestingMeiInt8uCommandParams = new LinkedHashMap(); InteractionInfo readUnitTestingMeiInt8uAttributeInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java index 32759bb97af64c..93a48d76bf61dc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterWriteMapping.java @@ -4827,6 +4827,28 @@ public Map> getWriteAttributeMap() { writeUnitTestingClusterErrorBooleanCommandParams ); writeUnitTestingInteractionInfo.put("writeClusterErrorBooleanAttribute", writeUnitTestingClusterErrorBooleanAttributeInteractionInfo); + Map writeUnitTestingGlobalEnumCommandParams = new LinkedHashMap(); + CommandParameterInfo unitTestingglobalEnumCommandParameterInfo = + new CommandParameterInfo( + "value", + Integer.class, + Integer.class + ); + writeUnitTestingGlobalEnumCommandParams.put( + "value", + unitTestingglobalEnumCommandParameterInfo + ); + InteractionInfo writeUnitTestingGlobalEnumAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.UnitTestingCluster) cluster).writeGlobalEnumAttribute( + (DefaultClusterCallback) callback, + (Integer) commandArguments.get("value") + ); + }, + () -> new ClusterInfoMapping.DelegatedDefaultClusterCallback(), + writeUnitTestingGlobalEnumCommandParams + ); + writeUnitTestingInteractionInfo.put("writeGlobalEnumAttribute", writeUnitTestingGlobalEnumAttributeInteractionInfo); Map writeUnitTestingUnsupportedCommandParams = new LinkedHashMap(); CommandParameterInfo unitTestingunsupportedCommandParameterInfo = new CommandParameterInfo( @@ -5575,6 +5597,28 @@ public Map> getWriteAttributeMap() { writeUnitTestingWriteOnlyInt8uCommandParams ); writeUnitTestingInteractionInfo.put("writeWriteOnlyInt8uAttribute", writeUnitTestingWriteOnlyInt8uAttributeInteractionInfo); + Map writeUnitTestingNullableGlobalEnumCommandParams = new LinkedHashMap(); + CommandParameterInfo unitTestingnullableGlobalEnumCommandParameterInfo = + new CommandParameterInfo( + "value", + Integer.class, + Integer.class + ); + writeUnitTestingNullableGlobalEnumCommandParams.put( + "value", + unitTestingnullableGlobalEnumCommandParameterInfo + ); + InteractionInfo writeUnitTestingNullableGlobalEnumAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.UnitTestingCluster) cluster).writeNullableGlobalEnumAttribute( + (DefaultClusterCallback) callback, + (Integer) commandArguments.get("value") + ); + }, + () -> new ClusterInfoMapping.DelegatedDefaultClusterCallback(), + writeUnitTestingNullableGlobalEnumCommandParams + ); + writeUnitTestingInteractionInfo.put("writeNullableGlobalEnumAttribute", writeUnitTestingNullableGlobalEnumAttributeInteractionInfo); Map writeUnitTestingMeiInt8uCommandParams = new LinkedHashMap(); CommandParameterInfo unitTestingmeiInt8uCommandParameterInfo = new CommandParameterInfo( diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni b/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni index e101562093412c..3cbd5cb52ce17a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni @@ -151,6 +151,7 @@ structs_sources = [ "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestFabricScoped.kt", + "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestGlobalStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestListStructOctet.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UserLabelClusterLabelStruct.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/WaterHeaterModeClusterModeOptionStruct.kt", diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt index 6ec856c422029a..74cfa88e79291f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt @@ -17,6 +17,7 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -26,12 +27,14 @@ class UnitTestingClusterNestedStruct( val a: UInt, val b: Boolean, val c: UnitTestingClusterSimpleStruct, + val d: Optional, ) { override fun toString(): String = buildString { append("UnitTestingClusterNestedStruct {\n") append("\ta : $a\n") append("\tb : $b\n") append("\tc : $c\n") + append("\td : $d\n") append("}\n") } @@ -41,6 +44,10 @@ class UnitTestingClusterNestedStruct( put(ContextSpecificTag(TAG_A), a) put(ContextSpecificTag(TAG_B), b) c.toTlv(ContextSpecificTag(TAG_C), this) + if (d.isPresent) { + val optd = d.get() + optd.toTlv(ContextSpecificTag(TAG_D), this) + } endStructure() } } @@ -49,16 +56,25 @@ class UnitTestingClusterNestedStruct( private const val TAG_A = 0 private const val TAG_B = 1 private const val TAG_C = 2 + private const val TAG_D = 3 fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterNestedStruct { tlvReader.enterStructure(tlvTag) val a = tlvReader.getUInt(ContextSpecificTag(TAG_A)) val b = tlvReader.getBoolean(ContextSpecificTag(TAG_B)) val c = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_C), tlvReader) + val d = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_D))) { + Optional.of( + UnitTestingClusterTestGlobalStruct.fromTlv(ContextSpecificTag(TAG_D), tlvReader) + ) + } else { + Optional.empty() + } tlvReader.exitContainer() - return UnitTestingClusterNestedStruct(a, b, c) + return UnitTestingClusterNestedStruct(a, b, c, d) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt index 24f06fb8752b6c..8a6d89c228c11d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt @@ -17,6 +17,7 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -31,6 +32,7 @@ class UnitTestingClusterSimpleStruct( val f: UInt, val g: Float, val h: Double, + val i: Optional, ) { override fun toString(): String = buildString { append("UnitTestingClusterSimpleStruct {\n") @@ -42,6 +44,7 @@ class UnitTestingClusterSimpleStruct( append("\tf : $f\n") append("\tg : $g\n") append("\th : $h\n") + append("\ti : $i\n") append("}\n") } @@ -56,6 +59,10 @@ class UnitTestingClusterSimpleStruct( put(ContextSpecificTag(TAG_F), f) put(ContextSpecificTag(TAG_G), g) put(ContextSpecificTag(TAG_H), h) + if (i.isPresent) { + val opti = i.get() + put(ContextSpecificTag(TAG_I), opti) + } endStructure() } } @@ -69,6 +76,7 @@ class UnitTestingClusterSimpleStruct( private const val TAG_F = 5 private const val TAG_G = 6 private const val TAG_H = 7 + private const val TAG_I = 8 fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterSimpleStruct { tlvReader.enterStructure(tlvTag) @@ -80,10 +88,16 @@ class UnitTestingClusterSimpleStruct( val f = tlvReader.getUInt(ContextSpecificTag(TAG_F)) val g = tlvReader.getFloat(ContextSpecificTag(TAG_G)) val h = tlvReader.getDouble(ContextSpecificTag(TAG_H)) + val i = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_I))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_I))) + } else { + Optional.empty() + } tlvReader.exitContainer() - return UnitTestingClusterSimpleStruct(a, b, c, d, e, f, g, h) + return UnitTestingClusterSimpleStruct(a, b, c, d, e, f, g, h, i) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestGlobalStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestGlobalStruct.kt new file mode 100644 index 00000000000000..aa66049b549524 --- /dev/null +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestGlobalStruct.kt @@ -0,0 +1,92 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package chip.devicecontroller.cluster.structs + +import chip.devicecontroller.cluster.* +import java.util.Optional +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class UnitTestingClusterTestGlobalStruct( + val name: String, + val myBitmap: ULong?, + val myEnum: Optional?, +) { + override fun toString(): String = buildString { + append("UnitTestingClusterTestGlobalStruct {\n") + append("\tname : $name\n") + append("\tmyBitmap : $myBitmap\n") + append("\tmyEnum : $myEnum\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_NAME), name) + if (myBitmap != null) { + put(ContextSpecificTag(TAG_MY_BITMAP), myBitmap) + } else { + putNull(ContextSpecificTag(TAG_MY_BITMAP)) + } + if (myEnum != null) { + if (myEnum.isPresent) { + val optmyEnum = myEnum.get() + put(ContextSpecificTag(TAG_MY_ENUM), optmyEnum) + } + } else { + putNull(ContextSpecificTag(TAG_MY_ENUM)) + } + endStructure() + } + } + + companion object { + private const val TAG_NAME = 0 + private const val TAG_MY_BITMAP = 1 + private const val TAG_MY_ENUM = 2 + + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestGlobalStruct { + tlvReader.enterStructure(tlvTag) + val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) + val myBitmap = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_MY_BITMAP)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_MY_BITMAP)) + null + } + val myEnum = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MY_ENUM))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MY_ENUM))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_MY_ENUM)) + null + } + + tlvReader.exitContainer() + + return UnitTestingClusterTestGlobalStruct(name, myBitmap, myEnum) + } + } +} 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 b50ab4468820d1..74402b19dcfdf3 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 @@ -123,6 +123,8 @@ class UnitTestingCluster(private val controller: MatterController, private val e class StringEchoResponse(val payload: ByteArray) + class GlobalEchoResponse(val field1: UnitTestingClusterTestGlobalStruct, val field2: UByte) + class TestDifferentVendorMeiResponse(val arg1: UByte, val eventNumber: ULong) class ListInt8uAttribute(val value: List) @@ -203,6 +205,17 @@ class UnitTestingCluster(private val controller: MatterController, private val e object SubscriptionEstablished : ListFabricScopedAttributeSubscriptionState() } + class GlobalStructAttribute(val value: UnitTestingClusterTestGlobalStruct) + + sealed class GlobalStructAttributeSubscriptionState { + data class Success(val value: UnitTestingClusterTestGlobalStruct) : + GlobalStructAttributeSubscriptionState() + + data class Error(val exception: Exception) : GlobalStructAttributeSubscriptionState() + + object SubscriptionEstablished : GlobalStructAttributeSubscriptionState() + } + class NullableBooleanAttribute(val value: Boolean?) sealed class NullableBooleanAttributeSubscriptionState { @@ -541,6 +554,27 @@ class UnitTestingCluster(private val controller: MatterController, private val e object SubscriptionEstablished : NullableRangeRestrictedInt16sAttributeSubscriptionState() } + class NullableGlobalEnumAttribute(val value: UByte?) + + sealed class NullableGlobalEnumAttributeSubscriptionState { + data class Success(val value: UByte?) : NullableGlobalEnumAttributeSubscriptionState() + + data class Error(val exception: Exception) : NullableGlobalEnumAttributeSubscriptionState() + + object SubscriptionEstablished : NullableGlobalEnumAttributeSubscriptionState() + } + + class NullableGlobalStructAttribute(val value: UnitTestingClusterTestGlobalStruct?) + + sealed class NullableGlobalStructAttributeSubscriptionState { + data class Success(val value: UnitTestingClusterTestGlobalStruct?) : + NullableGlobalStructAttributeSubscriptionState() + + data class Error(val exception: Exception) : NullableGlobalStructAttributeSubscriptionState() + + object SubscriptionEstablished : NullableGlobalStructAttributeSubscriptionState() + } + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { @@ -2386,6 +2420,68 @@ class UnitTestingCluster(private val controller: MatterController, private val e return StringEchoResponse(payload_decoded) } + suspend fun globalEchoRequest( + field1: UnitTestingClusterTestGlobalStruct, + field2: UByte, + timedInvokeTimeout: Duration? = null, + ): GlobalEchoResponse { + val commandId: UInt = 25u + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) + + val TAG_FIELD1_REQ: Int = 0 + field1.toTlv(ContextSpecificTag(TAG_FIELD1_REQ), tlvWriter) + + val TAG_FIELD2_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_FIELD2_REQ), field2) + 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_FIELD1: Int = 0 + var field1_decoded: UnitTestingClusterTestGlobalStruct? = null + + val TAG_FIELD2: Int = 1 + var field2_decoded: UByte? = null + + while (!tlvReader.isEndOfContainer()) { + val tag = tlvReader.peekElement().tag + + if (tag == ContextSpecificTag(TAG_FIELD1)) { + field1_decoded = UnitTestingClusterTestGlobalStruct.fromTlv(tag, tlvReader) + } + + if (tag == ContextSpecificTag(TAG_FIELD2)) { + field2_decoded = tlvReader.getUByte(tag) + } else { + tlvReader.skipElement() + } + } + + if (field1_decoded == null) { + throw IllegalStateException("field1 not found in TLV") + } + + if (field2_decoded == null) { + throw IllegalStateException("field2 not found in TLV") + } + + tlvReader.exitContainer() + + return GlobalEchoResponse(field1_decoded, field2_decoded) + } + suspend fun testDifferentVendorMeiRequest( arg1: UByte, timedInvokeTimeout: Duration? = null, @@ -8305,8 +8401,8 @@ class UnitTestingCluster(private val controller: MatterController, private val e } } - suspend fun readUnsupportedAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 255u + suspend fun readGlobalEnumAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 51u val attributePath = AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) @@ -8327,22 +8423,17 @@ class UnitTestingCluster(private val controller: MatterController, private val e it.path.attributeId == ATTRIBUTE_ID } - requireNotNull(attributeData) { "Unsupported attribute not found in response" } + requireNotNull(attributeData) { "Globalenum attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) return decodedValue } - suspend fun writeUnsupportedAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { - val ATTRIBUTE_ID: UInt = 255u + suspend fun writeGlobalEnumAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + val ATTRIBUTE_ID: UInt = 51u val tlvWriter = TlvWriter() tlvWriter.put(AnonymousTag, value) @@ -8381,11 +8472,11 @@ class UnitTestingCluster(private val controller: MatterController, private val e } } - suspend fun subscribeUnsupportedAttribute( + suspend fun subscribeGlobalEnumAttribute( minInterval: Int, maxInterval: Int, - ): Flow { - val ATTRIBUTE_ID: UInt = 255u + ): Flow { + val ATTRIBUTE_ID: UInt = 51u val attributePaths = listOf( AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) @@ -8403,7 +8494,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { emit( - BooleanSubscriptionState.Error( + UByteSubscriptionState.Error( Exception( "Subscription terminated with error code: ${subscriptionState.terminationCause}" ) @@ -8416,28 +8507,23 @@ class UnitTestingCluster(private val controller: MatterController, private val e .filterIsInstance() .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - requireNotNull(attributeData) { "Unsupported attribute not found in Node State update" } + requireNotNull(attributeData) { "Globalenum attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + emit(UByteSubscriptionState.Success(decodedValue)) } SubscriptionState.SubscriptionEstablished -> { - emit(BooleanSubscriptionState.SubscriptionEstablished) + emit(UByteSubscriptionState.SubscriptionEstablished) } } } } - suspend fun readNullableBooleanAttribute(): NullableBooleanAttribute { - val ATTRIBUTE_ID: UInt = 16384u + suspend fun readGlobalStructAttribute(): GlobalStructAttribute { + val ATTRIBUTE_ID: UInt = 52u val attributePath = AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) @@ -8458,26 +8544,24 @@ class UnitTestingCluster(private val controller: MatterController, private val e it.path.attributeId == ATTRIBUTE_ID } - requireNotNull(attributeData) { "Nullableboolean attribute not found in response" } + requireNotNull(attributeData) { "Globalstruct attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (!tlvReader.isNull()) { - tlvReader.getBoolean(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UnitTestingClusterTestGlobalStruct = + UnitTestingClusterTestGlobalStruct.fromTlv(AnonymousTag, tlvReader) - return NullableBooleanAttribute(decodedValue) + return GlobalStructAttribute(decodedValue) } - suspend fun writeNullableBooleanAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { - val ATTRIBUTE_ID: UInt = 16384u + suspend fun writeGlobalStructAttribute( + value: UnitTestingClusterTestGlobalStruct, + timedWriteTimeout: Duration? = null, + ) { + val ATTRIBUTE_ID: UInt = 52u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + value.toTlv(AnonymousTag, tlvWriter) val writeRequests: WriteRequests = WriteRequests( @@ -8513,11 +8597,11 @@ class UnitTestingCluster(private val controller: MatterController, private val e } } - suspend fun subscribeNullableBooleanAttribute( + suspend fun subscribeGlobalStructAttribute( minInterval: Int, maxInterval: Int, - ): Flow { - val ATTRIBUTE_ID: UInt = 16384u + ): Flow { + val ATTRIBUTE_ID: UInt = 52u val attributePaths = listOf( AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) @@ -8535,7 +8619,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { emit( - NullableBooleanAttributeSubscriptionState.Error( + GlobalStructAttributeSubscriptionState.Error( Exception( "Subscription terminated with error code: ${subscriptionState.terminationCause}" ) @@ -8548,31 +8632,24 @@ class UnitTestingCluster(private val controller: MatterController, private val e .filterIsInstance() .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - requireNotNull(attributeData) { - "Nullableboolean attribute not found in Node State update" - } + requireNotNull(attributeData) { "Globalstruct attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (!tlvReader.isNull()) { - tlvReader.getBoolean(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UnitTestingClusterTestGlobalStruct = + UnitTestingClusterTestGlobalStruct.fromTlv(AnonymousTag, tlvReader) - decodedValue?.let { emit(NullableBooleanAttributeSubscriptionState.Success(it)) } + emit(GlobalStructAttributeSubscriptionState.Success(decodedValue)) } SubscriptionState.SubscriptionEstablished -> { - emit(NullableBooleanAttributeSubscriptionState.SubscriptionEstablished) + emit(GlobalStructAttributeSubscriptionState.SubscriptionEstablished) } } } } - suspend fun readNullableBitmap8Attribute(): NullableBitmap8Attribute { - val ATTRIBUTE_ID: UInt = 16385u + suspend fun readUnsupportedAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 255u val attributePath = AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) @@ -8593,23 +8670,22 @@ class UnitTestingCluster(private val controller: MatterController, private val e it.path.attributeId == ATTRIBUTE_ID } - requireNotNull(attributeData) { "Nullablebitmap8 attribute not found in response" } + requireNotNull(attributeData) { "Unsupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) } else { - tlvReader.getNull(AnonymousTag) null } - return NullableBitmap8Attribute(decodedValue) + return decodedValue } - suspend fun writeNullableBitmap8Attribute(value: UByte, timedWriteTimeout: Duration? = null) { - val ATTRIBUTE_ID: UInt = 16385u + suspend fun writeUnsupportedAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { + val ATTRIBUTE_ID: UInt = 255u val tlvWriter = TlvWriter() tlvWriter.put(AnonymousTag, value) @@ -8648,11 +8724,11 @@ class UnitTestingCluster(private val controller: MatterController, private val e } } - suspend fun subscribeNullableBitmap8Attribute( + suspend fun subscribeUnsupportedAttribute( minInterval: Int, maxInterval: Int, - ): Flow { - val ATTRIBUTE_ID: UInt = 16385u + ): Flow { + val ATTRIBUTE_ID: UInt = 255u val attributePaths = listOf( AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) @@ -8670,7 +8746,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { emit( - NullableBitmap8AttributeSubscriptionState.Error( + BooleanSubscriptionState.Error( Exception( "Subscription terminated with error code: ${subscriptionState.terminationCause}" ) @@ -8683,31 +8759,28 @@ class UnitTestingCluster(private val controller: MatterController, private val e .filterIsInstance() .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - requireNotNull(attributeData) { - "Nullablebitmap8 attribute not found in Node State update" - } + requireNotNull(attributeData) { "Unsupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) } else { - tlvReader.getNull(AnonymousTag) null } - decodedValue?.let { emit(NullableBitmap8AttributeSubscriptionState.Success(it)) } + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { - emit(NullableBitmap8AttributeSubscriptionState.SubscriptionEstablished) + emit(BooleanSubscriptionState.SubscriptionEstablished) } } } } - suspend fun readNullableBitmap16Attribute(): NullableBitmap16Attribute { - val ATTRIBUTE_ID: UInt = 16386u + suspend fun readNullableBooleanAttribute(): NullableBooleanAttribute { + val ATTRIBUTE_ID: UInt = 16384u val attributePath = AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) @@ -8728,23 +8801,23 @@ class UnitTestingCluster(private val controller: MatterController, private val e it.path.attributeId == ATTRIBUTE_ID } - requireNotNull(attributeData) { "Nullablebitmap16 attribute not found in response" } + requireNotNull(attributeData) { "Nullableboolean attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = + val decodedValue: Boolean? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) + tlvReader.getBoolean(AnonymousTag) } else { tlvReader.getNull(AnonymousTag) null } - return NullableBitmap16Attribute(decodedValue) + return NullableBooleanAttribute(decodedValue) } - suspend fun writeNullableBitmap16Attribute(value: UShort, timedWriteTimeout: Duration? = null) { - val ATTRIBUTE_ID: UInt = 16386u + suspend fun writeNullableBooleanAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { + val ATTRIBUTE_ID: UInt = 16384u val tlvWriter = TlvWriter() tlvWriter.put(AnonymousTag, value) @@ -8783,11 +8856,11 @@ class UnitTestingCluster(private val controller: MatterController, private val e } } - suspend fun subscribeNullableBitmap16Attribute( + suspend fun subscribeNullableBooleanAttribute( minInterval: Int, maxInterval: Int, - ): Flow { - val ATTRIBUTE_ID: UInt = 16386u + ): Flow { + val ATTRIBUTE_ID: UInt = 16384u val attributePaths = listOf( AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) @@ -8805,7 +8878,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { emit( - NullableBitmap16AttributeSubscriptionState.Error( + NullableBooleanAttributeSubscriptionState.Error( Exception( "Subscription terminated with error code: ${subscriptionState.terminationCause}" ) @@ -8819,30 +8892,30 @@ class UnitTestingCluster(private val controller: MatterController, private val e .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } requireNotNull(attributeData) { - "Nullablebitmap16 attribute not found in Node State update" + "Nullableboolean attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = + val decodedValue: Boolean? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) + tlvReader.getBoolean(AnonymousTag) } else { tlvReader.getNull(AnonymousTag) null } - decodedValue?.let { emit(NullableBitmap16AttributeSubscriptionState.Success(it)) } + decodedValue?.let { emit(NullableBooleanAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { - emit(NullableBitmap16AttributeSubscriptionState.SubscriptionEstablished) + emit(NullableBooleanAttributeSubscriptionState.SubscriptionEstablished) } } } } - suspend fun readNullableBitmap32Attribute(): NullableBitmap32Attribute { - val ATTRIBUTE_ID: UInt = 16387u + suspend fun readNullableBitmap8Attribute(): NullableBitmap8Attribute { + val ATTRIBUTE_ID: UInt = 16385u val attributePath = AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) @@ -8863,23 +8936,23 @@ class UnitTestingCluster(private val controller: MatterController, private val e it.path.attributeId == ATTRIBUTE_ID } - requireNotNull(attributeData) { "Nullablebitmap32 attribute not found in response" } + requireNotNull(attributeData) { "Nullablebitmap8 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = + val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) + tlvReader.getUByte(AnonymousTag) } else { tlvReader.getNull(AnonymousTag) null } - return NullableBitmap32Attribute(decodedValue) + return NullableBitmap8Attribute(decodedValue) } - suspend fun writeNullableBitmap32Attribute(value: UInt, timedWriteTimeout: Duration? = null) { - val ATTRIBUTE_ID: UInt = 16387u + suspend fun writeNullableBitmap8Attribute(value: UByte, timedWriteTimeout: Duration? = null) { + val ATTRIBUTE_ID: UInt = 16385u val tlvWriter = TlvWriter() tlvWriter.put(AnonymousTag, value) @@ -8918,11 +8991,11 @@ class UnitTestingCluster(private val controller: MatterController, private val e } } - suspend fun subscribeNullableBitmap32Attribute( + suspend fun subscribeNullableBitmap8Attribute( minInterval: Int, maxInterval: Int, - ): Flow { - val ATTRIBUTE_ID: UInt = 16387u + ): Flow { + val ATTRIBUTE_ID: UInt = 16385u val attributePaths = listOf( AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) @@ -8940,7 +9013,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { emit( - NullableBitmap32AttributeSubscriptionState.Error( + NullableBitmap8AttributeSubscriptionState.Error( Exception( "Subscription terminated with error code: ${subscriptionState.terminationCause}" ) @@ -8954,30 +9027,30 @@ class UnitTestingCluster(private val controller: MatterController, private val e .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } requireNotNull(attributeData) { - "Nullablebitmap32 attribute not found in Node State update" + "Nullablebitmap8 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = + val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) + tlvReader.getUByte(AnonymousTag) } else { tlvReader.getNull(AnonymousTag) null } - decodedValue?.let { emit(NullableBitmap32AttributeSubscriptionState.Success(it)) } + decodedValue?.let { emit(NullableBitmap8AttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { - emit(NullableBitmap32AttributeSubscriptionState.SubscriptionEstablished) + emit(NullableBitmap8AttributeSubscriptionState.SubscriptionEstablished) } } } } - suspend fun readNullableBitmap64Attribute(): NullableBitmap64Attribute { - val ATTRIBUTE_ID: UInt = 16388u + suspend fun readNullableBitmap16Attribute(): NullableBitmap16Attribute { + val ATTRIBUTE_ID: UInt = 16386u val attributePath = AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) @@ -8998,23 +9071,23 @@ class UnitTestingCluster(private val controller: MatterController, private val e it.path.attributeId == ATTRIBUTE_ID } - requireNotNull(attributeData) { "Nullablebitmap64 attribute not found in response" } + requireNotNull(attributeData) { "Nullablebitmap16 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = + val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) + tlvReader.getUShort(AnonymousTag) } else { tlvReader.getNull(AnonymousTag) null } - return NullableBitmap64Attribute(decodedValue) + return NullableBitmap16Attribute(decodedValue) } - suspend fun writeNullableBitmap64Attribute(value: ULong, timedWriteTimeout: Duration? = null) { - val ATTRIBUTE_ID: UInt = 16388u + suspend fun writeNullableBitmap16Attribute(value: UShort, timedWriteTimeout: Duration? = null) { + val ATTRIBUTE_ID: UInt = 16386u val tlvWriter = TlvWriter() tlvWriter.put(AnonymousTag, value) @@ -9053,11 +9126,11 @@ class UnitTestingCluster(private val controller: MatterController, private val e } } - suspend fun subscribeNullableBitmap64Attribute( + suspend fun subscribeNullableBitmap16Attribute( minInterval: Int, maxInterval: Int, - ): Flow { - val ATTRIBUTE_ID: UInt = 16388u + ): Flow { + val ATTRIBUTE_ID: UInt = 16386u val attributePaths = listOf( AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) @@ -9075,7 +9148,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { emit( - NullableBitmap64AttributeSubscriptionState.Error( + NullableBitmap16AttributeSubscriptionState.Error( Exception( "Subscription terminated with error code: ${subscriptionState.terminationCause}" ) @@ -9089,12 +9162,282 @@ class UnitTestingCluster(private val controller: MatterController, private val e .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } requireNotNull(attributeData) { - "Nullablebitmap64 attribute not found in Node State update" + "Nullablebitmap16 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(NullableBitmap16AttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(NullableBitmap16AttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readNullableBitmap32Attribute(): NullableBitmap32Attribute { + val ATTRIBUTE_ID: UInt = 16387u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullablebitmap32 attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableBitmap32Attribute(decodedValue) + } + + suspend fun writeNullableBitmap32Attribute(value: UInt, timedWriteTimeout: Duration? = null) { + val ATTRIBUTE_ID: UInt = 16387u + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded(), + ) + ), + timedRequest = timedWriteTimeout, + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun subscribeNullableBitmap32Attribute( + minInterval: Int, + maxInterval: Int, + ): Flow { + val ATTRIBUTE_ID: UInt = 16387u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()), + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + NullableBitmap32AttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablebitmap32 attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(NullableBitmap32AttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(NullableBitmap32AttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readNullableBitmap64Attribute(): NullableBitmap64Attribute { + val ATTRIBUTE_ID: UInt = 16388u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullablebitmap64 attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableBitmap64Attribute(decodedValue) + } + + suspend fun writeNullableBitmap64Attribute(value: ULong, timedWriteTimeout: Duration? = null) { + val ATTRIBUTE_ID: UInt = 16388u + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded(), + ) + ), + timedRequest = timedWriteTimeout, + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun subscribeNullableBitmap64Attribute( + minInterval: Int, + maxInterval: Int, + ): Flow { + val ATTRIBUTE_ID: UInt = 16388u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()), + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + NullableBitmap64AttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablebitmap64 attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: ULong? = if (!tlvReader.isNull()) { tlvReader.getULong(AnonymousTag) } else { @@ -13051,6 +13394,279 @@ class UnitTestingCluster(private val controller: MatterController, private val e } } + suspend fun readNullableGlobalEnumAttribute(): NullableGlobalEnumAttribute { + val ATTRIBUTE_ID: UInt = 16435u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableglobalenum attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableGlobalEnumAttribute(decodedValue) + } + + suspend fun writeNullableGlobalEnumAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + val ATTRIBUTE_ID: UInt = 16435u + + val tlvWriter = TlvWriter() + tlvWriter.put(AnonymousTag, value) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded(), + ) + ), + timedRequest = timedWriteTimeout, + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun subscribeNullableGlobalEnumAttribute( + minInterval: Int, + maxInterval: Int, + ): Flow { + val ATTRIBUTE_ID: UInt = 16435u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()), + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + NullableGlobalEnumAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableglobalenum attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(NullableGlobalEnumAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(NullableGlobalEnumAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + + suspend fun readNullableGlobalStructAttribute(): NullableGlobalStructAttribute { + val ATTRIBUTE_ID: UInt = 16436u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Nullableglobalstruct attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UnitTestingClusterTestGlobalStruct? = + if (!tlvReader.isNull()) { + UnitTestingClusterTestGlobalStruct.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return NullableGlobalStructAttribute(decodedValue) + } + + suspend fun writeNullableGlobalStructAttribute( + value: UnitTestingClusterTestGlobalStruct, + timedWriteTimeout: Duration? = null, + ) { + val ATTRIBUTE_ID: UInt = 16436u + + val tlvWriter = TlvWriter() + value.toTlv(AnonymousTag, tlvWriter) + + val writeRequests: WriteRequests = + WriteRequests( + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded(), + ) + ), + timedRequest = timedWriteTimeout, + ) + + val response: WriteResponse = controller.write(writeRequests) + + when (response) { + is WriteResponse.Success -> { + logger.log(Level.FINE, "Write command succeeded") + } + is WriteResponse.PartialWriteFailure -> { + val aggregatedErrorMessage = + response.failures.joinToString("\n") { failure -> + "Error at ${failure.attributePath}: ${failure.ex.message}" + } + + response.failures.forEach { failure -> + logger.log(Level.WARNING, "Error at ${failure.attributePath}: ${failure.ex.message}") + } + + throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") + } + } + } + + suspend fun subscribeNullableGlobalStructAttribute( + minInterval: Int, + maxInterval: Int, + ): Flow { + val ATTRIBUTE_ID: UInt = 16436u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()), + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + NullableGlobalStructAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableglobalstruct attribute not found in Node State update" + } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UnitTestingClusterTestGlobalStruct? = + if (!tlvReader.isNull()) { + UnitTestingClusterTestGlobalStruct.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(NullableGlobalStructAttributeSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(NullableGlobalStructAttributeSubscriptionState.SubscriptionEstablished) + } + } + } + } + suspend fun readMeiInt8uAttribute(): UByte { val ATTRIBUTE_ID: UInt = 4294070017u diff --git a/src/controller/java/generated/java/matter/controller/cluster/files.gni b/src/controller/java/generated/java/matter/controller/cluster/files.gni index dc0b4b09ec96f6..021d82d5e5b25a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/files.gni +++ b/src/controller/java/generated/java/matter/controller/cluster/files.gni @@ -151,6 +151,7 @@ matter_structs_sources = [ "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestFabricScoped.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestGlobalStruct.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestListStructOctet.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/UserLabelClusterLabelStruct.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/structs/WaterHeaterModeClusterModeOptionStruct.kt", diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt index 3552ec2a5fc075..d57a0432a7c7ed 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -26,12 +27,14 @@ class UnitTestingClusterNestedStruct( val a: UByte, val b: Boolean, val c: UnitTestingClusterSimpleStruct, + val d: Optional, ) { override fun toString(): String = buildString { append("UnitTestingClusterNestedStruct {\n") append("\ta : $a\n") append("\tb : $b\n") append("\tc : $c\n") + append("\td : $d\n") append("}\n") } @@ -41,6 +44,10 @@ class UnitTestingClusterNestedStruct( put(ContextSpecificTag(TAG_A), a) put(ContextSpecificTag(TAG_B), b) c.toTlv(ContextSpecificTag(TAG_C), this) + if (d.isPresent) { + val optd = d.get() + optd.toTlv(ContextSpecificTag(TAG_D), this) + } endStructure() } } @@ -49,16 +56,25 @@ class UnitTestingClusterNestedStruct( private const val TAG_A = 0 private const val TAG_B = 1 private const val TAG_C = 2 + private const val TAG_D = 3 fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterNestedStruct { tlvReader.enterStructure(tlvTag) val a = tlvReader.getUByte(ContextSpecificTag(TAG_A)) val b = tlvReader.getBoolean(ContextSpecificTag(TAG_B)) val c = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_C), tlvReader) + val d = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_D))) { + Optional.of( + UnitTestingClusterTestGlobalStruct.fromTlv(ContextSpecificTag(TAG_D), tlvReader) + ) + } else { + Optional.empty() + } tlvReader.exitContainer() - return UnitTestingClusterNestedStruct(a, b, c) + return UnitTestingClusterNestedStruct(a, b, c, d) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt index 864a28ffd7defc..722445efea8504 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag @@ -31,6 +32,7 @@ class UnitTestingClusterSimpleStruct( val f: UByte, val g: Float, val h: Double, + val i: Optional, ) { override fun toString(): String = buildString { append("UnitTestingClusterSimpleStruct {\n") @@ -42,6 +44,7 @@ class UnitTestingClusterSimpleStruct( append("\tf : $f\n") append("\tg : $g\n") append("\th : $h\n") + append("\ti : $i\n") append("}\n") } @@ -56,6 +59,10 @@ class UnitTestingClusterSimpleStruct( put(ContextSpecificTag(TAG_F), f) put(ContextSpecificTag(TAG_G), g) put(ContextSpecificTag(TAG_H), h) + if (i.isPresent) { + val opti = i.get() + put(ContextSpecificTag(TAG_I), opti) + } endStructure() } } @@ -69,6 +76,7 @@ class UnitTestingClusterSimpleStruct( private const val TAG_F = 5 private const val TAG_G = 6 private const val TAG_H = 7 + private const val TAG_I = 8 fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterSimpleStruct { tlvReader.enterStructure(tlvTag) @@ -80,10 +88,16 @@ class UnitTestingClusterSimpleStruct( val f = tlvReader.getUByte(ContextSpecificTag(TAG_F)) val g = tlvReader.getFloat(ContextSpecificTag(TAG_G)) val h = tlvReader.getDouble(ContextSpecificTag(TAG_H)) + val i = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_I))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_I))) + } else { + Optional.empty() + } tlvReader.exitContainer() - return UnitTestingClusterSimpleStruct(a, b, c, d, e, f, g, h) + return UnitTestingClusterSimpleStruct(a, b, c, d, e, f, g, h, i) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestGlobalStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestGlobalStruct.kt new file mode 100644 index 00000000000000..66caded2c08ab3 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestGlobalStruct.kt @@ -0,0 +1,92 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package matter.controller.cluster.structs + +import java.util.Optional +import matter.controller.cluster.* +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class UnitTestingClusterTestGlobalStruct( + val name: String, + val myBitmap: UInt?, + val myEnum: Optional?, +) { + override fun toString(): String = buildString { + append("UnitTestingClusterTestGlobalStruct {\n") + append("\tname : $name\n") + append("\tmyBitmap : $myBitmap\n") + append("\tmyEnum : $myEnum\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_NAME), name) + if (myBitmap != null) { + put(ContextSpecificTag(TAG_MY_BITMAP), myBitmap) + } else { + putNull(ContextSpecificTag(TAG_MY_BITMAP)) + } + if (myEnum != null) { + if (myEnum.isPresent) { + val optmyEnum = myEnum.get() + put(ContextSpecificTag(TAG_MY_ENUM), optmyEnum) + } + } else { + putNull(ContextSpecificTag(TAG_MY_ENUM)) + } + endStructure() + } + } + + companion object { + private const val TAG_NAME = 0 + private const val TAG_MY_BITMAP = 1 + private const val TAG_MY_ENUM = 2 + + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestGlobalStruct { + tlvReader.enterStructure(tlvTag) + val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) + val myBitmap = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_MY_BITMAP)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_MY_BITMAP)) + null + } + val myEnum = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MY_ENUM))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_MY_ENUM))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_MY_ENUM)) + null + } + + tlvReader.exitContainer() + + return UnitTestingClusterTestGlobalStruct(name, myBitmap, myEnum) + } + } +} diff --git a/src/controller/java/tests/chip/devicecontroller/cluster/ChipClusterEventStructTest.kt b/src/controller/java/tests/chip/devicecontroller/cluster/ChipClusterEventStructTest.kt index 55c880e02e4bf2..bfee37f38f5437 100644 --- a/src/controller/java/tests/chip/devicecontroller/cluster/ChipClusterEventStructTest.kt +++ b/src/controller/java/tests/chip/devicecontroller/cluster/ChipClusterEventStructTest.kt @@ -19,6 +19,7 @@ package chip.devicecontroller.cluster import chip.devicecontroller.cluster.eventstructs.UnitTestingClusterTestEventEvent import chip.devicecontroller.cluster.eventstructs.UnitTestingClusterTestFabricScopedEventEvent import chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.TlvReader import matter.tlv.TlvWriter @@ -28,9 +29,29 @@ class ChipClusterEventStructTest { @Test fun testEventEventTlvTest() { val simpleStruct = - UnitTestingClusterSimpleStruct(1U, true, 2U, byteArrayOf(0x00, 0x01), "test", 3U, 4.5f, 6.7) + UnitTestingClusterSimpleStruct( + 1U, + true, + 2U, + byteArrayOf(0x00, 0x01), + "test", + 3U, + 4.5f, + 6.7, + Optional.empty() + ) val simpleStruct2 = - UnitTestingClusterSimpleStruct(8U, false, 9U, byteArrayOf(0x02, 0x03), "test2", 4U, 5.6f, 7.8) + UnitTestingClusterSimpleStruct( + 8U, + false, + 9U, + byteArrayOf(0x02, 0x03), + "test2", + 4U, + 5.6f, + 7.8, + Optional.empty() + ) val struct = UnitTestingClusterTestEventEvent( 1U, diff --git a/src/controller/java/tests/chip/devicecontroller/cluster/ChipClusterStructTest.kt b/src/controller/java/tests/chip/devicecontroller/cluster/ChipClusterStructTest.kt index ffa0044569e0af..a38a71d63141ee 100644 --- a/src/controller/java/tests/chip/devicecontroller/cluster/ChipClusterStructTest.kt +++ b/src/controller/java/tests/chip/devicecontroller/cluster/ChipClusterStructTest.kt @@ -35,9 +35,29 @@ class ChipClusterStructTest { @Test fun doubleNestedStructTlvTest() { val simpleStruct = - UnitTestingClusterSimpleStruct(1U, true, 2U, byteArrayOf(0x00, 0x01), "test", 3U, 4.5f, 6.7) + UnitTestingClusterSimpleStruct( + 1U, + true, + 2U, + byteArrayOf(0x00, 0x01), + "test", + 3U, + 4.5f, + 6.7, + Optional.empty() + ) val simpleStruct2 = - UnitTestingClusterSimpleStruct(8U, false, 9U, byteArrayOf(0x02, 0x03), "test2", 4U, 5.6f, 7.8) + UnitTestingClusterSimpleStruct( + 8U, + false, + 9U, + byteArrayOf(0x02, 0x03), + "test2", + 4U, + 5.6f, + 7.8, + Optional.empty() + ) val nestedStructList = UnitTestingClusterNestedStructList( 1U, @@ -82,7 +102,17 @@ class ChipClusterStructTest { @Test fun nullablesAndOptionalsStructTlvTest1() { val simpleStruct = - UnitTestingClusterSimpleStruct(1U, true, 2U, byteArrayOf(0x00, 0x01), "test", 3U, 4.5f, 6.7) + UnitTestingClusterSimpleStruct( + 1U, + true, + 2U, + byteArrayOf(0x00, 0x01), + "test", + 3U, + 4.5f, + 6.7, + Optional.empty() + ) val struct = UnitTestingClusterNullablesAndOptionalsStruct( 1U, @@ -121,7 +151,17 @@ class ChipClusterStructTest { // Optional Check - 1 fun nullablesAndOptionalsStructTlvTest2() { val simpleStruct = - UnitTestingClusterSimpleStruct(1U, true, 2U, byteArrayOf(0x00, 0x01), "test", 3U, 4.5f, 6.7) + UnitTestingClusterSimpleStruct( + 1U, + true, + 2U, + byteArrayOf(0x00, 0x01), + "test", + 3U, + 4.5f, + 6.7, + Optional.empty() + ) val struct = UnitTestingClusterNullablesAndOptionalsStruct( 1U, @@ -160,7 +200,17 @@ class ChipClusterStructTest { // Optional Check - 2 fun nullablesAndOptionalsStructTlvTest3() { val simpleStruct = - UnitTestingClusterSimpleStruct(1U, true, 2U, byteArrayOf(0x00, 0x01), "test", 3U, 4.5f, 6.7) + UnitTestingClusterSimpleStruct( + 1U, + true, + 2U, + byteArrayOf(0x00, 0x01), + "test", + 3U, + 4.5f, + 6.7, + Optional.empty() + ) val struct = UnitTestingClusterNullablesAndOptionalsStruct( 1U, @@ -199,7 +249,17 @@ class ChipClusterStructTest { // Nullable check - 1 fun nullablesAndOptionalsStructTlvTest4() { val simpleStruct = - UnitTestingClusterSimpleStruct(1U, true, 2U, byteArrayOf(0x00, 0x01), "test", 3U, 4.5f, 6.7) + UnitTestingClusterSimpleStruct( + 1U, + true, + 2U, + byteArrayOf(0x00, 0x01), + "test", + 3U, + 4.5f, + 6.7, + Optional.empty() + ) val struct = UnitTestingClusterNullablesAndOptionalsStruct( 1U, @@ -238,7 +298,17 @@ class ChipClusterStructTest { // Nullable check - 2 fun nullablesAndOptionalsStructTlvTest5() { val simpleStruct = - UnitTestingClusterSimpleStruct(1U, true, 2U, byteArrayOf(0x00, 0x01), "test", 3U, 4.5f, 6.7) + UnitTestingClusterSimpleStruct( + 1U, + true, + 2U, + byteArrayOf(0x00, 0x01), + "test", + 3U, + 4.5f, + 6.7, + Optional.empty() + ) val struct = UnitTestingClusterNullablesAndOptionalsStruct( null, @@ -276,7 +346,17 @@ class ChipClusterStructTest { @Test fun testFabricScopedTlvTest1() { val simpleStruct = - UnitTestingClusterSimpleStruct(1U, true, 2U, byteArrayOf(0x00, 0x01), "test", 3U, 4.5f, 6.7) + UnitTestingClusterSimpleStruct( + 1U, + true, + 2U, + byteArrayOf(0x00, 0x01), + "test", + 3U, + 4.5f, + 6.7, + Optional.empty() + ) val struct = UnitTestingClusterTestFabricScoped( 1U, @@ -309,7 +389,17 @@ class ChipClusterStructTest { @Test fun testFabricScopedTlvTest2() { val simpleStruct = - UnitTestingClusterSimpleStruct(1U, true, 2U, byteArrayOf(0x00, 0x01), "test", 3U, 4.5f, 6.7) + UnitTestingClusterSimpleStruct( + 1U, + true, + 2U, + byteArrayOf(0x00, 0x01), + "test", + 3U, + 4.5f, + 6.7, + Optional.empty() + ) val struct = UnitTestingClusterTestFabricScoped( 1U, @@ -342,7 +432,17 @@ class ChipClusterStructTest { @Test fun testFabricScopedTlvTest3() { val simpleStruct = - UnitTestingClusterSimpleStruct(1U, true, 2U, byteArrayOf(0x00, 0x01), "test", 3U, 4.5f, 6.7) + UnitTestingClusterSimpleStruct( + 1U, + true, + 2U, + byteArrayOf(0x00, 0x01), + "test", + 3U, + 4.5f, + 6.7, + Optional.empty() + ) val struct = UnitTestingClusterTestFabricScoped( 1U, diff --git a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp index 33c041e5bbe85f..81e24a4bc9dcd7 100644 --- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp @@ -46578,6 +46578,25 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR chip::JniReferences::GetInstance().CreateBoxedObject( newElement_0_nullableStruct_hClassName.c_str(), newElement_0_nullableStruct_hCtorSignature.c_str(), jninewElement_0_nullableStruct_h, newElement_0_nullableStruct_h); + jobject newElement_0_nullableStruct_i; + if (!entry_0.nullableStruct.Value().i.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_nullableStruct_i); + } + else + { + jobject newElement_0_nullableStruct_iInsideOptional; + std::string newElement_0_nullableStruct_iInsideOptionalClassName = "java/lang/Integer"; + std::string newElement_0_nullableStruct_iInsideOptionalCtorSignature = "(I)V"; + jint jninewElement_0_nullableStruct_iInsideOptional = + static_cast(entry_0.nullableStruct.Value().i.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_nullableStruct_iInsideOptionalClassName.c_str(), + newElement_0_nullableStruct_iInsideOptionalCtorSignature.c_str(), + jninewElement_0_nullableStruct_iInsideOptional, newElement_0_nullableStruct_iInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_nullableStruct_iInsideOptional, + newElement_0_nullableStruct_i); + } jclass simpleStructStructClass_3; err = chip::JniReferences::GetInstance().GetLocalClassRef( @@ -46592,7 +46611,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR err = chip::JniReferences::GetInstance().FindMethod( env, simpleStructStructClass_3, "", "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/lang/String;Ljava/lang/Integer;Ljava/" - "lang/Float;Ljava/lang/Double;)V", + "lang/Float;Ljava/lang/Double;Ljava/util/Optional;)V", &simpleStructStructCtor_3); if (err != CHIP_NO_ERROR || simpleStructStructCtor_3 == nullptr) { @@ -46604,7 +46623,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR env->NewObject(simpleStructStructClass_3, simpleStructStructCtor_3, newElement_0_nullableStruct_a, newElement_0_nullableStruct_b, newElement_0_nullableStruct_c, newElement_0_nullableStruct_d, newElement_0_nullableStruct_e, newElement_0_nullableStruct_f, newElement_0_nullableStruct_g, - newElement_0_nullableStruct_h); + newElement_0_nullableStruct_h, newElement_0_nullableStruct_i); } jobject newElement_0_optionalStruct; if (!entry_0.optionalStruct.HasValue()) @@ -46673,6 +46692,26 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_0_optionalStructInsideOptional_hClassName.c_str(), newElement_0_optionalStructInsideOptional_hCtorSignature.c_str(), jninewElement_0_optionalStructInsideOptional_h, newElement_0_optionalStructInsideOptional_h); + jobject newElement_0_optionalStructInsideOptional_i; + if (!entry_0.optionalStruct.Value().i.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_optionalStructInsideOptional_i); + } + else + { + jobject newElement_0_optionalStructInsideOptional_iInsideOptional; + std::string newElement_0_optionalStructInsideOptional_iInsideOptionalClassName = "java/lang/Integer"; + std::string newElement_0_optionalStructInsideOptional_iInsideOptionalCtorSignature = "(I)V"; + jint jninewElement_0_optionalStructInsideOptional_iInsideOptional = + static_cast(entry_0.optionalStruct.Value().i.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_optionalStructInsideOptional_iInsideOptionalClassName.c_str(), + newElement_0_optionalStructInsideOptional_iInsideOptionalCtorSignature.c_str(), + jninewElement_0_optionalStructInsideOptional_iInsideOptional, + newElement_0_optionalStructInsideOptional_iInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_optionalStructInsideOptional_iInsideOptional, + newElement_0_optionalStructInsideOptional_i); + } jclass simpleStructStructClass_3; err = chip::JniReferences::GetInstance().GetLocalClassRef( @@ -46687,7 +46726,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR err = chip::JniReferences::GetInstance().FindMethod( env, simpleStructStructClass_3, "", "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/lang/String;Ljava/lang/Integer;Ljava/" - "lang/Float;Ljava/lang/Double;)V", + "lang/Float;Ljava/lang/Double;Ljava/util/Optional;)V", &simpleStructStructCtor_3); if (err != CHIP_NO_ERROR || simpleStructStructCtor_3 == nullptr) { @@ -46695,12 +46734,12 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR return nullptr; } - newElement_0_optionalStructInsideOptional = - env->NewObject(simpleStructStructClass_3, simpleStructStructCtor_3, - newElement_0_optionalStructInsideOptional_a, newElement_0_optionalStructInsideOptional_b, - newElement_0_optionalStructInsideOptional_c, newElement_0_optionalStructInsideOptional_d, - newElement_0_optionalStructInsideOptional_e, newElement_0_optionalStructInsideOptional_f, - newElement_0_optionalStructInsideOptional_g, newElement_0_optionalStructInsideOptional_h); + newElement_0_optionalStructInsideOptional = env->NewObject( + simpleStructStructClass_3, simpleStructStructCtor_3, newElement_0_optionalStructInsideOptional_a, + newElement_0_optionalStructInsideOptional_b, newElement_0_optionalStructInsideOptional_c, + newElement_0_optionalStructInsideOptional_d, newElement_0_optionalStructInsideOptional_e, + newElement_0_optionalStructInsideOptional_f, newElement_0_optionalStructInsideOptional_g, + newElement_0_optionalStructInsideOptional_h, newElement_0_optionalStructInsideOptional_i); chip::JniReferences::GetInstance().CreateOptional(newElement_0_optionalStructInsideOptional, newElement_0_optionalStruct); } @@ -46790,6 +46829,29 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_0_nullableOptionalStructInsideOptional_hCtorSignature.c_str(), jninewElement_0_nullableOptionalStructInsideOptional_h, newElement_0_nullableOptionalStructInsideOptional_h); + jobject newElement_0_nullableOptionalStructInsideOptional_i; + if (!entry_0.nullableOptionalStruct.Value().Value().i.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, + newElement_0_nullableOptionalStructInsideOptional_i); + } + else + { + jobject newElement_0_nullableOptionalStructInsideOptional_iInsideOptional; + std::string newElement_0_nullableOptionalStructInsideOptional_iInsideOptionalClassName = + "java/lang/Integer"; + std::string newElement_0_nullableOptionalStructInsideOptional_iInsideOptionalCtorSignature = "(I)V"; + jint jninewElement_0_nullableOptionalStructInsideOptional_iInsideOptional = + static_cast(entry_0.nullableOptionalStruct.Value().Value().i.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_nullableOptionalStructInsideOptional_iInsideOptionalClassName.c_str(), + newElement_0_nullableOptionalStructInsideOptional_iInsideOptionalCtorSignature.c_str(), + jninewElement_0_nullableOptionalStructInsideOptional_iInsideOptional, + newElement_0_nullableOptionalStructInsideOptional_iInsideOptional); + chip::JniReferences::GetInstance().CreateOptional( + newElement_0_nullableOptionalStructInsideOptional_iInsideOptional, + newElement_0_nullableOptionalStructInsideOptional_i); + } jclass simpleStructStructClass_4; err = chip::JniReferences::GetInstance().GetLocalClassRef( @@ -46804,7 +46866,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR err = chip::JniReferences::GetInstance().FindMethod( env, simpleStructStructClass_4, "", "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/lang/String;Ljava/lang/" - "Integer;Ljava/lang/Float;Ljava/lang/Double;)V", + "Integer;Ljava/lang/Float;Ljava/lang/Double;Ljava/util/Optional;)V", &simpleStructStructCtor_4); if (err != CHIP_NO_ERROR || simpleStructStructCtor_4 == nullptr) { @@ -46821,7 +46883,8 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_0_nullableOptionalStructInsideOptional_e, newElement_0_nullableOptionalStructInsideOptional_f, newElement_0_nullableOptionalStructInsideOptional_g, - newElement_0_nullableOptionalStructInsideOptional_h); + newElement_0_nullableOptionalStructInsideOptional_h, + newElement_0_nullableOptionalStructInsideOptional_i); } chip::JniReferences::GetInstance().CreateOptional(newElement_0_nullableOptionalStructInsideOptional, newElement_0_nullableOptionalStruct); @@ -47009,6 +47072,22 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jdouble jnivalue_h = static_cast(cppValue.h); chip::JniReferences::GetInstance().CreateBoxedObject(value_hClassName.c_str(), value_hCtorSignature.c_str(), jnivalue_h, value_h); + jobject value_i; + if (!cppValue.i.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_i); + } + else + { + jobject value_iInsideOptional; + std::string value_iInsideOptionalClassName = "java/lang/Integer"; + std::string value_iInsideOptionalCtorSignature = "(I)V"; + jint jnivalue_iInsideOptional = static_cast(cppValue.i.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(value_iInsideOptionalClassName.c_str(), + value_iInsideOptionalCtorSignature.c_str(), + jnivalue_iInsideOptional, value_iInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_iInsideOptional, value_i); + } jclass simpleStructStructClass_0; err = chip::JniReferences::GetInstance().GetLocalClassRef( @@ -47023,7 +47102,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR err = chip::JniReferences::GetInstance().FindMethod( env, simpleStructStructClass_0, "", "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/lang/String;Ljava/lang/Integer;Ljava/lang/" - "Float;Ljava/lang/Double;)V", + "Float;Ljava/lang/Double;Ljava/util/Optional;)V", &simpleStructStructCtor_0); if (err != CHIP_NO_ERROR || simpleStructStructCtor_0 == nullptr) { @@ -47032,7 +47111,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } value = env->NewObject(simpleStructStructClass_0, simpleStructStructCtor_0, value_a, value_b, value_c, value_d, value_e, - value_f, value_g, value_h); + value_f, value_g, value_h, value_i); return value; } case Attributes::RangeRestrictedInt8u::Id: { @@ -47272,6 +47351,25 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_0_fabricSensitiveStruct_hClassName.c_str(), newElement_0_fabricSensitiveStruct_hCtorSignature.c_str(), jninewElement_0_fabricSensitiveStruct_h, newElement_0_fabricSensitiveStruct_h); + jobject newElement_0_fabricSensitiveStruct_i; + if (!entry_0.fabricSensitiveStruct.i.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_fabricSensitiveStruct_i); + } + else + { + jobject newElement_0_fabricSensitiveStruct_iInsideOptional; + std::string newElement_0_fabricSensitiveStruct_iInsideOptionalClassName = "java/lang/Integer"; + std::string newElement_0_fabricSensitiveStruct_iInsideOptionalCtorSignature = "(I)V"; + jint jninewElement_0_fabricSensitiveStruct_iInsideOptional = + static_cast(entry_0.fabricSensitiveStruct.i.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_fabricSensitiveStruct_iInsideOptionalClassName.c_str(), + newElement_0_fabricSensitiveStruct_iInsideOptionalCtorSignature.c_str(), + jninewElement_0_fabricSensitiveStruct_iInsideOptional, newElement_0_fabricSensitiveStruct_iInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_fabricSensitiveStruct_iInsideOptional, + newElement_0_fabricSensitiveStruct_i); + } jclass simpleStructStructClass_2; err = chip::JniReferences::GetInstance().GetLocalClassRef( @@ -47286,7 +47384,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR err = chip::JniReferences::GetInstance().FindMethod( env, simpleStructStructClass_2, "", "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/lang/String;Ljava/lang/Integer;Ljava/lang/" - "Float;Ljava/lang/Double;)V", + "Float;Ljava/lang/Double;Ljava/util/Optional;)V", &simpleStructStructCtor_2); if (err != CHIP_NO_ERROR || simpleStructStructCtor_2 == nullptr) { @@ -47299,7 +47397,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_0_fabricSensitiveStruct_b, newElement_0_fabricSensitiveStruct_c, newElement_0_fabricSensitiveStruct_d, newElement_0_fabricSensitiveStruct_e, newElement_0_fabricSensitiveStruct_f, newElement_0_fabricSensitiveStruct_g, - newElement_0_fabricSensitiveStruct_h); + newElement_0_fabricSensitiveStruct_h, newElement_0_fabricSensitiveStruct_i); jobject newElement_0_fabricSensitiveInt8uList; chip::JniReferences::GetInstance().CreateArrayList(newElement_0_fabricSensitiveInt8uList); @@ -47401,6 +47499,93 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jnivalue, value); return value; } + case Attributes::GlobalEnum::Id: { + using TypeInfo = Attributes::GlobalEnum::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + std::string valueClassName = "java/lang/Integer"; + std::string valueCtorSignature = "(I)V"; + jint jnivalue = static_cast(cppValue); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, + value); + return value; + } + case Attributes::GlobalStruct::Id: { + using TypeInfo = Attributes::GlobalStruct::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + jobject value_name; + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.name, value_name)); + jobject value_myBitmap; + if (cppValue.myBitmap.IsNull()) + { + value_myBitmap = nullptr; + } + else + { + std::string value_myBitmapClassName = "java/lang/Long"; + std::string value_myBitmapCtorSignature = "(J)V"; + jlong jnivalue_myBitmap = static_cast(cppValue.myBitmap.Value().Raw()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_myBitmapClassName.c_str(), value_myBitmapCtorSignature.c_str(), jnivalue_myBitmap, value_myBitmap); + } + jobject value_myEnum; + if (!cppValue.myEnum.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_myEnum); + } + else + { + jobject value_myEnumInsideOptional; + if (cppValue.myEnum.Value().IsNull()) + { + value_myEnumInsideOptional = nullptr; + } + else + { + std::string value_myEnumInsideOptionalClassName = "java/lang/Integer"; + std::string value_myEnumInsideOptionalCtorSignature = "(I)V"; + jint jnivalue_myEnumInsideOptional = static_cast(cppValue.myEnum.Value().Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_myEnumInsideOptionalClassName.c_str(), value_myEnumInsideOptionalCtorSignature.c_str(), + jnivalue_myEnumInsideOptional, value_myEnumInsideOptional); + } + chip::JniReferences::GetInstance().CreateOptional(value_myEnumInsideOptional, value_myEnum); + } + + jclass testGlobalStructStructClass_0; + err = chip::JniReferences::GetInstance().GetLocalClassRef( + env, "chip/devicecontroller/ChipStructs$UnitTestingClusterTestGlobalStruct", testGlobalStructStructClass_0); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterTestGlobalStruct"); + return nullptr; + } + + jmethodID testGlobalStructStructCtor_0; + err = chip::JniReferences::GetInstance().FindMethod(env, testGlobalStructStructClass_0, "", + "(Ljava/lang/String;Ljava/lang/Long;Ljava/util/Optional;)V", + &testGlobalStructStructCtor_0); + if (err != CHIP_NO_ERROR || testGlobalStructStructCtor_0 == nullptr) + { + ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterTestGlobalStruct constructor"); + return nullptr; + } + + value = env->NewObject(testGlobalStructStructClass_0, testGlobalStructStructCtor_0, value_name, value_myBitmap, + value_myEnum); + return value; + } case Attributes::Unsupported::Id: { using TypeInfo = Attributes::Unsupported::TypeInfo; TypeInfo::DecodableType cppValue; @@ -48114,6 +48299,22 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jdouble jnivalue_h = static_cast(cppValue.Value().h); chip::JniReferences::GetInstance().CreateBoxedObject(value_hClassName.c_str(), value_hCtorSignature.c_str(), jnivalue_h, value_h); + jobject value_i; + if (!cppValue.Value().i.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_i); + } + else + { + jobject value_iInsideOptional; + std::string value_iInsideOptionalClassName = "java/lang/Integer"; + std::string value_iInsideOptionalCtorSignature = "(I)V"; + jint jnivalue_iInsideOptional = static_cast(cppValue.Value().i.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(value_iInsideOptionalClassName.c_str(), + value_iInsideOptionalCtorSignature.c_str(), + jnivalue_iInsideOptional, value_iInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_iInsideOptional, value_i); + } jclass simpleStructStructClass_1; err = chip::JniReferences::GetInstance().GetLocalClassRef( @@ -48128,7 +48329,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR err = chip::JniReferences::GetInstance().FindMethod( env, simpleStructStructClass_1, "", "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/lang/String;Ljava/lang/Integer;Ljava/lang/" - "Float;Ljava/lang/Double;)V", + "Float;Ljava/lang/Double;Ljava/util/Optional;)V", &simpleStructStructCtor_1); if (err != CHIP_NO_ERROR || simpleStructStructCtor_1 == nullptr) { @@ -48137,7 +48338,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR } value = env->NewObject(simpleStructStructClass_1, simpleStructStructCtor_1, value_a, value_b, value_c, value_d, - value_e, value_f, value_g, value_h); + value_e, value_f, value_g, value_h, value_i); } return value; } @@ -48249,6 +48450,107 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR value); return value; } + case Attributes::NullableGlobalEnum::Id: { + using TypeInfo = Attributes::NullableGlobalEnum::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + std::string valueClassName = "java/lang/Integer"; + std::string valueCtorSignature = "(I)V"; + jint jnivalue = static_cast(cppValue.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + } + return value; + } + case Attributes::NullableGlobalStruct::Id: { + using TypeInfo = Attributes::NullableGlobalStruct::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + if (cppValue.IsNull()) + { + value = nullptr; + } + else + { + jobject value_name; + LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF(cppValue.Value().name, value_name)); + jobject value_myBitmap; + if (cppValue.Value().myBitmap.IsNull()) + { + value_myBitmap = nullptr; + } + else + { + std::string value_myBitmapClassName = "java/lang/Long"; + std::string value_myBitmapCtorSignature = "(J)V"; + jlong jnivalue_myBitmap = static_cast(cppValue.Value().myBitmap.Value().Raw()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_myBitmapClassName.c_str(), value_myBitmapCtorSignature.c_str(), jnivalue_myBitmap, value_myBitmap); + } + jobject value_myEnum; + if (!cppValue.Value().myEnum.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_myEnum); + } + else + { + jobject value_myEnumInsideOptional; + if (cppValue.Value().myEnum.Value().IsNull()) + { + value_myEnumInsideOptional = nullptr; + } + else + { + std::string value_myEnumInsideOptionalClassName = "java/lang/Integer"; + std::string value_myEnumInsideOptionalCtorSignature = "(I)V"; + jint jnivalue_myEnumInsideOptional = static_cast(cppValue.Value().myEnum.Value().Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_myEnumInsideOptionalClassName.c_str(), value_myEnumInsideOptionalCtorSignature.c_str(), + jnivalue_myEnumInsideOptional, value_myEnumInsideOptional); + } + chip::JniReferences::GetInstance().CreateOptional(value_myEnumInsideOptional, value_myEnum); + } + + jclass testGlobalStructStructClass_1; + err = chip::JniReferences::GetInstance().GetLocalClassRef( + env, "chip/devicecontroller/ChipStructs$UnitTestingClusterTestGlobalStruct", testGlobalStructStructClass_1); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipStructs$UnitTestingClusterTestGlobalStruct"); + return nullptr; + } + + jmethodID testGlobalStructStructCtor_1; + err = chip::JniReferences::GetInstance().FindMethod(env, testGlobalStructStructClass_1, "", + "(Ljava/lang/String;Ljava/lang/Long;Ljava/util/Optional;)V", + &testGlobalStructStructCtor_1); + if (err != CHIP_NO_ERROR || testGlobalStructStructCtor_1 == nullptr) + { + ChipLogError(Zcl, "Could not find ChipStructs$UnitTestingClusterTestGlobalStruct constructor"); + return nullptr; + } + + value = env->NewObject(testGlobalStructStructClass_1, testGlobalStructStructCtor_1, value_name, value_myBitmap, + value_myEnum); + } + return value; + } case Attributes::GeneratedCommandList::Id: { using TypeInfo = Attributes::GeneratedCommandList::TypeInfo; TypeInfo::DecodableType cppValue; diff --git a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp index 7f3c03f9e8ab05..89a4a256880158 100644 --- a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp @@ -8260,6 +8260,22 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jdouble jnivalue_arg4_h = static_cast(cppValue.arg4.h); chip::JniReferences::GetInstance().CreateBoxedObject( value_arg4_hClassName.c_str(), value_arg4_hCtorSignature.c_str(), jnivalue_arg4_h, value_arg4_h); + jobject value_arg4_i; + if (!cppValue.arg4.i.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, value_arg4_i); + } + else + { + jobject value_arg4_iInsideOptional; + std::string value_arg4_iInsideOptionalClassName = "java/lang/Integer"; + std::string value_arg4_iInsideOptionalCtorSignature = "(I)V"; + jint jnivalue_arg4_iInsideOptional = static_cast(cppValue.arg4.i.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_arg4_iInsideOptionalClassName.c_str(), value_arg4_iInsideOptionalCtorSignature.c_str(), + jnivalue_arg4_iInsideOptional, value_arg4_iInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(value_arg4_iInsideOptional, value_arg4_i); + } jclass simpleStructStructClass_0; err = chip::JniReferences::GetInstance().GetLocalClassRef( @@ -8274,7 +8290,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & err = chip::JniReferences::GetInstance().FindMethod( env, simpleStructStructClass_0, "", "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/lang/String;Ljava/lang/Integer;Ljava/lang/" - "Float;Ljava/lang/Double;)V", + "Float;Ljava/lang/Double;Ljava/util/Optional;)V", &simpleStructStructCtor_0); if (err != CHIP_NO_ERROR || simpleStructStructCtor_0 == nullptr) { @@ -8282,8 +8298,9 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } - value_arg4 = env->NewObject(simpleStructStructClass_0, simpleStructStructCtor_0, value_arg4_a, value_arg4_b, - value_arg4_c, value_arg4_d, value_arg4_e, value_arg4_f, value_arg4_g, value_arg4_h); + value_arg4 = + env->NewObject(simpleStructStructClass_0, simpleStructStructCtor_0, value_arg4_a, value_arg4_b, value_arg4_c, + value_arg4_d, value_arg4_e, value_arg4_f, value_arg4_g, value_arg4_h, value_arg4_i); jobject value_arg5; chip::JniReferences::GetInstance().CreateArrayList(value_arg5); @@ -8336,6 +8353,22 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & jdouble jninewElement_0_h = static_cast(entry_0.h); chip::JniReferences::GetInstance().CreateBoxedObject( newElement_0_hClassName.c_str(), newElement_0_hCtorSignature.c_str(), jninewElement_0_h, newElement_0_h); + jobject newElement_0_i; + if (!entry_0.i.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_0_i); + } + else + { + jobject newElement_0_iInsideOptional; + std::string newElement_0_iInsideOptionalClassName = "java/lang/Integer"; + std::string newElement_0_iInsideOptionalCtorSignature = "(I)V"; + jint jninewElement_0_iInsideOptional = static_cast(entry_0.i.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_0_iInsideOptionalClassName.c_str(), newElement_0_iInsideOptionalCtorSignature.c_str(), + jninewElement_0_iInsideOptional, newElement_0_iInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_0_iInsideOptional, newElement_0_i); + } jclass simpleStructStructClass_1; err = chip::JniReferences::GetInstance().GetLocalClassRef( @@ -8350,7 +8383,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & err = chip::JniReferences::GetInstance().FindMethod( env, simpleStructStructClass_1, "", "(Ljava/lang/Integer;Ljava/lang/Boolean;Ljava/lang/Integer;[BLjava/lang/String;Ljava/lang/Integer;Ljava/lang/" - "Float;Ljava/lang/Double;)V", + "Float;Ljava/lang/Double;Ljava/util/Optional;)V", &simpleStructStructCtor_1); if (err != CHIP_NO_ERROR || simpleStructStructCtor_1 == nullptr) { @@ -8358,9 +8391,9 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } - newElement_0 = - env->NewObject(simpleStructStructClass_1, simpleStructStructCtor_1, newElement_0_a, newElement_0_b, - newElement_0_c, newElement_0_d, newElement_0_e, newElement_0_f, newElement_0_g, newElement_0_h); + newElement_0 = env->NewObject(simpleStructStructClass_1, simpleStructStructCtor_1, newElement_0_a, newElement_0_b, + newElement_0_c, newElement_0_d, newElement_0_e, newElement_0_f, newElement_0_g, + newElement_0_h, newElement_0_i); chip::JniReferences::GetInstance().AddToList(value_arg5, newElement_0); } diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index 588c3da4f020eb..cc0b5aaa65a4b2 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -14491,6 +14491,14 @@ class ChipClusters: "payload": "bytes", }, }, + 0x00000019: { + "commandId": 0x00000019, + "commandName": "GlobalEchoRequest", + "args": { + "field1": "TestGlobalStruct", + "field2": "int", + }, + }, 0xFFF200AA: { "commandId": 0xFFF200AA, "commandName": "TestDifferentVendorMeiRequest", @@ -14829,6 +14837,20 @@ class ChipClusters: "reportable": True, "writable": True, }, + 0x00000033: { + "attributeName": "GlobalEnum", + "attributeId": 0x00000033, + "type": "int", + "reportable": True, + "writable": True, + }, + 0x00000034: { + "attributeName": "GlobalStruct", + "attributeId": 0x00000034, + "type": "", + "reportable": True, + "writable": True, + }, 0x000000FF: { "attributeName": "Unsupported", "attributeId": 0x000000FF, @@ -15074,6 +15096,20 @@ class ChipClusters: "reportable": True, "writable": True, }, + 0x00004033: { + "attributeName": "NullableGlobalEnum", + "attributeId": 0x00004033, + "type": "int", + "reportable": True, + "writable": True, + }, + 0x00004034: { + "attributeName": "NullableGlobalStruct", + "attributeId": 0x00004034, + "type": "", + "reportable": True, + "writable": True, + }, 0x0000FFF8: { "attributeName": "GeneratedCommandList", "attributeId": 0x0000FFF8, diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index b84ad31879c1d5..3795b08dd230e3 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -50101,6 +50101,8 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="timedWriteBoolean", Tag=0x00000030, Type=bool), ClusterObjectFieldDescriptor(Label="generalErrorBoolean", Tag=0x00000031, Type=bool), ClusterObjectFieldDescriptor(Label="clusterErrorBoolean", Tag=0x00000032, Type=bool), + ClusterObjectFieldDescriptor(Label="globalEnum", Tag=0x00000033, Type=Globals.Enums.TestGlobalEnum), + ClusterObjectFieldDescriptor(Label="globalStruct", Tag=0x00000034, Type=Globals.Structs.TestGlobalStruct), ClusterObjectFieldDescriptor(Label="unsupported", Tag=0x000000FF, Type=typing.Optional[bool]), ClusterObjectFieldDescriptor(Label="nullableBoolean", Tag=0x00004000, Type=typing.Union[Nullable, bool]), ClusterObjectFieldDescriptor(Label="nullableBitmap8", Tag=0x00004001, Type=typing.Union[Nullable, uint]), @@ -50136,6 +50138,8 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="nullableRangeRestrictedInt16u", Tag=0x00004028, Type=typing.Union[Nullable, uint]), ClusterObjectFieldDescriptor(Label="nullableRangeRestrictedInt16s", Tag=0x00004029, Type=typing.Union[Nullable, int]), ClusterObjectFieldDescriptor(Label="writeOnlyInt8u", Tag=0x0000402A, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="nullableGlobalEnum", Tag=0x00004033, Type=typing.Union[Nullable, Globals.Enums.TestGlobalEnum]), + ClusterObjectFieldDescriptor(Label="nullableGlobalStruct", Tag=0x00004034, Type=typing.Union[Nullable, Globals.Structs.TestGlobalStruct]), ClusterObjectFieldDescriptor(Label="generatedCommandList", Tag=0x0000FFF8, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="acceptedCommandList", Tag=0x0000FFF9, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="eventList", Tag=0x0000FFFA, Type=typing.List[uint]), @@ -50192,6 +50196,8 @@ def descriptor(cls) -> ClusterObjectDescriptor: timedWriteBoolean: 'bool' = None generalErrorBoolean: 'bool' = None clusterErrorBoolean: 'bool' = None + globalEnum: 'Globals.Enums.TestGlobalEnum' = None + globalStruct: 'Globals.Structs.TestGlobalStruct' = None unsupported: 'typing.Optional[bool]' = None nullableBoolean: 'typing.Union[Nullable, bool]' = None nullableBitmap8: 'typing.Union[Nullable, uint]' = None @@ -50227,6 +50233,8 @@ def descriptor(cls) -> ClusterObjectDescriptor: nullableRangeRestrictedInt16u: 'typing.Union[Nullable, uint]' = None nullableRangeRestrictedInt16s: 'typing.Union[Nullable, int]' = None writeOnlyInt8u: 'typing.Optional[uint]' = None + nullableGlobalEnum: 'typing.Union[Nullable, Globals.Enums.TestGlobalEnum]' = None + nullableGlobalStruct: 'typing.Union[Nullable, Globals.Structs.TestGlobalStruct]' = None generatedCommandList: 'typing.List[uint]' = None acceptedCommandList: 'typing.List[uint]' = None eventList: 'typing.List[uint]' = None @@ -50292,6 +50300,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="f", Tag=5, Type=uint), ClusterObjectFieldDescriptor(Label="g", Tag=6, Type=float32), ClusterObjectFieldDescriptor(Label="h", Tag=7, Type=float), + ClusterObjectFieldDescriptor(Label="i", Tag=8, Type=typing.Optional[Globals.Enums.TestGlobalEnum]), ]) a: 'uint' = 0 @@ -50302,6 +50311,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: f: 'uint' = 0 g: 'float32' = 0.0 h: 'float' = 0.0 + i: 'typing.Optional[Globals.Enums.TestGlobalEnum]' = None @dataclass class TestFabricScoped(ClusterObject): @@ -50370,11 +50380,13 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="a", Tag=0, Type=uint), ClusterObjectFieldDescriptor(Label="b", Tag=1, Type=bool), ClusterObjectFieldDescriptor(Label="c", Tag=2, Type=UnitTesting.Structs.SimpleStruct), + ClusterObjectFieldDescriptor(Label="d", Tag=3, Type=typing.Optional[Globals.Structs.TestGlobalStruct]), ]) a: 'uint' = 0 b: 'bool' = False c: 'UnitTesting.Structs.SimpleStruct' = field(default_factory=lambda: UnitTesting.Structs.SimpleStruct()) + d: 'typing.Optional[Globals.Structs.TestGlobalStruct]' = None @dataclass class NestedStructList(ClusterObject): @@ -50962,6 +50974,24 @@ def descriptor(cls) -> ClusterObjectDescriptor: arg1: 'uint' = 0 arg2: 'UnitTesting.Enums.SimpleEnum' = 0 + @dataclass + class GlobalEchoResponse(ClusterCommand): + cluster_id: typing.ClassVar[int] = 0xFFF1FC05 + command_id: typing.ClassVar[int] = 0x0000000E + is_client: typing.ClassVar[bool] = False + response_type: typing.ClassVar[str] = None + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="field1", Tag=0, Type=Globals.Structs.TestGlobalStruct), + ClusterObjectFieldDescriptor(Label="field2", Tag=1, Type=Globals.Enums.TestGlobalEnum), + ]) + + field1: 'Globals.Structs.TestGlobalStruct' = field(default_factory=lambda: UnitTesting.Structs.TestGlobalStruct()) + field2: 'Globals.Enums.TestGlobalEnum' = 0 + @dataclass class TestNullableOptionalRequest(ClusterCommand): cluster_id: typing.ClassVar[int] = 0xFFF1FC05 @@ -51157,6 +51187,24 @@ def descriptor(cls) -> ClusterObjectDescriptor: payload: 'bytes' = b"" + @dataclass + class GlobalEchoRequest(ClusterCommand): + cluster_id: typing.ClassVar[int] = 0xFFF1FC05 + command_id: typing.ClassVar[int] = 0x00000019 + is_client: typing.ClassVar[bool] = True + response_type: typing.ClassVar[str] = 'GlobalEchoResponse' + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="field1", Tag=0, Type=Globals.Structs.TestGlobalStruct), + ClusterObjectFieldDescriptor(Label="field2", Tag=1, Type=Globals.Enums.TestGlobalEnum), + ]) + + field1: 'Globals.Structs.TestGlobalStruct' = field(default_factory=lambda: UnitTesting.Structs.TestGlobalStruct()) + field2: 'Globals.Enums.TestGlobalEnum' = 0 + @dataclass class TestDifferentVendorMeiRequest(ClusterCommand): cluster_id: typing.ClassVar[int] = 0xFFF1FC05 @@ -51948,6 +51996,38 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'bool' = False + @dataclass + class GlobalEnum(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0xFFF1FC05 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000033 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=Globals.Enums.TestGlobalEnum) + + value: 'Globals.Enums.TestGlobalEnum' = 0 + + @dataclass + class GlobalStruct(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0xFFF1FC05 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000034 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=Globals.Structs.TestGlobalStruct) + + value: 'Globals.Structs.TestGlobalStruct' = field(default_factory=lambda: UnitTesting.Structs.TestGlobalStruct()) + @dataclass class Unsupported(ClusterAttributeDescriptor): @ChipUtility.classproperty @@ -52508,6 +52588,38 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'typing.Optional[uint]' = None + @dataclass + class NullableGlobalEnum(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0xFFF1FC05 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00004033 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[Nullable, Globals.Enums.TestGlobalEnum]) + + value: 'typing.Union[Nullable, Globals.Enums.TestGlobalEnum]' = NullValue + + @dataclass + class NullableGlobalStruct(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0xFFF1FC05 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00004034 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[Nullable, Globals.Structs.TestGlobalStruct]) + + value: 'typing.Union[Nullable, Globals.Structs.TestGlobalStruct]' = NullValue + @dataclass class GeneratedCommandList(ClusterAttributeDescriptor): @ChipUtility.classproperty diff --git a/src/darwin/Framework/CHIP/templates/availability.yaml b/src/darwin/Framework/CHIP/templates/availability.yaml index aed4d52a4c4b3c..ee6351b3c6793e 100644 --- a/src/darwin/Framework/CHIP/templates/availability.yaml +++ b/src/darwin/Framework/CHIP/templates/availability.yaml @@ -9695,29 +9695,38 @@ - WaterHeaterMode - WiFiNetworkManagement attributes: - OccupancySensing: - # Targeting 1.4 - - HoldTime - - HoldTimeLimits GeneralCommissioning: # Targeting 1.4 - TCAcceptedVersion - TCMinRequiredVersion - TCAcknowledgements - TCAcknowledgementsRequired + OccupancySensing: + # Targeting 1.4 + - HoldTime + - HoldTimeLimits + UnitTesting: + # Ideally none of UnitTesting would be exposed as public API, but + # for now just start doing that for new additions to it. + - GlobalEnum + - GlobalStruct + - NullableGlobalEnum + - NullableGlobalStruct commands: BridgedDeviceBasicInformation: # Targeting 1.4 - KeepActive + GeneralCommissioning: + # Targeting 1.4 + - SetTCAcknowledgements + - SetTCAcknowledgementsResponse UnitTesting: # Ideally none of UnitTesting would be exposed as public API, but # for now just start doing that for new additions to it. + - GlobalEchoRequest + - GlobalEchoResponse - StringEchoRequest - StringEchoResponse - GeneralCommissioning: - # Targeting 1.4 - - SetTCAcknowledgements - - SetTCAcknowledgementsResponse structs: Globals: # Test-only value @@ -9725,6 +9734,14 @@ OccupancySensing: # Targeting 1.4 - HoldTimeLimitsStruct + struct fields: + UnitTesting: + # Ideally none of UnitTesting would be exposed as public API, but + # for now just start doing that for new additions to it. + SimpleStruct: + - i + NestedStruct: + - d events: BridgedDeviceBasicInformation: # Targeting 1.4 @@ -9744,10 +9761,10 @@ BridgedDeviceBasicInformation: # Targeting 1.4 - Feature - OccupancySensing: + GeneralCommissioning: # Targeting 1.4 - Feature - GeneralCommissioning: + OccupancySensing: # Targeting 1.4 - Feature bitmap values: diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm index d214e061ec9f65..d0ea9a364af749 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm @@ -6678,6 +6678,12 @@ static BOOL AttributeIsSpecifiedInUnitTestingCluster(AttributeId aAttributeId) case Attributes::ClusterErrorBoolean::Id: { return YES; } + case Attributes::GlobalEnum::Id: { + return YES; + } + case Attributes::GlobalStruct::Id: { + return YES; + } case Attributes::Unsupported::Id: { return YES; } @@ -6783,6 +6789,12 @@ static BOOL AttributeIsSpecifiedInUnitTestingCluster(AttributeId aAttributeId) case Attributes::WriteOnlyInt8u::Id: { return YES; } + case Attributes::NullableGlobalEnum::Id: { + return YES; + } + case Attributes::NullableGlobalStruct::Id: { + return YES; + } case Attributes::GeneratedCommandList::Id: { return YES; } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm index 7920a04dc597b1..c6d743173044cd 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm @@ -19333,6 +19333,11 @@ static id _Nullable DecodeAttributeValueForUnitTestingCluster(AttributeId aAttri newElement_0.nullableStruct.f = [NSNumber numberWithUnsignedChar:entry_0.nullableStruct.Value().f.Raw()]; newElement_0.nullableStruct.g = [NSNumber numberWithFloat:entry_0.nullableStruct.Value().g]; newElement_0.nullableStruct.h = [NSNumber numberWithDouble:entry_0.nullableStruct.Value().h]; + if (entry_0.nullableStruct.Value().i.HasValue()) { + newElement_0.nullableStruct.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.nullableStruct.Value().i.Value())]; + } else { + newElement_0.nullableStruct.i = nil; + } } if (entry_0.optionalStruct.HasValue()) { newElement_0.optionalStruct = [MTRUnitTestingClusterSimpleStruct new]; @@ -19349,6 +19354,11 @@ static id _Nullable DecodeAttributeValueForUnitTestingCluster(AttributeId aAttri newElement_0.optionalStruct.f = [NSNumber numberWithUnsignedChar:entry_0.optionalStruct.Value().f.Raw()]; newElement_0.optionalStruct.g = [NSNumber numberWithFloat:entry_0.optionalStruct.Value().g]; newElement_0.optionalStruct.h = [NSNumber numberWithDouble:entry_0.optionalStruct.Value().h]; + if (entry_0.optionalStruct.Value().i.HasValue()) { + newElement_0.optionalStruct.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.optionalStruct.Value().i.Value())]; + } else { + newElement_0.optionalStruct.i = nil; + } } else { newElement_0.optionalStruct = nil; } @@ -19370,6 +19380,11 @@ static id _Nullable DecodeAttributeValueForUnitTestingCluster(AttributeId aAttri newElement_0.nullableOptionalStruct.f = [NSNumber numberWithUnsignedChar:entry_0.nullableOptionalStruct.Value().Value().f.Raw()]; newElement_0.nullableOptionalStruct.g = [NSNumber numberWithFloat:entry_0.nullableOptionalStruct.Value().Value().g]; newElement_0.nullableOptionalStruct.h = [NSNumber numberWithDouble:entry_0.nullableOptionalStruct.Value().Value().h]; + if (entry_0.nullableOptionalStruct.Value().Value().i.HasValue()) { + newElement_0.nullableOptionalStruct.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.nullableOptionalStruct.Value().Value().i.Value())]; + } else { + newElement_0.nullableOptionalStruct.i = nil; + } } } else { newElement_0.nullableOptionalStruct = nil; @@ -19482,6 +19497,11 @@ static id _Nullable DecodeAttributeValueForUnitTestingCluster(AttributeId aAttri value.f = [NSNumber numberWithUnsignedChar:cppValue.f.Raw()]; value.g = [NSNumber numberWithFloat:cppValue.g]; value.h = [NSNumber numberWithDouble:cppValue.h]; + if (cppValue.i.HasValue()) { + value.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue.i.Value())]; + } else { + value.i = nil; + } return value; } case Attributes::RangeRestrictedInt8u::Id: { @@ -19609,6 +19629,11 @@ static id _Nullable DecodeAttributeValueForUnitTestingCluster(AttributeId aAttri newElement_0.fabricSensitiveStruct.f = [NSNumber numberWithUnsignedChar:entry_0.fabricSensitiveStruct.f.Raw()]; newElement_0.fabricSensitiveStruct.g = [NSNumber numberWithFloat:entry_0.fabricSensitiveStruct.g]; newElement_0.fabricSensitiveStruct.h = [NSNumber numberWithDouble:entry_0.fabricSensitiveStruct.h]; + if (entry_0.fabricSensitiveStruct.i.HasValue()) { + newElement_0.fabricSensitiveStruct.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.fabricSensitiveStruct.i.Value())]; + } else { + newElement_0.fabricSensitiveStruct.i = nil; + } { // Scope for our temporary variables auto * array_2 = [NSMutableArray new]; auto iter_2 = entry_0.fabricSensitiveInt8uList.begin(); @@ -19670,6 +19695,48 @@ static id _Nullable DecodeAttributeValueForUnitTestingCluster(AttributeId aAttri value = [NSNumber numberWithBool:cppValue]; return value; } + case Attributes::GlobalEnum::Id: { + using TypeInfo = Attributes::GlobalEnum::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nonnull value; + value = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue)]; + return value; + } + case Attributes::GlobalStruct::Id: { + using TypeInfo = Attributes::GlobalStruct::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + MTRDataTypeTestGlobalStruct * _Nonnull value; + value = [MTRDataTypeTestGlobalStruct new]; + value.name = AsString(cppValue.name); + if (value.name == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + *aError = err; + return nil; + } + if (cppValue.myBitmap.IsNull()) { + value.myBitmap = nil; + } else { + value.myBitmap = [NSNumber numberWithUnsignedInt:cppValue.myBitmap.Value().Raw()]; + } + if (cppValue.myEnum.HasValue()) { + if (cppValue.myEnum.Value().IsNull()) { + value.myEnum = nil; + } else { + value.myEnum = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue.myEnum.Value().Value())]; + } + } else { + value.myEnum = nil; + } + return value; + } case Attributes::Unsupported::Id: { using TypeInfo = Attributes::Unsupported::TypeInfo; TypeInfo::DecodableType cppValue; @@ -20131,6 +20198,11 @@ static id _Nullable DecodeAttributeValueForUnitTestingCluster(AttributeId aAttri value.f = [NSNumber numberWithUnsignedChar:cppValue.Value().f.Raw()]; value.g = [NSNumber numberWithFloat:cppValue.Value().g]; value.h = [NSNumber numberWithDouble:cppValue.Value().h]; + if (cppValue.Value().i.HasValue()) { + value.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue.Value().i.Value())]; + } else { + value.i = nil; + } } return value; } @@ -20205,6 +20277,56 @@ static id _Nullable DecodeAttributeValueForUnitTestingCluster(AttributeId aAttri value = [NSNumber numberWithUnsignedChar:cppValue]; return value; } + case Attributes::NullableGlobalEnum::Id: { + using TypeInfo = Attributes::NullableGlobalEnum::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue.Value())]; + } + return value; + } + case Attributes::NullableGlobalStruct::Id: { + using TypeInfo = Attributes::NullableGlobalStruct::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + MTRDataTypeTestGlobalStruct * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [MTRDataTypeTestGlobalStruct new]; + value.name = AsString(cppValue.Value().name); + if (value.name == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + *aError = err; + return nil; + } + if (cppValue.Value().myBitmap.IsNull()) { + value.myBitmap = nil; + } else { + value.myBitmap = [NSNumber numberWithUnsignedInt:cppValue.Value().myBitmap.Value().Raw()]; + } + if (cppValue.Value().myEnum.HasValue()) { + if (cppValue.Value().myEnum.Value().IsNull()) { + value.myEnum = nil; + } else { + value.myEnum = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue.Value().myEnum.Value().Value())]; + } + } else { + value.myEnum = nil; + } + } + return value; + } case Attributes::MeiInt8u::Id: { using TypeInfo = Attributes::MeiInt8u::TypeInfo; TypeInfo::DecodableType cppValue; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index bdd3bcf1f78a2f..0f17934d1ee74f 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -16339,6 +16339,13 @@ MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) supports large payloads. */ - (void)stringEchoRequestWithParams:(MTRUnitTestingClusterStringEchoRequestParams *)params completion:(void (^)(MTRUnitTestingClusterStringEchoResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +/** + * Command GlobalEchoRequest + * + * Command that takes arguments that are global structs/enums and the + response just echoes them back. + */ +- (void)globalEchoRequestWithParams:(MTRUnitTestingClusterGlobalEchoRequestParams *)params completion:(void (^)(MTRUnitTestingClusterGlobalEchoResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; /** * Command TestDifferentVendorMeiRequest * @@ -16722,6 +16729,22 @@ MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); + (void)readAttributeClusterErrorBooleanWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +- (void)readAttributeGlobalEnumWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)writeAttributeGlobalEnumWithValue:(NSNumber * _Nonnull)value completion:(MTRStatusCompletion)completion MTR_PROVISIONALLY_AVAILABLE; +- (void)writeAttributeGlobalEnumWithValue:(NSNumber * _Nonnull)value params:(MTRWriteParams * _Nullable)params completion:(MTRStatusCompletion)completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeGlobalEnumWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeGlobalEnumWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeGlobalStructWithCompletion:(void (^)(MTRDataTypeTestGlobalStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)writeAttributeGlobalStructWithValue:(MTRDataTypeTestGlobalStruct * _Nonnull)value completion:(MTRStatusCompletion)completion MTR_PROVISIONALLY_AVAILABLE; +- (void)writeAttributeGlobalStructWithValue:(MTRDataTypeTestGlobalStruct * _Nonnull)value params:(MTRWriteParams * _Nullable)params completion:(MTRStatusCompletion)completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeGlobalStructWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(MTRDataTypeTestGlobalStruct * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeGlobalStructWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRDataTypeTestGlobalStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + - (void)readAttributeUnsupportedWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); - (void)writeAttributeUnsupportedWithValue:(NSNumber * _Nonnull)value completion:(MTRStatusCompletion)completion MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); - (void)writeAttributeUnsupportedWithValue:(NSNumber * _Nonnull)value params:(MTRWriteParams * _Nullable)params completion:(MTRStatusCompletion)completion MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); @@ -17002,6 +17025,22 @@ MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); + (void)readAttributeWriteOnlyInt8uWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +- (void)readAttributeNullableGlobalEnumWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)writeAttributeNullableGlobalEnumWithValue:(NSNumber * _Nullable)value completion:(MTRStatusCompletion)completion MTR_PROVISIONALLY_AVAILABLE; +- (void)writeAttributeNullableGlobalEnumWithValue:(NSNumber * _Nullable)value params:(MTRWriteParams * _Nullable)params completion:(MTRStatusCompletion)completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeNullableGlobalEnumWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeNullableGlobalEnumWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + +- (void)readAttributeNullableGlobalStructWithCompletion:(void (^)(MTRDataTypeTestGlobalStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)writeAttributeNullableGlobalStructWithValue:(MTRDataTypeTestGlobalStruct * _Nullable)value completion:(MTRStatusCompletion)completion MTR_PROVISIONALLY_AVAILABLE; +- (void)writeAttributeNullableGlobalStructWithValue:(MTRDataTypeTestGlobalStruct * _Nullable)value params:(MTRWriteParams * _Nullable)params completion:(MTRStatusCompletion)completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeNullableGlobalStructWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(MTRDataTypeTestGlobalStruct * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeNullableGlobalStructWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRDataTypeTestGlobalStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + - (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); - (void)subscribeAttributeGeneratedCommandListWithParams:(MTRSubscribeParams *)params subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm index e2bb0e376dffe1..3ca3bfe55708dd 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm @@ -116509,6 +116509,30 @@ - (void)stringEchoRequestWithParams:(MTRUnitTestingClusterStringEchoRequestParam queue:self.callbackQueue completion:responseHandler]; } +- (void)globalEchoRequestWithParams:(MTRUnitTestingClusterGlobalEchoRequestParams *)params completion:(void (^)(MTRUnitTestingClusterGlobalEchoResponseParams * _Nullable data, NSError * _Nullable error))completion +{ + if (params == nil) { + params = [[MTRUnitTestingClusterGlobalEchoRequestParams + alloc] init]; + } + + auto responseHandler = ^(id _Nullable response, NSError * _Nullable error) { + completion(response, error); + }; + + auto * timedInvokeTimeoutMs = params.timedInvokeTimeoutMs; + + using RequestType = UnitTesting::Commands::GlobalEchoRequest::Type; + [self.device _invokeKnownCommandWithEndpointID:self.endpointID + clusterID:@(RequestType::GetClusterId()) + commandID:@(RequestType::GetCommandId()) + commandPayload:params + timedInvokeTimeout:timedInvokeTimeoutMs + serverSideProcessingTimeout:params.serverSideProcessingTimeout + responseClass:MTRUnitTestingClusterGlobalEchoResponseParams.class + queue:self.callbackQueue + completion:responseHandler]; +} - (void)testDifferentVendorMeiRequestWithParams:(MTRUnitTestingClusterTestDifferentVendorMeiRequestParams *)params completion:(void (^)(MTRUnitTestingClusterTestDifferentVendorMeiResponseParams * _Nullable data, NSError * _Nullable error))completion { if (params == nil) { @@ -118935,6 +118959,10 @@ - (void)writeAttributeListNullablesAndOptionalsStructWithValue:(NSArray * _Nonnu nonNullValue_2.f = static_cast>(element_0.nullableStruct.f.unsignedCharValue); nonNullValue_2.g = element_0.nullableStruct.g.floatValue; nonNullValue_2.h = element_0.nullableStruct.h.doubleValue; + if (element_0.nullableStruct.i != nil) { + auto & definedValue_4 = nonNullValue_2.i.Emplace(); + definedValue_4 = static_cast>(element_0.nullableStruct.i.unsignedCharValue); + } } if (element_0.optionalStruct != nil) { auto & definedValue_2 = listHolder_0->mList[i_0].optionalStruct.Emplace(); @@ -118946,6 +118974,10 @@ - (void)writeAttributeListNullablesAndOptionalsStructWithValue:(NSArray * _Nonnu definedValue_2.f = static_cast>(element_0.optionalStruct.f.unsignedCharValue); definedValue_2.g = element_0.optionalStruct.g.floatValue; definedValue_2.h = element_0.optionalStruct.h.doubleValue; + if (element_0.optionalStruct.i != nil) { + auto & definedValue_4 = definedValue_2.i.Emplace(); + definedValue_4 = static_cast>(element_0.optionalStruct.i.unsignedCharValue); + } } if (element_0.nullableOptionalStruct != nil) { auto & definedValue_2 = listHolder_0->mList[i_0].nullableOptionalStruct.Emplace(); @@ -118961,6 +118993,10 @@ - (void)writeAttributeListNullablesAndOptionalsStructWithValue:(NSArray * _Nonnu nonNullValue_3.f = static_cast>(element_0.nullableOptionalStruct.f.unsignedCharValue); nonNullValue_3.g = element_0.nullableOptionalStruct.g.floatValue; nonNullValue_3.h = element_0.nullableOptionalStruct.h.doubleValue; + if (element_0.nullableOptionalStruct.i != nil) { + auto & definedValue_5 = nonNullValue_3.i.Emplace(); + definedValue_5 = static_cast>(element_0.nullableOptionalStruct.i.unsignedCharValue); + } } } if (element_0.nullableList == nil) { @@ -119186,6 +119222,10 @@ - (void)writeAttributeStructAttrWithValue:(MTRUnitTestingClusterSimpleStruct * _ cppValue.f = static_cast>(value.f.unsignedCharValue); cppValue.g = value.g.floatValue; cppValue.h = value.h.doubleValue; + if (value.i != nil) { + auto & definedValue_1 = cppValue.i.Emplace(); + definedValue_1 = static_cast>(value.i.unsignedCharValue); + } chip::Controller::ClusterBase cppCluster(exchangeManager, session, self.endpointID.unsignedShortValue); return cppCluster.WriteAttribute(cppValue, bridge, successCb, failureCb, timedWriteTimeout); }); @@ -119634,6 +119674,10 @@ - (void)writeAttributeListFabricScopedWithValue:(NSArray * _Nonnull)value params listHolder_0->mList[i_0].fabricSensitiveStruct.f = static_castmList[i_0].fabricSensitiveStruct.f)>>(element_0.fabricSensitiveStruct.f.unsignedCharValue); listHolder_0->mList[i_0].fabricSensitiveStruct.g = element_0.fabricSensitiveStruct.g.floatValue; listHolder_0->mList[i_0].fabricSensitiveStruct.h = element_0.fabricSensitiveStruct.h.doubleValue; + if (element_0.fabricSensitiveStruct.i != nil) { + auto & definedValue_3 = listHolder_0->mList[i_0].fabricSensitiveStruct.i.Emplace(); + definedValue_3 = static_cast>(element_0.fabricSensitiveStruct.i.unsignedCharValue); + } { using ListType_2 = std::remove_reference_tmList[i_0].fabricSensitiveInt8uList)>; using ListMemberType_2 = ListMemberTypeGetter::Type; @@ -119889,6 +119933,149 @@ + (void)readAttributeClusterErrorBooleanWithClusterStateCache:(MTRClusterStateCa completion:completion]; } +- (void)readAttributeGlobalEnumWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = UnitTesting::Attributes::GlobalEnum::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)writeAttributeGlobalEnumWithValue:(NSNumber * _Nonnull)value completion:(MTRStatusCompletion)completion +{ + [self writeAttributeGlobalEnumWithValue:(NSNumber * _Nonnull) value params:nil completion:completion]; +} +- (void)writeAttributeGlobalEnumWithValue:(NSNumber * _Nonnull)value params:(MTRWriteParams * _Nullable)params completion:(MTRStatusCompletion)completion +{ + // Make a copy of params before we go async. + params = [params copy]; + value = [value copy]; + + auto * bridge = new MTRDefaultSuccessCallbackBridge(self.callbackQueue, ^(id _Nullable ignored, NSError * _Nullable error) { completion(error); }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, DefaultSuccessCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { + chip::Optional timedWriteTimeout; + if (params != nil) { + if (params.timedWriteTimeout != nil){ + timedWriteTimeout.SetValue(params.timedWriteTimeout.unsignedShortValue); + } + } + + ListFreer listFreer; + using TypeInfo = UnitTesting::Attributes::GlobalEnum::TypeInfo; + TypeInfo::Type cppValue; + cppValue = static_cast>(value.unsignedCharValue); + + chip::Controller::ClusterBase cppCluster(exchangeManager, session, self.endpointID.unsignedShortValue); + return cppCluster.WriteAttribute(cppValue, bridge, successCb, failureCb, timedWriteTimeout); }); + std::move(*bridge).DispatchAction(self.device); +} + +- (void)subscribeAttributeGlobalEnumWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = UnitTesting::Attributes::GlobalEnum::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeGlobalEnumWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = UnitTesting::Attributes::GlobalEnum::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeGlobalStructWithCompletion:(void (^)(MTRDataTypeTestGlobalStruct * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = UnitTesting::Attributes::GlobalStruct::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)writeAttributeGlobalStructWithValue:(MTRDataTypeTestGlobalStruct * _Nonnull)value completion:(MTRStatusCompletion)completion +{ + [self writeAttributeGlobalStructWithValue:(MTRDataTypeTestGlobalStruct * _Nonnull) value params:nil completion:completion]; +} +- (void)writeAttributeGlobalStructWithValue:(MTRDataTypeTestGlobalStruct * _Nonnull)value params:(MTRWriteParams * _Nullable)params completion:(MTRStatusCompletion)completion +{ + // Make a copy of params before we go async. + params = [params copy]; + value = [value copy]; + + auto * bridge = new MTRDefaultSuccessCallbackBridge(self.callbackQueue, ^(id _Nullable ignored, NSError * _Nullable error) { completion(error); }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, DefaultSuccessCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { + chip::Optional timedWriteTimeout; + if (params != nil) { + if (params.timedWriteTimeout != nil){ + timedWriteTimeout.SetValue(params.timedWriteTimeout.unsignedShortValue); + } + } + + ListFreer listFreer; + using TypeInfo = UnitTesting::Attributes::GlobalStruct::TypeInfo; + TypeInfo::Type cppValue; + cppValue.name = AsCharSpan(value.name); + if (value.myBitmap == nil) { + cppValue.myBitmap.SetNull(); + } else { + auto & nonNullValue_1 = cppValue.myBitmap.SetNonNull(); + nonNullValue_1 = static_cast>(value.myBitmap.unsignedIntValue); + } + if (value.myEnum != nil) { + auto & definedValue_1 = cppValue.myEnum.Emplace(); + if (value.myEnum == nil) { + definedValue_1.SetNull(); + } else { + auto & nonNullValue_2 = definedValue_1.SetNonNull(); + nonNullValue_2 = static_cast>(value.myEnum.unsignedCharValue); + } + } + + chip::Controller::ClusterBase cppCluster(exchangeManager, session, self.endpointID.unsignedShortValue); + return cppCluster.WriteAttribute(cppValue, bridge, successCb, failureCb, timedWriteTimeout); }); + std::move(*bridge).DispatchAction(self.device); +} + +- (void)subscribeAttributeGlobalStructWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(MTRDataTypeTestGlobalStruct * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = UnitTesting::Attributes::GlobalStruct::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeGlobalStructWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRDataTypeTestGlobalStruct * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = UnitTesting::Attributes::GlobalStruct::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + - (void)readAttributeUnsupportedWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion { using TypeInfo = UnitTesting::Attributes::Unsupported::TypeInfo; @@ -121929,6 +122116,10 @@ - (void)writeAttributeNullableStructWithValue:(MTRUnitTestingClusterSimpleStruct nonNullValue_0.f = static_cast>(value.f.unsignedCharValue); nonNullValue_0.g = value.g.floatValue; nonNullValue_0.h = value.h.doubleValue; + if (value.i != nil) { + auto & definedValue_2 = nonNullValue_0.i.Emplace(); + definedValue_2 = static_cast>(value.i.unsignedCharValue); + } } chip::Controller::ClusterBase cppCluster(exchangeManager, session, self.endpointID.unsignedShortValue); @@ -122301,6 +122492,159 @@ + (void)readAttributeWriteOnlyInt8uWithClusterStateCache:(MTRClusterStateCacheCo completion:completion]; } +- (void)readAttributeNullableGlobalEnumWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = UnitTesting::Attributes::NullableGlobalEnum::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)writeAttributeNullableGlobalEnumWithValue:(NSNumber * _Nullable)value completion:(MTRStatusCompletion)completion +{ + [self writeAttributeNullableGlobalEnumWithValue:(NSNumber * _Nullable) value params:nil completion:completion]; +} +- (void)writeAttributeNullableGlobalEnumWithValue:(NSNumber * _Nullable)value params:(MTRWriteParams * _Nullable)params completion:(MTRStatusCompletion)completion +{ + // Make a copy of params before we go async. + params = [params copy]; + value = [value copy]; + + auto * bridge = new MTRDefaultSuccessCallbackBridge(self.callbackQueue, ^(id _Nullable ignored, NSError * _Nullable error) { completion(error); }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, DefaultSuccessCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { + chip::Optional timedWriteTimeout; + if (params != nil) { + if (params.timedWriteTimeout != nil){ + timedWriteTimeout.SetValue(params.timedWriteTimeout.unsignedShortValue); + } + } + + ListFreer listFreer; + using TypeInfo = UnitTesting::Attributes::NullableGlobalEnum::TypeInfo; + TypeInfo::Type cppValue; + if (value == nil) { + cppValue.SetNull(); + } else { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = static_cast>(value.unsignedCharValue); + } + + chip::Controller::ClusterBase cppCluster(exchangeManager, session, self.endpointID.unsignedShortValue); + return cppCluster.WriteAttribute(cppValue, bridge, successCb, failureCb, timedWriteTimeout); }); + std::move(*bridge).DispatchAction(self.device); +} + +- (void)subscribeAttributeNullableGlobalEnumWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = UnitTesting::Attributes::NullableGlobalEnum::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeNullableGlobalEnumWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = UnitTesting::Attributes::NullableGlobalEnum::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + +- (void)readAttributeNullableGlobalStructWithCompletion:(void (^)(MTRDataTypeTestGlobalStruct * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = UnitTesting::Attributes::NullableGlobalStruct::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)writeAttributeNullableGlobalStructWithValue:(MTRDataTypeTestGlobalStruct * _Nullable)value completion:(MTRStatusCompletion)completion +{ + [self writeAttributeNullableGlobalStructWithValue:(MTRDataTypeTestGlobalStruct * _Nullable) value params:nil completion:completion]; +} +- (void)writeAttributeNullableGlobalStructWithValue:(MTRDataTypeTestGlobalStruct * _Nullable)value params:(MTRWriteParams * _Nullable)params completion:(MTRStatusCompletion)completion +{ + // Make a copy of params before we go async. + params = [params copy]; + value = [value copy]; + + auto * bridge = new MTRDefaultSuccessCallbackBridge(self.callbackQueue, ^(id _Nullable ignored, NSError * _Nullable error) { completion(error); }, ^(ExchangeManager & exchangeManager, const SessionHandle & session, DefaultSuccessCallbackType successCb, MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) { + chip::Optional timedWriteTimeout; + if (params != nil) { + if (params.timedWriteTimeout != nil){ + timedWriteTimeout.SetValue(params.timedWriteTimeout.unsignedShortValue); + } + } + + ListFreer listFreer; + using TypeInfo = UnitTesting::Attributes::NullableGlobalStruct::TypeInfo; + TypeInfo::Type cppValue; + if (value == nil) { + cppValue.SetNull(); + } else { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0.name = AsCharSpan(value.name); + if (value.myBitmap == nil) { + nonNullValue_0.myBitmap.SetNull(); + } else { + auto & nonNullValue_2 = nonNullValue_0.myBitmap.SetNonNull(); + nonNullValue_2 = static_cast>(value.myBitmap.unsignedIntValue); + } + if (value.myEnum != nil) { + auto & definedValue_2 = nonNullValue_0.myEnum.Emplace(); + if (value.myEnum == nil) { + definedValue_2.SetNull(); + } else { + auto & nonNullValue_3 = definedValue_2.SetNonNull(); + nonNullValue_3 = static_cast>(value.myEnum.unsignedCharValue); + } + } + } + + chip::Controller::ClusterBase cppCluster(exchangeManager, session, self.endpointID.unsignedShortValue); + return cppCluster.WriteAttribute(cppValue, bridge, successCb, failureCb, timedWriteTimeout); }); + std::move(*bridge).DispatchAction(self.device); +} + +- (void)subscribeAttributeNullableGlobalStructWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(MTRDataTypeTestGlobalStruct * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = UnitTesting::Attributes::NullableGlobalStruct::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:self.endpointID + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeNullableGlobalStructWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRDataTypeTestGlobalStruct * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = UnitTesting::Attributes::NullableGlobalStruct::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + - (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion { using TypeInfo = UnitTesting::Attributes::GeneratedCommandList::TypeInfo; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h index 98ca2f96263d50..f920a8e336cd92 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h @@ -5764,6 +5764,8 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { MTRAttributeIDTypeClusterUnitTestingAttributeTimedWriteBooleanID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000030, MTRAttributeIDTypeClusterUnitTestingAttributeGeneralErrorBooleanID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000031, MTRAttributeIDTypeClusterUnitTestingAttributeClusterErrorBooleanID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000032, + MTRAttributeIDTypeClusterUnitTestingAttributeGlobalEnumID MTR_PROVISIONALLY_AVAILABLE = 0x00000033, + MTRAttributeIDTypeClusterUnitTestingAttributeGlobalStructID MTR_PROVISIONALLY_AVAILABLE = 0x00000034, MTRAttributeIDTypeClusterUnitTestingAttributeUnsupportedID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x000000FF, MTRAttributeIDTypeClusterUnitTestingAttributeNullableBooleanID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00004000, MTRAttributeIDTypeClusterUnitTestingAttributeNullableBitmap8ID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00004001, @@ -5799,6 +5801,8 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { MTRAttributeIDTypeClusterUnitTestingAttributeNullableRangeRestrictedInt16uID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00004028, MTRAttributeIDTypeClusterUnitTestingAttributeNullableRangeRestrictedInt16sID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00004029, MTRAttributeIDTypeClusterUnitTestingAttributeWriteOnlyInt8uID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x0000402A, + MTRAttributeIDTypeClusterUnitTestingAttributeNullableGlobalEnumID MTR_PROVISIONALLY_AVAILABLE = 0x00004033, + MTRAttributeIDTypeClusterUnitTestingAttributeNullableGlobalStructID MTR_PROVISIONALLY_AVAILABLE = 0x00004034, MTRAttributeIDTypeClusterUnitTestingAttributeGeneratedCommandListID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID, MTRAttributeIDTypeClusterUnitTestingAttributeAcceptedCommandListID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = MTRAttributeIDTypeGlobalAttributeAcceptedCommandListID, MTRAttributeIDTypeClusterUnitTestingAttributeEventListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeEventListID, @@ -7102,6 +7106,7 @@ typedef NS_ENUM(uint32_t, MTRCommandIDType) { MTRCommandIDTypeClusterUnitTestingCommandTestListInt8UReverseRequestID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x0000000D, MTRCommandIDTypeClusterUnitTestingCommandStringEchoResponseID MTR_PROVISIONALLY_AVAILABLE = 0x0000000D, MTRCommandIDTypeClusterUnitTestingCommandTestEnumsRequestID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x0000000E, + MTRCommandIDTypeClusterUnitTestingCommandGlobalEchoResponseID MTR_PROVISIONALLY_AVAILABLE = 0x0000000E, MTRCommandIDTypeClusterUnitTestingCommandTestNullableOptionalRequestID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x0000000F, MTRCommandIDTypeClusterUnitTestingCommandTestComplexNullableOptionalRequestID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000010, MTRCommandIDTypeClusterUnitTestingCommandSimpleStructEchoRequestID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000011, @@ -7112,6 +7117,7 @@ typedef NS_ENUM(uint32_t, MTRCommandIDType) { MTRCommandIDTypeClusterUnitTestingCommandTestBatchHelperRequestID MTR_PROVISIONALLY_AVAILABLE = 0x00000016, MTRCommandIDTypeClusterUnitTestingCommandTestSecondBatchHelperRequestID MTR_PROVISIONALLY_AVAILABLE = 0x00000017, MTRCommandIDTypeClusterUnitTestingCommandStringEchoRequestID MTR_PROVISIONALLY_AVAILABLE = 0x00000018, + MTRCommandIDTypeClusterUnitTestingCommandGlobalEchoRequestID MTR_PROVISIONALLY_AVAILABLE = 0x00000019, MTRCommandIDTypeClusterUnitTestingCommandTestDifferentVendorMeiRequestID MTR_PROVISIONALLY_AVAILABLE = 0xFFF200AA, MTRCommandIDTypeClusterUnitTestingCommandTestDifferentVendorMeiResponseID MTR_PROVISIONALLY_AVAILABLE = 0xFFF200BB, diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusterNames.mm b/src/darwin/Framework/CHIP/zap-generated/MTRClusterNames.mm index 5f9d1b8e510ed6..6191e7c60d53eb 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusterNames.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterNames.mm @@ -9163,6 +9163,14 @@ result = @"ClusterErrorBoolean"; break; + case MTRAttributeIDTypeClusterUnitTestingAttributeGlobalEnumID: + result = @"GlobalEnum"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeGlobalStructID: + result = @"GlobalStruct"; + break; + case MTRAttributeIDTypeClusterUnitTestingAttributeUnsupportedID: result = @"Unsupported"; break; @@ -9303,6 +9311,14 @@ result = @"WriteOnlyInt8u"; break; + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableGlobalEnumID: + result = @"NullableGlobalEnum"; + break; + + case MTRAttributeIDTypeClusterUnitTestingAttributeNullableGlobalStructID: + result = @"NullableGlobalStruct"; + break; + case MTRAttributeIDTypeClusterUnitTestingAttributeGeneratedCommandListID: result = @"GeneratedCommandList"; break; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h index 8da2b1f2ec4f2b..44ecc1e0119c46 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h @@ -7455,6 +7455,7 @@ 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; - (void)stringEchoRequestWithParams:(MTRUnitTestingClusterStringEchoRequestParams *)params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRUnitTestingClusterStringEchoResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)globalEchoRequestWithParams:(MTRUnitTestingClusterGlobalEchoRequestParams *)params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRUnitTestingClusterGlobalEchoResponseParams * _Nullable data, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; - (void)testDifferentVendorMeiRequestWithParams:(MTRUnitTestingClusterTestDifferentVendorMeiRequestParams *)params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRUnitTestingClusterTestDifferentVendorMeiResponseParams * _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)); @@ -7645,6 +7646,14 @@ MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) - (void)writeAttributeClusterErrorBooleanWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); - (void)writeAttributeClusterErrorBooleanWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +- (NSDictionary * _Nullable)readAttributeGlobalEnumWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; +- (void)writeAttributeGlobalEnumWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs MTR_PROVISIONALLY_AVAILABLE; +- (void)writeAttributeGlobalEnumWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeGlobalStructWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; +- (void)writeAttributeGlobalStructWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs MTR_PROVISIONALLY_AVAILABLE; +- (void)writeAttributeGlobalStructWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + - (NSDictionary * _Nullable)readAttributeUnsupportedWithParams:(MTRReadParams * _Nullable)params MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); - (void)writeAttributeUnsupportedWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); - (void)writeAttributeUnsupportedWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); @@ -7785,6 +7794,14 @@ MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) - (void)writeAttributeWriteOnlyInt8uWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); - (void)writeAttributeWriteOnlyInt8uWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +- (NSDictionary * _Nullable)readAttributeNullableGlobalEnumWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; +- (void)writeAttributeNullableGlobalEnumWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs MTR_PROVISIONALLY_AVAILABLE; +- (void)writeAttributeNullableGlobalEnumWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + +- (NSDictionary * _Nullable)readAttributeNullableGlobalStructWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; +- (void)writeAttributeNullableGlobalStructWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs MTR_PROVISIONALLY_AVAILABLE; +- (void)writeAttributeNullableGlobalStructWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + - (NSDictionary * _Nullable)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); - (NSDictionary * _Nullable)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params 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 ec6f0c49b74d73..8e06c4d288084f 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm @@ -21757,6 +21757,33 @@ - (void)stringEchoRequestWithParams:(MTRUnitTestingClusterStringEchoRequestParam completion:responseHandler]; } +- (void)globalEchoRequestWithParams:(MTRUnitTestingClusterGlobalEchoRequestParams *)params expectedValues:(NSArray *> * _Nullable)expectedValues expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRUnitTestingClusterGlobalEchoResponseParams * _Nullable data, NSError * _Nullable error))completion +{ + if (params == nil) { + params = [[MTRUnitTestingClusterGlobalEchoRequestParams + alloc] init]; + } + + auto responseHandler = ^(id _Nullable response, NSError * _Nullable error) { + completion(response, error); + }; + + auto * timedInvokeTimeoutMs = params.timedInvokeTimeoutMs; + + using RequestType = UnitTesting::Commands::GlobalEchoRequest::Type; + [self.device _invokeKnownCommandWithEndpointID:self.endpointID + clusterID:@(RequestType::GetClusterId()) + commandID:@(RequestType::GetCommandId()) + commandPayload:params + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + timedInvokeTimeout:timedInvokeTimeoutMs + serverSideProcessingTimeout:params.serverSideProcessingTimeout + responseClass:MTRUnitTestingClusterGlobalEchoResponseParams.class + queue:self.callbackQueue + completion:responseHandler]; +} + - (void)testDifferentVendorMeiRequestWithParams:(MTRUnitTestingClusterTestDifferentVendorMeiRequestParams *)params expectedValues:(NSArray *> * _Nullable)expectedValues expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(void (^)(MTRUnitTestingClusterTestDifferentVendorMeiResponseParams * _Nullable data, NSError * _Nullable error))completion { if (params == nil) { @@ -22539,6 +22566,38 @@ - (void)writeAttributeClusterErrorBooleanWithValue:(NSDictionary [self.device writeAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeUnitTestingID) attributeID:@(MTRAttributeIDTypeClusterUnitTestingAttributeClusterErrorBooleanID) value:dataValueDictionary expectedValueInterval:expectedValueIntervalMs timedWriteTimeout:timedWriteTimeout]; } +- (NSDictionary * _Nullable)readAttributeGlobalEnumWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeUnitTestingID) attributeID:@(MTRAttributeIDTypeClusterUnitTestingAttributeGlobalEnumID) params:params]; +} + +- (void)writeAttributeGlobalEnumWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeGlobalEnumWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeGlobalEnumWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params +{ + NSNumber * timedWriteTimeout = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeUnitTestingID) attributeID:@(MTRAttributeIDTypeClusterUnitTestingAttributeGlobalEnumID) value:dataValueDictionary expectedValueInterval:expectedValueIntervalMs timedWriteTimeout:timedWriteTimeout]; +} + +- (NSDictionary * _Nullable)readAttributeGlobalStructWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeUnitTestingID) attributeID:@(MTRAttributeIDTypeClusterUnitTestingAttributeGlobalStructID) params:params]; +} + +- (void)writeAttributeGlobalStructWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeGlobalStructWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeGlobalStructWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params +{ + NSNumber * timedWriteTimeout = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeUnitTestingID) attributeID:@(MTRAttributeIDTypeClusterUnitTestingAttributeGlobalStructID) value:dataValueDictionary expectedValueInterval:expectedValueIntervalMs timedWriteTimeout:timedWriteTimeout]; +} + - (NSDictionary * _Nullable)readAttributeUnsupportedWithParams:(MTRReadParams * _Nullable)params { return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeUnitTestingID) attributeID:@(MTRAttributeIDTypeClusterUnitTestingAttributeUnsupportedID) params:params]; @@ -23099,6 +23158,38 @@ - (void)writeAttributeWriteOnlyInt8uWithValue:(NSDictionary *)da [self.device writeAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeUnitTestingID) attributeID:@(MTRAttributeIDTypeClusterUnitTestingAttributeWriteOnlyInt8uID) value:dataValueDictionary expectedValueInterval:expectedValueIntervalMs timedWriteTimeout:timedWriteTimeout]; } +- (NSDictionary * _Nullable)readAttributeNullableGlobalEnumWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeUnitTestingID) attributeID:@(MTRAttributeIDTypeClusterUnitTestingAttributeNullableGlobalEnumID) params:params]; +} + +- (void)writeAttributeNullableGlobalEnumWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableGlobalEnumWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableGlobalEnumWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params +{ + NSNumber * timedWriteTimeout = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeUnitTestingID) attributeID:@(MTRAttributeIDTypeClusterUnitTestingAttributeNullableGlobalEnumID) value:dataValueDictionary expectedValueInterval:expectedValueIntervalMs timedWriteTimeout:timedWriteTimeout]; +} + +- (NSDictionary * _Nullable)readAttributeNullableGlobalStructWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeUnitTestingID) attributeID:@(MTRAttributeIDTypeClusterUnitTestingAttributeNullableGlobalStructID) params:params]; +} + +- (void)writeAttributeNullableGlobalStructWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs +{ + [self writeAttributeNullableGlobalStructWithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:nil]; +} +- (void)writeAttributeNullableGlobalStructWithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params +{ + NSNumber * timedWriteTimeout = params.timedWriteTimeout; + + [self.device writeAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeUnitTestingID) attributeID:@(MTRAttributeIDTypeClusterUnitTestingAttributeNullableGlobalStructID) value:dataValueDictionary expectedValueInterval:expectedValueIntervalMs timedWriteTimeout:timedWriteTimeout]; +} + - (NSDictionary * _Nullable)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params { return [self.device readAttributeWithEndpointID:self.endpointID clusterID:@(MTRClusterIDTypeUnitTestingID) attributeID:@(MTRAttributeIDTypeClusterUnitTestingAttributeGeneratedCommandListID) params:params]; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h index 54073ac579e846..62f200fe8623f7 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h @@ -12925,6 +12925,27 @@ MTR_DEPRECATED("Please use MTRUnitTestingClusterTestEnumsRequestParams", ios(16. @property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout; @end +MTR_PROVISIONALLY_AVAILABLE +@interface MTRUnitTestingClusterGlobalEchoResponseParams : NSObject + +@property (nonatomic, copy) MTRDataTypeTestGlobalStruct * _Nonnull field1 MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy) NSNumber * _Nonnull field2 MTR_PROVISIONALLY_AVAILABLE; + +/** + * Initialize an MTRUnitTestingClusterGlobalEchoResponseParams 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 MTRUnitTestingClusterTestNullableOptionalRequestParams : NSObject @@ -13491,6 +13512,38 @@ MTR_PROVISIONALLY_AVAILABLE @property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout; @end +MTR_PROVISIONALLY_AVAILABLE +@interface MTRUnitTestingClusterGlobalEchoRequestParams : NSObject + +@property (nonatomic, copy) MTRDataTypeTestGlobalStruct * _Nonnull field1 MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy) NSNumber * _Nonnull field2 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 MTRUnitTestingClusterTestDifferentVendorMeiRequestParams : NSObject diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm index c49195ce1016eb..6b10028ec18d78 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm @@ -32884,6 +32884,11 @@ - (CHIP_ERROR)_setFieldsFromDecodableStruct:(const chip::app::Clusters::UnitTest newElement_0.c.f = [NSNumber numberWithUnsignedChar:entry_0.c.f.Raw()]; newElement_0.c.g = [NSNumber numberWithFloat:entry_0.c.g]; newElement_0.c.h = [NSNumber numberWithDouble:entry_0.c.h]; + if (entry_0.c.i.HasValue()) { + newElement_0.c.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.c.i.Value())]; + } else { + newElement_0.c.i = nil; + } { // Scope for our temporary variables auto * array_2 = [NSMutableArray new]; auto iter_2 = entry_0.d.begin(); @@ -32903,6 +32908,11 @@ - (CHIP_ERROR)_setFieldsFromDecodableStruct:(const chip::app::Clusters::UnitTest newElement_2.f = [NSNumber numberWithUnsignedChar:entry_2.f.Raw()]; newElement_2.g = [NSNumber numberWithFloat:entry_2.g]; newElement_2.h = [NSNumber numberWithDouble:entry_2.h]; + if (entry_2.i.HasValue()) { + newElement_2.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_2.i.Value())]; + } else { + newElement_2.i = nil; + } [array_2 addObject:newElement_2]; } CHIP_ERROR err = iter_2.GetStatus(); @@ -32985,6 +32995,11 @@ - (CHIP_ERROR)_setFieldsFromDecodableStruct:(const chip::app::Clusters::UnitTest newElement_0.f = [NSNumber numberWithUnsignedChar:entry_0.f.Raw()]; newElement_0.g = [NSNumber numberWithFloat:entry_0.g]; newElement_0.h = [NSNumber numberWithDouble:entry_0.h]; + if (entry_0.i.HasValue()) { + newElement_0.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.i.Value())]; + } else { + newElement_0.i = nil; + } [array_0 addObject:newElement_0]; } CHIP_ERROR err = iter_0.GetStatus(); @@ -33497,6 +33512,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader listHolder_0->mList[i_0].c.f = static_castmList[i_0].c.f)>>(element_0.c.f.unsignedCharValue); listHolder_0->mList[i_0].c.g = element_0.c.g.floatValue; listHolder_0->mList[i_0].c.h = element_0.c.h.doubleValue; + if (element_0.c.i != nil) { + auto & definedValue_3 = listHolder_0->mList[i_0].c.i.Emplace(); + definedValue_3 = static_cast>(element_0.c.i.unsignedCharValue); + } { using ListType_2 = std::remove_reference_tmList[i_0].d)>; using ListMemberType_2 = ListMemberTypeGetter::Type; @@ -33520,6 +33539,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader listHolder_2->mList[i_2].f = static_castmList[i_2].f)>>(element_2.f.unsignedCharValue); listHolder_2->mList[i_2].g = element_2.g.floatValue; listHolder_2->mList[i_2].h = element_2.h.doubleValue; + if (element_2.i != nil) { + auto & definedValue_4 = listHolder_2->mList[i_2].i.Emplace(); + definedValue_4 = static_cast>(element_2.i.unsignedCharValue); + } } listHolder_0->mList[i_0].d = ListType_2(listHolder_2->mList, element_0.d.count); } else { @@ -33623,6 +33646,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader listHolder_0->mList[i_0].f = static_castmList[i_0].f)>>(element_0.f.unsignedCharValue); listHolder_0->mList[i_0].g = element_0.g.floatValue; listHolder_0->mList[i_0].h = element_0.h.doubleValue; + if (element_0.i != nil) { + auto & definedValue_2 = listHolder_0->mList[i_0].i.Emplace(); + definedValue_2 = static_cast>(element_0.i.unsignedCharValue); + } } encodableStruct.arg2 = ListType_0(listHolder_0->mList, self.arg2.count); } else { @@ -33903,6 +33930,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.arg1.f = static_cast>(self.arg1.f.unsignedCharValue); encodableStruct.arg1.g = self.arg1.g.floatValue; encodableStruct.arg1.h = self.arg1.h.doubleValue; + if (self.arg1.i != nil) { + auto & definedValue_1 = encodableStruct.arg1.i.Emplace(); + definedValue_1 = static_cast>(self.arg1.i.unsignedCharValue); + } } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -34207,6 +34238,11 @@ - (CHIP_ERROR)_setFieldsFromDecodableStruct:(const chip::app::Clusters::UnitTest self.nullableStructValue.f = [NSNumber numberWithUnsignedChar:decodableStruct.nullableStructValue.Value().f.Raw()]; self.nullableStructValue.g = [NSNumber numberWithFloat:decodableStruct.nullableStructValue.Value().g]; self.nullableStructValue.h = [NSNumber numberWithDouble:decodableStruct.nullableStructValue.Value().h]; + if (decodableStruct.nullableStructValue.Value().i.HasValue()) { + self.nullableStructValue.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.nullableStructValue.Value().i.Value())]; + } else { + self.nullableStructValue.i = nil; + } } else { self.nullableStructValue = nil; } @@ -34229,6 +34265,11 @@ - (CHIP_ERROR)_setFieldsFromDecodableStruct:(const chip::app::Clusters::UnitTest self.optionalStructValue.f = [NSNumber numberWithUnsignedChar:decodableStruct.optionalStructValue.Value().f.Raw()]; self.optionalStructValue.g = [NSNumber numberWithFloat:decodableStruct.optionalStructValue.Value().g]; self.optionalStructValue.h = [NSNumber numberWithDouble:decodableStruct.optionalStructValue.Value().h]; + if (decodableStruct.optionalStructValue.Value().i.HasValue()) { + self.optionalStructValue.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.optionalStructValue.Value().i.Value())]; + } else { + self.optionalStructValue.i = nil; + } } else { self.optionalStructValue = nil; } @@ -34258,6 +34299,11 @@ - (CHIP_ERROR)_setFieldsFromDecodableStruct:(const chip::app::Clusters::UnitTest self.nullableOptionalStructValue.f = [NSNumber numberWithUnsignedChar:decodableStruct.nullableOptionalStructValue.Value().f.Raw()]; self.nullableOptionalStructValue.g = [NSNumber numberWithFloat:decodableStruct.nullableOptionalStructValue.Value().g]; self.nullableOptionalStructValue.h = [NSNumber numberWithDouble:decodableStruct.nullableOptionalStructValue.Value().h]; + if (decodableStruct.nullableOptionalStructValue.Value().i.HasValue()) { + self.nullableOptionalStructValue.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.nullableOptionalStructValue.Value().i.Value())]; + } else { + self.nullableOptionalStructValue.i = nil; + } } else { self.nullableOptionalStructValue = nil; } @@ -34426,6 +34472,29 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.arg1.c.f = static_cast>(self.arg1.c.f.unsignedCharValue); encodableStruct.arg1.c.g = self.arg1.c.g.floatValue; encodableStruct.arg1.c.h = self.arg1.c.h.doubleValue; + if (self.arg1.c.i != nil) { + auto & definedValue_2 = encodableStruct.arg1.c.i.Emplace(); + definedValue_2 = static_cast>(self.arg1.c.i.unsignedCharValue); + } + if (self.arg1.d != nil) { + auto & definedValue_1 = encodableStruct.arg1.d.Emplace(); + definedValue_1.name = AsCharSpan(self.arg1.d.name); + if (self.arg1.d.myBitmap == nil) { + definedValue_1.myBitmap.SetNull(); + } else { + auto & nonNullValue_3 = definedValue_1.myBitmap.SetNonNull(); + nonNullValue_3 = static_cast>(self.arg1.d.myBitmap.unsignedIntValue); + } + if (self.arg1.d.myEnum != nil) { + auto & definedValue_3 = definedValue_1.myEnum.Emplace(); + if (self.arg1.d.myEnum == nil) { + definedValue_3.SetNull(); + } else { + auto & nonNullValue_4 = definedValue_3.SetNonNull(); + nonNullValue_4 = static_cast>(self.arg1.d.myEnum.unsignedCharValue); + } + } + } } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -34619,6 +34688,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader listHolder_0->mList[i_0].f = static_castmList[i_0].f)>>(element_0.f.unsignedCharValue); listHolder_0->mList[i_0].g = element_0.g.floatValue; listHolder_0->mList[i_0].h = element_0.h.doubleValue; + if (element_0.i != nil) { + auto & definedValue_2 = listHolder_0->mList[i_0].i.Emplace(); + definedValue_2 = static_cast>(element_0.i.unsignedCharValue); + } } encodableStruct.arg1 = ListType_0(listHolder_0->mList, self.arg1.count); } else { @@ -34758,6 +34831,11 @@ - (CHIP_ERROR)_setFieldsFromDecodableStruct:(const chip::app::Clusters::UnitTest self.arg1.f = [NSNumber numberWithUnsignedChar:decodableStruct.arg1.f.Raw()]; self.arg1.g = [NSNumber numberWithFloat:decodableStruct.arg1.g]; self.arg1.h = [NSNumber numberWithDouble:decodableStruct.arg1.h]; + if (decodableStruct.arg1.i.HasValue()) { + self.arg1.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.arg1.i.Value())]; + } else { + self.arg1.i = nil; + } } return CHIP_NO_ERROR; } @@ -35009,6 +35087,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.arg1.c.f = static_cast>(self.arg1.c.f.unsignedCharValue); encodableStruct.arg1.c.g = self.arg1.c.g.floatValue; encodableStruct.arg1.c.h = self.arg1.c.h.doubleValue; + if (self.arg1.c.i != nil) { + auto & definedValue_2 = encodableStruct.arg1.c.i.Emplace(); + definedValue_2 = static_cast>(self.arg1.c.i.unsignedCharValue); + } { using ListType_1 = std::remove_reference_t; using ListMemberType_1 = ListMemberTypeGetter::Type; @@ -35032,6 +35114,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader listHolder_1->mList[i_1].f = static_castmList[i_1].f)>>(element_1.f.unsignedCharValue); listHolder_1->mList[i_1].g = element_1.g.floatValue; listHolder_1->mList[i_1].h = element_1.h.doubleValue; + if (element_1.i != nil) { + auto & definedValue_3 = listHolder_1->mList[i_1].i.Emplace(); + definedValue_3 = static_cast>(element_1.i.unsignedCharValue); + } } encodableStruct.arg1.d = ListType_1(listHolder_1->mList, self.arg1.d.count); } else { @@ -35299,6 +35385,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader listHolder_0->mList[i_0].c.f = static_castmList[i_0].c.f)>>(element_0.c.f.unsignedCharValue); listHolder_0->mList[i_0].c.g = element_0.c.g.floatValue; listHolder_0->mList[i_0].c.h = element_0.c.h.doubleValue; + if (element_0.c.i != nil) { + auto & definedValue_3 = listHolder_0->mList[i_0].c.i.Emplace(); + definedValue_3 = static_cast>(element_0.c.i.unsignedCharValue); + } { using ListType_2 = std::remove_reference_tmList[i_0].d)>; using ListMemberType_2 = ListMemberTypeGetter::Type; @@ -35322,6 +35412,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader listHolder_2->mList[i_2].f = static_castmList[i_2].f)>>(element_2.f.unsignedCharValue); listHolder_2->mList[i_2].g = element_2.g.floatValue; listHolder_2->mList[i_2].h = element_2.h.doubleValue; + if (element_2.i != nil) { + auto & definedValue_4 = listHolder_2->mList[i_2].i.Emplace(); + definedValue_4 = static_cast>(element_2.i.unsignedCharValue); + } } listHolder_0->mList[i_0].d = ListType_2(listHolder_2->mList, element_0.d.count); } else { @@ -35802,6 +35896,110 @@ @implementation MTRTestClusterClusterTestEnumsRequestParams @dynamic timedInvokeTimeoutMs; @dynamic serverSideProcessingTimeout; @end +@implementation MTRUnitTestingClusterGlobalEchoResponseParams +- (instancetype)init +{ + if (self = [super init]) { + + _field1 = [MTRDataTypeTestGlobalStruct new]; + + _field2 = @(0); + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone; +{ + auto other = [[MTRUnitTestingClusterGlobalEchoResponseParams alloc] init]; + + other.field1 = self.field1; + other.field2 = self.field2; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: field1:%@; field2:%@; >", NSStringFromClass([self class]), _field1, _field2]; + return descriptionString; +} + +- (nullable instancetype)initWithResponseValue:(NSDictionary *)responseValue + error:(NSError * __autoreleasing *)error +{ + if (!(self = [super init])) { + return nil; + } + + using DecodableType = chip::app::Clusters::UnitTesting::Commands::GlobalEchoResponse::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 MTRUnitTestingClusterGlobalEchoResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct:(const chip::app::Clusters::UnitTesting::Commands::GlobalEchoResponse::DecodableType &)decodableStruct +{ + { + self.field1 = [MTRDataTypeTestGlobalStruct new]; + self.field1.name = AsString(decodableStruct.field1.name); + if (self.field1.name == nil) { + CHIP_ERROR err = CHIP_ERROR_INVALID_ARGUMENT; + return err; + } + if (decodableStruct.field1.myBitmap.IsNull()) { + self.field1.myBitmap = nil; + } else { + self.field1.myBitmap = [NSNumber numberWithUnsignedInt:decodableStruct.field1.myBitmap.Value().Raw()]; + } + if (decodableStruct.field1.myEnum.HasValue()) { + if (decodableStruct.field1.myEnum.Value().IsNull()) { + self.field1.myEnum = nil; + } else { + self.field1.myEnum = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.field1.myEnum.Value().Value())]; + } + } else { + self.field1.myEnum = nil; + } + } + { + self.field2 = [NSNumber numberWithUnsignedChar:chip::to_underlying(decodableStruct.field2)]; + } + return CHIP_NO_ERROR; +} + +@end + @implementation MTRUnitTestingClusterTestNullableOptionalRequestParams - (instancetype)init { @@ -36028,6 +36226,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader nonNullValue_0.f = static_cast>(self.nullableStruct.f.unsignedCharValue); nonNullValue_0.g = self.nullableStruct.g.floatValue; nonNullValue_0.h = self.nullableStruct.h.doubleValue; + if (self.nullableStruct.i != nil) { + auto & definedValue_2 = nonNullValue_0.i.Emplace(); + definedValue_2 = static_cast>(self.nullableStruct.i.unsignedCharValue); + } } } { @@ -36041,6 +36243,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader definedValue_0.f = static_cast>(self.optionalStruct.f.unsignedCharValue); definedValue_0.g = self.optionalStruct.g.floatValue; definedValue_0.h = self.optionalStruct.h.doubleValue; + if (self.optionalStruct.i != nil) { + auto & definedValue_2 = definedValue_0.i.Emplace(); + definedValue_2 = static_cast>(self.optionalStruct.i.unsignedCharValue); + } } } { @@ -36058,6 +36264,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader nonNullValue_1.f = static_cast>(self.nullableOptionalStruct.f.unsignedCharValue); nonNullValue_1.g = self.nullableOptionalStruct.g.floatValue; nonNullValue_1.h = self.nullableOptionalStruct.h.doubleValue; + if (self.nullableOptionalStruct.i != nil) { + auto & definedValue_3 = nonNullValue_1.i.Emplace(); + definedValue_3 = static_cast>(self.nullableOptionalStruct.i.unsignedCharValue); + } } } } @@ -36251,6 +36461,10 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader encodableStruct.arg1.f = static_cast>(self.arg1.f.unsignedCharValue); encodableStruct.arg1.g = self.arg1.g.floatValue; encodableStruct.arg1.h = self.arg1.h.doubleValue; + if (self.arg1.i != nil) { + auto & definedValue_1 = encodableStruct.arg1.i.Emplace(); + definedValue_1 = static_cast>(self.arg1.i.unsignedCharValue); + } } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); @@ -36908,6 +37122,106 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader } @end +@implementation MTRUnitTestingClusterGlobalEchoRequestParams +- (instancetype)init +{ + if (self = [super init]) { + + _field1 = [MTRDataTypeTestGlobalStruct new]; + + _field2 = @(0); + _timedInvokeTimeoutMs = nil; + _serverSideProcessingTimeout = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone; +{ + auto other = [[MTRUnitTestingClusterGlobalEchoRequestParams alloc] init]; + + other.field1 = self.field1; + other.field2 = self.field2; + other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; + other.serverSideProcessingTimeout = self.serverSideProcessingTimeout; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: field1:%@; field2:%@; >", NSStringFromClass([self class]), _field1, _field2]; + return descriptionString; +} + +@end + +@implementation MTRUnitTestingClusterGlobalEchoRequestParams (InternalMethods) + +- (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader +{ + chip::app::Clusters::UnitTesting::Commands::GlobalEchoRequest::Type encodableStruct; + ListFreer listFreer; + { + encodableStruct.field1.name = AsCharSpan(self.field1.name); + if (self.field1.myBitmap == nil) { + encodableStruct.field1.myBitmap.SetNull(); + } else { + auto & nonNullValue_1 = encodableStruct.field1.myBitmap.SetNonNull(); + nonNullValue_1 = static_cast>(self.field1.myBitmap.unsignedIntValue); + } + if (self.field1.myEnum != nil) { + auto & definedValue_1 = encodableStruct.field1.myEnum.Emplace(); + if (self.field1.myEnum == nil) { + definedValue_1.SetNull(); + } else { + auto & nonNullValue_2 = definedValue_1.SetNonNull(); + nonNullValue_2 = static_cast>(self.field1.myEnum.unsignedCharValue); + } + } + } + { + encodableStruct.field2 = static_cast>(self.field2.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 MTRUnitTestingClusterTestDifferentVendorMeiRequestParams - (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 d3058d649ee710..93191eb3caa64d 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h @@ -2266,6 +2266,12 @@ NS_ASSUME_NONNULL_BEGIN @end +@interface MTRUnitTestingClusterGlobalEchoResponseParams (InternalMethods) + +- (CHIP_ERROR)_setFieldsFromDecodableStruct:(const chip::app::Clusters::UnitTesting::Commands::GlobalEchoResponse::DecodableType &)decodableStruct; + +@end + @interface MTRUnitTestingClusterTestNullableOptionalRequestParams (InternalMethods) - (NSDictionary * _Nullable)_encodeAsDataValue:(NSError * __autoreleasing *)error; @@ -2326,6 +2332,12 @@ NS_ASSUME_NONNULL_BEGIN @end +@interface MTRUnitTestingClusterGlobalEchoRequestParams (InternalMethods) + +- (NSDictionary * _Nullable)_encodeAsDataValue:(NSError * __autoreleasing *)error; + +@end + @interface MTRUnitTestingClusterTestDifferentVendorMeiRequestParams (InternalMethods) - (NSDictionary * _Nullable)_encodeAsDataValue:(NSError * __autoreleasing *)error; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm index 4d70a00ee32937..821b8f6d58173d 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm @@ -4637,6 +4637,11 @@ static id _Nullable DecodeEventPayloadForUnitTestingCluster(EventId aEventId, TL memberValue.f = [NSNumber numberWithUnsignedChar:cppValue.arg4.f.Raw()]; memberValue.g = [NSNumber numberWithFloat:cppValue.arg4.g]; memberValue.h = [NSNumber numberWithDouble:cppValue.arg4.h]; + if (cppValue.arg4.i.HasValue()) { + memberValue.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue.arg4.i.Value())]; + } else { + memberValue.i = nil; + } value.arg4 = memberValue; } while (0); do { @@ -4661,6 +4666,11 @@ static id _Nullable DecodeEventPayloadForUnitTestingCluster(EventId aEventId, TL newElement_0.f = [NSNumber numberWithUnsignedChar:entry_0.f.Raw()]; newElement_0.g = [NSNumber numberWithFloat:entry_0.g]; newElement_0.h = [NSNumber numberWithDouble:entry_0.h]; + if (entry_0.i.HasValue()) { + newElement_0.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.i.Value())]; + } else { + newElement_0.i = nil; + } [array_0 addObject:newElement_0]; } CHIP_ERROR err = iter_0.GetStatus(); diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h index 3a11fc91e44536..d73fc257e6bcd6 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h @@ -2139,6 +2139,7 @@ MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @property (nonatomic, copy) NSNumber * _Nonnull f MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); @property (nonatomic, copy) NSNumber * _Nonnull g MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); @property (nonatomic, copy) NSNumber * _Nonnull h MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +@property (nonatomic, copy) NSNumber * _Nullable i MTR_PROVISIONALLY_AVAILABLE; @end MTR_DEPRECATED("Please use MTRUnitTestingClusterSimpleStruct", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)) @@ -2214,6 +2215,7 @@ MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) @property (nonatomic, copy) NSNumber * _Nonnull a MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); @property (nonatomic, copy) NSNumber * _Nonnull b MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); @property (nonatomic, copy) MTRUnitTestingClusterSimpleStruct * _Nonnull c MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +@property (nonatomic, copy) MTRDataTypeTestGlobalStruct * _Nullable d MTR_PROVISIONALLY_AVAILABLE; @end MTR_DEPRECATED("Please use MTRUnitTestingClusterNestedStruct", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)) diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm index 94a6b90dfeac88..632b70647eb6d0 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm @@ -8825,6 +8825,8 @@ - (instancetype)init _g = @(0); _h = @(0); + + _i = nil; } return self; } @@ -8841,13 +8843,14 @@ - (id)copyWithZone:(NSZone * _Nullable)zone other.f = self.f; other.g = self.g; other.h = self.h; + other.i = self.i; return other; } - (NSString *)description { - NSString * descriptionString = [NSString stringWithFormat:@"<%@: a:%@; b:%@; c:%@; d:%@; e:%@; f:%@; g:%@; h:%@; >", NSStringFromClass([self class]), _a, _b, _c, [_d base64EncodedStringWithOptions:0], _e, _f, _g, _h]; + NSString * descriptionString = [NSString stringWithFormat:@"<%@: a:%@; b:%@; c:%@; d:%@; e:%@; f:%@; g:%@; h:%@; i:%@; >", NSStringFromClass([self class]), _a, _b, _c, [_d base64EncodedStringWithOptions:0], _e, _f, _g, _h, _i]; return descriptionString; } @@ -9008,6 +9011,8 @@ - (instancetype)init _b = @(0); _c = [MTRUnitTestingClusterSimpleStruct new]; + + _d = nil; } return self; } @@ -9019,13 +9024,14 @@ - (id)copyWithZone:(NSZone * _Nullable)zone other.a = self.a; other.b = self.b; other.c = self.c; + other.d = self.d; return other; } - (NSString *)description { - NSString * descriptionString = [NSString stringWithFormat:@"<%@: a:%@; b:%@; c:%@; >", NSStringFromClass([self class]), _a, _b, _c]; + NSString * descriptionString = [NSString stringWithFormat:@"<%@: a:%@; b:%@; c:%@; d:%@; >", NSStringFromClass([self class]), _a, _b, _c, _d]; return descriptionString; } diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp index 1ba55467d670af..ca6df3d1c72e99 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp @@ -46078,6 +46078,53 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, bool value) } // namespace TimedWriteBoolean +namespace GlobalEnum { + +Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, chip::app::Clusters::Globals::TestGlobalEnum * value) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + Protocols::InteractionModel::Status status = + emberAfReadAttribute(endpoint, Clusters::UnitTesting::Id, Id, readable, sizeof(temp)); + VerifyOrReturnError(Protocols::InteractionModel::Status::Success == status, status); + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) + { + return Protocols::InteractionModel::Status::ConstraintError; + } + *value = Traits::StorageToWorking(temp); + return status; +} + +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::Globals::TestGlobalEnum value, + MarkAttributeDirty markDirty) +{ + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + { + return Protocols::InteractionModel::Status::ConstraintError; + } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::UnitTesting::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE, markDirty); +} + +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::Globals::TestGlobalEnum value) +{ + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + { + return Protocols::InteractionModel::Status::ConstraintError; + } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::UnitTesting::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); +} + +} // namespace GlobalEnum + namespace Unsupported { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, bool * value) @@ -49016,6 +49063,98 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value } // namespace WriteOnlyInt8u +namespace NullableGlobalEnum { + +Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, + DataModel::Nullable & value) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + Protocols::InteractionModel::Status status = + emberAfReadAttribute(endpoint, Clusters::UnitTesting::Id, Id, readable, sizeof(temp)); + VerifyOrReturnError(Protocols::InteractionModel::Status::Success == status, status); + if (Traits::IsNullValue(temp)) + { + value.SetNull(); + } + else + { + value.SetNonNull() = Traits::StorageToWorking(temp); + } + return status; +} + +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::Globals::TestGlobalEnum value, + MarkAttributeDirty markDirty) +{ + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) + { + return Protocols::InteractionModel::Status::ConstraintError; + } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::UnitTesting::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE, markDirty); +} + +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::Globals::TestGlobalEnum value) +{ + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) + { + return Protocols::InteractionModel::Status::ConstraintError; + } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteAttribute(endpoint, Clusters::UnitTesting::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); +} + +Protocols::InteractionModel::Status SetNull(chip::EndpointId endpoint, MarkAttributeDirty markDirty) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteAttribute(endpoint, Clusters::UnitTesting::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE, markDirty); +} + +Protocols::InteractionModel::Status SetNull(chip::EndpointId endpoint) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteAttribute(endpoint, Clusters::UnitTesting::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); +} + +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, + const chip::app::DataModel::Nullable & value, + MarkAttributeDirty markDirty) +{ + if (value.IsNull()) + { + return SetNull(endpoint, markDirty); + } + + return Set(endpoint, value.Value(), markDirty); +} + +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, + const chip::app::DataModel::Nullable & value) +{ + if (value.IsNull()) + { + return SetNull(endpoint); + } + + return Set(endpoint, value.Value()); +} + +} // namespace NullableGlobalEnum + namespace FeatureMap { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint32_t * value) diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h index 53e24c079fc4bd..ea344fcc49b7cd 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h @@ -6957,6 +6957,14 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, bool value); Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, bool value, MarkAttributeDirty markDirty); } // namespace TimedWriteBoolean +namespace GlobalEnum { +Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, + chip::app::Clusters::Globals::TestGlobalEnum * value); // TestGlobalEnum +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::Globals::TestGlobalEnum value); +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::Globals::TestGlobalEnum value, + MarkAttributeDirty markDirty); +} // namespace GlobalEnum + namespace Unsupported { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, bool * value); // boolean Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, bool value); @@ -7362,6 +7370,21 @@ Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint8_t value, MarkAttributeDirty markDirty); } // namespace WriteOnlyInt8u +namespace NullableGlobalEnum { +Protocols::InteractionModel::Status +Get(chip::EndpointId endpoint, DataModel::Nullable & value); // TestGlobalEnum +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::Globals::TestGlobalEnum value); +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, chip::app::Clusters::Globals::TestGlobalEnum value, + MarkAttributeDirty markDirty); +Protocols::InteractionModel::Status SetNull(chip::EndpointId endpoint); +Protocols::InteractionModel::Status SetNull(chip::EndpointId endpoint, MarkAttributeDirty markDirty); +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, + const chip::app::DataModel::Nullable & value); +Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, + const chip::app::DataModel::Nullable & value, + MarkAttributeDirty markDirty); +} // namespace NullableGlobalEnum + namespace FeatureMap { Protocols::InteractionModel::Status Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 Protocols::InteractionModel::Status Set(chip::EndpointId endpoint, uint32_t value); 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 60cdf13689cf10..d1f11db1e93cc5 100644 --- a/zzz_generated/app-common/app-common/zap-generated/callback.h +++ b/zzz_generated/app-common/app-common/zap-generated/callback.h @@ -6929,6 +6929,12 @@ bool emberAfUnitTestingClusterTestSecondBatchHelperRequestCallback( bool emberAfUnitTestingClusterStringEchoRequestCallback( chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, const chip::app::Clusters::UnitTesting::Commands::StringEchoRequest::DecodableType & commandData); +/** + * @brief Unit Testing Cluster GlobalEchoRequest Command callback (from client) + */ +bool emberAfUnitTestingClusterGlobalEchoRequestCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::UnitTesting::Commands::GlobalEchoRequest::DecodableType & commandData); /** * @brief Unit Testing Cluster TestDifferentVendorMeiRequest 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 af49e0617caa1f..f206178484a6c3 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 @@ -29391,6 +29391,7 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const encoder.Encode(to_underlying(Fields::kF), f); encoder.Encode(to_underlying(Fields::kG), g); encoder.Encode(to_underlying(Fields::kH), h); + encoder.Encode(to_underlying(Fields::kI), i); return encoder.Finalize(); } @@ -29440,6 +29441,10 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) { err = DataModel::Decode(reader, h); } + else if (__context_tag == to_underlying(Fields::kI)) + { + err = DataModel::Decode(reader, i); + } else { } @@ -29657,6 +29662,7 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const encoder.Encode(to_underlying(Fields::kA), a); encoder.Encode(to_underlying(Fields::kB), b); encoder.Encode(to_underlying(Fields::kC), c); + encoder.Encode(to_underlying(Fields::kD), d); return encoder.Finalize(); } @@ -29686,6 +29692,10 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) { err = DataModel::Decode(reader, c); } + else if (__context_tag == to_underlying(Fields::kD)) + { + err = DataModel::Decode(reader, d); + } else { } @@ -30986,6 +30996,45 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } } } // namespace TestEnumsRequest. +namespace GlobalEchoResponse { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; + encoder.Encode(to_underlying(Fields::kField1), field1); + encoder.Encode(to_underlying(Fields::kField2), field2); + 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::kField1)) + { + err = DataModel::Decode(reader, field1); + } + else if (__context_tag == to_underlying(Fields::kField2)) + { + err = DataModel::Decode(reader, field2); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} +} // namespace GlobalEchoResponse. namespace TestNullableOptionalRequest { CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const { @@ -31397,6 +31446,45 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } } } // namespace StringEchoRequest. +namespace GlobalEchoRequest { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; + encoder.Encode(to_underlying(Fields::kField1), field1); + encoder.Encode(to_underlying(Fields::kField2), field2); + 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::kField1)) + { + err = DataModel::Decode(reader, field1); + } + else if (__context_tag == to_underlying(Fields::kField2)) + { + err = DataModel::Decode(reader, field2); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} +} // namespace GlobalEchoRequest. namespace TestDifferentVendorMeiRequest { CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const { @@ -31571,6 +31659,10 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre return DataModel::Decode(reader, generalErrorBoolean); case Attributes::ClusterErrorBoolean::TypeInfo::GetAttributeId(): return DataModel::Decode(reader, clusterErrorBoolean); + case Attributes::GlobalEnum::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, globalEnum); + case Attributes::GlobalStruct::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, globalStruct); case Attributes::Unsupported::TypeInfo::GetAttributeId(): return DataModel::Decode(reader, unsupported); case Attributes::NullableBoolean::TypeInfo::GetAttributeId(): @@ -31641,6 +31733,10 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre return DataModel::Decode(reader, nullableRangeRestrictedInt16s); case Attributes::WriteOnlyInt8u::TypeInfo::GetAttributeId(): return DataModel::Decode(reader, writeOnlyInt8u); + case Attributes::NullableGlobalEnum::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, nullableGlobalEnum); + case Attributes::NullableGlobalStruct::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, nullableGlobalStruct); case Attributes::GeneratedCommandList::TypeInfo::GetAttributeId(): return DataModel::Decode(reader, generatedCommandList); case Attributes::AcceptedCommandList::TypeInfo::GetAttributeId(): 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 25ded74c85a287..719c1de9e28975 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 @@ -44013,6 +44013,7 @@ enum class Fields : uint8_t kF = 5, kG = 6, kH = 7, + kI = 8, }; struct Type @@ -44026,6 +44027,7 @@ struct Type chip::BitMask f = static_cast>(0); float g = static_cast(0); double h = static_cast(0); + Optional i; CHIP_ERROR Decode(TLV::TLVReader & reader); @@ -44163,6 +44165,7 @@ enum class Fields : uint8_t kA = 0, kB = 1, kC = 2, + kD = 3, }; struct Type @@ -44171,6 +44174,7 @@ struct Type uint8_t a = static_cast(0); bool b = static_cast(0); Structs::SimpleStruct::Type c; + Optional d; CHIP_ERROR Decode(TLV::TLVReader & reader); @@ -44427,6 +44431,11 @@ struct Type; struct DecodableType; } // namespace TestEnumsRequest +namespace GlobalEchoResponse { +struct Type; +struct DecodableType; +} // namespace GlobalEchoResponse + namespace TestNullableOptionalRequest { struct Type; struct DecodableType; @@ -44477,6 +44486,11 @@ struct Type; struct DecodableType; } // namespace StringEchoRequest +namespace GlobalEchoRequest { +struct Type; +struct DecodableType; +} // namespace GlobalEchoRequest + namespace TestDifferentVendorMeiRequest { struct Type; struct DecodableType; @@ -45531,6 +45545,41 @@ struct DecodableType CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace TestEnumsRequest +namespace GlobalEchoResponse { +enum class Fields : uint8_t +{ + kField1 = 0, + kField2 = 1, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return Commands::GlobalEchoResponse::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::UnitTesting::Id; } + + Globals::Structs::TestGlobalStruct::Type field1; + Globals::TestGlobalEnum field2 = static_cast(0); + + 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::GlobalEchoResponse::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::UnitTesting::Id; } + + Globals::Structs::TestGlobalStruct::DecodableType field1; + Globals::TestGlobalEnum field2 = static_cast(0); + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace GlobalEchoResponse namespace TestNullableOptionalRequest { enum class Fields : uint8_t { @@ -45898,6 +45947,41 @@ struct DecodableType CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace StringEchoRequest +namespace GlobalEchoRequest { +enum class Fields : uint8_t +{ + kField1 = 0, + kField2 = 1, +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return Commands::GlobalEchoRequest::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::UnitTesting::Id; } + + Globals::Structs::TestGlobalStruct::Type field1; + Globals::TestGlobalEnum field2 = static_cast(0); + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; + + using ResponseType = Clusters::UnitTesting::Commands::GlobalEchoResponse::DecodableType; + + static constexpr bool MustUseTimedInvoke() { return false; } +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return Commands::GlobalEchoRequest::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::UnitTesting::Id; } + + Globals::Structs::TestGlobalStruct::DecodableType field1; + Globals::TestGlobalEnum field2 = static_cast(0); + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace GlobalEchoRequest namespace TestDifferentVendorMeiRequest { enum class Fields : uint8_t { @@ -46543,6 +46627,30 @@ struct TypeInfo static constexpr bool MustUseTimedWrite() { return false; } }; } // namespace ClusterErrorBoolean +namespace GlobalEnum { +struct TypeInfo +{ + using Type = chip::app::Clusters::Globals::TestGlobalEnum; + using DecodableType = chip::app::Clusters::Globals::TestGlobalEnum; + using DecodableArgType = chip::app::Clusters::Globals::TestGlobalEnum; + + static constexpr ClusterId GetClusterId() { return Clusters::UnitTesting::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::GlobalEnum::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace GlobalEnum +namespace GlobalStruct { +struct TypeInfo +{ + using Type = chip::app::Clusters::Globals::Structs::TestGlobalStruct::Type; + using DecodableType = chip::app::Clusters::Globals::Structs::TestGlobalStruct::DecodableType; + using DecodableArgType = const chip::app::Clusters::Globals::Structs::TestGlobalStruct::DecodableType &; + + static constexpr ClusterId GetClusterId() { return Clusters::UnitTesting::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::GlobalStruct::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace GlobalStruct namespace Unsupported { struct TypeInfo { @@ -46970,6 +47078,31 @@ struct TypeInfo static constexpr bool MustUseTimedWrite() { return false; } }; } // namespace WriteOnlyInt8u +namespace NullableGlobalEnum { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; + + static constexpr ClusterId GetClusterId() { return Clusters::UnitTesting::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::NullableGlobalEnum::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace NullableGlobalEnum +namespace NullableGlobalStruct { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = + const chip::app::DataModel::Nullable &; + + static constexpr ClusterId GetClusterId() { return Clusters::UnitTesting::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::NullableGlobalStruct::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace NullableGlobalStruct namespace GeneratedCommandList { struct TypeInfo : public Clusters::Globals::Attributes::GeneratedCommandList::TypeInfo { @@ -47078,7 +47211,9 @@ struct TypeInfo Attributes::TimedWriteBoolean::TypeInfo::DecodableType timedWriteBoolean = static_cast(0); Attributes::GeneralErrorBoolean::TypeInfo::DecodableType generalErrorBoolean = static_cast(0); Attributes::ClusterErrorBoolean::TypeInfo::DecodableType clusterErrorBoolean = static_cast(0); - Attributes::Unsupported::TypeInfo::DecodableType unsupported = static_cast(0); + Attributes::GlobalEnum::TypeInfo::DecodableType globalEnum = static_cast(0); + Attributes::GlobalStruct::TypeInfo::DecodableType globalStruct; + Attributes::Unsupported::TypeInfo::DecodableType unsupported = static_cast(0); Attributes::NullableBoolean::TypeInfo::DecodableType nullableBoolean; Attributes::NullableBitmap8::TypeInfo::DecodableType nullableBitmap8; Attributes::NullableBitmap16::TypeInfo::DecodableType nullableBitmap16; @@ -47113,6 +47248,8 @@ struct TypeInfo Attributes::NullableRangeRestrictedInt16u::TypeInfo::DecodableType nullableRangeRestrictedInt16u; Attributes::NullableRangeRestrictedInt16s::TypeInfo::DecodableType nullableRangeRestrictedInt16s; Attributes::WriteOnlyInt8u::TypeInfo::DecodableType writeOnlyInt8u = static_cast(0); + Attributes::NullableGlobalEnum::TypeInfo::DecodableType nullableGlobalEnum; + Attributes::NullableGlobalStruct::TypeInfo::DecodableType nullableGlobalStruct; Attributes::GeneratedCommandList::TypeInfo::DecodableType generatedCommandList; Attributes::AcceptedCommandList::TypeInfo::DecodableType acceptedCommandList; Attributes::EventList::TypeInfo::DecodableType eventList; diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h index 0a144da9030e42..5deab64ef504fc 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h @@ -8296,6 +8296,14 @@ namespace ClusterErrorBoolean { static constexpr AttributeId Id = 0x00000032; } // namespace ClusterErrorBoolean +namespace GlobalEnum { +static constexpr AttributeId Id = 0x00000033; +} // namespace GlobalEnum + +namespace GlobalStruct { +static constexpr AttributeId Id = 0x00000034; +} // namespace GlobalStruct + namespace Unsupported { static constexpr AttributeId Id = 0x000000FF; } // namespace Unsupported @@ -8436,6 +8444,14 @@ namespace WriteOnlyInt8u { static constexpr AttributeId Id = 0x0000402A; } // namespace WriteOnlyInt8u +namespace NullableGlobalEnum { +static constexpr AttributeId Id = 0x00004033; +} // namespace NullableGlobalEnum + +namespace NullableGlobalStruct { +static constexpr AttributeId Id = 0x00004034; +} // namespace NullableGlobalStruct + namespace GeneratedCommandList { static constexpr AttributeId Id = Globals::Attributes::GeneratedCommandList::Id; } // namespace GeneratedCommandList 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 68b11f130dcb4c..e9210638315112 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 @@ -1980,6 +1980,10 @@ namespace TestEnumsRequest { static constexpr CommandId Id = 0x0000000E; } // namespace TestEnumsRequest +namespace GlobalEchoResponse { +static constexpr CommandId Id = 0x0000000E; +} // namespace GlobalEchoResponse + namespace TestNullableOptionalRequest { static constexpr CommandId Id = 0x0000000F; } // namespace TestNullableOptionalRequest @@ -2020,6 +2024,10 @@ namespace StringEchoRequest { static constexpr CommandId Id = 0x00000018; } // namespace StringEchoRequest +namespace GlobalEchoRequest { +static constexpr CommandId Id = 0x00000019; +} // namespace GlobalEchoRequest + namespace TestDifferentVendorMeiRequest { static constexpr CommandId Id = 0xFFF200AA; } // namespace TestDifferentVendorMeiRequest diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index 9367f844d3c16b..a48a4b5376f2b7 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -14243,6 +14243,7 @@ class ElectricalMeasurementGetMeasurementProfileCommand : public ClusterCommand | * TestBatchHelperRequest | 0x16 | | * TestSecondBatchHelperRequest | 0x17 | | * StringEchoRequest | 0x18 | +| * GlobalEchoRequest | 0x19 | | * TestDifferentVendorMeiRequest | 0xFFF200AA| |------------------------------------------------------------------------------| | Attributes: | | @@ -14293,6 +14294,8 @@ class ElectricalMeasurementGetMeasurementProfileCommand : public ClusterCommand | * TimedWriteBoolean | 0x0030 | | * GeneralErrorBoolean | 0x0031 | | * ClusterErrorBoolean | 0x0032 | +| * GlobalEnum | 0x0033 | +| * GlobalStruct | 0x0034 | | * Unsupported | 0x00FF | | * NullableBoolean | 0x4000 | | * NullableBitmap8 | 0x4001 | @@ -14328,6 +14331,8 @@ class ElectricalMeasurementGetMeasurementProfileCommand : public ClusterCommand | * NullableRangeRestrictedInt16u | 0x4028 | | * NullableRangeRestrictedInt16s | 0x4029 | | * WriteOnlyInt8u | 0x402A | +| * NullableGlobalEnum | 0x4033 | +| * NullableGlobalStruct | 0x4034 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -15344,6 +15349,46 @@ class UnitTestingStringEchoRequest : public ClusterCommand chip::app::Clusters::UnitTesting::Commands::StringEchoRequest::Type mRequest; }; +/* + * Command GlobalEchoRequest + */ +class UnitTestingGlobalEchoRequest : public ClusterCommand +{ +public: + UnitTestingGlobalEchoRequest(CredentialIssuerCommands * credsIssuerConfig) : + ClusterCommand("global-echo-request", credsIssuerConfig), mComplex_Field1(&mRequest.field1) + { + AddArgument("Field1", &mComplex_Field1); + AddArgument("Field2", 0, UINT8_MAX, &mRequest.field2); + 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::GlobalEchoRequest::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::GlobalEchoRequest::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::GlobalEchoRequest::Type mRequest; + TypedComplexArgument mComplex_Field1; +}; + /* * Command TestDifferentVendorMeiRequest */ @@ -27673,6 +27718,7 @@ void registerClusterUnitTesting(Commands & commands, CredentialIssuerCommands * make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // + make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // // // Attributes @@ -27726,6 +27772,8 @@ void registerClusterUnitTesting(Commands & commands, CredentialIssuerCommands * make_unique(Id, "timed-write-boolean", Attributes::TimedWriteBoolean::Id, credsIssuerConfig), // make_unique(Id, "general-error-boolean", Attributes::GeneralErrorBoolean::Id, credsIssuerConfig), // make_unique(Id, "cluster-error-boolean", Attributes::ClusterErrorBoolean::Id, credsIssuerConfig), // + make_unique(Id, "global-enum", Attributes::GlobalEnum::Id, credsIssuerConfig), // + make_unique(Id, "global-struct", Attributes::GlobalStruct::Id, credsIssuerConfig), // make_unique(Id, "unsupported", Attributes::Unsupported::Id, credsIssuerConfig), // make_unique(Id, "nullable-boolean", Attributes::NullableBoolean::Id, credsIssuerConfig), // make_unique(Id, "nullable-bitmap8", Attributes::NullableBitmap8::Id, credsIssuerConfig), // @@ -27765,6 +27813,8 @@ void registerClusterUnitTesting(Commands & commands, CredentialIssuerCommands * make_unique(Id, "nullable-range-restricted-int16s", Attributes::NullableRangeRestrictedInt16s::Id, credsIssuerConfig), // make_unique(Id, "write-only-int8u", Attributes::WriteOnlyInt8u::Id, credsIssuerConfig), // + make_unique(Id, "nullable-global-enum", Attributes::NullableGlobalEnum::Id, credsIssuerConfig), // + make_unique(Id, "nullable-global-struct", Attributes::NullableGlobalStruct::Id, credsIssuerConfig), // make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // @@ -27873,6 +27923,10 @@ void registerClusterUnitTesting(Commands & commands, CredentialIssuerCommands * WriteCommandType::kWrite, credsIssuerConfig), // make_unique>(Id, "cluster-error-boolean", 0, 1, Attributes::ClusterErrorBoolean::Id, WriteCommandType::kWrite, credsIssuerConfig), // + make_unique>( + Id, "global-enum", 0, UINT8_MAX, Attributes::GlobalEnum::Id, WriteCommandType::kWrite, credsIssuerConfig), // + make_unique>( + Id, "global-struct", Attributes::GlobalStruct::Id, WriteCommandType::kWrite, credsIssuerConfig), // make_unique>(Id, "unsupported", 0, 1, Attributes::Unsupported::Id, WriteCommandType::kWrite, credsIssuerConfig), // make_unique>>( @@ -27966,6 +28020,12 @@ void registerClusterUnitTesting(Commands & commands, CredentialIssuerCommands * WriteCommandType::kWrite, credsIssuerConfig), // make_unique>(Id, "write-only-int8u", 0, UINT8_MAX, Attributes::WriteOnlyInt8u::Id, WriteCommandType::kWrite, credsIssuerConfig), // + make_unique>>( + Id, "nullable-global-enum", 0, UINT8_MAX, Attributes::NullableGlobalEnum::Id, WriteCommandType::kWrite, + credsIssuerConfig), // + make_unique< + WriteAttributeAsComplex>>( + Id, "nullable-global-struct", Attributes::NullableGlobalStruct::Id, WriteCommandType::kWrite, credsIssuerConfig), // make_unique>>( Id, "generated-command-list", Attributes::GeneratedCommandList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // @@ -28031,6 +28091,8 @@ void registerClusterUnitTesting(Commands & commands, CredentialIssuerCommands * make_unique(Id, "timed-write-boolean", Attributes::TimedWriteBoolean::Id, credsIssuerConfig), // make_unique(Id, "general-error-boolean", Attributes::GeneralErrorBoolean::Id, credsIssuerConfig), // make_unique(Id, "cluster-error-boolean", Attributes::ClusterErrorBoolean::Id, credsIssuerConfig), // + make_unique(Id, "global-enum", Attributes::GlobalEnum::Id, credsIssuerConfig), // + make_unique(Id, "global-struct", Attributes::GlobalStruct::Id, credsIssuerConfig), // make_unique(Id, "unsupported", Attributes::Unsupported::Id, credsIssuerConfig), // make_unique(Id, "nullable-boolean", Attributes::NullableBoolean::Id, credsIssuerConfig), // make_unique(Id, "nullable-bitmap8", Attributes::NullableBitmap8::Id, credsIssuerConfig), // @@ -28070,6 +28132,8 @@ void registerClusterUnitTesting(Commands & commands, CredentialIssuerCommands * make_unique(Id, "nullable-range-restricted-int16s", Attributes::NullableRangeRestrictedInt16s::Id, credsIssuerConfig), // make_unique(Id, "write-only-int8u", Attributes::WriteOnlyInt8u::Id, credsIssuerConfig), // + make_unique(Id, "nullable-global-enum", Attributes::NullableGlobalEnum::Id, credsIssuerConfig), // + make_unique(Id, "nullable-global-struct", Attributes::NullableGlobalStruct::Id, credsIssuerConfig), // make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp index 3b958cf45af7ff..8a9766461d448c 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp @@ -19,6 +19,44 @@ #include +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::Globals::Structs::TestGlobalStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("TestGlobalStruct.name", "name", value.isMember("name"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("TestGlobalStruct.myBitmap", "myBitmap", value.isMember("myBitmap"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + valueCopy.removeMember("name"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "myBitmap"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.myBitmap, value["myBitmap"])); + valueCopy.removeMember("myBitmap"); + + if (value.isMember("myEnum")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "myEnum"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.myEnum, value["myEnum"])); + } + valueCopy.removeMember("myEnum"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::Globals::Structs::TestGlobalStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.name); + ComplexArgumentParser::Finalize(request.myBitmap); + ComplexArgumentParser::Finalize(request.myEnum); +} + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::detail::Structs::ModeTagStruct::Type & request, Json::Value & value) { @@ -423,44 +461,6 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::detail::Structs::Opera ComplexArgumentParser::Finalize(request.operationalStateLabel); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::Globals::Structs::TestGlobalStruct::Type & request, - Json::Value & value) -{ - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); - - // Copy to track which members we already processed. - Json::Value valueCopy(value); - - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("TestGlobalStruct.name", "name", value.isMember("name"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("TestGlobalStruct.myBitmap", "myBitmap", value.isMember("myBitmap"))); - - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); - valueCopy.removeMember("name"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "myBitmap"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.myBitmap, value["myBitmap"])); - valueCopy.removeMember("myBitmap"); - - if (value.isMember("myEnum")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "myEnum"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.myEnum, value["myEnum"])); - } - valueCopy.removeMember("myEnum"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} - -void ComplexArgumentParser::Finalize(chip::app::Clusters::Globals::Structs::TestGlobalStruct::Type & request) -{ - ComplexArgumentParser::Finalize(request.name); - ComplexArgumentParser::Finalize(request.myBitmap); - ComplexArgumentParser::Finalize(request.myEnum); -} - CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::Descriptor::Structs::SemanticTagStruct::Type & request, Json::Value & value) @@ -5739,6 +5739,13 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters: ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.h, value["h"])); valueCopy.removeMember("h"); + if (value.isMember("i")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "i"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.i, value["i"])); + } + valueCopy.removeMember("i"); + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } @@ -5752,6 +5759,7 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs:: ComplexArgumentParser::Finalize(request.f); ComplexArgumentParser::Finalize(request.g); ComplexArgumentParser::Finalize(request.h); + ComplexArgumentParser::Finalize(request.i); } CHIP_ERROR ComplexArgumentParser::Setup(const char * label, @@ -5978,6 +5986,13 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters: ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.c, value["c"])); valueCopy.removeMember("c"); + if (value.isMember("d")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "d"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.d, value["d"])); + } + valueCopy.removeMember("d"); + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } @@ -5986,6 +6001,7 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs:: ComplexArgumentParser::Finalize(request.a); ComplexArgumentParser::Finalize(request.b); ComplexArgumentParser::Finalize(request.c); + ComplexArgumentParser::Finalize(request.d); } CHIP_ERROR ComplexArgumentParser::Setup(const char * label, diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h index 47683b1ab87888..5bb0718efb81ea 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h @@ -22,6 +22,11 @@ #include #include +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Globals::Structs::TestGlobalStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::Globals::Structs::TestGlobalStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::detail::Structs::ModeTagStruct::Type & request, Json::Value & value); @@ -71,11 +76,6 @@ static CHIP_ERROR Setup(const char * label, chip::app::Clusters::detail::Structs static void Finalize(chip::app::Clusters::detail::Structs::OperationalStateStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Globals::Structs::TestGlobalStruct::Type & request, - Json::Value & value); - -static void Finalize(chip::app::Clusters::Globals::Structs::TestGlobalStruct::Type & request); - static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Descriptor::Structs::SemanticTagStruct::Type & request, Json::Value & value); 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 fb156dee2d45dc..7fe1851ba370ce 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -21,6 +21,39 @@ using namespace chip::app::Clusters; +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::Globals::Structs::TestGlobalStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("MyBitmap", indent + 1, value.myBitmap); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MyBitmap'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("MyEnum", indent + 1, value.myEnum); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MyEnum'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const chip::app::Clusters::detail::Structs::ModeTagStruct::DecodableType & value) { @@ -368,39 +401,6 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Globals::Structs::TestGlobalStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); - { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("MyBitmap", indent + 1, value.myBitmap); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MyBitmap'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("MyEnum", indent + 1, value.myEnum); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MyEnum'"); - return err; - } - } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} - CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const chip::app::Clusters::Descriptor::Structs::SemanticTagStruct::DecodableType & value) { @@ -5083,6 +5083,14 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return err; } } + { + CHIP_ERROR err = LogValue("I", indent + 1, value.i); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'I'"); + return err; + } + } DataModelLogger::LogString(indent, "}"); return CHIP_NO_ERROR; @@ -5296,6 +5304,14 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return err; } } + { + CHIP_ERROR err = LogValue("D", indent + 1, value.d); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'D'"); + return err; + } + } DataModelLogger::LogString(indent, "}"); return CHIP_NO_ERROR; @@ -8758,6 +8774,15 @@ 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::GlobalEchoResponse::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + ReturnErrorOnFailure(DataModelLogger::LogValue("field1", indent + 1, value.field1)); + ReturnErrorOnFailure(DataModelLogger::LogValue("field2", indent + 1, value.field2)); + DataModelLogger::LogString(indent, "}"); + return CHIP_NO_ERROR; +} CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const UnitTesting::Commands::TestDifferentVendorMeiResponse::DecodableType & value) { @@ -19002,6 +19027,16 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("cluster_error_boolean", 1, value); } + case UnitTesting::Attributes::GlobalEnum::Id: { + chip::app::Clusters::Globals::TestGlobalEnum value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("global_enum", 1, value); + } + case UnitTesting::Attributes::GlobalStruct::Id: { + chip::app::Clusters::Globals::Structs::TestGlobalStruct::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("global_struct", 1, value); + } case UnitTesting::Attributes::Unsupported::Id: { bool value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); @@ -19177,6 +19212,16 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("write_only_int8u", 1, value); } + case UnitTesting::Attributes::NullableGlobalEnum::Id: { + chip::app::DataModel::Nullable value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("nullable_global_enum", 1, value); + } + case UnitTesting::Attributes::NullableGlobalStruct::Id: { + chip::app::DataModel::Nullable value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("nullable_global_struct", 1, value); + } case UnitTesting::Attributes::GeneratedCommandList::Id: { chip::app::DataModel::DecodableList value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); @@ -19991,6 +20036,11 @@ CHIP_ERROR DataModelLogger::LogCommand(const chip::app::ConcreteCommandPath & pa ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("StringEchoResponse", 1, value); } + case UnitTesting::Commands::GlobalEchoResponse::Id: { + UnitTesting::Commands::GlobalEchoResponse::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("GlobalEchoResponse", 1, value); + } case UnitTesting::Commands::TestDifferentVendorMeiResponse::Id: { UnitTesting::Commands::TestDifferentVendorMeiResponse::DecodableType value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); 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 165d44db24002f..52dede56ab7ec0 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h @@ -20,6 +20,9 @@ #include #include +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::Globals::Structs::TestGlobalStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::detail::Structs::ModeTagStruct::DecodableType & value); @@ -50,9 +53,6 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::detail::Structs::OperationalStateStruct::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::Globals::Structs::TestGlobalStruct::DecodableType & value); - static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::Descriptor::Structs::SemanticTagStruct::DecodableType & value); @@ -868,6 +868,8 @@ 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::UnitTesting::Commands::StringEchoResponse::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::UnitTesting::Commands::GlobalEchoResponse::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::UnitTesting::Commands::TestDifferentVendorMeiResponse::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, 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 d31a6b22803f88..e226d87a19aec8 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -177168,6 +177168,7 @@ class SubscribeAttributeElectricalMeasurementClusterRevision : public SubscribeA | * TestBatchHelperRequest | 0x16 | | * TestSecondBatchHelperRequest | 0x17 | | * StringEchoRequest | 0x18 | +| * GlobalEchoRequest | 0x19 | | * TestDifferentVendorMeiRequest | 0xFFF200AA| |------------------------------------------------------------------------------| | Attributes: | | @@ -177218,6 +177219,8 @@ class SubscribeAttributeElectricalMeasurementClusterRevision : public SubscribeA | * TimedWriteBoolean | 0x0030 | | * GeneralErrorBoolean | 0x0031 | | * ClusterErrorBoolean | 0x0032 | +| * GlobalEnum | 0x0033 | +| * GlobalStruct | 0x0034 | | * Unsupported | 0x00FF | | * NullableBoolean | 0x4000 | | * NullableBitmap8 | 0x4001 | @@ -177253,6 +177256,8 @@ class SubscribeAttributeElectricalMeasurementClusterRevision : public SubscribeA | * NullableRangeRestrictedInt16u | 0x4028 | | * NullableRangeRestrictedInt16s | 0x4029 | | * WriteOnlyInt8u | 0x402A | +| * NullableGlobalEnum | 0x4033 | +| * NullableGlobalStruct | 0x4034 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -177605,6 +177610,11 @@ class UnitTestingTestStructArrayArgumentRequest : public ClusterCommand { newElement_0.c.f = [NSNumber numberWithUnsignedChar:entry_0.c.f.Raw()]; newElement_0.c.g = [NSNumber numberWithFloat:entry_0.c.g]; newElement_0.c.h = [NSNumber numberWithDouble:entry_0.c.h]; + if (entry_0.c.i.HasValue()) { + newElement_0.c.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.c.i.Value())]; + } else { + newElement_0.c.i = nil; + } { // Scope for our temporary variables auto * array_2 = [NSMutableArray new]; for (auto & entry_2 : entry_0.d) { @@ -177618,6 +177628,11 @@ class UnitTestingTestStructArrayArgumentRequest : public ClusterCommand { newElement_2.f = [NSNumber numberWithUnsignedChar:entry_2.f.Raw()]; newElement_2.g = [NSNumber numberWithFloat:entry_2.g]; newElement_2.h = [NSNumber numberWithDouble:entry_2.h]; + if (entry_2.i.HasValue()) { + newElement_2.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_2.i.Value())]; + } else { + newElement_2.i = nil; + } [array_2 addObject:newElement_2]; } newElement_0.d = array_2; @@ -177666,6 +177681,11 @@ class UnitTestingTestStructArrayArgumentRequest : public ClusterCommand { newElement_0.f = [NSNumber numberWithUnsignedChar:entry_0.f.Raw()]; newElement_0.g = [NSNumber numberWithFloat:entry_0.g]; newElement_0.h = [NSNumber numberWithDouble:entry_0.h]; + if (entry_0.i.HasValue()) { + newElement_0.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.i.Value())]; + } else { + newElement_0.i = nil; + } [array_0 addObject:newElement_0]; } params.arg2 = array_0; @@ -177756,6 +177776,11 @@ class UnitTestingTestStructArgumentRequest : public ClusterCommand { params.arg1.f = [NSNumber numberWithUnsignedChar:mRequest.arg1.f.Raw()]; params.arg1.g = [NSNumber numberWithFloat:mRequest.arg1.g]; params.arg1.h = [NSNumber numberWithDouble:mRequest.arg1.h]; + if (mRequest.arg1.i.HasValue()) { + params.arg1.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.arg1.i.Value())]; + } else { + params.arg1.i = nil; + } uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -177822,6 +177847,31 @@ class UnitTestingTestNestedStructArgumentRequest : public ClusterCommand { params.arg1.c.f = [NSNumber numberWithUnsignedChar:mRequest.arg1.c.f.Raw()]; params.arg1.c.g = [NSNumber numberWithFloat:mRequest.arg1.c.g]; params.arg1.c.h = [NSNumber numberWithDouble:mRequest.arg1.c.h]; + if (mRequest.arg1.c.i.HasValue()) { + params.arg1.c.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.arg1.c.i.Value())]; + } else { + params.arg1.c.i = nil; + } + if (mRequest.arg1.d.HasValue()) { + params.arg1.d = [MTRDataTypeTestGlobalStruct new]; + params.arg1.d.name = [[NSString alloc] initWithBytes:mRequest.arg1.d.Value().name.data() length:mRequest.arg1.d.Value().name.size() encoding:NSUTF8StringEncoding]; + if (mRequest.arg1.d.Value().myBitmap.IsNull()) { + params.arg1.d.myBitmap = nil; + } else { + params.arg1.d.myBitmap = [NSNumber numberWithUnsignedInt:mRequest.arg1.d.Value().myBitmap.Value().Raw()]; + } + if (mRequest.arg1.d.Value().myEnum.HasValue()) { + if (mRequest.arg1.d.Value().myEnum.Value().IsNull()) { + params.arg1.d.myEnum = nil; + } else { + params.arg1.d.myEnum = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.arg1.d.Value().myEnum.Value().Value())]; + } + } else { + params.arg1.d.myEnum = nil; + } + } else { + params.arg1.d = nil; + } uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -177889,6 +177939,11 @@ class UnitTestingTestListStructArgumentRequest : public ClusterCommand { newElement_0.f = [NSNumber numberWithUnsignedChar:entry_0.f.Raw()]; newElement_0.g = [NSNumber numberWithFloat:entry_0.g]; newElement_0.h = [NSNumber numberWithDouble:entry_0.h]; + if (entry_0.i.HasValue()) { + newElement_0.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.i.Value())]; + } else { + newElement_0.i = nil; + } [array_0 addObject:newElement_0]; } params.arg1 = array_0; @@ -178022,6 +178077,11 @@ class UnitTestingTestNestedStructListArgumentRequest : public ClusterCommand { params.arg1.c.f = [NSNumber numberWithUnsignedChar:mRequest.arg1.c.f.Raw()]; params.arg1.c.g = [NSNumber numberWithFloat:mRequest.arg1.c.g]; params.arg1.c.h = [NSNumber numberWithDouble:mRequest.arg1.c.h]; + if (mRequest.arg1.c.i.HasValue()) { + params.arg1.c.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.arg1.c.i.Value())]; + } else { + params.arg1.c.i = nil; + } { // Scope for our temporary variables auto * array_1 = [NSMutableArray new]; for (auto & entry_1 : mRequest.arg1.d) { @@ -178035,6 +178095,11 @@ class UnitTestingTestNestedStructListArgumentRequest : public ClusterCommand { newElement_1.f = [NSNumber numberWithUnsignedChar:entry_1.f.Raw()]; newElement_1.g = [NSNumber numberWithFloat:entry_1.g]; newElement_1.h = [NSNumber numberWithDouble:entry_1.h]; + if (entry_1.i.HasValue()) { + newElement_1.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_1.i.Value())]; + } else { + newElement_1.i = nil; + } [array_1 addObject:newElement_1]; } params.arg1.d = array_1; @@ -178136,6 +178201,11 @@ class UnitTestingTestListNestedStructListArgumentRequest : public ClusterCommand newElement_0.c.f = [NSNumber numberWithUnsignedChar:entry_0.c.f.Raw()]; newElement_0.c.g = [NSNumber numberWithFloat:entry_0.c.g]; newElement_0.c.h = [NSNumber numberWithDouble:entry_0.c.h]; + if (entry_0.c.i.HasValue()) { + newElement_0.c.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.c.i.Value())]; + } else { + newElement_0.c.i = nil; + } { // Scope for our temporary variables auto * array_2 = [NSMutableArray new]; for (auto & entry_2 : entry_0.d) { @@ -178149,6 +178219,11 @@ class UnitTestingTestListNestedStructListArgumentRequest : public ClusterCommand newElement_2.f = [NSNumber numberWithUnsignedChar:entry_2.f.Raw()]; newElement_2.g = [NSNumber numberWithFloat:entry_2.g]; newElement_2.h = [NSNumber numberWithDouble:entry_2.h]; + if (entry_2.i.HasValue()) { + newElement_2.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_2.i.Value())]; + } else { + newElement_2.i = nil; + } [array_2 addObject:newElement_2]; } newElement_0.d = array_2; @@ -178483,6 +178558,11 @@ class UnitTestingTestComplexNullableOptionalRequest : public ClusterCommand { params.nullableStruct.f = [NSNumber numberWithUnsignedChar:mRequest.nullableStruct.Value().f.Raw()]; params.nullableStruct.g = [NSNumber numberWithFloat:mRequest.nullableStruct.Value().g]; params.nullableStruct.h = [NSNumber numberWithDouble:mRequest.nullableStruct.Value().h]; + if (mRequest.nullableStruct.Value().i.HasValue()) { + params.nullableStruct.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.nullableStruct.Value().i.Value())]; + } else { + params.nullableStruct.i = nil; + } } if (mRequest.optionalStruct.HasValue()) { params.optionalStruct = [MTRUnitTestingClusterSimpleStruct new]; @@ -178494,6 +178574,11 @@ class UnitTestingTestComplexNullableOptionalRequest : public ClusterCommand { params.optionalStruct.f = [NSNumber numberWithUnsignedChar:mRequest.optionalStruct.Value().f.Raw()]; params.optionalStruct.g = [NSNumber numberWithFloat:mRequest.optionalStruct.Value().g]; params.optionalStruct.h = [NSNumber numberWithDouble:mRequest.optionalStruct.Value().h]; + if (mRequest.optionalStruct.Value().i.HasValue()) { + params.optionalStruct.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.optionalStruct.Value().i.Value())]; + } else { + params.optionalStruct.i = nil; + } } else { params.optionalStruct = nil; } @@ -178510,6 +178595,11 @@ class UnitTestingTestComplexNullableOptionalRequest : public ClusterCommand { params.nullableOptionalStruct.f = [NSNumber numberWithUnsignedChar:mRequest.nullableOptionalStruct.Value().Value().f.Raw()]; params.nullableOptionalStruct.g = [NSNumber numberWithFloat:mRequest.nullableOptionalStruct.Value().Value().g]; params.nullableOptionalStruct.h = [NSNumber numberWithDouble:mRequest.nullableOptionalStruct.Value().Value().h]; + if (mRequest.nullableOptionalStruct.Value().Value().i.HasValue()) { + params.nullableOptionalStruct.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.nullableOptionalStruct.Value().Value().i.Value())]; + } else { + params.nullableOptionalStruct.i = nil; + } } } else { params.nullableOptionalStruct = nil; @@ -178625,6 +178715,11 @@ class UnitTestingSimpleStructEchoRequest : public ClusterCommand { params.arg1.f = [NSNumber numberWithUnsignedChar:mRequest.arg1.f.Raw()]; params.arg1.g = [NSNumber numberWithFloat:mRequest.arg1.g]; params.arg1.h = [NSNumber numberWithDouble:mRequest.arg1.h]; + if (mRequest.arg1.i.HasValue()) { + params.arg1.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.arg1.i.Value())]; + } else { + params.arg1.i = nil; + } uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; while (repeatCount--) { @@ -179060,6 +179155,88 @@ class UnitTestingStringEchoRequest : public ClusterCommand { chip::app::Clusters::UnitTesting::Commands::StringEchoRequest::Type mRequest; }; +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL +/* + * Command GlobalEchoRequest + */ +class UnitTestingGlobalEchoRequest : public ClusterCommand { +public: + UnitTestingGlobalEchoRequest() + : ClusterCommand("global-echo-request") + , mComplex_Field1(&mRequest.field1) + { +#if MTR_ENABLE_PROVISIONAL + AddArgument("Field1", &mComplex_Field1); +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + AddArgument("Field2", 0, UINT8_MAX, &mRequest.field2); +#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::GlobalEchoRequest::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 = [[MTRUnitTestingClusterGlobalEchoRequestParams alloc] init]; + params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; +#if MTR_ENABLE_PROVISIONAL + params.field1 = [MTRDataTypeTestGlobalStruct new]; + params.field1.name = [[NSString alloc] initWithBytes:mRequest.field1.name.data() length:mRequest.field1.name.size() encoding:NSUTF8StringEncoding]; + if (mRequest.field1.myBitmap.IsNull()) { + params.field1.myBitmap = nil; + } else { + params.field1.myBitmap = [NSNumber numberWithUnsignedInt:mRequest.field1.myBitmap.Value().Raw()]; + } + if (mRequest.field1.myEnum.HasValue()) { + if (mRequest.field1.myEnum.Value().IsNull()) { + params.field1.myEnum = nil; + } else { + params.field1.myEnum = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.field1.myEnum.Value().Value())]; + } + } else { + params.field1.myEnum = nil; + } +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + params.field2 = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.field2)]; +#endif // MTR_ENABLE_PROVISIONAL + uint16_t repeatCount = mRepeatCount.ValueOr(1); + uint16_t __block responsesNeeded = repeatCount; + while (repeatCount--) { + [cluster globalEchoRequestWithParams:params completion: + ^(MTRUnitTestingClusterGlobalEchoResponseParams * _Nullable values, NSError * _Nullable error) { + NSLog(@"Values: %@", values); + if (error == nil) { + constexpr chip::CommandId responseId = chip::app::Clusters::UnitTesting::Commands::GlobalEchoResponse::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::GlobalEchoResponse::Id; + RemoteDataModelLogger::LogCommandErrorAsJSON(@(endpointId), @(clusterId), @(responseId), error); + } + if (responsesNeeded == 0) { + SetCommandExitStatus(mError); + } + }]; + } + return CHIP_NO_ERROR; + } + +private: + chip::app::Clusters::UnitTesting::Commands::GlobalEchoRequest::Type mRequest; + TypedComplexArgument mComplex_Field1; +}; + #endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL /* @@ -183580,6 +183757,11 @@ class WriteUnitTestingListNullablesAndOptionalsStruct : public WriteAttribute { newElement_0.nullableStruct.f = [NSNumber numberWithUnsignedChar:entry_0.nullableStruct.Value().f.Raw()]; newElement_0.nullableStruct.g = [NSNumber numberWithFloat:entry_0.nullableStruct.Value().g]; newElement_0.nullableStruct.h = [NSNumber numberWithDouble:entry_0.nullableStruct.Value().h]; + if (entry_0.nullableStruct.Value().i.HasValue()) { + newElement_0.nullableStruct.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.nullableStruct.Value().i.Value())]; + } else { + newElement_0.nullableStruct.i = nil; + } } if (entry_0.optionalStruct.HasValue()) { newElement_0.optionalStruct = [MTRUnitTestingClusterSimpleStruct new]; @@ -183591,6 +183773,11 @@ class WriteUnitTestingListNullablesAndOptionalsStruct : public WriteAttribute { newElement_0.optionalStruct.f = [NSNumber numberWithUnsignedChar:entry_0.optionalStruct.Value().f.Raw()]; newElement_0.optionalStruct.g = [NSNumber numberWithFloat:entry_0.optionalStruct.Value().g]; newElement_0.optionalStruct.h = [NSNumber numberWithDouble:entry_0.optionalStruct.Value().h]; + if (entry_0.optionalStruct.Value().i.HasValue()) { + newElement_0.optionalStruct.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.optionalStruct.Value().i.Value())]; + } else { + newElement_0.optionalStruct.i = nil; + } } else { newElement_0.optionalStruct = nil; } @@ -183607,6 +183794,11 @@ class WriteUnitTestingListNullablesAndOptionalsStruct : public WriteAttribute { newElement_0.nullableOptionalStruct.f = [NSNumber numberWithUnsignedChar:entry_0.nullableOptionalStruct.Value().Value().f.Raw()]; newElement_0.nullableOptionalStruct.g = [NSNumber numberWithFloat:entry_0.nullableOptionalStruct.Value().Value().g]; newElement_0.nullableOptionalStruct.h = [NSNumber numberWithDouble:entry_0.nullableOptionalStruct.Value().Value().h]; + if (entry_0.nullableOptionalStruct.Value().Value().i.HasValue()) { + newElement_0.nullableOptionalStruct.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.nullableOptionalStruct.Value().Value().i.Value())]; + } else { + newElement_0.nullableOptionalStruct.i = nil; + } } } else { newElement_0.nullableOptionalStruct = nil; @@ -183915,6 +184107,11 @@ class WriteUnitTestingStructAttr : public WriteAttribute { value.f = [NSNumber numberWithUnsignedChar:mValue.f.Raw()]; value.g = [NSNumber numberWithFloat:mValue.g]; value.h = [NSNumber numberWithDouble:mValue.h]; + if (mValue.i.HasValue()) { + value.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(mValue.i.Value())]; + } else { + value.i = nil; + } [cluster writeAttributeStructAttrWithValue:value params:params completion:^(NSError * _Nullable error) { if (error != nil) { @@ -184705,6 +184902,11 @@ class WriteUnitTestingListFabricScoped : public WriteAttribute { newElement_0.fabricSensitiveStruct.f = [NSNumber numberWithUnsignedChar:entry_0.fabricSensitiveStruct.f.Raw()]; newElement_0.fabricSensitiveStruct.g = [NSNumber numberWithFloat:entry_0.fabricSensitiveStruct.g]; newElement_0.fabricSensitiveStruct.h = [NSNumber numberWithDouble:entry_0.fabricSensitiveStruct.h]; + if (entry_0.fabricSensitiveStruct.i.HasValue()) { + newElement_0.fabricSensitiveStruct.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(entry_0.fabricSensitiveStruct.i.Value())]; + } else { + newElement_0.fabricSensitiveStruct.i = nil; + } { // Scope for our temporary variables auto * array_2 = [NSMutableArray new]; for (auto & entry_2 : entry_0.fabricSensitiveInt8uList) { @@ -185065,22 +185267,274 @@ class ReadUnitTestingClusterErrorBoolean : public ReadAttribute { class WriteUnitTestingClusterErrorBoolean : public WriteAttribute { public: - WriteUnitTestingClusterErrorBoolean() - : WriteAttribute("cluster-error-boolean") + WriteUnitTestingClusterErrorBoolean() + : WriteAttribute("cluster-error-boolean") + { + AddArgument("attr-name", "cluster-error-boolean"); + AddArgument("attr-value", 0, 1, &mValue); + WriteAttribute::AddArguments(); + } + + ~WriteUnitTestingClusterErrorBoolean() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::UnitTesting::Attributes::ClusterErrorBoolean::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") WriteAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, 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 = [[MTRWriteParams alloc] init]; + params.timedWriteTimeout = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; + params.dataVersion = mDataVersion.HasValue() ? [NSNumber numberWithUnsignedInt:mDataVersion.Value()] : nil; + NSNumber * _Nonnull value = [NSNumber numberWithBool:mValue]; + + [cluster writeAttributeClusterErrorBooleanWithValue:value params:params completion:^(NSError * _Nullable error) { + if (error != nil) { + LogNSError("UnitTesting ClusterErrorBoolean write Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } + +private: + bool mValue; +}; + +class SubscribeAttributeUnitTestingClusterErrorBoolean : public SubscribeAttribute { +public: + SubscribeAttributeUnitTestingClusterErrorBoolean() + : SubscribeAttribute("cluster-error-boolean") + { + } + + ~SubscribeAttributeUnitTestingClusterErrorBoolean() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::UnitTesting::Attributes::ClusterErrorBoolean::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, 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 = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeClusterErrorBooleanWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"UnitTesting.ClusterErrorBoolean response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute GlobalEnum + */ +class ReadUnitTestingGlobalEnum : public ReadAttribute { +public: + ReadUnitTestingGlobalEnum() + : ReadAttribute("global-enum") + { + } + + ~ReadUnitTestingGlobalEnum() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::UnitTesting::Attributes::GlobalEnum::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeGlobalEnumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"UnitTesting.GlobalEnum response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("UnitTesting GlobalEnum read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class WriteUnitTestingGlobalEnum : public WriteAttribute { +public: + WriteUnitTestingGlobalEnum() + : WriteAttribute("global-enum") + { + AddArgument("attr-name", "global-enum"); + AddArgument("attr-value", 0, UINT8_MAX, &mValue); + WriteAttribute::AddArguments(); + } + + ~WriteUnitTestingGlobalEnum() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::UnitTesting::Attributes::GlobalEnum::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") WriteAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, 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 = [[MTRWriteParams alloc] init]; + params.timedWriteTimeout = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; + params.dataVersion = mDataVersion.HasValue() ? [NSNumber numberWithUnsignedInt:mDataVersion.Value()] : nil; + NSNumber * _Nonnull value = [NSNumber numberWithUnsignedChar:mValue]; + + [cluster writeAttributeGlobalEnumWithValue:value params:params completion:^(NSError * _Nullable error) { + if (error != nil) { + LogNSError("UnitTesting GlobalEnum write Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } + +private: + uint8_t mValue; +}; + +class SubscribeAttributeUnitTestingGlobalEnum : public SubscribeAttribute { +public: + SubscribeAttributeUnitTestingGlobalEnum() + : SubscribeAttribute("global-enum") + { + } + + ~SubscribeAttributeUnitTestingGlobalEnum() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::UnitTesting::Attributes::GlobalEnum::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, 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 = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeGlobalEnumWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"UnitTesting.GlobalEnum response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute GlobalStruct + */ +class ReadUnitTestingGlobalStruct : public ReadAttribute { +public: + ReadUnitTestingGlobalStruct() + : ReadAttribute("global-struct") + { + } + + ~ReadUnitTestingGlobalStruct() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::UnitTesting::Attributes::GlobalStruct::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeGlobalStructWithCompletion:^(MTRDataTypeTestGlobalStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"UnitTesting.GlobalStruct response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("UnitTesting GlobalStruct read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class WriteUnitTestingGlobalStruct : public WriteAttribute { +public: + WriteUnitTestingGlobalStruct() + : WriteAttribute("global-struct") + , mComplex(&mValue) { - AddArgument("attr-name", "cluster-error-boolean"); - AddArgument("attr-value", 0, 1, &mValue); + AddArgument("attr-name", "global-struct"); + AddArgument("attr-value", &mComplex); WriteAttribute::AddArguments(); } - ~WriteUnitTestingClusterErrorBoolean() + ~WriteUnitTestingGlobalStruct() { } CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override { constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; - constexpr chip::AttributeId attributeId = chip::app::Clusters::UnitTesting::Attributes::ClusterErrorBoolean::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::UnitTesting::Attributes::GlobalStruct::Id; ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") WriteAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); @@ -185088,11 +185542,27 @@ class WriteUnitTestingClusterErrorBoolean : public WriteAttribute { __auto_type * params = [[MTRWriteParams alloc] init]; params.timedWriteTimeout = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; params.dataVersion = mDataVersion.HasValue() ? [NSNumber numberWithUnsignedInt:mDataVersion.Value()] : nil; - NSNumber * _Nonnull value = [NSNumber numberWithBool:mValue]; + MTRDataTypeTestGlobalStruct * _Nonnull value; + value = [MTRDataTypeTestGlobalStruct new]; + value.name = [[NSString alloc] initWithBytes:mValue.name.data() length:mValue.name.size() encoding:NSUTF8StringEncoding]; + if (mValue.myBitmap.IsNull()) { + value.myBitmap = nil; + } else { + value.myBitmap = [NSNumber numberWithUnsignedInt:mValue.myBitmap.Value().Raw()]; + } + if (mValue.myEnum.HasValue()) { + if (mValue.myEnum.Value().IsNull()) { + value.myEnum = nil; + } else { + value.myEnum = [NSNumber numberWithUnsignedChar:chip::to_underlying(mValue.myEnum.Value().Value())]; + } + } else { + value.myEnum = nil; + } - [cluster writeAttributeClusterErrorBooleanWithValue:value params:params completion:^(NSError * _Nullable error) { + [cluster writeAttributeGlobalStructWithValue:value params:params completion:^(NSError * _Nullable error) { if (error != nil) { - LogNSError("UnitTesting ClusterErrorBoolean write Error", error); + LogNSError("UnitTesting GlobalStruct write Error", error); RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); } SetCommandExitStatus(error); @@ -185101,24 +185571,25 @@ class WriteUnitTestingClusterErrorBoolean : public WriteAttribute { } private: - bool mValue; + chip::app::Clusters::Globals::Structs::TestGlobalStruct::Type mValue; + TypedComplexArgument mComplex; }; -class SubscribeAttributeUnitTestingClusterErrorBoolean : public SubscribeAttribute { +class SubscribeAttributeUnitTestingGlobalStruct : public SubscribeAttribute { public: - SubscribeAttributeUnitTestingClusterErrorBoolean() - : SubscribeAttribute("cluster-error-boolean") + SubscribeAttributeUnitTestingGlobalStruct() + : SubscribeAttribute("global-struct") { } - ~SubscribeAttributeUnitTestingClusterErrorBoolean() + ~SubscribeAttributeUnitTestingGlobalStruct() { } CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override { constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; - constexpr chip::CommandId attributeId = chip::app::Clusters::UnitTesting::Attributes::ClusterErrorBoolean::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::UnitTesting::Attributes::GlobalStruct::Id; ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); @@ -185133,10 +185604,10 @@ class SubscribeAttributeUnitTestingClusterErrorBoolean : public SubscribeAttribu if (mAutoResubscribe.HasValue()) { params.resubscribeAutomatically = mAutoResubscribe.Value(); } - [cluster subscribeAttributeClusterErrorBooleanWithParams:params + [cluster subscribeAttributeGlobalStructWithParams:params subscriptionEstablished:^() { mSubscriptionEstablished = YES; } - reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { - NSLog(@"UnitTesting.ClusterErrorBoolean response %@", [value description]); + reportHandler:^(MTRDataTypeTestGlobalStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"UnitTesting.GlobalStruct response %@", [value description]); if (error == nil) { RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); } else { @@ -185149,6 +185620,8 @@ class SubscribeAttributeUnitTestingClusterErrorBoolean : public SubscribeAttribu } }; +#endif // MTR_ENABLE_PROVISIONAL + /* * Attribute Unsupported */ @@ -188876,6 +189349,11 @@ class WriteUnitTestingNullableStruct : public WriteAttribute { value.f = [NSNumber numberWithUnsignedChar:mValue.Value().f.Raw()]; value.g = [NSNumber numberWithFloat:mValue.Value().g]; value.h = [NSNumber numberWithDouble:mValue.Value().h]; + if (mValue.Value().i.HasValue()) { + value.i = [NSNumber numberWithUnsignedChar:chip::to_underlying(mValue.Value().i.Value())]; + } else { + value.i = nil; + } } [cluster writeAttributeNullableStructWithValue:value params:params completion:^(NSError * _Nullable error) { @@ -189565,6 +190043,284 @@ class SubscribeAttributeUnitTestingWriteOnlyInt8u : public SubscribeAttribute { } }; +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute NullableGlobalEnum + */ +class ReadUnitTestingNullableGlobalEnum : public ReadAttribute { +public: + ReadUnitTestingNullableGlobalEnum() + : ReadAttribute("nullable-global-enum") + { + } + + ~ReadUnitTestingNullableGlobalEnum() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::UnitTesting::Attributes::NullableGlobalEnum::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeNullableGlobalEnumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"UnitTesting.NullableGlobalEnum response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("UnitTesting NullableGlobalEnum read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class WriteUnitTestingNullableGlobalEnum : public WriteAttribute { +public: + WriteUnitTestingNullableGlobalEnum() + : WriteAttribute("nullable-global-enum") + { + AddArgument("attr-name", "nullable-global-enum"); + AddArgument("attr-value", 0, UINT8_MAX, &mValue); + WriteAttribute::AddArguments(); + } + + ~WriteUnitTestingNullableGlobalEnum() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::UnitTesting::Attributes::NullableGlobalEnum::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") WriteAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, 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 = [[MTRWriteParams alloc] init]; + params.timedWriteTimeout = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; + params.dataVersion = mDataVersion.HasValue() ? [NSNumber numberWithUnsignedInt:mDataVersion.Value()] : nil; + NSNumber * _Nullable value = nil; + if (!mValue.IsNull()) { + value = [NSNumber numberWithUnsignedChar:mValue.Value()]; + } + + [cluster writeAttributeNullableGlobalEnumWithValue:value params:params completion:^(NSError * _Nullable error) { + if (error != nil) { + LogNSError("UnitTesting NullableGlobalEnum write Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } + +private: + chip::app::DataModel::Nullable mValue; +}; + +class SubscribeAttributeUnitTestingNullableGlobalEnum : public SubscribeAttribute { +public: + SubscribeAttributeUnitTestingNullableGlobalEnum() + : SubscribeAttribute("nullable-global-enum") + { + } + + ~SubscribeAttributeUnitTestingNullableGlobalEnum() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::UnitTesting::Attributes::NullableGlobalEnum::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, 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 = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeNullableGlobalEnumWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"UnitTesting.NullableGlobalEnum response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + +/* + * Attribute NullableGlobalStruct + */ +class ReadUnitTestingNullableGlobalStruct : public ReadAttribute { +public: + ReadUnitTestingNullableGlobalStruct() + : ReadAttribute("nullable-global-struct") + { + } + + ~ReadUnitTestingNullableGlobalStruct() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::UnitTesting::Attributes::NullableGlobalStruct::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeNullableGlobalStructWithCompletion:^(MTRDataTypeTestGlobalStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"UnitTesting.NullableGlobalStruct response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("UnitTesting NullableGlobalStruct read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class WriteUnitTestingNullableGlobalStruct : public WriteAttribute { +public: + WriteUnitTestingNullableGlobalStruct() + : WriteAttribute("nullable-global-struct") + , mComplex(&mValue) + { + AddArgument("attr-name", "nullable-global-struct"); + AddArgument("attr-value", &mComplex); + WriteAttribute::AddArguments(); + } + + ~WriteUnitTestingNullableGlobalStruct() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::UnitTesting::Attributes::NullableGlobalStruct::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") WriteAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, 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 = [[MTRWriteParams alloc] init]; + params.timedWriteTimeout = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; + params.dataVersion = mDataVersion.HasValue() ? [NSNumber numberWithUnsignedInt:mDataVersion.Value()] : nil; + MTRDataTypeTestGlobalStruct * _Nullable value; + if (mValue.IsNull()) { + value = nil; + } else { + value = [MTRDataTypeTestGlobalStruct new]; + value.name = [[NSString alloc] initWithBytes:mValue.Value().name.data() length:mValue.Value().name.size() encoding:NSUTF8StringEncoding]; + if (mValue.Value().myBitmap.IsNull()) { + value.myBitmap = nil; + } else { + value.myBitmap = [NSNumber numberWithUnsignedInt:mValue.Value().myBitmap.Value().Raw()]; + } + if (mValue.Value().myEnum.HasValue()) { + if (mValue.Value().myEnum.Value().IsNull()) { + value.myEnum = nil; + } else { + value.myEnum = [NSNumber numberWithUnsignedChar:chip::to_underlying(mValue.Value().myEnum.Value().Value())]; + } + } else { + value.myEnum = nil; + } + } + + [cluster writeAttributeNullableGlobalStructWithValue:value params:params completion:^(NSError * _Nullable error) { + if (error != nil) { + LogNSError("UnitTesting NullableGlobalStruct write Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } + +private: + chip::app::DataModel::Nullable mValue; + TypedComplexArgument> mComplex; +}; + +class SubscribeAttributeUnitTestingNullableGlobalStruct : public SubscribeAttribute { +public: + SubscribeAttributeUnitTestingNullableGlobalStruct() + : SubscribeAttribute("nullable-global-struct") + { + } + + ~SubscribeAttributeUnitTestingNullableGlobalStruct() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::UnitTesting::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::UnitTesting::Attributes::NullableGlobalStruct::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, 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 = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeNullableGlobalStructWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(MTRDataTypeTestGlobalStruct * _Nullable value, NSError * _Nullable error) { + NSLog(@"UnitTesting.NullableGlobalStruct response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL + /* * Attribute GeneratedCommandList */ @@ -198236,6 +198992,9 @@ void registerClusterUnitTesting(Commands & commands) #if MTR_ENABLE_PROVISIONAL make_unique(), // #endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL make_unique(), // #endif // MTR_ENABLE_PROVISIONAL @@ -198383,6 +199142,16 @@ void registerClusterUnitTesting(Commands & commands) make_unique(), // make_unique(), // make_unique(), // +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL make_unique(), // make_unique(), // make_unique(), // @@ -198488,6 +199257,16 @@ void registerClusterUnitTesting(Commands & commands) make_unique(), // make_unique(), // make_unique(), // +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL make_unique(), // make_unique(), // make_unique(), //