Skip to content

Commit

Permalink
Reporting relevant attribute change when various faults are detected (#…
Browse files Browse the repository at this point in the history
…12116)

* Reporting relevant attribute change when various faults are detected

* Update src/app/clusters/general_diagnostics_server/general_diagnostics_server.cpp

Co-authored-by: Michael Sandstedt <michael.sandstedt@gmail.com>

* Update src/app/clusters/general_diagnostics_server/general_diagnostics_server.cpp

Co-authored-by: Michael Sandstedt <michael.sandstedt@gmail.com>

Co-authored-by: Michael Sandstedt <michael.sandstedt@gmail.com>
  • Loading branch information
2 people authored and pull[bot] committed Feb 17, 2022
1 parent c78af6e commit 4503597
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,69 @@ class GeneralDiagnosticDelegate : public DeviceLayer::ConnectivityManagerDelegat
}
}
}

// Get called when the Node detects a hardware fault has been raised.
void OnHardwareFaultsDetected() override
{
ChipLogProgress(Zcl, "GeneralDiagnosticDelegate: OnHardwareFaultsDetected");

for (uint16_t index = 0; index < emberAfEndpointCount(); index++)
{
if (emberAfEndpointIndexIsEnabled(index))
{
EndpointId endpointId = emberAfEndpointFromIndex(index);

if (emberAfContainsServer(endpointId, GeneralDiagnostics::Id))
{
// If General Diagnostics cluster is implemented on this endpoint
MatterReportingAttributeChangeCallback(endpointId, GeneralDiagnostics::Id,
GeneralDiagnostics::Attributes::ActiveHardwareFaults::Id);
}
}
}
}

// Get called when the Node detects a radio fault has been raised.
void OnRadioFaultsDetected() override
{
ChipLogProgress(Zcl, "GeneralDiagnosticDelegate: OnHardwareFaultsDetected");

for (uint16_t index = 0; index < emberAfEndpointCount(); index++)
{
if (emberAfEndpointIndexIsEnabled(index))
{
EndpointId endpointId = emberAfEndpointFromIndex(index);

if (emberAfContainsServer(endpointId, GeneralDiagnostics::Id))
{
// If General Diagnostics cluster is implemented on this endpoint
MatterReportingAttributeChangeCallback(endpointId, GeneralDiagnostics::Id,
GeneralDiagnostics::Attributes::ActiveRadioFaults::Id);
}
}
}
}

// Get called when the Node detects a network fault has been raised.
void OnNetworkFaultsDetected() override
{
ChipLogProgress(Zcl, "GeneralDiagnosticDelegate: OnHardwareFaultsDetected");

for (uint16_t index = 0; index < emberAfEndpointCount(); index++)
{
if (emberAfEndpointIndexIsEnabled(index))
{
EndpointId endpointId = emberAfEndpointFromIndex(index);

if (emberAfContainsServer(endpointId, GeneralDiagnostics::Id))
{
// If General Diagnostics cluster is implemented on this endpoint
MatterReportingAttributeChangeCallback(endpointId, GeneralDiagnostics::Id,
GeneralDiagnostics::Attributes::ActiveNetworkFaults::Id);
}
}
}
}
};

GeneralDiagnosticDelegate gDiagnosticDelegate;
Expand Down
20 changes: 19 additions & 1 deletion src/include/platform/DiagnosticDataProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,27 @@ class DiagnosticsDelegate

/**
* @brief
* Called after the current device is rebooted
* Called after the current device is rebooted.
*/
virtual void OnDeviceRebooted() {}

/**
* @brief
* Called when the Node detects a hardware fault has been raised.
*/
virtual void OnHardwareFaultsDetected() {}

/**
* @brief
* Called when the Node detects a radio fault has been raised.
*/
virtual void OnRadioFaultsDetected() {}

/**
* @brief
* Called when the Node detects a network fault has been raised.
*/
virtual void OnNetworkFaultsDetected() {}
};

/**
Expand Down

0 comments on commit 4503597

Please sign in to comment.