From 13a3b8d7face0d57ff1acf8c5cf86689950d5ffd Mon Sep 17 00:00:00 2001 From: erwinpan1 Date: Fri, 8 Dec 2023 20:23:58 +0800 Subject: [PATCH 01/11] Add draft version of samplemei implementing event --- .../rootnode_onofflight_samplemei.matter | 7 +++ .../devices/rootnode_onofflight_samplemei.zap | 28 ++++++++- .../sample-mei-server/sample-mei-server.cpp | 14 ++++- .../data-model/chip/sample-mei-cluster.xml | 5 ++ .../data_model/controller-clusters.matter | 5 ++ .../devicecontroller/ChipEventStructs.java | 61 +++++++++++++++++++ .../devicecontroller/ClusterIDMapping.java | 3 +- .../SampleMeiClusterPingedEvent.kt | 56 +++++++++++++++++ .../chip/devicecontroller/cluster/files.gni | 1 + .../SampleMeiClusterPingedEvent.kt | 56 +++++++++++++++++ .../matter/devicecontroller/cluster/files.gni | 1 + .../CHIPEventTLVValueDecoder.cpp | 41 +++++++++++++ .../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 | 34 +++++++++++ .../cluster/logging/DataModelLogger.h | 2 + .../zap-generated/cluster/Commands.h | 3 + 24 files changed, 494 insertions(+), 6 deletions(-) create mode 100644 src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingedEvent.kt create mode 100644 src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SampleMeiClusterPingedEvent.kt diff --git a/examples/chef/devices/rootnode_onofflight_samplemei.matter b/examples/chef/devices/rootnode_onofflight_samplemei.matter index ace3dace3f80fb..c3b96cbbe113ae 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 Pinged = 0 { + int8u arg1 = 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 Pinged; 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 473df045095cdc..5a676c8d676416 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": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "AttributeList", "code": 65531, @@ -3586,6 +3602,15 @@ "maxInterval": 65534, "reportableChange": 0 } + ], + "events": [ + { + "name": "Pinged", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + } ] } ] @@ -3606,5 +3631,6 @@ "endpointId": 1, "networkId": 0 } - ] + ], + "log": [] } \ No newline at end of file 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..64783609b2d911 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 @@ -67,6 +68,7 @@ SampleMeiContent::SampleMeiContent(EndpointId aEndpoint) // ***************************************************************************** // SampleMeiServer +static uint8_t gPinged = 0; void SampleMeiServer::InvokeCommand(HandlerContext & ctxt) { auto endpoint = ctxt.mRequestPath.mEndpointId; @@ -82,7 +84,17 @@ void SampleMeiServer::InvokeCommand(HandlerContext & ctxt) 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); + Events::Pinged::Type event{ .arg1 = gPinged++, .fabricIndex = 1 }; + chip::EventNumber n = gPinged; + if (CHIP_NO_ERROR != LogEvent(event, 1 /*endpoint*/, n)) + { + // TBD + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::Success); + } + else + { + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::Success); + } }); return; case Commands::AddArguments::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..1dadc1cae411a2 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 3602cad6d8899a..6ab96347158897 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -8724,6 +8724,11 @@ internal cluster FaultInjection = 4294048774 { cluster SampleMei = 4294048800 { revision 1; // NOTE: Default/not specifically set + fabric_sensitive info event Pinged = 0 { + int8u arg1 = 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 256d205a09e8df..fc404945541f14 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java @@ -4713,4 +4713,65 @@ public String toString() { return output.toString(); } } +public static class SampleMeiClusterPingedEvent { + public Integer arg1; + public Integer fabricIndex; + private static final long ARG1_ID = 1L; + private static final long FABRIC_INDEX_ID = 254L; + + public SampleMeiClusterPingedEvent( + Integer arg1, + Integer fabricIndex + ) { + this.arg1 = arg1; + this.fabricIndex = fabricIndex; + } + + public StructType encodeTlv() { + ArrayList values = new ArrayList<>(); + values.add(new StructElement(ARG1_ID, new UIntType(arg1))); + values.add(new StructElement(FABRIC_INDEX_ID, new UIntType(fabricIndex))); + + return new StructType(values); + } + + public static SampleMeiClusterPingedEvent decodeTlv(BaseTLVType tlvValue) { + if (tlvValue == null || tlvValue.type() != TLVType.Struct) { + return null; + } + Integer arg1 = null; + Integer fabricIndex = null; + for (StructElement element: ((StructType)tlvValue).value()) { + if (element.contextTagNum() == ARG1_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + arg1 = castingValue.value(Integer.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 SampleMeiClusterPingedEvent( + arg1, + fabricIndex + ); + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(); + output.append("SampleMeiClusterPingedEvent {\n"); + output.append("\targ1: "); + output.append(arg1); + 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 96f0183b3dadf3..cf6783b13cd7b6 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java @@ -16337,7 +16337,8 @@ public static Attribute value(long id) throws NoSuchFieldError { } } - public enum Event {; + public enum Event { + Pinged(0L),; private final long id; Event(long id) { this.id = id; diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingedEvent.kt new file mode 100644 index 00000000000000..6f61ec256f2d5b --- /dev/null +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingedEvent.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 SampleMeiClusterPingedEvent(val arg1: UInt, val fabricIndex: UInt) { + override fun toString(): String = buildString { + append("SampleMeiClusterPingedEvent {\n") + append("\targ1 : $arg1\n") + append("\tfabricIndex : $fabricIndex\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_ARG1), arg1) + put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) + endStructure() + } + } + + companion object { + private const val TAG_ARG1 = 1 + private const val TAG_FABRIC_INDEX = 254 + + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SampleMeiClusterPingedEvent { + tlvReader.enterStructure(tlvTag) + val arg1 = tlvReader.getUInt(ContextSpecificTag(TAG_ARG1)) + val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) + + tlvReader.exitContainer() + + return SampleMeiClusterPingedEvent(arg1, 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 a7049a39a43861..25b74e75057c66 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni @@ -164,6 +164,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/SampleMeiClusterPingedEvent.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/devicecontroller/cluster/eventstructs/SampleMeiClusterPingedEvent.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SampleMeiClusterPingedEvent.kt new file mode 100644 index 00000000000000..a85446c9824cc6 --- /dev/null +++ b/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SampleMeiClusterPingedEvent.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.devicecontroller.cluster.eventstructs + +import matter.devicecontroller.cluster.* +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class SampleMeiClusterPingedEvent(val arg1: UByte, val fabricIndex: UByte) { + override fun toString(): String = buildString { + append("SampleMeiClusterPingedEvent {\n") + append("\targ1 : $arg1\n") + append("\tfabricIndex : $fabricIndex\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_ARG1), arg1) + put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) + endStructure() + } + } + + companion object { + private const val TAG_ARG1 = 1 + private const val TAG_FABRIC_INDEX = 254 + + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SampleMeiClusterPingedEvent { + tlvReader.enterStructure(tlvTag) + val arg1 = tlvReader.getUByte(ContextSpecificTag(TAG_ARG1)) + val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) + + tlvReader.exitContainer() + + return SampleMeiClusterPingedEvent(arg1, fabricIndex) + } + } +} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/files.gni b/src/controller/java/generated/java/matter/devicecontroller/cluster/files.gni index bbcafb5fbff65a..0bb50316d445c6 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/files.gni +++ b/src/controller/java/generated/java/matter/devicecontroller/cluster/files.gni @@ -164,6 +164,7 @@ matter_eventstructs_sources = [ "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SampleMeiClusterPingedEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt", diff --git a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp index 4b67ac79cd7b9f..5566638dffdee0 100644 --- a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp @@ -6701,6 +6701,47 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & using namespace app::Clusters::SampleMei; switch (aPath.mEventId) { + case Events::Pinged::Id: { + Events::Pinged::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value_arg1; + std::string value_arg1ClassName = "java/lang/Integer"; + std::string value_arg1CtorSignature = "(I)V"; + jint jnivalue_arg1 = static_cast(cppValue.arg1); + chip::JniReferences::GetInstance().CreateBoxedObject(value_arg1ClassName.c_str(), value_arg1CtorSignature.c_str(), + jnivalue_arg1, value_arg1); + + 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 pingedStructClass; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipEventStructs$SampleMeiClusterPingedEvent", pingedStructClass); + if (err != CHIP_NO_ERROR) + { + ChipLogError(Zcl, "Could not find class ChipEventStructs$SampleMeiClusterPingedEvent"); + return nullptr; + } + jmethodID pingedStructCtor = env->GetMethodID(pingedStructClass, "", "(Ljava/lang/Integer;Ljava/lang/Integer;)V"); + if (pingedStructCtor == nullptr) + { + ChipLogError(Zcl, "Could not find ChipEventStructs$SampleMeiClusterPingedEvent constructor"); + return nullptr; + } + + jobject value = env->NewObject(pingedStructClass, pingedStructCtor, value_arg1, 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 9b7b5c38555d43..dd75d67d584080 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -46871,3 +46871,25 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'uint' = 0 + class Events: + @dataclass + class Pinged(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="arg1", Tag=1, Type=uint), + ClusterObjectFieldDescriptor(Label="fabricIndex", Tag=254, Type=uint), + ]) + + arg1: '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 0907ddf7c3bb0d..56155c0e8c58e2 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h @@ -7281,4 +7281,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 + MTREventIDTypeClusterSampleMEIEventPingedID 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 5912d3d8d6454e..659b9ec8de033a 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm @@ -4075,6 +4075,28 @@ static id _Nullable DecodeEventPayloadForSampleMEICluster(EventId aEventId, TLV: { using namespace Clusters::SampleMei; switch (aEventId) { + case Events::Pinged::Id: { + Events::Pinged::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + + __auto_type * value = [MTRSampleMEIClusterPingedEvent new]; + + do { + NSNumber * _Nonnull memberValue; + memberValue = [NSNumber numberWithUnsignedChar:cppValue.arg1]; + value.arg1 = 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 65a361cf605a95..ab137267363b8e 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h @@ -1919,4 +1919,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 MTRSampleMEIClusterPingedEvent : NSObject +@property (nonatomic, copy) NSNumber * _Nonnull arg1 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 1262d5d534593a..8c0f75838b4260 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm @@ -7515,4 +7515,34 @@ @implementation MTRTestClusterClusterTestFabricScopedEventEvent : MTRUnitTesting @dynamic fabricIndex; @end +@implementation MTRSampleMEIClusterPingedEvent +- (instancetype)init +{ + if (self = [super init]) { + + _arg1 = @(0); + + _fabricIndex = @(0); + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone +{ + auto other = [[MTRSampleMEIClusterPingedEvent alloc] init]; + + other.arg1 = self.arg1; + other.fabricIndex = self.fabricIndex; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: arg1:%@; fabricIndex:%@; >", NSStringFromClass([self class]), _arg1, _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 56efe1d5e0bc3e..bece1eaef9d37c 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 @@ -27640,7 +27640,48 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre } } // namespace Attributes -namespace Events {} // namespace Events +namespace Events { +namespace Pinged { +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::kArg1), arg1)); + 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::kArg1)) + { + err = DataModel::Decode(reader, arg1); + } + else if (__context_tag == to_underlying(Fields::kFabricIndex)) + { + err = DataModel::Decode(reader, fabricIndex); + } + else + { + } + + ReturnErrorOnFailure(err); + } +} +} // namespace Pinged. +} // 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 421dad0af3e981..d3bbae47e3fc10 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 @@ -42020,6 +42020,46 @@ struct TypeInfo }; }; } // namespace Attributes +namespace Events { +namespace Pinged { +static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; + +enum class Fields : uint8_t +{ + kArg1 = 1, + kFabricIndex = 254, +}; + +struct Type +{ +public: + static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } + static constexpr EventId GetEventId() { return Events::Pinged::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::SampleMei::Id; } + static constexpr bool kIsFabricScoped = true; + + uint8_t arg1 = 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::Pinged::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::SampleMei::Id; } + + uint8_t arg1 = static_cast(0); + chip::FabricIndex fabricIndex = static_cast(0); + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +} // namespace Pinged +} // 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 38d917c669e297..51f5afcbfe10b0 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 @@ -623,6 +623,16 @@ static constexpr EventId Id = 0x00000002; } // namespace Events } // namespace UnitTesting +namespace SampleMei { +namespace Events { + +namespace Pinged { +static constexpr EventId Id = 0x00000000; +} // namespace Pinged + +} // 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 c966ee0534f603..f7095514651428 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -13840,6 +13840,7 @@ class FaultInjectionFailRandomlyAtFault : public ClusterCommand | * ClusterRevision | 0xFFFD | |------------------------------------------------------------------------------| | Events: | | +| * Pinged | 0x0000 | \*----------------------------------------------------------------------------*/ /* @@ -25170,8 +25171,10 @@ void registerClusterSampleMei(Commands & commands, CredentialIssuerCommands * cr // // Events // - make_unique(Id, credsIssuerConfig), // - make_unique(Id, credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "pinged", Events::Pinged::Id, credsIssuerConfig), // + make_unique(Id, credsIssuerConfig), // + make_unique(Id, "pinged", Events::Pinged::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 f6e11f2ac60c10..a35b466872d4a4 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -6263,6 +6263,29 @@ 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::Pinged::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = DataModelLogger::LogValue("Arg1", indent + 1, value.arg1); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'Arg1'"); + 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) @@ -17768,6 +17791,17 @@ CHIP_ERROR DataModelLogger::LogEvent(const chip::app::EventHeader & header, chip } break; } + case SampleMei::Id: { + switch (header.mPath.mEventId) + { + case SampleMei::Events::Pinged::Id: { + chip::app::Clusters::SampleMei::Events::Pinged::DecodableType value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("Pinged", 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 ac9d4a8a4ccd5b..f6ccbe3adac288 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h @@ -548,6 +548,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::Pinged::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 b481d620a2a43b..f93274807d08c9 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -171277,6 +171277,7 @@ class SubscribeAttributeUnitTestingClusterRevision : public SubscribeAttribute { | * ClusterRevision | 0xFFFD | |------------------------------------------------------------------------------| | Events: | | +| * Pinged | 0x0000 | \*----------------------------------------------------------------------------*/ #if MTR_ENABLE_PROVISIONAL @@ -179057,6 +179058,8 @@ void registerClusterSampleMei(Commands & commands) make_unique(), // make_unique(), // #endif // MTR_ENABLE_PROVISIONAL + make_unique(Id), // + make_unique(Id), // }; commands.RegisterCluster(clusterName, clusterCommands); From 40fb3c1d5b4ccbb587d089545ebf195b94cf16db Mon Sep 17 00:00:00 2001 From: erwinpan1 Date: Fri, 8 Dec 2023 20:31:37 +0800 Subject: [PATCH 02/11] Fix correct Pinged number --- src/app/clusters/sample-mei-server/sample-mei-server.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 64783609b2d911..fcdbb5efdd81bd 100644 --- a/src/app/clusters/sample-mei-server/sample-mei-server.cpp +++ b/src/app/clusters/sample-mei-server/sample-mei-server.cpp @@ -84,7 +84,7 @@ void SampleMeiServer::InvokeCommand(HandlerContext & ctxt) case Commands::Ping::Id: HandleCommand(ctxt, [endpoint](HandlerContext & ctx, const auto & req) { ChipLogProgress(Zcl, "Ping Command on Ep %d", endpoint); - Events::Pinged::Type event{ .arg1 = gPinged++, .fabricIndex = 1 }; + Events::Pinged::Type event{ .arg1 = ++gPinged, .fabricIndex = 1 }; chip::EventNumber n = gPinged; if (CHIP_NO_ERROR != LogEvent(event, 1 /*endpoint*/, n)) { From 41229300fd6f44a13fad51f70fc96f2b8eabe046 Mon Sep 17 00:00:00 2001 From: "tennessee.carmelveilleux@gmail.com" Date: Fri, 8 Dec 2023 16:59:10 -0500 Subject: [PATCH 03/11] Fix sample --- .../rootnode_onofflight_samplemei.matter | 6 +- .../sample-mei-server/sample-mei-server.cpp | 20 +++---- .../sample-mei-server/sample-mei-server.h | 2 + .../data-model/chip/sample-mei-cluster.xml | 4 +- .../data_model/controller-clusters.matter | 4 +- .../devicecontroller/ChipEventStructs.java | 32 +++++------ .../devicecontroller/ClusterIDMapping.java | 2 +- .../SampleMeiClusterPingCountEventEvent.kt | 56 +++++++++++++++++++ .../chip/devicecontroller/cluster/files.gni | 2 +- .../SampleMeiClusterPingCountEventEvent.kt | 56 +++++++++++++++++++ .../matter/devicecontroller/cluster/files.gni | 2 +- .../CHIPEventTLVValueDecoder.cpp | 31 +++++----- .../python/chip/clusters/Objects.py | 6 +- .../CHIP/zap-generated/MTRClusterConstants.h | 2 +- .../zap-generated/MTREventTLVValueDecoder.mm | 10 ++-- .../CHIP/zap-generated/MTRStructsObjc.h | 4 +- .../CHIP/zap-generated/MTRStructsObjc.mm | 10 ++-- .../zap-generated/cluster-objects.cpp | 10 ++-- .../zap-generated/cluster-objects.h | 14 ++--- .../app-common/zap-generated/ids/Events.h | 4 +- .../zap-generated/cluster/Commands.h | 10 ++-- .../cluster/logging/DataModelLogger.cpp | 13 +++-- .../cluster/logging/DataModelLogger.h | 2 +- .../zap-generated/cluster/Commands.h | 2 +- 24 files changed, 209 insertions(+), 95 deletions(-) create mode 100644 src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt create mode 100644 src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt diff --git a/examples/chef/devices/rootnode_onofflight_samplemei.matter b/examples/chef/devices/rootnode_onofflight_samplemei.matter index c3b96cbbe113ae..9910342d11e89d 100644 --- a/examples/chef/devices/rootnode_onofflight_samplemei.matter +++ b/examples/chef/devices/rootnode_onofflight_samplemei.matter @@ -1491,8 +1491,8 @@ cluster FixedLabel = 64 { cluster SampleMei = 4294048800 { revision 1; // NOTE: Default/not specifically set - fabric_sensitive info event Pinged = 0 { - int8u arg1 = 1; + fabric_sensitive info event PingCountEvent = 0 { + int32u count = 1; fabric_idx fabricIndex = 254; } @@ -1830,7 +1830,7 @@ endpoint 1 { } server cluster SampleMei { - emits event Pinged; + emits event PingCountEvent; ram attribute flipFlop default = false; callback attribute generatedCommandList; callback attribute acceptedCommandList; 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 fcdbb5efdd81bd..749dfbc1e05355 100644 --- a/src/app/clusters/sample-mei-server/sample-mei-server.cpp +++ b/src/app/clusters/sample-mei-server/sample-mei-server.cpp @@ -60,6 +60,7 @@ SampleMeiContent::SampleMeiContent() : SampleMeiContent(kInvalidEndpointId) {} SampleMeiContent::SampleMeiContent(EndpointId aEndpoint) { endpoint = aEndpoint; + pingCount = 10000; // Attribute default values flipflop = false; @@ -68,10 +69,10 @@ SampleMeiContent::SampleMeiContent(EndpointId aEndpoint) // ***************************************************************************** // SampleMeiServer -static uint8_t gPinged = 0; 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()) { @@ -82,19 +83,16 @@ void SampleMeiServer::InvokeCommand(HandlerContext & ctxt) switch (ctxt.mRequestPath.mCommandId) { case Commands::Ping::Id: - HandleCommand(ctxt, [endpoint](HandlerContext & ctx, const auto & req) { + HandleCommand(ctxt, [this, endpoint, fabricIndex, endpointIndex, ctxt](HandlerContext & ctx, const auto & req) { ChipLogProgress(Zcl, "Ping Command on Ep %d", endpoint); - Events::Pinged::Type event{ .arg1 = ++gPinged, .fabricIndex = 1 }; - chip::EventNumber n = gPinged; - if (CHIP_NO_ERROR != LogEvent(event, 1 /*endpoint*/, n)) + 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) { - // TBD - ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::Success); - } - else - { - ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Protocols::InteractionModel::Status::Success); + 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: 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..c7a11fb6aaf480 100644 --- a/src/app/clusters/sample-mei-server/sample-mei-server.h +++ b/src/app/clusters/sample-mei-server/sample-mei-server.h @@ -32,10 +32,12 @@ class SampleMeiContent { public: EndpointId endpoint; + uint32_t pingCount; // Attribute List bool flipflop; /* Attributes::FlipFlop::Id */ + SampleMeiContent(EndpointId endpoint); SampleMeiContent(); }; 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 1dadc1cae411a2..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 @@ -56,9 +56,9 @@ limitations under the License. - + 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 6ab96347158897..5730434edcc351 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -8724,8 +8724,8 @@ internal cluster FaultInjection = 4294048774 { cluster SampleMei = 4294048800 { revision 1; // NOTE: Default/not specifically set - fabric_sensitive info event Pinged = 0 { - int8u arg1 = 1; + fabric_sensitive info event PingCountEvent = 0 { + int32u count = 1; fabric_idx fabricIndex = 254; } diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java b/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java index fc404945541f14..fed5d098563f46 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java @@ -4713,39 +4713,39 @@ public String toString() { return output.toString(); } } -public static class SampleMeiClusterPingedEvent { - public Integer arg1; +public static class SampleMeiClusterPingCountEventEvent { + public Long count; public Integer fabricIndex; - private static final long ARG1_ID = 1L; + private static final long COUNT_ID = 1L; private static final long FABRIC_INDEX_ID = 254L; - public SampleMeiClusterPingedEvent( - Integer arg1, + public SampleMeiClusterPingCountEventEvent( + Long count, Integer fabricIndex ) { - this.arg1 = arg1; + this.count = count; this.fabricIndex = fabricIndex; } public StructType encodeTlv() { ArrayList values = new ArrayList<>(); - values.add(new StructElement(ARG1_ID, new UIntType(arg1))); + 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 SampleMeiClusterPingedEvent decodeTlv(BaseTLVType tlvValue) { + public static SampleMeiClusterPingCountEventEvent decodeTlv(BaseTLVType tlvValue) { if (tlvValue == null || tlvValue.type() != TLVType.Struct) { return null; } - Integer arg1 = null; + Long count = null; Integer fabricIndex = null; for (StructElement element: ((StructType)tlvValue).value()) { - if (element.contextTagNum() == ARG1_ID) { + if (element.contextTagNum() == COUNT_ID) { if (element.value(BaseTLVType.class).type() == TLVType.UInt) { UIntType castingValue = element.value(UIntType.class); - arg1 = castingValue.value(Integer.class); + count = castingValue.value(Long.class); } } else if (element.contextTagNum() == FABRIC_INDEX_ID) { if (element.value(BaseTLVType.class).type() == TLVType.UInt) { @@ -4754,8 +4754,8 @@ public static SampleMeiClusterPingedEvent decodeTlv(BaseTLVType tlvValue) { } } } - return new SampleMeiClusterPingedEvent( - arg1, + return new SampleMeiClusterPingCountEventEvent( + count, fabricIndex ); } @@ -4763,9 +4763,9 @@ public static SampleMeiClusterPingedEvent decodeTlv(BaseTLVType tlvValue) { @Override public String toString() { StringBuilder output = new StringBuilder(); - output.append("SampleMeiClusterPingedEvent {\n"); - output.append("\targ1: "); - output.append(arg1); + output.append("SampleMeiClusterPingCountEventEvent {\n"); + output.append("\tcount: "); + output.append(count); output.append("\n"); output.append("\tfabricIndex: "); output.append(fabricIndex); diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java index cf6783b13cd7b6..b85392a134dbf7 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java @@ -16338,7 +16338,7 @@ public static Attribute value(long id) throws NoSuchFieldError { } public enum Event { - Pinged(0L),; + 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 25b74e75057c66..f231cd305c2e37 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni @@ -164,7 +164,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/SampleMeiClusterPingedEvent.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/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt new file mode 100644 index 00000000000000..946a5949dae51e --- /dev/null +++ b/src/controller/java/generated/java/matter/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 matter.devicecontroller.cluster.eventstructs + +import matter.devicecontroller.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/devicecontroller/cluster/files.gni b/src/controller/java/generated/java/matter/devicecontroller/cluster/files.gni index 0bb50316d445c6..66ea78282f44c2 100644 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/files.gni +++ b/src/controller/java/generated/java/matter/devicecontroller/cluster/files.gni @@ -164,7 +164,7 @@ matter_eventstructs_sources = [ "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt", - "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SampleMeiClusterPingedEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt", diff --git a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp index 5566638dffdee0..0ff5d7e683c313 100644 --- a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp @@ -6701,19 +6701,19 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & using namespace app::Clusters::SampleMei; switch (aPath.mEventId) { - case Events::Pinged::Id: { - Events::Pinged::DecodableType cppValue; + case Events::PingCountEvent::Id: { + Events::PingCountEvent::DecodableType cppValue; *aError = app::DataModel::Decode(aReader, cppValue); if (*aError != CHIP_NO_ERROR) { return nullptr; } - jobject value_arg1; - std::string value_arg1ClassName = "java/lang/Integer"; - std::string value_arg1CtorSignature = "(I)V"; - jint jnivalue_arg1 = static_cast(cppValue.arg1); - chip::JniReferences::GetInstance().CreateBoxedObject(value_arg1ClassName.c_str(), value_arg1CtorSignature.c_str(), - jnivalue_arg1, value_arg1); + 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"; @@ -6723,22 +6723,23 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & value_fabricIndexCtorSignature.c_str(), jnivalue_fabricIndex, value_fabricIndex); - jclass pingedStructClass; + jclass pingCountEventStructClass; err = chip::JniReferences::GetInstance().GetClassRef( - env, "chip/devicecontroller/ChipEventStructs$SampleMeiClusterPingedEvent", pingedStructClass); + env, "chip/devicecontroller/ChipEventStructs$SampleMeiClusterPingCountEventEvent", pingCountEventStructClass); if (err != CHIP_NO_ERROR) { - ChipLogError(Zcl, "Could not find class ChipEventStructs$SampleMeiClusterPingedEvent"); + ChipLogError(Zcl, "Could not find class ChipEventStructs$SampleMeiClusterPingCountEventEvent"); return nullptr; } - jmethodID pingedStructCtor = env->GetMethodID(pingedStructClass, "", "(Ljava/lang/Integer;Ljava/lang/Integer;)V"); - if (pingedStructCtor == nullptr) + jmethodID pingCountEventStructCtor = + env->GetMethodID(pingCountEventStructClass, "", "(Ljava/lang/Long;Ljava/lang/Integer;)V"); + if (pingCountEventStructCtor == nullptr) { - ChipLogError(Zcl, "Could not find ChipEventStructs$SampleMeiClusterPingedEvent constructor"); + ChipLogError(Zcl, "Could not find ChipEventStructs$SampleMeiClusterPingCountEventEvent constructor"); return nullptr; } - jobject value = env->NewObject(pingedStructClass, pingedStructCtor, value_arg1, value_fabricIndex); + jobject value = env->NewObject(pingCountEventStructClass, pingCountEventStructCtor, value_count, value_fabricIndex); return value; } diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index dd75d67d584080..aea06752bbcd60 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -46873,7 +46873,7 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: class Events: @dataclass - class Pinged(ClusterEvent): + class PingCountEvent(ClusterEvent): @ChipUtility.classproperty def cluster_id(cls) -> int: return 0xFFF1FC20 @@ -46886,10 +46886,10 @@ def event_id(cls) -> int: def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ - ClusterObjectFieldDescriptor(Label="arg1", Tag=1, Type=uint), + ClusterObjectFieldDescriptor(Label="count", Tag=1, Type=uint), ClusterObjectFieldDescriptor(Label="fabricIndex", Tag=254, Type=uint), ]) - arg1: 'uint' = 0 + 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 56155c0e8c58e2..5587bb989e376a 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h @@ -7282,6 +7282,6 @@ typedef NS_ENUM(uint32_t, MTREventIDType) { MTREventIDTypeClusterUnitTestingEventTestFabricScopedEventID MTR_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000002, // Cluster SampleMEI events - MTREventIDTypeClusterSampleMEIEventPingedID MTR_PROVISIONALLY_AVAILABLE = 0x00000000, + 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 659b9ec8de033a..4f14340ed8ac46 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm @@ -4075,19 +4075,19 @@ static id _Nullable DecodeEventPayloadForSampleMEICluster(EventId aEventId, TLV: { using namespace Clusters::SampleMei; switch (aEventId) { - case Events::Pinged::Id: { - Events::Pinged::DecodableType cppValue; + case Events::PingCountEvent::Id: { + Events::PingCountEvent::DecodableType cppValue; *aError = DataModel::Decode(aReader, cppValue); if (*aError != CHIP_NO_ERROR) { return nil; } - __auto_type * value = [MTRSampleMEIClusterPingedEvent new]; + __auto_type * value = [MTRSampleMEIClusterPingCountEventEvent new]; do { NSNumber * _Nonnull memberValue; - memberValue = [NSNumber numberWithUnsignedChar:cppValue.arg1]; - value.arg1 = memberValue; + memberValue = [NSNumber numberWithUnsignedInt:cppValue.count]; + value.count = memberValue; } while (0); do { NSNumber * _Nonnull memberValue; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h index ab137267363b8e..69fe111006c2a4 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h @@ -1920,8 +1920,8 @@ MTR_DEPRECATED("Please use MTRUnitTestingClusterTestFabricScopedEventEvent", ios @end MTR_PROVISIONALLY_AVAILABLE -@interface MTRSampleMEIClusterPingedEvent : NSObject -@property (nonatomic, copy) NSNumber * _Nonnull arg1 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 diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm index 8c0f75838b4260..28d308386a5828 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm @@ -7515,12 +7515,12 @@ @implementation MTRTestClusterClusterTestFabricScopedEventEvent : MTRUnitTesting @dynamic fabricIndex; @end -@implementation MTRSampleMEIClusterPingedEvent +@implementation MTRSampleMEIClusterPingCountEventEvent - (instancetype)init { if (self = [super init]) { - _arg1 = @(0); + _count = @(0); _fabricIndex = @(0); } @@ -7529,9 +7529,9 @@ - (instancetype)init - (id)copyWithZone:(NSZone * _Nullable)zone { - auto other = [[MTRSampleMEIClusterPingedEvent alloc] init]; + auto other = [[MTRSampleMEIClusterPingCountEventEvent alloc] init]; - other.arg1 = self.arg1; + other.count = self.count; other.fabricIndex = self.fabricIndex; return other; @@ -7539,7 +7539,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone - (NSString *)description { - NSString * descriptionString = [NSString stringWithFormat:@"<%@: arg1:%@; fabricIndex:%@; >", NSStringFromClass([self class]), _arg1, _fabricIndex]; + NSString * descriptionString = [NSString stringWithFormat:@"<%@: count:%@; fabricIndex:%@; >", NSStringFromClass([self class]), _count, _fabricIndex]; return descriptionString; } 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 bece1eaef9d37c..95c90f55c328e6 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 @@ -27641,12 +27641,12 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre } // namespace Attributes namespace Events { -namespace Pinged { +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::kArg1), arg1)); + ReturnErrorOnFailure(DataModel::Encode(aWriter, TLV::ContextTag(Fields::kCount), count)); ReturnErrorOnFailure(DataModel::Encode(aWriter, TLV::ContextTag(Fields::kFabricIndex), fabricIndex)); return aWriter.EndContainer(outer); } @@ -27665,9 +27665,9 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) CHIP_ERROR err = CHIP_NO_ERROR; const uint8_t __context_tag = std::get(__element); - if (__context_tag == to_underlying(Fields::kArg1)) + if (__context_tag == to_underlying(Fields::kCount)) { - err = DataModel::Decode(reader, arg1); + err = DataModel::Decode(reader, count); } else if (__context_tag == to_underlying(Fields::kFabricIndex)) { @@ -27680,7 +27680,7 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) ReturnErrorOnFailure(err); } } -} // namespace Pinged. +} // 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 d3bbae47e3fc10..815b945b5ab9ef 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 @@ -42021,12 +42021,12 @@ struct TypeInfo }; } // namespace Attributes namespace Events { -namespace Pinged { +namespace PingCountEvent { static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; enum class Fields : uint8_t { - kArg1 = 1, + kCount = 1, kFabricIndex = 254, }; @@ -42034,11 +42034,11 @@ struct Type { public: static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } - static constexpr EventId GetEventId() { return Events::Pinged::Id; } + static constexpr EventId GetEventId() { return Events::PingCountEvent::Id; } static constexpr ClusterId GetClusterId() { return Clusters::SampleMei::Id; } static constexpr bool kIsFabricScoped = true; - uint8_t arg1 = static_cast(0); + uint32_t count = static_cast(0); chip::FabricIndex fabricIndex = static_cast(0); auto GetFabricIndex() const { return fabricIndex; } @@ -42050,15 +42050,15 @@ struct DecodableType { public: static constexpr PriorityLevel GetPriorityLevel() { return kPriorityLevel; } - static constexpr EventId GetEventId() { return Events::Pinged::Id; } + static constexpr EventId GetEventId() { return Events::PingCountEvent::Id; } static constexpr ClusterId GetClusterId() { return Clusters::SampleMei::Id; } - uint8_t arg1 = static_cast(0); + uint32_t count = static_cast(0); chip::FabricIndex fabricIndex = static_cast(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; -} // namespace Pinged +} // namespace PingCountEvent } // namespace Events } // namespace SampleMei 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 51f5afcbfe10b0..807f2f077d8095 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 @@ -626,9 +626,9 @@ static constexpr EventId Id = 0x00000002; namespace SampleMei { namespace Events { -namespace Pinged { +namespace PingCountEvent { static constexpr EventId Id = 0x00000000; -} // namespace Pinged +} // namespace PingCountEvent } // namespace Events } // namespace SampleMei diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index f7095514651428..66c4f61ede9bf3 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -13840,7 +13840,7 @@ class FaultInjectionFailRandomlyAtFault : public ClusterCommand | * ClusterRevision | 0xFFFD | |------------------------------------------------------------------------------| | Events: | | -| * Pinged | 0x0000 | +| * PingCountEvent | 0x0000 | \*----------------------------------------------------------------------------*/ /* @@ -25171,10 +25171,10 @@ void registerClusterSampleMei(Commands & commands, CredentialIssuerCommands * cr // // Events // - make_unique(Id, credsIssuerConfig), // - make_unique(Id, "pinged", Events::Pinged::Id, credsIssuerConfig), // - make_unique(Id, credsIssuerConfig), // - make_unique(Id, "pinged", Events::Pinged::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 a35b466872d4a4..3b93c648c9aea4 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -6263,14 +6263,15 @@ 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::Pinged::DecodableType & value) +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("Arg1", indent + 1, value.arg1); + 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 'Arg1'"); + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'Count'"); return err; } } @@ -17794,10 +17795,10 @@ CHIP_ERROR DataModelLogger::LogEvent(const chip::app::EventHeader & header, chip case SampleMei::Id: { switch (header.mPath.mEventId) { - case SampleMei::Events::Pinged::Id: { - chip::app::Clusters::SampleMei::Events::Pinged::DecodableType value; + case SampleMei::Events::PingCountEvent::Id: { + chip::app::Clusters::SampleMei::Events::PingCountEvent::DecodableType value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); - return DataModelLogger::LogValue("Pinged", 1, value); + return DataModelLogger::LogValue("PingCountEvent", 1, value); } } break; diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h index f6ccbe3adac288..3265347dfed29c 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h @@ -549,7 +549,7 @@ static CHIP_ERROR LogValue(const char * label, size_t indent, static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::UnitTesting::Events::TestFabricScopedEvent::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::SampleMei::Events::Pinged::DecodableType & value); + 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 f93274807d08c9..0e9787d9ff24ae 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -171277,7 +171277,7 @@ class SubscribeAttributeUnitTestingClusterRevision : public SubscribeAttribute { | * ClusterRevision | 0xFFFD | |------------------------------------------------------------------------------| | Events: | | -| * Pinged | 0x0000 | +| * PingCountEvent | 0x0000 | \*----------------------------------------------------------------------------*/ #if MTR_ENABLE_PROVISIONAL From 5d032ff210ab27060636c64543476c1c3fd00161 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Fri, 8 Dec 2023 22:02:00 +0000 Subject: [PATCH 04/11] Restyled by clang-format --- .../sample-mei-server/sample-mei-server.cpp | 26 ++++++++++--------- .../sample-mei-server/sample-mei-server.h | 1 - 2 files changed, 14 insertions(+), 13 deletions(-) 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 749dfbc1e05355..22a8f48bdf8a00 100644 --- a/src/app/clusters/sample-mei-server/sample-mei-server.cpp +++ b/src/app/clusters/sample-mei-server/sample-mei-server.cpp @@ -59,7 +59,7 @@ SampleMeiContent::SampleMeiContent() : SampleMeiContent(kInvalidEndpointId) {} SampleMeiContent::SampleMeiContent(EndpointId aEndpoint) { - endpoint = aEndpoint; + endpoint = aEndpoint; pingCount = 10000; // Attribute default values @@ -83,17 +83,19 @@ void SampleMeiServer::InvokeCommand(HandlerContext & ctxt) switch (ctxt.mRequestPath.mCommandId) { case Commands::Ping::Id: - 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); - }); + 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 c7a11fb6aaf480..9f5307dba6d753 100644 --- a/src/app/clusters/sample-mei-server/sample-mei-server.h +++ b/src/app/clusters/sample-mei-server/sample-mei-server.h @@ -37,7 +37,6 @@ class SampleMeiContent // Attribute List bool flipflop; /* Attributes::FlipFlop::Id */ - SampleMeiContent(EndpointId endpoint); SampleMeiContent(); }; From db1f1aa968c26e3c72d35f9ef385e1183fb3f61f Mon Sep 17 00:00:00 2001 From: erwinpan1 Date: Mon, 11 Dec 2023 23:45:49 +0800 Subject: [PATCH 05/11] Fix Chef ZAP event from Pinged to PingCountEvent --- examples/chef/devices/rootnode_onofflight_samplemei.zap | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/chef/devices/rootnode_onofflight_samplemei.zap b/examples/chef/devices/rootnode_onofflight_samplemei.zap index 5a676c8d676416..0bcd495ba65859 100644 --- a/examples/chef/devices/rootnode_onofflight_samplemei.zap +++ b/examples/chef/devices/rootnode_onofflight_samplemei.zap @@ -3548,7 +3548,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3605,7 +3605,7 @@ ], "events": [ { - "name": "Pinged", + "name": "PingCountEvent", "code": 0, "mfgCode": null, "side": "server", From 6630985205f85a2f993616c200d467121f13ad84 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Tue, 12 Dec 2023 10:11:03 -0500 Subject: [PATCH 06/11] zap regen --- .../eventstructs/SampleMeiClusterPingCountEventEvent.kt | 4 ++-- .../java/generated/java/matter/controller/cluster/files.gni | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) 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 index 946a5949dae51e..5570ba7a3af4a3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt @@ -14,9 +14,9 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package matter.devicecontroller.cluster.eventstructs +package matter.controller.cluster.eventstructs -import matter.devicecontroller.cluster.* +import matter.controller.cluster.* import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader 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", From 57a787cf5f71113ca1eb835a6dbd837050ae1bd7 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Tue, 12 Dec 2023 10:14:14 -0500 Subject: [PATCH 07/11] Remove files that are not to be generated anymore --- .../SampleMeiClusterPingedEvent.kt | 56 --- ...statClusterThermostatScheduleTransition.kt | 88 ---- .../SampleMeiClusterPingedEvent.kt | 56 --- .../ElectricalEnergyMeasurementCluster.kt | 472 ------------------ 4 files changed, 672 deletions(-) delete mode 100644 src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingedEvent.kt delete mode 100644 src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterThermostatScheduleTransition.kt delete mode 100644 src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingedEvent.kt delete mode 100644 src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingedEvent.kt deleted file mode 100644 index 6f61ec256f2d5b..00000000000000 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingedEvent.kt +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * 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 SampleMeiClusterPingedEvent(val arg1: UInt, val fabricIndex: UInt) { - override fun toString(): String = buildString { - append("SampleMeiClusterPingedEvent {\n") - append("\targ1 : $arg1\n") - append("\tfabricIndex : $fabricIndex\n") - append("}\n") - } - - fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { - tlvWriter.apply { - startStructure(tlvTag) - put(ContextSpecificTag(TAG_ARG1), arg1) - put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) - endStructure() - } - } - - companion object { - private const val TAG_ARG1 = 1 - private const val TAG_FABRIC_INDEX = 254 - - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SampleMeiClusterPingedEvent { - tlvReader.enterStructure(tlvTag) - val arg1 = tlvReader.getUInt(ContextSpecificTag(TAG_ARG1)) - val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - - tlvReader.exitContainer() - - return SampleMeiClusterPingedEvent(arg1, fabricIndex) - } - } -} diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterThermostatScheduleTransition.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterThermostatScheduleTransition.kt deleted file mode 100644 index 385f331a718700..00000000000000 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterThermostatScheduleTransition.kt +++ /dev/null @@ -1,88 +0,0 @@ -/* - * - * 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 matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvReader -import matter.tlv.TlvWriter - -class ThermostatClusterThermostatScheduleTransition( - val transitionTime: UInt, - val heatSetpoint: Int?, - val coolSetpoint: Int? -) { - override fun toString(): String = buildString { - append("ThermostatClusterThermostatScheduleTransition {\n") - append("\ttransitionTime : $transitionTime\n") - append("\theatSetpoint : $heatSetpoint\n") - append("\tcoolSetpoint : $coolSetpoint\n") - append("}\n") - } - - fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { - tlvWriter.apply { - startStructure(tlvTag) - put(ContextSpecificTag(TAG_TRANSITION_TIME), transitionTime) - if (heatSetpoint != null) { - put(ContextSpecificTag(TAG_HEAT_SETPOINT), heatSetpoint) - } else { - putNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) - } - if (coolSetpoint != null) { - put(ContextSpecificTag(TAG_COOL_SETPOINT), coolSetpoint) - } else { - putNull(ContextSpecificTag(TAG_COOL_SETPOINT)) - } - endStructure() - } - } - - companion object { - private const val TAG_TRANSITION_TIME = 0 - private const val TAG_HEAT_SETPOINT = 1 - private const val TAG_COOL_SETPOINT = 2 - - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterThermostatScheduleTransition { - tlvReader.enterStructure(tlvTag) - val transitionTime = tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_TIME)) - val heatSetpoint = - if (!tlvReader.isNull()) { - tlvReader.getInt(ContextSpecificTag(TAG_HEAT_SETPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) - null - } - val coolSetpoint = - if (!tlvReader.isNull()) { - tlvReader.getInt(ContextSpecificTag(TAG_COOL_SETPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOL_SETPOINT)) - null - } - - tlvReader.exitContainer() - - return ThermostatClusterThermostatScheduleTransition( - transitionTime, - heatSetpoint, - coolSetpoint - ) - } - } -} diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingedEvent.kt deleted file mode 100644 index a85446c9824cc6..00000000000000 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingedEvent.kt +++ /dev/null @@ -1,56 +0,0 @@ -/* - * - * 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.devicecontroller.cluster.eventstructs - -import matter.devicecontroller.cluster.* -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvReader -import matter.tlv.TlvWriter - -class SampleMeiClusterPingedEvent(val arg1: UByte, val fabricIndex: UByte) { - override fun toString(): String = buildString { - append("SampleMeiClusterPingedEvent {\n") - append("\targ1 : $arg1\n") - append("\tfabricIndex : $fabricIndex\n") - append("}\n") - } - - fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { - tlvWriter.apply { - startStructure(tlvTag) - put(ContextSpecificTag(TAG_ARG1), arg1) - put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) - endStructure() - } - } - - companion object { - private const val TAG_ARG1 = 1 - private const val TAG_FABRIC_INDEX = 254 - - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SampleMeiClusterPingedEvent { - tlvReader.enterStructure(tlvTag) - val arg1 = tlvReader.getUByte(ContextSpecificTag(TAG_ARG1)) - val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - - tlvReader.exitContainer() - - return SampleMeiClusterPingedEvent(arg1, fabricIndex) - } - } -} diff --git a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt b/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt deleted file mode 100644 index d9c3677d557c85..00000000000000 --- a/src/controller/java/generated/java/matter/devicecontroller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt +++ /dev/null @@ -1,472 +0,0 @@ -/* - * - * 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.devicecontroller.cluster.clusters - -import java.util.logging.Level -import java.util.logging.Logger -import matter.controller.* -import matter.controller.model.AttributePath -import matter.devicecontroller.cluster.structs.* -import matter.tlv.AnonymousTag -import matter.tlv.TlvReader - -class ElectricalEnergyMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class AccuracyAttribute(val value: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct) - - class CumulativeEnergyImportedAttribute( - val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? - ) - - class CumulativeEnergyExportedAttribute( - val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? - ) - - class PeriodicEnergyImportedAttribute( - val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? - ) - - class PeriodicEnergyExportedAttribute( - val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? - ) - - class GeneratedCommandListAttribute(val value: List) - - class AcceptedCommandListAttribute(val value: List) - - class EventListAttribute(val value: List) - - class AttributeListAttribute(val value: List) - - suspend fun readAccuracyAttribute(): AccuracyAttribute { - val ATTRIBUTE_ID: UInt = 0u - - 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) { "Accuracy attribute not found in response" } - - // Decode the TLV data into the appropriate type - val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct = - ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.fromTlv(AnonymousTag, tlvReader) - - return AccuracyAttribute(decodedValue) - } - - suspend fun readCumulativeEnergyImportedAttribute(): CumulativeEnergyImportedAttribute { - val ATTRIBUTE_ID: UInt = 1u - - 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) { "Cumulativeenergyimported attribute not found in response" } - - // Decode the TLV data into the appropriate type - val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - return CumulativeEnergyImportedAttribute(decodedValue) - } - - suspend fun readCumulativeEnergyExportedAttribute(): CumulativeEnergyExportedAttribute { - val ATTRIBUTE_ID: UInt = 2u - - 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) { "Cumulativeenergyexported attribute not found in response" } - - // Decode the TLV data into the appropriate type - val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - return CumulativeEnergyExportedAttribute(decodedValue) - } - - suspend fun readPeriodicEnergyImportedAttribute(): PeriodicEnergyImportedAttribute { - val ATTRIBUTE_ID: UInt = 3u - - 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) { "Periodicenergyimported attribute not found in response" } - - // Decode the TLV data into the appropriate type - val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - return PeriodicEnergyImportedAttribute(decodedValue) - } - - suspend fun readPeriodicEnergyExportedAttribute(): PeriodicEnergyExportedAttribute { - val ATTRIBUTE_ID: UInt = 4u - - 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) { "Periodicenergyexported attribute not found in response" } - - // Decode the TLV data into the appropriate type - val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - return PeriodicEnergyExportedAttribute(decodedValue) - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - 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) { "Generatedcommandlist attribute not found in response" } - - // Decode the TLV data into the appropriate type - val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - - return GeneratedCommandListAttribute(decodedValue) - } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - 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) { "Acceptedcommandlist attribute not found in response" } - - // Decode the TLV data into the appropriate type - val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - - return AcceptedCommandListAttribute(decodedValue) - } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - 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) { "Eventlist attribute not found in response" } - - // Decode the TLV data into the appropriate type - val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - - return EventListAttribute(decodedValue) - } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - 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) { "Attributelist attribute not found in response" } - - // Decode the TLV data into the appropriate type - val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - - return AttributeListAttribute(decodedValue) - } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - 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) { "Featuremap attribute not found in response" } - - // Decode the TLV data into the appropriate type - val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - - return decodedValue - } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - 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) { "Clusterrevision attribute not found in response" } - - // Decode the TLV data into the appropriate type - val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - - return decodedValue - } - - companion object { - private val logger = Logger.getLogger(ElectricalEnergyMeasurementCluster::class.java.name) - const val CLUSTER_ID: UInt = 145u - } -} From 47a50579d473b78f352427a6f2dfd1eaedad1f62 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 09:26:15 -0500 Subject: [PATCH 08/11] 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> --- .github/workflows/labeler.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/labeler.yaml b/.github/workflows/labeler.yaml index 057208eda328d2..0127be63320271 100644 --- a/.github/workflows/labeler.yaml +++ b/.github/workflows/labeler.yaml @@ -9,6 +9,6 @@ jobs: pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/labeler@v4 + - uses: actions/labeler@v5 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" From a0ffd533157a256e7f20ebd1a16bff009a384c7c Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Mon, 11 Dec 2023 09:55:52 -0500 Subject: [PATCH 09/11] Revert "Bump actions/labeler from 4 to 5 (#30911)" (#30922) This reverts commit e15db829cde4a484a283c0e935df4738f572bb4c. --- .github/workflows/labeler.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/labeler.yaml b/.github/workflows/labeler.yaml index 0127be63320271..057208eda328d2 100644 --- a/.github/workflows/labeler.yaml +++ b/.github/workflows/labeler.yaml @@ -9,6 +9,6 @@ jobs: pull-requests: write runs-on: ubuntu-latest steps: - - uses: actions/labeler@v5 + - uses: actions/labeler@v4 with: repo-token: "${{ secrets.GITHUB_TOKEN }}" From da96af5361e82b3b6023535d6749783b70b3f951 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Tue, 12 Dec 2023 06:33:30 -0800 Subject: [PATCH 10/11] Change the package of Kotlin cluster lib to package matter.controller.cluster.clusters (#30945) --- .../java/generated/java/matter/controller/cluster/files.gni | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 d7d18479992e91..05d6714999311a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/files.gni +++ b/src/controller/java/generated/java/matter/controller/cluster/files.gni @@ -310,4 +310,4 @@ matter_clusters_sources = [ "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/WakeOnLanCluster.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/WindowCoveringCluster.kt", -] \ No newline at end of file +] From d76e8e09cc3afb05c1919ecd747dff5fa4bfb2e4 Mon Sep 17 00:00:00 2001 From: erwinpan1 Date: Wed, 13 Dec 2023 00:40:41 +0800 Subject: [PATCH 11/11] Fix newline in the end of files.gni --- .../java/generated/java/matter/controller/cluster/files.gni | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 05d6714999311a..d7d18479992e91 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/files.gni +++ b/src/controller/java/generated/java/matter/controller/cluster/files.gni @@ -310,4 +310,4 @@ matter_clusters_sources = [ "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/WakeOnLanCluster.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/clusters/WindowCoveringCluster.kt", -] +] \ No newline at end of file