20
20
#include < app-common/zap-generated/ids/Attributes.h>
21
21
#include < app-common/zap-generated/ids/Clusters.h>
22
22
#include < app/AttributeAccessInterface.h>
23
+ #include < app/EventLogging.h>
23
24
#include < app/reporting/reporting.h>
24
25
#include < app/util/attribute-storage.h>
25
26
#include < platform/ConnectivityManager.h>
@@ -211,6 +212,34 @@ class GeneralDiagnosticsDelegate : public DeviceLayer::ConnectivityManagerDelega
211
212
ChipLogProgress (Zcl, " GeneralDiagnosticsDelegate: OnHardwareFaultsDetected" );
212
213
213
214
ReportAttributeOnAllEndpoints (GeneralDiagnostics::Attributes::ActiveHardwareFaults::Id);
215
+
216
+ for (uint16_t index = 0 ; index < emberAfEndpointCount (); index ++)
217
+ {
218
+ if (emberAfEndpointIndexIsEnabled (index ))
219
+ {
220
+ EndpointId endpointId = emberAfEndpointFromIndex (index );
221
+
222
+ if (emberAfContainsServer (endpointId, GeneralDiagnostics::Id))
223
+ {
224
+ // If General Diagnostics cluster is implemented on this endpoint
225
+ MatterReportingAttributeChangeCallback (endpointId, GeneralDiagnostics::Id,
226
+ GeneralDiagnostics::Attributes::ActiveHardwareFaults::Id);
227
+
228
+ // Record HardwareFault event
229
+ EventNumber eventNumber;
230
+ DataModel::List<const HardwareFaultType> currentList = DataModel::List<const HardwareFaultType>(
231
+ reinterpret_cast <const HardwareFaultType *>(current.data ()), current.size ());
232
+ DataModel::List<const HardwareFaultType> previousList = DataModel::List<const HardwareFaultType>(
233
+ reinterpret_cast <const HardwareFaultType *>(previous.data ()), previous.size ());
234
+ Events::HardwareFaultChange::Type event{ currentList, previousList };
235
+
236
+ if (CHIP_NO_ERROR != LogEvent (event, endpointId, eventNumber, EventOptions::Type::kUrgent ))
237
+ {
238
+ ChipLogError (Zcl, " GeneralDiagnosticsDelegate: Failed to record HardwareFault event" );
239
+ }
240
+ }
241
+ }
242
+ }
214
243
}
215
244
216
245
// Get called when the Node detects a radio fault has been raised.
@@ -219,6 +248,34 @@ class GeneralDiagnosticsDelegate : public DeviceLayer::ConnectivityManagerDelega
219
248
ChipLogProgress (Zcl, " GeneralDiagnosticsDelegate: OnHardwareFaultsDetected" );
220
249
221
250
ReportAttributeOnAllEndpoints (GeneralDiagnostics::Attributes::ActiveRadioFaults::Id);
251
+
252
+ for (uint16_t index = 0 ; index < emberAfEndpointCount (); index ++)
253
+ {
254
+ if (emberAfEndpointIndexIsEnabled (index ))
255
+ {
256
+ EndpointId endpointId = emberAfEndpointFromIndex (index );
257
+
258
+ if (emberAfContainsServer (endpointId, GeneralDiagnostics::Id))
259
+ {
260
+ // If General Diagnostics cluster is implemented on this endpoint
261
+ MatterReportingAttributeChangeCallback (endpointId, GeneralDiagnostics::Id,
262
+ GeneralDiagnostics::Attributes::ActiveRadioFaults::Id);
263
+
264
+ // Record RadioFault event
265
+ EventNumber eventNumber;
266
+ DataModel::List<const RadioFaultType> currentList = DataModel::List<const RadioFaultType>(
267
+ reinterpret_cast <const RadioFaultType *>(current.data ()), current.size ());
268
+ DataModel::List<const RadioFaultType> previousList = DataModel::List<const RadioFaultType>(
269
+ reinterpret_cast <const RadioFaultType *>(previous.data ()), previous.size ());
270
+ Events::RadioFaultChange::Type event{ currentList, previousList };
271
+
272
+ if (CHIP_NO_ERROR != LogEvent (event, endpointId, eventNumber, EventOptions::Type::kUrgent ))
273
+ {
274
+ ChipLogError (Zcl, " GeneralDiagnosticsDelegate: Failed to record RadioFault event" );
275
+ }
276
+ }
277
+ }
278
+ }
222
279
}
223
280
224
281
// Get called when the Node detects a network fault has been raised.
@@ -227,6 +284,34 @@ class GeneralDiagnosticsDelegate : public DeviceLayer::ConnectivityManagerDelega
227
284
ChipLogProgress (Zcl, " GeneralDiagnosticsDelegate: OnHardwareFaultsDetected" );
228
285
229
286
ReportAttributeOnAllEndpoints (GeneralDiagnostics::Attributes::ActiveNetworkFaults::Id);
287
+
288
+ for (uint16_t index = 0 ; index < emberAfEndpointCount (); index ++)
289
+ {
290
+ if (emberAfEndpointIndexIsEnabled (index ))
291
+ {
292
+ EndpointId endpointId = emberAfEndpointFromIndex (index );
293
+
294
+ if (emberAfContainsServer (endpointId, GeneralDiagnostics::Id))
295
+ {
296
+ // If General Diagnostics cluster is implemented on this endpoint
297
+ MatterReportingAttributeChangeCallback (endpointId, GeneralDiagnostics::Id,
298
+ GeneralDiagnostics::Attributes::ActiveNetworkFaults::Id);
299
+
300
+ // Record NetworkFault event
301
+ EventNumber eventNumber;
302
+ DataModel::List<const NetworkFaultType> currentList = DataModel::List<const NetworkFaultType>(
303
+ reinterpret_cast <const NetworkFaultType *>(current.data ()), current.size ());
304
+ DataModel::List<const NetworkFaultType> previousList = DataModel::List<const NetworkFaultType>(
305
+ reinterpret_cast <const NetworkFaultType *>(previous.data ()), previous.size ());
306
+ Events::NetworkFaultChange::Type event{ currentList, previousList };
307
+
308
+ if (CHIP_NO_ERROR != LogEvent (event, endpointId, eventNumber, EventOptions::Type::kUrgent ))
309
+ {
310
+ ChipLogError (Zcl, " GeneralDiagnosticsDelegate: Failed to record NetworkFault event" );
311
+ }
312
+ }
313
+ }
314
+ }
230
315
}
231
316
};
232
317
0 commit comments