Skip to content

Commit

Permalink
Run Codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
erjiaqing committed Apr 14, 2021
1 parent 7a5acd0 commit 8a823f7
Show file tree
Hide file tree
Showing 11 changed files with 4,925 additions and 3,905 deletions.
2,011 changes: 1,118 additions & 893 deletions examples/all-clusters-app/all-clusters-common/gen/IMClusterCommandHandler.cpp

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -468,8 +468,8 @@
{ 0x0000, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(0) }, /* Descriptor (server): device list */ \
{ 0x0001, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(254) }, /* Descriptor (server): server list */ \
{ 0x0002, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(508) }, /* Descriptor (server): client list */ \
{ 0x0003, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(762) }, /* Descriptor (server): parts list */ \
{ 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* Descriptor (server): cluster revision */ \
{ 0x0003, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(762) }, /* Descriptor (server): parts list */ \
{ 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), \
ZAP_SIMPLE_DEFAULT(3) }, /* Basic (server): cluster revision */ \
{ 0x0000, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), \
Expand Down
486 changes: 269 additions & 217 deletions examples/bridge-app/bridge-common/gen/IMClusterCommandHandler.cpp

Large diffs are not rendered by default.

1,164 changes: 653 additions & 511 deletions examples/chip-tool/gen/IMClusterCommandHandler.cpp

Large diffs are not rendered by default.

486 changes: 269 additions & 217 deletions examples/lighting-app/lighting-common/gen/IMClusterCommandHandler.cpp

Large diffs are not rendered by default.

284 changes: 157 additions & 127 deletions examples/lock-app/lock-common/gen/IMClusterCommandHandler.cpp

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1,907 changes: 1,062 additions & 845 deletions examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp

Large diffs are not rendered by default.

88 changes: 51 additions & 37 deletions examples/window-app/common/gen/IMClusterCommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ namespace clusters {

namespace WindowCovering {

void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv)
{
{
switch (commandId)
switch (aCommandId)
{
case ZCL_WINDOW_COVERING_DOWN_CLOSE_COMMAND_ID: {

Expand All @@ -62,18 +62,18 @@ void DispatchServerCommand(app::Command * command, CommandId commandId, Endpoint
bool percentageLiftValueExists = false;
uint32_t validArgumentCount = 0;

while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR)
{
switch (TLV::TagNumFromTag(dataTlv.GetTag()))
switch (TLV::TagNumFromTag(aDataTlv.GetTag()))
{
case 0:
if (percentageLiftValueExists)
{
ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(dataTlv.GetTag()));
ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag()));
TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT;
break;
}
TLVUnpackError = dataTlv.Get(percentageLiftValue);
TLVUnpackError = aDataTlv.Get(percentageLiftValue);
if (CHIP_NO_ERROR == TLVUnpackError)
{
percentageLiftValueExists = true;
Expand All @@ -88,7 +88,7 @@ void DispatchServerCommand(app::Command * command, CommandId commandId, Endpoint
if (TLVUnpackError != CHIP_NO_ERROR)
{
ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
TLV::TagNumFromTag(dataTlv.GetTag()), TLVUnpackError);
TLV::TagNumFromTag(aDataTlv.GetTag()), TLVUnpackError);
break;
}
}
Expand All @@ -109,10 +109,13 @@ void DispatchServerCommand(app::Command * command, CommandId commandId, Endpoint
// TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
emberAfWindowCoveringClusterWindowCoveringGoToLiftPercentageCallback(percentageLiftValue);
}
else if (1 != validArgumentCount)
else
{
ChipLogProgress(Zcl, "Missing command arguments in TLV data, command requires %d, given %" PRIu32, 1,
validArgumentCount);
apCommandObj->AddStatusCode(nullptr, Protocols::SecureChannel::GeneralStatusCode::kBadRequest,
Protocols::SecureChannel::Id, Protocols::SecureChannel::kProtocolCodeGeneralFailure);
ChipLogProgress(
Zcl, "Failed to dispatch command, %d/%" PRIu32 " arguments parsed, TLVError=%" PRIu32 ", UnpackError=%" PRIu32,
1, validArgumentCount, TLVError, TLVUnpackError);
}
break;
}
Expand All @@ -126,18 +129,18 @@ void DispatchServerCommand(app::Command * command, CommandId commandId, Endpoint
bool liftValueExists = false;
uint32_t validArgumentCount = 0;

while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR)
{
switch (TLV::TagNumFromTag(dataTlv.GetTag()))
switch (TLV::TagNumFromTag(aDataTlv.GetTag()))
{
case 0:
if (liftValueExists)
{
ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(dataTlv.GetTag()));
ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag()));
TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT;
break;
}
TLVUnpackError = dataTlv.Get(liftValue);
TLVUnpackError = aDataTlv.Get(liftValue);
if (CHIP_NO_ERROR == TLVUnpackError)
{
liftValueExists = true;
Expand All @@ -152,7 +155,7 @@ void DispatchServerCommand(app::Command * command, CommandId commandId, Endpoint
if (TLVUnpackError != CHIP_NO_ERROR)
{
ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
TLV::TagNumFromTag(dataTlv.GetTag()), TLVUnpackError);
TLV::TagNumFromTag(aDataTlv.GetTag()), TLVUnpackError);
break;
}
}
Expand All @@ -173,10 +176,13 @@ void DispatchServerCommand(app::Command * command, CommandId commandId, Endpoint
// TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
emberAfWindowCoveringClusterWindowCoveringGoToLiftValueCallback(liftValue);
}
else if (1 != validArgumentCount)
else
{
ChipLogProgress(Zcl, "Missing command arguments in TLV data, command requires %d, given %" PRIu32, 1,
validArgumentCount);
apCommandObj->AddStatusCode(nullptr, Protocols::SecureChannel::GeneralStatusCode::kBadRequest,
Protocols::SecureChannel::Id, Protocols::SecureChannel::kProtocolCodeGeneralFailure);
ChipLogProgress(
Zcl, "Failed to dispatch command, %d/%" PRIu32 " arguments parsed, TLVError=%" PRIu32 ", UnpackError=%" PRIu32,
1, validArgumentCount, TLVError, TLVUnpackError);
}
break;
}
Expand All @@ -190,18 +196,18 @@ void DispatchServerCommand(app::Command * command, CommandId commandId, Endpoint
bool percentageTiltValueExists = false;
uint32_t validArgumentCount = 0;

while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR)
{
switch (TLV::TagNumFromTag(dataTlv.GetTag()))
switch (TLV::TagNumFromTag(aDataTlv.GetTag()))
{
case 0:
if (percentageTiltValueExists)
{
ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(dataTlv.GetTag()));
ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag()));
TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT;
break;
}
TLVUnpackError = dataTlv.Get(percentageTiltValue);
TLVUnpackError = aDataTlv.Get(percentageTiltValue);
if (CHIP_NO_ERROR == TLVUnpackError)
{
percentageTiltValueExists = true;
Expand All @@ -216,7 +222,7 @@ void DispatchServerCommand(app::Command * command, CommandId commandId, Endpoint
if (TLVUnpackError != CHIP_NO_ERROR)
{
ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
TLV::TagNumFromTag(dataTlv.GetTag()), TLVUnpackError);
TLV::TagNumFromTag(aDataTlv.GetTag()), TLVUnpackError);
break;
}
}
Expand All @@ -237,10 +243,13 @@ void DispatchServerCommand(app::Command * command, CommandId commandId, Endpoint
// TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
emberAfWindowCoveringClusterWindowCoveringGoToTiltPercentageCallback(percentageTiltValue);
}
else if (1 != validArgumentCount)
else
{
ChipLogProgress(Zcl, "Missing command arguments in TLV data, command requires %d, given %" PRIu32, 1,
validArgumentCount);
apCommandObj->AddStatusCode(nullptr, Protocols::SecureChannel::GeneralStatusCode::kBadRequest,
Protocols::SecureChannel::Id, Protocols::SecureChannel::kProtocolCodeGeneralFailure);
ChipLogProgress(
Zcl, "Failed to dispatch command, %d/%" PRIu32 " arguments parsed, TLVError=%" PRIu32 ", UnpackError=%" PRIu32,
1, validArgumentCount, TLVError, TLVUnpackError);
}
break;
}
Expand All @@ -254,18 +263,18 @@ void DispatchServerCommand(app::Command * command, CommandId commandId, Endpoint
bool tiltValueExists = false;
uint32_t validArgumentCount = 0;

while ((TLVError = dataTlv.Next()) == CHIP_NO_ERROR)
while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR)
{
switch (TLV::TagNumFromTag(dataTlv.GetTag()))
switch (TLV::TagNumFromTag(aDataTlv.GetTag()))
{
case 0:
if (tiltValueExists)
{
ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(dataTlv.GetTag()));
ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag()));
TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT;
break;
}
TLVUnpackError = dataTlv.Get(tiltValue);
TLVUnpackError = aDataTlv.Get(tiltValue);
if (CHIP_NO_ERROR == TLVUnpackError)
{
tiltValueExists = true;
Expand All @@ -280,7 +289,7 @@ void DispatchServerCommand(app::Command * command, CommandId commandId, Endpoint
if (TLVUnpackError != CHIP_NO_ERROR)
{
ChipLogProgress(Zcl, "Failed to decode TLV data with tag %" PRIx32 ": %" PRId32,
TLV::TagNumFromTag(dataTlv.GetTag()), TLVUnpackError);
TLV::TagNumFromTag(aDataTlv.GetTag()), TLVUnpackError);
break;
}
}
Expand All @@ -301,10 +310,13 @@ void DispatchServerCommand(app::Command * command, CommandId commandId, Endpoint
// TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
emberAfWindowCoveringClusterWindowCoveringGoToTiltValueCallback(tiltValue);
}
else if (1 != validArgumentCount)
else
{
ChipLogProgress(Zcl, "Missing command arguments in TLV data, command requires %d, given %" PRIu32, 1,
validArgumentCount);
apCommandObj->AddStatusCode(nullptr, Protocols::SecureChannel::GeneralStatusCode::kBadRequest,
Protocols::SecureChannel::Id, Protocols::SecureChannel::kProtocolCodeGeneralFailure);
ChipLogProgress(
Zcl, "Failed to dispatch command, %d/%" PRIu32 " arguments parsed, TLVError=%" PRIu32 ", UnpackError=%" PRIu32,
1, validArgumentCount, TLVError, TLVUnpackError);
}
break;
}
Expand All @@ -322,8 +334,9 @@ void DispatchServerCommand(app::Command * command, CommandId commandId, Endpoint
}
default: {
// Unrecognized command ID, error status will apply.
// TODO: Encode response for command not found
ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_WINDOW_COVERING_CLUSTER_ID);
apCommandObj->AddStatusCode(nullptr, Protocols::SecureChannel::GeneralStatusCode::kNotFound,
Protocols::SecureChannel::Id, Protocols::SecureChannel::kProtocolCodeGeneralFailure);
ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, aCommandId, ZCL_WINDOW_COVERING_CLUSTER_ID);
break;
}
}
Expand All @@ -347,7 +360,8 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC
break;
default:
// Unrecognized cluster ID, error status will apply.
// TODO: Encode response for Cluster not found
apCommandObj->AddStatusCode(nullptr, Protocols::SecureChannel::GeneralStatusCode::kNotFound, Protocols::SecureChannel::Id,
Protocols::SecureChannel::kProtocolCodeGeneralFailure);
ChipLogError(Zcl, "Unknown cluster %" PRIx16, aClusterId);
break;
}
Expand Down
Loading

0 comments on commit 8a823f7

Please sign in to comment.