From 94853cfe98c73708a3636163a66d6ffcc22a35d2 Mon Sep 17 00:00:00 2001 From: Marius Tache <102153746+marius-alex-tache@users.noreply.github.com> Date: Thu, 21 Sep 2023 15:35:00 +0300 Subject: [PATCH] [data-model] Add general diagnostics average wear count (#29285) * [clusters] Add AverageWearCount attribute support in GeneralDiagnostics Signed-off-by: marius-alex-tache * [codegen] Regenerate generated code Signed-off-by: marius-alex-tache * Add AverageWearCount to zcl data Signed-off-by: marius-alex-tache * Remove AverageWearCount from Darwin availability Signed-off-by: marius-alex-tache * Add API documentation for General Diagnostics interface Signed-off-by: marius-alex-tache * Restyled by whitespace * Restyled by prettier-json * Remove redundant comments from General Diagnostics interface Signed-off-by: marius-alex-tache * [codegen] Regenerate generated code Signed-off-by: marius-alex-tache * Remove redundant min/max range for General Diagnostics attributes Signed-off-by: marius-alex-tache --------- Signed-off-by: marius-alex-tache Co-authored-by: Restyled.io --- .../general-diagnostics-server.cpp | 3 + .../chip/general-diagnostics-cluster.xml | 7 +- .../zcl/zcl-with-test-extensions.json | 3 +- src/app/zap-templates/zcl/zcl.json | 3 +- .../data_model/controller-clusters.matter | 1 + .../devicecontroller/ClusterIDMapping.java | 1 + .../devicecontroller/ClusterReadMapping.java | 11 +++ .../CHIPAttributeTLVValueDecoder.cpp | 16 ++++ .../chip/devicecontroller/ChipClusters.java | 19 ++++ .../python/chip/clusters/CHIPClusters.py | 6 ++ .../python/chip/clusters/Objects.py | 18 ++++ .../MTRAttributeSpecifiedCheck.mm | 3 + .../MTRAttributeTLVValueDecoder.mm | 11 +++ .../CHIP/zap-generated/MTRBaseClusters.h | 12 +++ .../CHIP/zap-generated/MTRBaseClusters.mm | 44 +++++++++ .../CHIP/zap-generated/MTRClusterConstants.h | 1 + .../CHIP/zap-generated/MTRClusters.h | 2 + .../CHIP/zap-generated/MTRClusters.mm | 8 ++ src/include/platform/DiagnosticDataProvider.h | 60 +++++++++++++ .../zap-generated/cluster-objects.cpp | 3 + .../zap-generated/cluster-objects.h | 13 +++ .../app-common/zap-generated/ids/Attributes.h | 4 + .../zap-generated/cluster/Commands.h | 5 ++ .../cluster/logging/DataModelLogger.cpp | 5 ++ .../zap-generated/cluster/Commands.h | 89 +++++++++++++++++++ 25 files changed, 343 insertions(+), 5 deletions(-) diff --git a/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp b/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp index 6fb013b0ff0282..994104abf22a75 100644 --- a/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp +++ b/src/app/clusters/general-diagnostics-server/general-diagnostics-server.cpp @@ -204,6 +204,9 @@ CHIP_ERROR GeneralDiagosticsAttrAccess::Read(const ConcreteReadAttributePath & a bool isTestEventTriggersEnabled = IsTestEventTriggerEnabled(); return aEncoder.Encode(isTestEventTriggersEnabled); } + case AverageWearCount::Id: { + return ReadIfSupported(&DiagnosticDataProvider::GetAverageWearCount, aEncoder); + } default: { break; } diff --git a/src/app/zap-templates/zcl/data-model/chip/general-diagnostics-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/general-diagnostics-cluster.xml index 9eb0036b3ee6f8..f8bd8ec8f1c664 100644 --- a/src/app/zap-templates/zcl/data-model/chip/general-diagnostics-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/general-diagnostics-cluster.xml @@ -84,14 +84,15 @@ limitations under the License. GENERAL_DIAGNOSTICS_CLUSTER The General Diagnostics Cluster, along with other diagnostics clusters, provide a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. NetworkInterfaces - RebootCount - UpTime - TotalOperationalHours + RebootCount + UpTime + TotalOperationalHours BootReason ActiveHardwareFaults ActiveRadioFaults ActiveNetworkFaults TestEventTriggersEnabled + AverageWearCount Provide a means for certification tests to trigger some test-plan-specific events diff --git a/src/app/zap-templates/zcl/zcl-with-test-extensions.json b/src/app/zap-templates/zcl/zcl-with-test-extensions.json index cda276d24e3012..f3b1164762f269 100644 --- a/src/app/zap-templates/zcl/zcl-with-test-extensions.json +++ b/src/app/zap-templates/zcl/zcl-with-test-extensions.json @@ -187,7 +187,8 @@ "RebootCount", "UpTime", "TotalOperationalHours", - "BootReason" + "BootReason", + "AverageWearCount" ], "Group Key Management": [ "ClusterRevision", diff --git a/src/app/zap-templates/zcl/zcl.json b/src/app/zap-templates/zcl/zcl.json index d83714d040a20b..c6de8dc8cf24c6 100644 --- a/src/app/zap-templates/zcl/zcl.json +++ b/src/app/zap-templates/zcl/zcl.json @@ -185,7 +185,8 @@ "RebootCount", "UpTime", "TotalOperationalHours", - "BootReason" + "BootReason", + "AverageWearCount" ], "Group Key Management": [ "ClusterRevision", diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index eb2e77f0a5ac96..db4326c1145065 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -1803,6 +1803,7 @@ client cluster GeneralDiagnostics = 51 { readonly attribute optional RadioFaultEnum activeRadioFaults[] = 6; readonly attribute optional NetworkFaultEnum activeNetworkFaults[] = 7; readonly attribute boolean testEventTriggersEnabled = 8; + readonly attribute optional int32u averageWearCount = 9; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java index 9d5be1817a7cdd..002fe71784dfc5 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java @@ -3746,6 +3746,7 @@ public enum Attribute { ActiveRadioFaults(6L), ActiveNetworkFaults(7L), TestEventTriggersEnabled(8L), + AverageWearCount(9L), GeneratedCommandList(65528L), AcceptedCommandList(65529L), EventList(65530L), diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java index 16cdf60a0085df..43e73e97980866 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java @@ -3154,6 +3154,17 @@ private static Map readGeneralDiagnosticsInteractionInf readGeneralDiagnosticsTestEventTriggersEnabledCommandParams ); result.put("readTestEventTriggersEnabledAttribute", readGeneralDiagnosticsTestEventTriggersEnabledAttributeInteractionInfo); + Map readGeneralDiagnosticsAverageWearCountCommandParams = new LinkedHashMap(); + InteractionInfo readGeneralDiagnosticsAverageWearCountAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.GeneralDiagnosticsCluster) cluster).readAverageWearCountAttribute( + (ChipClusters.LongAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedLongAttributeCallback(), + readGeneralDiagnosticsAverageWearCountCommandParams + ); + result.put("readAverageWearCountAttribute", readGeneralDiagnosticsAverageWearCountAttributeInteractionInfo); Map readGeneralDiagnosticsGeneratedCommandListCommandParams = new LinkedHashMap(); InteractionInfo readGeneralDiagnosticsGeneratedCommandListAttributeInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { diff --git a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp index d7ceccc2757ba6..6faa72db2086ba 100644 --- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp @@ -6527,6 +6527,22 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jnivalue, value); return value; } + case Attributes::AverageWearCount::Id: { + using TypeInfo = Attributes::AverageWearCount::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; + } + jobject value; + std::string valueClassName = "java/lang/Long"; + std::string valueCtorSignature = "(J)V"; + jlong jnivalue = static_cast(cppValue); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), + jnivalue, value); + return value; + } case Attributes::GeneratedCommandList::Id: { using TypeInfo = Attributes::GeneratedCommandList::TypeInfo; TypeInfo::DecodableType cppValue; diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java index 8eac9532c59054..a3df84a30dd9bc 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java @@ -7576,6 +7576,18 @@ public void subscribeTestEventTriggersEnabledAttribute( subscribeTestEventTriggersEnabledAttribute(chipClusterPtr, callback, minInterval, maxInterval); } + public void readAverageWearCountAttribute( + LongAttributeCallback callback + ) { + readAverageWearCountAttribute(chipClusterPtr, callback); + } + public void subscribeAverageWearCountAttribute( + LongAttributeCallback callback +, + int minInterval, int maxInterval) { + subscribeAverageWearCountAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + public void readGeneratedCommandListAttribute( GeneratedCommandListAttributeCallback callback ) { @@ -7711,6 +7723,13 @@ private native void subscribeTestEventTriggersEnabledAttribute(long chipClusterP BooleanAttributeCallback callback , int minInterval, int maxInterval); + private native void readAverageWearCountAttribute(long chipClusterPtr, + LongAttributeCallback callback + ); + private native void subscribeAverageWearCountAttribute(long chipClusterPtr, + LongAttributeCallback callback +, int minInterval, int maxInterval); + private native void readGeneratedCommandListAttribute(long chipClusterPtr, GeneratedCommandListAttributeCallback callback ); diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index d86b766bd87f68..434296a3c1761d 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -2435,6 +2435,12 @@ class ChipClusters: "type": "bool", "reportable": True, }, + 0x00000009: { + "attributeName": "AverageWearCount", + "attributeId": 0x00000009, + "type": "int", + "reportable": True, + }, 0x0000FFF8: { "attributeName": "GeneratedCommandList", "attributeId": 0x0000FFF8, diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 0939509b6f47fd..ca33a46589350a 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -8144,6 +8144,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="activeRadioFaults", Tag=0x00000006, Type=typing.Optional[typing.List[GeneralDiagnostics.Enums.RadioFaultEnum]]), ClusterObjectFieldDescriptor(Label="activeNetworkFaults", Tag=0x00000007, Type=typing.Optional[typing.List[GeneralDiagnostics.Enums.NetworkFaultEnum]]), ClusterObjectFieldDescriptor(Label="testEventTriggersEnabled", Tag=0x00000008, Type=bool), + ClusterObjectFieldDescriptor(Label="averageWearCount", Tag=0x00000009, Type=typing.Optional[uint]), ClusterObjectFieldDescriptor(Label="generatedCommandList", Tag=0x0000FFF8, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="acceptedCommandList", Tag=0x0000FFF9, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="eventList", Tag=0x0000FFFA, Type=typing.List[uint]), @@ -8161,6 +8162,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: activeRadioFaults: 'typing.Optional[typing.List[GeneralDiagnostics.Enums.RadioFaultEnum]]' = None activeNetworkFaults: 'typing.Optional[typing.List[GeneralDiagnostics.Enums.NetworkFaultEnum]]' = None testEventTriggersEnabled: 'bool' = None + averageWearCount: 'typing.Optional[uint]' = None generatedCommandList: 'typing.List[uint]' = None acceptedCommandList: 'typing.List[uint]' = None eventList: 'typing.List[uint]' = None @@ -8428,6 +8430,22 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'bool' = False + @dataclass + class AverageWearCount(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000033 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000009 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Optional[uint]) + + value: 'typing.Optional[uint]' = None + @dataclass class GeneratedCommandList(ClusterAttributeDescriptor): @ChipUtility.classproperty diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm index 66dfabb230d236..3f725fa73972b2 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm @@ -1071,6 +1071,9 @@ static BOOL AttributeIsSpecifiedInGeneralDiagnosticsCluster(AttributeId aAttribu case Attributes::TestEventTriggersEnabled::Id: { return YES; } + case Attributes::AverageWearCount::Id: { + return YES; + } case Attributes::GeneratedCommandList::Id: { return YES; } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm index 85158a4548c461..c1100d389c1ce8 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm @@ -2772,6 +2772,17 @@ static id _Nullable DecodeAttributeValueForGeneralDiagnosticsCluster( value = [NSNumber numberWithBool:cppValue]; return value; } + case Attributes::AverageWearCount::Id: { + using TypeInfo = Attributes::AverageWearCount::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nonnull value; + value = [NSNumber numberWithUnsignedInt:cppValue]; + return value; + } default: { break; } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index 3777a49c291399..2ca810eff72c96 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -4880,6 +4880,18 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) NSError * _Nullable error))completion API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +- (void)readAttributeAverageWearCountWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion + MTR_NEWLY_AVAILABLE; +- (void)subscribeAttributeAverageWearCountWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler + MTR_NEWLY_AVAILABLE; ++ (void)readAttributeAverageWearCountWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion:(void (^)(NSNumber * _Nullable value, + NSError * _Nullable error))completion MTR_NEWLY_AVAILABLE; + - (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); - (void)subscribeAttributeGeneratedCommandListWithParams:(MTRSubscribeParams *)params diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm index 81828982cc015c..4a836a0ee0f31f 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm @@ -27988,6 +27988,50 @@ + (void)readAttributeTestEventTriggersEnabledWithClusterStateCache:(MTRClusterSt }); } +- (void)readAttributeAverageWearCountWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + MTRReadParams * params = [[MTRReadParams alloc] init]; + using TypeInfo = GeneralDiagnostics::Attributes::AverageWearCount::TypeInfo; + return MTRReadAttribute( + params, completion, self.callbackQueue, self.device, self.endpoint, TypeInfo::GetClusterId(), TypeInfo::GetAttributeId()); +} + +- (void)subscribeAttributeAverageWearCountWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = GeneralDiagnostics::Attributes::AverageWearCount::TypeInfo; + MTRSubscribeAttribute(params, + subscriptionEstablished, reportHandler, self.callbackQueue, self.device, self.endpoint, TypeInfo::GetClusterId(), + TypeInfo::GetAttributeId()); +} + ++ (void)readAttributeAverageWearCountWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer + endpoint:(NSNumber *)endpoint + queue:(dispatch_queue_t)queue + completion: + (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + auto * bridge = new MTRInt32uAttributeCallbackBridge(queue, completion); + std::move(*bridge).DispatchLocalAction( + clusterStateCacheContainer.baseDevice, ^(Int32uAttributeCallback successCb, MTRErrorCallback failureCb) { + if (clusterStateCacheContainer.cppClusterStateCache) { + chip::app::ConcreteAttributePath path; + using TypeInfo = GeneralDiagnostics::Attributes::AverageWearCount::TypeInfo; + path.mEndpointId = static_cast([endpoint unsignedShortValue]); + path.mClusterId = TypeInfo::GetClusterId(); + path.mAttributeId = TypeInfo::GetAttributeId(); + TypeInfo::DecodableType value; + CHIP_ERROR err = clusterStateCacheContainer.cppClusterStateCache->Get(path, value); + if (err == CHIP_NO_ERROR) { + successCb(bridge, value); + } + return err; + } + return CHIP_ERROR_NOT_FOUND; + }); +} + - (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion { MTRReadParams * params = [[MTRReadParams alloc] init]; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h index ee2cc2a922214d..0037872c3e9406 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h @@ -2103,6 +2103,7 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeTestEventTriggersEnabledID API_AVAILABLE( ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = 0x00000008, + MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeAverageWearCountID MTR_NEWLY_AVAILABLE = 0x00000009, MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeGeneratedCommandListID API_AVAILABLE( ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) = MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID, diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h index 3d6810e6961d35..2c29065af237e8 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h @@ -1902,6 +1902,8 @@ API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)) - (NSDictionary *)readAttributeTestEventTriggersEnabledWithParams:(MTRReadParams * _Nullable)params API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); +- (NSDictionary *)readAttributeAverageWearCountWithParams:(MTRReadParams * _Nullable)params MTR_NEWLY_AVAILABLE; + - (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params API_AVAILABLE(ios(16.1), macos(13.0), watchos(9.1), tvos(16.1)); diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm index 6588f0db6f4c79..d7a137da21ed48 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm @@ -6851,6 +6851,14 @@ - (void)testEventTriggerWithParams:(MTRGeneralDiagnosticsClusterTestEventTrigger params:params]; } +- (NSDictionary *)readAttributeAverageWearCountWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(self.endpoint) + clusterID:@(MTRClusterIDTypeGeneralDiagnosticsID) + attributeID:@(MTRAttributeIDTypeClusterGeneralDiagnosticsAttributeAverageWearCountID) + params:params]; +} + - (NSDictionary *)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params { return [self.device readAttributeWithEndpointID:@(self.endpoint) diff --git a/src/include/platform/DiagnosticDataProvider.h b/src/include/platform/DiagnosticDataProvider.h index 12eacf0a6d2b60..b6f44ee7e93e2a 100644 --- a/src/include/platform/DiagnosticDataProvider.h +++ b/src/include/platform/DiagnosticDataProvider.h @@ -103,14 +103,69 @@ class DiagnosticDataProvider /** * General Diagnostics methods. */ + + /** + * @brief Obtain the number of times the node has rebooted. + * The reboot count value will be reset only upon a factory reset of the node. + * + * @param[out] rebootCount Reference to location where the reboot count integer will be copied. + */ virtual CHIP_ERROR GetRebootCount(uint16_t & rebootCount); + + /** + * @brief Obtain the time (in seconds) since the node's last reboot. + * The up time value will be reset upon a node reboot. + * + * @param[out] upTime Reference to location where the up time integer will be copied. + */ virtual CHIP_ERROR GetUpTime(uint64_t & upTime); + + /** + * @brief Obtain the total time (in hours) the node has been operational. + * The total operational hours value will be reset only upon a factory reset of the node. + * + * @param[out] totalOperationalHours Reference to location where the total operation hours integer will be copied. + */ virtual CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours); + + /** + * @brief Obtain the reason for the node's most recent reboot. + * + * @param[out] bootReason Reference to location where the boot reason enum value will be copied. + */ virtual CHIP_ERROR GetBootReason(BootReasonType & bootReason); + + /** + * @brief Obtain the set of hardware faults currently detected by the node. + * + * @param[out] hardwareFaults Reference to location of a GeneralFaults instance. + * The instance can be populated by sequentially calling add method. + */ virtual CHIP_ERROR GetActiveHardwareFaults(GeneralFaults & hardwareFaults); + + /** + * @brief Obtain the set of radio faults currently detected by the node. + * + * @param[out] radioFaults Reference to location of a GeneralFaults instance. + * The instance can be populated by sequentially calling add method. + */ virtual CHIP_ERROR GetActiveRadioFaults(GeneralFaults & radioFaults); + + /** + * @brief Obtain the set of network faults currently detected by the node. + * + * @param[out] networkFaults Reference to location of a GeneralFaults instance. + * The instance can be populated by sequentially calling add method. + */ virtual CHIP_ERROR GetActiveNetworkFaults(GeneralFaults & networkFaults); + /** + * @brief Obtain the average wear count of the node's persistent storage backend. + * + * @param[out] averageWearCount Reference to location where the average wear count integer will be copied. + */ + virtual CHIP_ERROR GetAverageWearCount(uint32_t & averageWearCount); + /* * Get the linked list of network interfaces of the current plaform. After usage, each caller of GetNetworkInterfaces * needs to release the network interface list it gets via ReleaseNetworkInterfaces. @@ -277,6 +332,11 @@ inline CHIP_ERROR DiagnosticDataProvider::GetActiveNetworkFaults(GeneralFaults(0); + Attributes::AverageWearCount::TypeInfo::DecodableType averageWearCount = static_cast(0); Attributes::GeneratedCommandList::TypeInfo::DecodableType generatedCommandList; Attributes::AcceptedCommandList::TypeInfo::DecodableType acceptedCommandList; Attributes::EventList::TypeInfo::DecodableType eventList; diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h index 2032a2c22bfbf6..975aa66497e83b 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h @@ -1312,6 +1312,10 @@ namespace TestEventTriggersEnabled { static constexpr AttributeId Id = 0x00000008; } // namespace TestEventTriggersEnabled +namespace AverageWearCount { +static constexpr AttributeId Id = 0x00000009; +} // namespace AverageWearCount + namespace GeneratedCommandList { static constexpr AttributeId Id = Globals::Attributes::GeneratedCommandList::Id; } // namespace GeneratedCommandList diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index 5ea3aa9d7c9afb..a85437d32e538f 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -3061,6 +3061,7 @@ class DiagnosticLogsRetrieveLogsRequest : public ClusterCommand | * ActiveRadioFaults | 0x0006 | | * ActiveNetworkFaults | 0x0007 | | * TestEventTriggersEnabled | 0x0008 | +| * AverageWearCount | 0x0009 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -13360,6 +13361,7 @@ void registerClusterGeneralDiagnostics(Commands & commands, CredentialIssuerComm make_unique(Id, "active-network-faults", Attributes::ActiveNetworkFaults::Id, credsIssuerConfig), // make_unique(Id, "test-event-triggers-enabled", Attributes::TestEventTriggersEnabled::Id, credsIssuerConfig), // + make_unique(Id, "average-wear-count", Attributes::AverageWearCount::Id, credsIssuerConfig), // make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // @@ -13390,6 +13392,8 @@ void registerClusterGeneralDiagnostics(Commands & commands, CredentialIssuerComm Id, "active-network-faults", Attributes::ActiveNetworkFaults::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>(Id, "test-event-triggers-enabled", 0, 1, Attributes::TestEventTriggersEnabled::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>(Id, "average-wear-count", 0, UINT32_MAX, Attributes::AverageWearCount::Id, + WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>>( Id, "generated-command-list", Attributes::GeneratedCommandList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // @@ -13414,6 +13418,7 @@ void registerClusterGeneralDiagnostics(Commands & commands, CredentialIssuerComm make_unique(Id, "active-network-faults", Attributes::ActiveNetworkFaults::Id, credsIssuerConfig), // make_unique(Id, "test-event-triggers-enabled", Attributes::TestEventTriggersEnabled::Id, credsIssuerConfig), // + make_unique(Id, "average-wear-count", Attributes::AverageWearCount::Id, credsIssuerConfig), // make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp index 7b4d3fc30a3108..951dfcd79506fb 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -6639,6 +6639,11 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("TestEventTriggersEnabled", 1, value); } + case GeneralDiagnostics::Attributes::AverageWearCount::Id: { + uint32_t value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("AverageWearCount", 1, value); + } case GeneralDiagnostics::Attributes::GeneratedCommandList::Id: { chip::app::DataModel::DecodableList value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, 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 4bbfdba0783824..ad359cde71a567 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -29070,6 +29070,7 @@ class SubscribeAttributeDiagnosticLogsClusterRevision : public SubscribeAttribut | * ActiveRadioFaults | 0x0006 | | * ActiveNetworkFaults | 0x0007 | | * TestEventTriggersEnabled | 0x0008 | +| * AverageWearCount | 0x0009 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -29912,6 +29913,92 @@ class SubscribeAttributeGeneralDiagnosticsTestEventTriggersEnabled : public Subs } }; +/* + * Attribute AverageWearCount + */ +class ReadGeneralDiagnosticsAverageWearCount : public ReadAttribute { +public: + ReadGeneralDiagnosticsAverageWearCount() + : ReadAttribute("average-wear-count") + { + } + + ~ReadGeneralDiagnosticsAverageWearCount() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::GeneralDiagnostics::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::GeneralDiagnostics::Attributes::AverageWearCount::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, + clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + [cluster readAttributeAverageWearCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"GeneralDiagnostics.AverageWearCount response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("GeneralDiagnostics AverageWearCount read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeGeneralDiagnosticsAverageWearCount : public SubscribeAttribute { +public: + SubscribeAttributeGeneralDiagnosticsAverageWearCount() + : SubscribeAttribute("average-wear-count") + { + } + + ~SubscribeAttributeGeneralDiagnosticsAverageWearCount() {} + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::GeneralDiagnostics::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::GeneralDiagnostics::Attributes::AverageWearCount::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, + attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device + endpointID:@(endpointId) + queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeAverageWearCountWithParams:params + subscriptionEstablished:^() { + mSubscriptionEstablished = YES; + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"GeneralDiagnostics.AverageWearCount response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + /* * Attribute GeneratedCommandList */ @@ -163480,6 +163567,8 @@ void registerClusterGeneralDiagnostics(Commands & commands) make_unique(), // make_unique(), // make_unique(), // + make_unique(), // + make_unique(), // make_unique(), // make_unique(), // make_unique(), //