From ee21178ec982a740e0d2cd61d58661f1db79ecc4 Mon Sep 17 00:00:00 2001 From: Erwin Pan Date: Wed, 13 Dec 2023 02:56:46 +0800 Subject: [PATCH] [Chef] Add Pinged event to samplemei (#30890) * Add draft version of samplemei implementing event * Fix correct Pinged number * Fix sample * Restyled by clang-format * Fix Chef ZAP event from Pinged to PingCountEvent * zap regen * Remove files that are not to be generated anymore * Bump actions/labeler from 4 to 5 (#30911) Bumps [actions/labeler](https://github.com/actions/labeler) from 4 to 5. - [Release notes](https://github.com/actions/labeler/releases) - [Commits](https://github.com/actions/labeler/compare/v4...v5) --- updated-dependencies: - dependency-name: actions/labeler dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Revert "Bump actions/labeler from 4 to 5 (#30911)" (#30922) This reverts commit e15db829cde4a484a283c0e935df4738f572bb4c. * Change the package of Kotlin cluster lib to package matter.controller.cluster.clusters (#30945) * Fix newline in the end of files.gni --------- Signed-off-by: dependabot[bot] Co-authored-by: tennessee.carmelveilleux@gmail.com Co-authored-by: Restyled.io Co-authored-by: Andrei Litvin Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Andrei Litvin Co-authored-by: Yufeng Wang --- .../rootnode_onofflight_samplemei.matter | 7 +++ .../devices/rootnode_onofflight_samplemei.zap | 25 ++++++++ .../sample-mei-server/sample-mei-server.cpp | 22 +++++-- .../sample-mei-server/sample-mei-server.h | 1 + .../data-model/chip/sample-mei-cluster.xml | 5 ++ .../data_model/controller-clusters.matter | 5 ++ .../devicecontroller/ChipEventStructs.java | 61 +++++++++++++++++++ .../devicecontroller/ClusterIDMapping.java | 3 +- .../SampleMeiClusterPingCountEventEvent.kt | 56 +++++++++++++++++ .../chip/devicecontroller/cluster/files.gni | 1 + .../SampleMeiClusterPingCountEventEvent.kt | 56 +++++++++++++++++ .../java/matter/controller/cluster/files.gni | 1 + .../CHIPEventTLVValueDecoder.cpp | 42 +++++++++++++ .../python/chip/clusters/Objects.py | 22 +++++++ .../CHIP/zap-generated/MTRClusterConstants.h | 3 + .../zap-generated/MTREventTLVValueDecoder.mm | 22 +++++++ .../CHIP/zap-generated/MTRStructsObjc.h | 6 ++ .../CHIP/zap-generated/MTRStructsObjc.mm | 30 +++++++++ .../zap-generated/cluster-objects.cpp | 43 ++++++++++++- .../zap-generated/cluster-objects.h | 40 ++++++++++++ .../app-common/zap-generated/ids/Events.h | 10 +++ .../zap-generated/cluster/Commands.h | 7 ++- .../cluster/logging/DataModelLogger.cpp | 35 +++++++++++ .../cluster/logging/DataModelLogger.h | 2 + .../zap-generated/cluster/Commands.h | 3 + 25 files changed, 499 insertions(+), 9 deletions(-) create mode 100644 src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt create mode 100644 src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt diff --git a/examples/chef/devices/rootnode_onofflight_samplemei.matter b/examples/chef/devices/rootnode_onofflight_samplemei.matter index ace3dace3f80fb..9910342d11e89d 100644 --- a/examples/chef/devices/rootnode_onofflight_samplemei.matter +++ b/examples/chef/devices/rootnode_onofflight_samplemei.matter @@ -1491,6 +1491,11 @@ cluster FixedLabel = 64 { cluster SampleMei = 4294048800 { revision 1; // NOTE: Default/not specifically set + fabric_sensitive info event PingCountEvent = 0 { + int32u count = 1; + fabric_idx fabricIndex = 254; + } + attribute boolean flipFlop = 0; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; @@ -1825,9 +1830,11 @@ endpoint 1 { } server cluster SampleMei { + emits event PingCountEvent; ram attribute flipFlop default = false; callback attribute generatedCommandList; callback attribute acceptedCommandList; + callback attribute eventList; callback attribute attributeList; ram attribute featureMap default = 0; ram attribute clusterRevision default = 1; diff --git a/examples/chef/devices/rootnode_onofflight_samplemei.zap b/examples/chef/devices/rootnode_onofflight_samplemei.zap index 958c902905add3..0bcd495ba65859 100644 --- a/examples/chef/devices/rootnode_onofflight_samplemei.zap +++ b/examples/chef/devices/rootnode_onofflight_samplemei.zap @@ -3538,6 +3538,22 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": null, + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "AttributeList", "code": 65531, @@ -3586,6 +3602,15 @@ "maxInterval": 65534, "reportableChange": 0 } + ], + "events": [ + { + "name": "PingCountEvent", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + } ] } ] diff --git a/src/app/clusters/sample-mei-server/sample-mei-server.cpp b/src/app/clusters/sample-mei-server/sample-mei-server.cpp index 94b83419f59a87..22a8f48bdf8a00 100644 --- a/src/app/clusters/sample-mei-server/sample-mei-server.cpp +++ b/src/app/clusters/sample-mei-server/sample-mei-server.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -58,7 +59,8 @@ SampleMeiContent::SampleMeiContent() : SampleMeiContent(kInvalidEndpointId) {} SampleMeiContent::SampleMeiContent(EndpointId aEndpoint) { - endpoint = aEndpoint; + endpoint = aEndpoint; + pingCount = 10000; // Attribute default values flipflop = false; @@ -70,6 +72,7 @@ SampleMeiContent::SampleMeiContent(EndpointId aEndpoint) void SampleMeiServer::InvokeCommand(HandlerContext & ctxt) { auto endpoint = ctxt.mRequestPath.mEndpointId; + auto fabricIndex = ctxt.mCommandHandler.GetAccessingFabricIndex(); auto endpointIndex = EndpointIndex(endpoint); if (endpointIndex == std::numeric_limits::max()) { @@ -80,10 +83,19 @@ void SampleMeiServer::InvokeCommand(HandlerContext & ctxt) switch (ctxt.mRequestPath.mCommandId) { case Commands::Ping::Id: - HandleCommand(ctxt, [endpoint](HandlerContext & ctx, const auto & req) { - ChipLogProgress(Zcl, "Ping Command on Ep %d", endpoint); - ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::Success); - }); + HandleCommand( + ctxt, [this, endpoint, fabricIndex, endpointIndex, ctxt](HandlerContext & ctx, const auto & req) { + ChipLogProgress(Zcl, "Ping Command on Ep %d", endpoint); + Events::PingCountEvent::Type event{ .count = content[endpointIndex].pingCount++, .fabricIndex = fabricIndex }; + chip::EventNumber placeholderEventNumber; + CHIP_ERROR err = LogEvent(event, endpoint, placeholderEventNumber); + if (CHIP_NO_ERROR != err) + { + ChipLogError(Zcl, "Failed to record event on endpoint %d: %" CHIP_ERROR_FORMAT, static_cast(endpoint), + err.Format()); + } + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::Success); + }); return; case Commands::AddArguments::Id: HandleCommand(ctxt, [endpoint](HandlerContext & ctx, const auto & req) { diff --git a/src/app/clusters/sample-mei-server/sample-mei-server.h b/src/app/clusters/sample-mei-server/sample-mei-server.h index 3f4463215e4acc..9f5307dba6d753 100644 --- a/src/app/clusters/sample-mei-server/sample-mei-server.h +++ b/src/app/clusters/sample-mei-server/sample-mei-server.h @@ -32,6 +32,7 @@ class SampleMeiContent { public: EndpointId endpoint; + uint32_t pingCount; // Attribute List bool flipflop; /* Attributes::FlipFlop::Id */ diff --git a/src/app/zap-templates/zcl/data-model/chip/sample-mei-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/sample-mei-cluster.xml index ca5768f156476e..9b812b85c535d3 100644 --- a/src/app/zap-templates/zcl/data-model/chip/sample-mei-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/sample-mei-cluster.xml @@ -54,6 +54,11 @@ limitations under the License. Simple command without any parameters and without a response. + + + Example events generated by Ping command + + diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index 2d1909cb0ee41b..5ee0a9704a4462 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -8803,6 +8803,11 @@ internal cluster FaultInjection = 4294048774 { cluster SampleMei = 4294048800 { revision 1; // NOTE: Default/not specifically set + fabric_sensitive info event PingCountEvent = 0 { + int32u count = 1; + fabric_idx fabricIndex = 254; + } + attribute boolean flipFlop = 0; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java b/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java index 5f9984935302be..81b0180a39df4f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java @@ -4835,4 +4835,65 @@ public String toString() { return output.toString(); } } +public static class SampleMeiClusterPingCountEventEvent { + public Long count; + public Integer fabricIndex; + private static final long COUNT_ID = 1L; + private static final long FABRIC_INDEX_ID = 254L; + + public SampleMeiClusterPingCountEventEvent( + Long count, + Integer fabricIndex + ) { + this.count = count; + this.fabricIndex = fabricIndex; + } + + public StructType encodeTlv() { + ArrayList values = new ArrayList<>(); + values.add(new StructElement(COUNT_ID, new UIntType(count))); + values.add(new StructElement(FABRIC_INDEX_ID, new UIntType(fabricIndex))); + + return new StructType(values); + } + + public static SampleMeiClusterPingCountEventEvent decodeTlv(BaseTLVType tlvValue) { + if (tlvValue == null || tlvValue.type() != TLVType.Struct) { + return null; + } + Long count = null; + Integer fabricIndex = null; + for (StructElement element: ((StructType)tlvValue).value()) { + if (element.contextTagNum() == COUNT_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + count = castingValue.value(Long.class); + } + } else if (element.contextTagNum() == FABRIC_INDEX_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + fabricIndex = castingValue.value(Integer.class); + } + } + } + return new SampleMeiClusterPingCountEventEvent( + count, + fabricIndex + ); + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("SampleMeiClusterPingCountEventEvent {\n"); + output.append("\tcount: "); + output.append(count); + output.append("\n"); + output.append("\tfabricIndex: "); + output.append(fabricIndex); + 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 0762d4168da6f5..cfdcfa8a6434d7 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java @@ -16447,7 +16447,8 @@ public static Attribute value(long id) throws NoSuchFieldError { } } - public enum Event {; + public enum Event { + PingCountEvent(0L),; private final long id; Event(long id) { this.id = id; diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt new file mode 100644 index 00000000000000..a0588f4ad66d56 --- /dev/null +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt @@ -0,0 +1,56 @@ +/* + * + * 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.eventstructs + +import chip.devicecontroller.cluster.* +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class SampleMeiClusterPingCountEventEvent(val count: ULong, val fabricIndex: UInt) { + override fun toString(): String = buildString { + append("SampleMeiClusterPingCountEventEvent {\n") + append("\tcount : $count\n") + append("\tfabricIndex : $fabricIndex\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_COUNT), count) + put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) + endStructure() + } + } + + companion object { + private const val TAG_COUNT = 1 + private const val TAG_FABRIC_INDEX = 254 + + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SampleMeiClusterPingCountEventEvent { + tlvReader.enterStructure(tlvTag) + val count = tlvReader.getULong(ContextSpecificTag(TAG_COUNT)) + val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) + + tlvReader.exitContainer() + + return SampleMeiClusterPingCountEventEvent(count, fabricIndex) + } + } +} 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 f4242b257d9ce1..6180ecae906183 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni @@ -169,6 +169,7 @@ eventstructs_sources = [ "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt", + "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt", diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt new file mode 100644 index 00000000000000..5570ba7a3af4a3 --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt @@ -0,0 +1,56 @@ +/* + * + * 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.eventstructs + +import matter.controller.cluster.* +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class SampleMeiClusterPingCountEventEvent(val count: UInt, val fabricIndex: UByte) { + override fun toString(): String = buildString { + append("SampleMeiClusterPingCountEventEvent {\n") + append("\tcount : $count\n") + append("\tfabricIndex : $fabricIndex\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_COUNT), count) + put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) + endStructure() + } + } + + companion object { + private const val TAG_COUNT = 1 + private const val TAG_FABRIC_INDEX = 254 + + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SampleMeiClusterPingCountEventEvent { + tlvReader.enterStructure(tlvTag) + val count = tlvReader.getUInt(ContextSpecificTag(TAG_COUNT)) + val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) + + tlvReader.exitContainer() + + return SampleMeiClusterPingCountEventEvent(count, fabricIndex) + } + } +} 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 75ff840918cdf4..d7d18479992e91 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/files.gni +++ b/src/controller/java/generated/java/matter/controller/cluster/files.gni @@ -169,6 +169,7 @@ matter_eventstructs_sources = [ "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt", diff --git a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp index 26bd0d48009066..4dd1ffd1e2e2c1 100644 --- a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp @@ -7275,6 +7275,48 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & using namespace app::Clusters::SampleMei; switch (aPath.mEventId) { + case Events::PingCountEvent::Id: { + Events::PingCountEvent::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value_count; + std::string value_countClassName = "java/lang/Long"; + std::string value_countCtorSignature = "(J)V"; + jlong jnivalue_count = static_cast(cppValue.count); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_countClassName.c_str(), value_countCtorSignature.c_str(), jnivalue_count, value_count); + + jobject value_fabricIndex; + std::string value_fabricIndexClassName = "java/lang/Integer"; + std::string value_fabricIndexCtorSignature = "(I)V"; + jint jnivalue_fabricIndex = static_cast(cppValue.fabricIndex); + chip::JniReferences::GetInstance().CreateBoxedObject(value_fabricIndexClassName.c_str(), + value_fabricIndexCtorSignature.c_str(), jnivalue_fabricIndex, + value_fabricIndex); + + jclass pingCountEventStructClass; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipEventStructs$SampleMeiClusterPingCountEventEvent", pingCountEventStructClass); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipEventStructs$SampleMeiClusterPingCountEventEvent"); + return nullptr; + } + jmethodID pingCountEventStructCtor = + env->GetMethodID(pingCountEventStructClass, "", "(Ljava/lang/Long;Ljava/lang/Integer;)V"); + if (pingCountEventStructCtor == nullptr) + { + ChipLogError(Zcl, "Could not find ChipEventStructs$SampleMeiClusterPingCountEventEvent constructor"); + return nullptr; + } + + jobject value = env->NewObject(pingCountEventStructClass, pingCountEventStructCtor, value_count, value_fabricIndex); + + return value; + } default: *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB; break; diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index f346a96ecb3785..a76a5978a0a820 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -47219,3 +47219,25 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'uint' = 0 + class Events: + @dataclass + class PingCountEvent(ClusterEvent): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0xFFF1FC20 + + @ChipUtility.classproperty + def event_id(cls) -> int: + return 0x00000000 + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ClusterObjectFieldDescriptor(Label="count", Tag=1, Type=uint), + ClusterObjectFieldDescriptor(Label="fabricIndex", Tag=254, Type=uint), + ]) + + count: 'uint' = 0 + fabricIndex: 'uint' = 0 + diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h index d01196579b4023..6d66edeb9fbdff 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h @@ -7299,4 +7299,7 @@ typedef NS_ENUM(uint32_t, MTREventIDType) { MTREventIDTypeClusterUnitTestingEventTestEventID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000001, MTREventIDTypeClusterUnitTestingEventTestFabricScopedEventID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000002, + // Cluster SampleMEI events + MTREventIDTypeClusterSampleMEIEventPingCountEventID MTR_PROVISIONALLY_AVAILABLE = 0x00000000, + }; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm index 8119e5be2e3021..c9a38080b463dc 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm @@ -4231,6 +4231,28 @@ static id _Nullable DecodeEventPayloadForSampleMEICluster(EventId aEventId, TLV: { using namespace Clusters::SampleMei; switch (aEventId) { + case Events::PingCountEvent::Id: { + Events::PingCountEvent::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + + __auto_type * value = [MTRSampleMEIClusterPingCountEventEvent new]; + + do { + NSNumber * _Nonnull memberValue; + memberValue = [NSNumber numberWithUnsignedInt:cppValue.count]; + value.count = memberValue; + } while (0); + do { + NSNumber * _Nonnull memberValue; + memberValue = [NSNumber numberWithUnsignedChar:cppValue.fabricIndex]; + value.fabricIndex = memberValue; + } while (0); + + return value; + } default: { break; } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h index b21a35ab11b40f..6242c7e9460229 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h @@ -1961,4 +1961,10 @@ MTR_DEPRECATED("Please use MTRUnitTestingClusterTestFabricScopedEventEvent", ios @property (nonatomic, copy) NSNumber * _Nonnull fabricIndex MTR_DEPRECATED("Please use MTRUnitTestingClusterTestFabricScopedEventEvent", ios(16.1, 16.4), macos(13.0, 13.3), watchos(9.1, 9.4), tvos(16.1, 16.4)); @end +MTR_PROVISIONALLY_AVAILABLE +@interface MTRSampleMEIClusterPingCountEventEvent : NSObject +@property (nonatomic, copy, getter=getCount) NSNumber * _Nonnull count MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull fabricIndex MTR_PROVISIONALLY_AVAILABLE; +@end + NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm index 074a9001c288b5..06be97e69ee61b 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm @@ -7701,4 +7701,34 @@ @implementation MTRTestClusterClusterTestFabricScopedEventEvent : MTRUnitTesting @dynamic fabricIndex; @end +@implementation MTRSampleMEIClusterPingCountEventEvent +- (instancetype)init +{ + if (self = [super init]) { + + _count = @(0); + + _fabricIndex = @(0); + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRSampleMEIClusterPingCountEventEvent alloc] init]; + + other.count = self.count; + other.fabricIndex = self.fabricIndex; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: count:%@; fabricIndex:%@; >", NSStringFromClass([self class]), _count, _fabricIndex]; + return descriptionString; +} + +@end + NS_ASSUME_NONNULL_END 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 78bf30815c3084..df15ba3324775f 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 @@ -27946,7 +27946,48 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre } } // namespace Attributes -namespace Events {} // namespace Events +namespace Events { +namespace PingCountEvent { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(aWriter.StartContainer(aTag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(aWriter, TLV::ContextTag(Fields::kCount), count)); + ReturnErrorOnFailure(DataModel::Encode(aWriter, TLV::ContextTag(Fields::kFabricIndex), fabricIndex)); + return aWriter.EndContainer(outer); +} + +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::kCount)) + { + err = DataModel::Decode(reader, count); + } + else if (__context_tag == to_underlying(Fields::kFabricIndex)) + { + err = DataModel::Decode(reader, fabricIndex); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} +} // namespace PingCountEvent. +} // namespace Events } // namespace SampleMei 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 afb183bc0de418..753e52108eb6a5 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 @@ -42336,6 +42336,46 @@ struct TypeInfo }; }; } // namespace Attributes +namespace Events { +namespace PingCountEvent { +static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; + +enum class Fields : uint8_t +{ + kCount = 1, + kFabricIndex = 254, +}; + +struct Type +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::PingCountEvent::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::SampleMei::Id; } + static constexpr bool kIsFabricScoped = true; + + uint32_t count = static_cast(0); + chip::FabricIndex fabricIndex = static_cast(0); + + auto GetFabricIndex() const { return fabricIndex; } + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; +}; + +struct DecodableType +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::PingCountEvent::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::SampleMei::Id; } + + uint32_t count = static_cast(0); + chip::FabricIndex fabricIndex = static_cast(0); + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +} // namespace PingCountEvent +} // namespace Events } // namespace SampleMei } // namespace Clusters diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Events.h b/zzz_generated/app-common/app-common/zap-generated/ids/Events.h index 9fadaafb4062d3..f65f37b9cd13e5 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Events.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Events.h @@ -637,6 +637,16 @@ static constexpr EventId Id = 0x00000002; } // namespace Events } // namespace UnitTesting +namespace SampleMei { +namespace Events { + +namespace PingCountEvent { +static constexpr EventId Id = 0x00000000; +} // namespace PingCountEvent + +} // namespace Events +} // namespace SampleMei + } // namespace Clusters } // namespace app } // namespace chip diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index 645a06603e14c0..f1020496d9781d 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -13864,6 +13864,7 @@ class FaultInjectionFailRandomlyAtFault : public ClusterCommand | * ClusterRevision | 0xFFFD | |------------------------------------------------------------------------------| | Events: | | +| * PingCountEvent | 0x0000 | \*----------------------------------------------------------------------------*/ /* @@ -25284,8 +25285,10 @@ void registerClusterSampleMei(Commands & commands, CredentialIssuerCommands * cr // // Events // - make_unique(Id, credsIssuerConfig), // - make_unique(Id, credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "ping-count-event", Events::PingCountEvent::Id, credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "ping-count-event", Events::PingCountEvent::Id, credsIssuerConfig), // }; commands.RegisterCluster(clusterName, clusterCommands); 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 63017e72e36b37..4ae5691c8c8c33 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -6485,6 +6485,30 @@ 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 SampleMei::Events::PingCountEvent::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = DataModelLogger::LogValue("Count", indent + 1, value.count); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'Count'"); + return err; + } + } + { + CHIP_ERROR err = DataModelLogger::LogValue("FabricIndex", indent + 1, value.fabricIndex); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'FabricIndex'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const Groups::Commands::AddGroupResponse::DecodableType & value) @@ -18075,6 +18099,17 @@ CHIP_ERROR DataModelLogger::LogEvent(const chip::app::EventHeader & header, chip } break; } + case SampleMei::Id: { + switch (header.mPath.mEventId) + { + case SampleMei::Events::PingCountEvent::Id: { + chip::app::Clusters::SampleMei::Events::PingCountEvent::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("PingCountEvent", 1, value); + } + } + break; + } default: break; } diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h index 5dc0cb3d19ef90..c208cac4302149 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h @@ -566,6 +566,8 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::UnitTesting::Events::TestEvent::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::UnitTesting::Events::TestFabricScopedEvent::DecodableType & value); +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::SampleMei::Events::PingCountEvent::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::Groups::Commands::AddGroupResponse::DecodableType & value); diff --git a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h index 80646cb029a5d7..1a33c71a4eb1b2 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -172238,6 +172238,7 @@ class SubscribeAttributeUnitTestingClusterRevision : public SubscribeAttribute { | * ClusterRevision | 0xFFFD | |------------------------------------------------------------------------------| | Events: | | +| * PingCountEvent | 0x0000 | \*----------------------------------------------------------------------------*/ #if MTR_ENABLE_PROVISIONAL @@ -180081,6 +180082,8 @@ void registerClusterSampleMei(Commands & commands) make_unique(), // make_unique(), // #endif // MTR_ENABLE_PROVISIONAL + make_unique(Id), // + make_unique(Id), // }; commands.RegisterCluster(clusterName, clusterCommands);