Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reporting relevant attribute change when various faults are detected #12116

Merged
merged 3 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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