Skip to content

Commit

Permalink
Implement ResetCounts command for Thread/WiFi/Ethernet Network Diagno…
Browse files Browse the repository at this point in the history
…stics Cluster (#8679)
  • Loading branch information
yufengwangca authored and pull[bot] committed Aug 28, 2021
1 parent 2575a07 commit 5402374
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,29 @@
*/

#include <app/CommandHandler.h>
#include <app/common/gen/attributes/Accessors.h>
#include <app/util/af.h>

using namespace chip::app::Clusters;

bool emberAfEthernetNetworkDiagnosticsClusterResetCountsCallback(chip::EndpointId endpoint, chip::app::CommandHandler * commandObj)
{
// TODO: Implement the ResetCounts in the platform layer.
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
EmberAfStatus status = EthernetNetworkDiagnostics::Attributes::SetPacketRxCount(endpoint, 0);
VerifyOrExit(status == EMBER_ZCL_STATUS_SUCCESS, ChipLogError(Zcl, "Failed to reset PacketRxCount attribute"));

status = EthernetNetworkDiagnostics::Attributes::SetPacketTxCount(endpoint, 0);
VerifyOrExit(status == EMBER_ZCL_STATUS_SUCCESS, ChipLogError(Zcl, "Failed to reset PacketTxCount attribute"));

status = EthernetNetworkDiagnostics::Attributes::SetTxErrCount(endpoint, 0);
VerifyOrExit(status == EMBER_ZCL_STATUS_SUCCESS, ChipLogError(Zcl, "Failed to reset TxErrCount attribute"));

status = EthernetNetworkDiagnostics::Attributes::SetCollisionCount(endpoint, 0);
VerifyOrExit(status == EMBER_ZCL_STATUS_SUCCESS, ChipLogError(Zcl, "Failed to reset CollisionCount attribute"));

status = EthernetNetworkDiagnostics::Attributes::SetOverrunCount(endpoint, 0);
VerifyOrExit(status == EMBER_ZCL_STATUS_SUCCESS, ChipLogError(Zcl, "Failed to reset OverrunCount attribute"));

exit:
emberAfSendImmediateDefaultResponse(status);
return true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@
*/

#include <app/CommandHandler.h>
#include <app/common/gen/attributes/Accessors.h>
#include <app/util/af.h>

using namespace chip::app::Clusters;

bool emberAfThreadNetworkDiagnosticsClusterResetCountsCallback(chip::EndpointId endpoint, chip::app::CommandHandler * commandObj)
{
// TODO: Implement the ResetCounts in the platform layer.
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
EmberAfStatus status = ThreadNetworkDiagnostics::Attributes::SetOverrunCount(endpoint, 0);
if (status != EMBER_ZCL_STATUS_SUCCESS)
{
ChipLogError(Zcl, "Failed to reset OverrunCount attribute");
}

emberAfSendImmediateDefaultResponse(status);
return true;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,36 @@
*/

#include <app/CommandHandler.h>
#include <app/common/gen/attributes/Accessors.h>
#include <app/util/af.h>

using namespace chip::app::Clusters;

bool emberAfWiFiNetworkDiagnosticsClusterResetCountsCallback(chip::EndpointId endpoint, chip::app::CommandHandler * commandObj)
{
// TODO: Implement the ResetCounts in the platform layer.
EmberAfStatus status = EMBER_ZCL_STATUS_SUCCESS;
EmberAfStatus status = WiFiNetworkDiagnostics::Attributes::SetBeaconLostCount(endpoint, 0);
VerifyOrExit(status == EMBER_ZCL_STATUS_SUCCESS, ChipLogError(Zcl, "Failed to reset BeaconLostCount attribute"));

status = WiFiNetworkDiagnostics::Attributes::SetBeaconRxCount(endpoint, 0);
VerifyOrExit(status == EMBER_ZCL_STATUS_SUCCESS, ChipLogError(Zcl, "Failed to reset BeaconRxCount attribute"));

status = WiFiNetworkDiagnostics::Attributes::SetPacketMulticastRxCount(endpoint, 0);
VerifyOrExit(status == EMBER_ZCL_STATUS_SUCCESS, ChipLogError(Zcl, "Failed to reset PacketMulticastRxCount attribute"));

status = WiFiNetworkDiagnostics::Attributes::SetPacketMulticastTxCount(endpoint, 0);
VerifyOrExit(status == EMBER_ZCL_STATUS_SUCCESS, ChipLogError(Zcl, "Failed to reset PacketMulticastTxCount attribute"));

status = WiFiNetworkDiagnostics::Attributes::SetPacketUnicastRxCount(endpoint, 0);
VerifyOrExit(status == EMBER_ZCL_STATUS_SUCCESS, ChipLogError(Zcl, "Failed to reset PacketUnicastRxCount attribute"));

status = WiFiNetworkDiagnostics::Attributes::SetPacketUnicastTxCount(endpoint, 0);
VerifyOrExit(status == EMBER_ZCL_STATUS_SUCCESS, ChipLogError(Zcl, "Failed to reset PacketUnicastTxCount attribute"));

status = WiFiNetworkDiagnostics::Attributes::SetOverrunCount(endpoint, 0);
VerifyOrExit(status == EMBER_ZCL_STATUS_SUCCESS, ChipLogError(Zcl, "Failed to reset OverrunCount attribute"));

exit:
emberAfSendImmediateDefaultResponse(status);

return true;
}

0 comments on commit 5402374

Please sign in to comment.