@@ -275,22 +275,64 @@ void PlatformManagerImpl::HandleGeneralFault(uint32_t EventId)
275
275
{
276
276
GeneralDiagnosticsDelegate * delegate = GetDiagnosticDataProvider ().GetGeneralDiagnosticsDelegate ();
277
277
278
- if (delegate != nullptr )
278
+ if (delegate == nullptr )
279
+ {
280
+ ChipLogError (DeviceLayer, " No delegate registered to handle General Diagnostics event" );
281
+ return ;
282
+ }
283
+
284
+ if (EventId == GeneralDiagnostics::Events::HardwareFaultChange::kEventId )
285
+ {
286
+ GeneralFaults<kMaxHardwareFaults > previous;
287
+ GeneralFaults<kMaxHardwareFaults > current;
288
+
289
+ #if CHIP_CONFIG_TEST
290
+ // On Linux Simulation, set following hardware faults statically.
291
+ ReturnOnFailure (previous.add (EMBER_ZCL_HARDWARE_FAULT_TYPE_RADIO));
292
+ ReturnOnFailure (previous.add (EMBER_ZCL_HARDWARE_FAULT_TYPE_POWER_SOURCE));
293
+
294
+ ReturnOnFailure (current.add (EMBER_ZCL_HARDWARE_FAULT_TYPE_RADIO));
295
+ ReturnOnFailure (current.add (EMBER_ZCL_HARDWARE_FAULT_TYPE_SENSOR));
296
+ ReturnOnFailure (current.add (EMBER_ZCL_HARDWARE_FAULT_TYPE_POWER_SOURCE));
297
+ ReturnOnFailure (current.add (EMBER_ZCL_HARDWARE_FAULT_TYPE_USER_INTERFACE_FAULT));
298
+ #endif
299
+ delegate->OnHardwareFaultsDetected (previous, current);
300
+ }
301
+ else if (EventId == GeneralDiagnostics::Events::RadioFaultChange::kEventId )
302
+ {
303
+ GeneralFaults<kMaxRadioFaults > previous;
304
+ GeneralFaults<kMaxRadioFaults > current;
305
+
306
+ #if CHIP_CONFIG_TEST
307
+ // On Linux Simulation, set following radio faults statically.
308
+ ReturnOnFailure (previous.add (EMBER_ZCL_RADIO_FAULT_TYPE_WI_FI_FAULT));
309
+ ReturnOnFailure (previous.add (EMBER_ZCL_RADIO_FAULT_TYPE_THREAD_FAULT));
310
+
311
+ ReturnOnFailure (current.add (EMBER_ZCL_RADIO_FAULT_TYPE_WI_FI_FAULT));
312
+ ReturnOnFailure (current.add (EMBER_ZCL_RADIO_FAULT_TYPE_CELLULAR_FAULT));
313
+ ReturnOnFailure (current.add (EMBER_ZCL_RADIO_FAULT_TYPE_THREAD_FAULT));
314
+ ReturnOnFailure (current.add (EMBER_ZCL_RADIO_FAULT_TYPE_NFC_FAULT));
315
+ #endif
316
+ delegate->OnRadioFaultsDetected (previous, current);
317
+ }
318
+ else if (EventId == GeneralDiagnostics::Events::NetworkFaultChange::kEventId )
319
+ {
320
+ GeneralFaults<kMaxNetworkFaults > previous;
321
+ GeneralFaults<kMaxNetworkFaults > current;
322
+
323
+ #if CHIP_CONFIG_TEST
324
+ // On Linux Simulation, set following radio faults statically.
325
+ ReturnOnFailure (previous.add (EMBER_ZCL_NETWORK_FAULT_TYPE_HARDWARE_FAILURE));
326
+ ReturnOnFailure (previous.add (EMBER_ZCL_NETWORK_FAULT_TYPE_NETWORK_JAMMED));
327
+
328
+ ReturnOnFailure (current.add (EMBER_ZCL_NETWORK_FAULT_TYPE_HARDWARE_FAILURE));
329
+ ReturnOnFailure (current.add (EMBER_ZCL_NETWORK_FAULT_TYPE_NETWORK_JAMMED));
330
+ ReturnOnFailure (current.add (EMBER_ZCL_NETWORK_FAULT_TYPE_CONNECTION_FAILED));
331
+ #endif
332
+ delegate->OnNetworkFaultsDetected (previous, current);
333
+ }
334
+ else
279
335
{
280
- switch (EventId)
281
- {
282
- case GeneralDiagnostics::Events::HardwareFaultChange::kEventId :
283
- delegate->OnHardwareFaultsDetected ();
284
- break ;
285
- case GeneralDiagnostics::Events::RadioFaultChange::kEventId :
286
- delegate->OnRadioFaultsDetected ();
287
- break ;
288
- case GeneralDiagnostics::Events::NetworkFaultChange::kEventId :
289
- delegate->OnNetworkFaultsDetected ();
290
- break ;
291
- default :
292
- break ;
293
- }
294
336
}
295
337
}
296
338
0 commit comments