Skip to content

Commit

Permalink
Update gen folders
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca committed Jul 23, 2021
1 parent 05ae96f commit 1164000
Show file tree
Hide file tree
Showing 16 changed files with 585 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6977,6 +6977,67 @@ void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aComman

} // namespace Scenes

namespace SoftwareDiagnostics {

void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId,
TLV::TLVReader & aDataTlv)
{
// We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV
// When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error.
// Any error value TLVUnpackError means we have received an illegal value.
// The following variables are used for all commands to save code size.
CHIP_ERROR TLVError = CHIP_NO_ERROR;
CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR;
uint32_t validArgumentCount = 0;
uint32_t expectArgumentCount = 0;
uint32_t currentDecodeTagId = 0;
bool wasHandled = false;
{
switch (aCommandId)
{
case Clusters::SoftwareDiagnostics::Commands::Ids::ResetWatermarks: {

// TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
wasHandled = emberAfSoftwareDiagnosticsClusterResetWatermarksCallback(apCommandObj);
break;
}
default: {
// Unrecognized command ID, error status will apply.
chip::app::CommandPathParams returnStatusParam = { aEndpointId,
0, // GroupId
Clusters::SoftwareDiagnostics::Id, aCommandId,
(chip::app::CommandPathFlags::kEndpointIdValid) };
apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound,
Protocols::SecureChannel::Id,
Protocols::InteractionModel::ProtocolCode::UnsupportedCommand);
ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::SoftwareDiagnostics::Id);
return;
}
}
}

if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled)
{
chip::app::CommandPathParams returnStatusParam = { aEndpointId,
0, // GroupId
Clusters::SoftwareDiagnostics::Id, aCommandId,
(chip::app::CommandPathFlags::kEndpointIdValid) };
apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest,
Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand);
ChipLogProgress(Zcl,
"Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT
", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32,
validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError),
ChipError::FormatError(TLVUnpackError), currentDecodeTagId);
// A command with no arguments would never write currentDecodeTagId. If
// progress logging is also disabled, it would look unused. Silence that
// warning.
UNUSED_VAR(currentDecodeTagId);
}
}

} // namespace SoftwareDiagnostics

namespace TestCluster {

void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId,
Expand Down Expand Up @@ -7050,6 +7111,129 @@ void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aComman

} // namespace TestCluster

namespace ThreadNetworkDiagnostics {

void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId,
TLV::TLVReader & aDataTlv)
{
// We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV
// When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error.
// Any error value TLVUnpackError means we have received an illegal value.
// The following variables are used for all commands to save code size.
CHIP_ERROR TLVError = CHIP_NO_ERROR;
CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR;
uint32_t validArgumentCount = 0;
uint32_t expectArgumentCount = 0;
uint32_t currentDecodeTagId = 0;
bool wasHandled = false;
{
switch (aCommandId)
{
case Clusters::ThreadNetworkDiagnostics::Commands::Ids::ResetCounts: {

// TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
wasHandled = emberAfThreadNetworkDiagnosticsClusterResetCountsCallback(apCommandObj);
break;
}
default: {
// Unrecognized command ID, error status will apply.
chip::app::CommandPathParams returnStatusParam = { aEndpointId,
0, // GroupId
Clusters::ThreadNetworkDiagnostics::Id, aCommandId,
(chip::app::CommandPathFlags::kEndpointIdValid) };
apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound,
Protocols::SecureChannel::Id,
Protocols::InteractionModel::ProtocolCode::UnsupportedCommand);
ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId,
Clusters::ThreadNetworkDiagnostics::Id);
return;
}
}
}

if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled)
{
chip::app::CommandPathParams returnStatusParam = { aEndpointId,
0, // GroupId
Clusters::ThreadNetworkDiagnostics::Id, aCommandId,
(chip::app::CommandPathFlags::kEndpointIdValid) };
apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest,
Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand);
ChipLogProgress(Zcl,
"Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT
", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32,
validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError),
ChipError::FormatError(TLVUnpackError), currentDecodeTagId);
// A command with no arguments would never write currentDecodeTagId. If
// progress logging is also disabled, it would look unused. Silence that
// warning.
UNUSED_VAR(currentDecodeTagId);
}
}

} // namespace ThreadNetworkDiagnostics

namespace WiFiNetworkDiagnostics {

void DispatchServerCommand(app::CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId,
TLV::TLVReader & aDataTlv)
{
// We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV
// When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error.
// Any error value TLVUnpackError means we have received an illegal value.
// The following variables are used for all commands to save code size.
CHIP_ERROR TLVError = CHIP_NO_ERROR;
CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR;
uint32_t validArgumentCount = 0;
uint32_t expectArgumentCount = 0;
uint32_t currentDecodeTagId = 0;
bool wasHandled = false;
{
switch (aCommandId)
{
case Clusters::WiFiNetworkDiagnostics::Commands::Ids::ResetCounts: {

// TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
wasHandled = emberAfWiFiNetworkDiagnosticsClusterResetCountsCallback(apCommandObj);
break;
}
default: {
// Unrecognized command ID, error status will apply.
chip::app::CommandPathParams returnStatusParam = { aEndpointId,
0, // GroupId
Clusters::WiFiNetworkDiagnostics::Id, aCommandId,
(chip::app::CommandPathFlags::kEndpointIdValid) };
apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound,
Protocols::SecureChannel::Id,
Protocols::InteractionModel::ProtocolCode::UnsupportedCommand);
ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::WiFiNetworkDiagnostics::Id);
return;
}
}
}

if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled)
{
chip::app::CommandPathParams returnStatusParam = { aEndpointId,
0, // GroupId
Clusters::WiFiNetworkDiagnostics::Id, aCommandId,
(chip::app::CommandPathFlags::kEndpointIdValid) };
apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest,
Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand);
ChipLogProgress(Zcl,
"Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT
", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32,
validArgumentCount, expectArgumentCount, ChipError::FormatError(TLVError),
ChipError::FormatError(TLVUnpackError), currentDecodeTagId);
// A command with no arguments would never write currentDecodeTagId. If
// progress logging is also disabled, it would look unused. Silence that
// warning.
UNUSED_VAR(currentDecodeTagId);
}
}

} // namespace WiFiNetworkDiagnostics

} // namespace clusters

void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aCommandId, chip::EndpointId aEndPointId,
Expand Down Expand Up @@ -7116,9 +7300,18 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC
case Clusters::Scenes::Id:
clusters::Scenes::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
break;
case Clusters::SoftwareDiagnostics::Id:
clusters::SoftwareDiagnostics::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
break;
case Clusters::TestCluster::Id:
clusters::TestCluster::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
break;
case Clusters::ThreadNetworkDiagnostics::Id:
clusters::ThreadNetworkDiagnostics::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
break;
case Clusters::WiFiNetworkDiagnostics::Id:
clusters::WiFiNetworkDiagnostics::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
break;
default:
// Unrecognized cluster ID, error status will apply.
chip::app::CommandPathParams returnStatusParam = { aEndPointId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2753,7 +2753,7 @@

// Array of EmberAfCommandMetadata structs.
#define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask
#define EMBER_AF_GENERATED_COMMAND_COUNT (206)
#define EMBER_AF_GENERATED_COMMAND_COUNT (208)
#define GENERATED_COMMANDS \
{ \
\
Expand Down Expand Up @@ -2804,6 +2804,12 @@
/* Endpoint: 0, Cluster: Software Diagnostics (server) */ \
{ 0x0034, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* ResetWatermarks */ \
\
/* Endpoint: 0, Cluster: Thread Network Diagnostics (server) */ \
{ 0x0035, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* ResetCounts */ \
\
/* Endpoint: 0, Cluster: WiFi Network Diagnostics (server) */ \
{ 0x0036, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* ResetCounts */ \
\
/* Endpoint: 0, Cluster: Ethernet Network Diagnostics (server) */ \
{ 0x0037, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* ResetCounts */ \
\
Expand Down
38 changes: 34 additions & 4 deletions examples/chip-tool/commands/clusters/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -21595,6 +21595,7 @@ class ReadWakeOnLanClusterRevision : public ModelCommand
| Cluster WiFiNetworkDiagnostics | 0x0036 |
|------------------------------------------------------------------------------|
| Commands: | |
| * ResetCounts | 0x00 |
|------------------------------------------------------------------------------|
| Attributes: | |
| * Bssid | 0x0000 |
Expand All @@ -21605,6 +21606,35 @@ class ReadWakeOnLanClusterRevision : public ModelCommand
| * ClusterRevision | 0xFFFD |
\*----------------------------------------------------------------------------*/

/*
* Command ResetCounts
*/
class WiFiNetworkDiagnosticsResetCounts : public ModelCommand
{
public:
WiFiNetworkDiagnosticsResetCounts() : ModelCommand("reset-counts") { ModelCommand::AddArguments(); }
~WiFiNetworkDiagnosticsResetCounts()
{
delete onSuccessCallback;
delete onFailureCallback;
}

CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override
{
ChipLogProgress(chipTool, "Sending cluster (0x0036) command (0x00) on endpoint %" PRIu8, endpointId);

chip::Controller::WiFiNetworkDiagnosticsCluster cluster;
cluster.Associate(device, endpointId);
return cluster.ResetCounts(onSuccessCallback->Cancel(), onFailureCallback->Cancel());
}

private:
chip::Callback::Callback<DefaultSuccessCallback> * onSuccessCallback =
new chip::Callback::Callback<DefaultSuccessCallback>(OnDefaultSuccessResponse, this);
chip::Callback::Callback<DefaultFailureCallback> * onFailureCallback =
new chip::Callback::Callback<DefaultFailureCallback>(OnDefaultFailureResponse, this);
};

/*
* Discover Attributes
*/
Expand Down Expand Up @@ -24095,10 +24125,10 @@ void registerClusterWiFiNetworkDiagnostics(Commands & commands)
const char * clusterName = "WiFiNetworkDiagnostics";

commands_list clusterCommands = {
make_unique<DiscoverWiFiNetworkDiagnosticsAttributes>(), make_unique<ReadWiFiNetworkDiagnosticsBssid>(),
make_unique<ReadWiFiNetworkDiagnosticsSecurityType>(), make_unique<ReadWiFiNetworkDiagnosticsWiFiVersion>(),
make_unique<ReadWiFiNetworkDiagnosticsChannelNumber>(), make_unique<ReadWiFiNetworkDiagnosticsRssi>(),
make_unique<ReadWiFiNetworkDiagnosticsClusterRevision>(),
make_unique<WiFiNetworkDiagnosticsResetCounts>(), make_unique<DiscoverWiFiNetworkDiagnosticsAttributes>(),
make_unique<ReadWiFiNetworkDiagnosticsBssid>(), make_unique<ReadWiFiNetworkDiagnosticsSecurityType>(),
make_unique<ReadWiFiNetworkDiagnosticsWiFiVersion>(), make_unique<ReadWiFiNetworkDiagnosticsChannelNumber>(),
make_unique<ReadWiFiNetworkDiagnosticsRssi>(), make_unique<ReadWiFiNetworkDiagnosticsClusterRevision>(),
};

commands.Register(clusterName, clusterCommands);
Expand Down
Loading

0 comments on commit 1164000

Please sign in to comment.