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 f831261 commit 3048cb0
Show file tree
Hide file tree
Showing 12 changed files with 1,629 additions and 4,840 deletions.
1,467 changes: 403 additions & 1,064 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 @@ -592,8 +592,8 @@
{ 0x0001, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* Application Basic (server): vendor id */ \
{ 0x0002, ZAP_TYPE(OCTET_STRING), 32, 0, \
ZAP_LONG_DEFAULTS_INDEX(1570) }, /* Application Basic (server): application name */ \
{ 0x0003, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* Application Basic (server): product id */ \
{ 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* Application Basic (server): cluster revision */ \
{ 0x0003, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* Application Basic (server): product id */ \
{ 0x0005, ZAP_TYPE(OCTET_STRING), 32, 0, \
ZAP_LONG_DEFAULTS_INDEX(1602) }, /* Application Basic (server): application id */ \
{ 0x0006, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* Application Basic (server): catalog vendor id */ \
Expand Down
333 changes: 90 additions & 243 deletions examples/bridge-app/bridge-common/gen/IMClusterCommandHandler.cpp

Large diffs are not rendered by default.

879 changes: 198 additions & 681 deletions examples/chip-tool/gen/IMClusterCommandHandler.cpp

Large diffs are not rendered by default.

333 changes: 90 additions & 243 deletions examples/lighting-app/lighting-common/gen/IMClusterCommandHandler.cpp

Large diffs are not rendered by default.

194 changes: 57 additions & 137 deletions examples/lock-app/lock-common/gen/IMClusterCommandHandler.cpp

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1,394 changes: 362 additions & 1,032 deletions examples/tv-app/tv-common/gen/IMClusterCommandHandler.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/tv-app/tv-common/gen/endpoint_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,8 @@
{ 0x0001, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* Application Basic (server): vendor id */ \
{ 0x0002, ZAP_TYPE(OCTET_STRING), 32, 0, \
ZAP_LONG_DEFAULTS_INDEX(538) }, /* Application Basic (server): application name */ \
{ 0x0003, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* Application Basic (server): product id */ \
{ 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* Application Basic (server): cluster revision */ \
{ 0x0003, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* Application Basic (server): product id */ \
{ 0x0005, ZAP_TYPE(OCTET_STRING), 32, 0, \
ZAP_LONG_DEFAULTS_INDEX(570) }, /* Application Basic (server): application id */ \
{ 0x0006, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* Application Basic (server): catalog vendor id */ \
Expand Down
90 changes: 29 additions & 61 deletions examples/window-app/common/gen/IMClusterCommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,28 @@ namespace WindowCovering {

void DispatchServerCommand(app::Command * 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;
{
switch (aCommandId)
{
case ZCL_WINDOW_COVERING_DOWN_CLOSE_COMMAND_ID: {

// TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
emberAfWindowCoveringClusterWindowCoveringDownCloseCallback();
return;
break;
}
case ZCL_WINDOW_COVERING_GO_TO_LIFT_PERCENTAGE_COMMAND_ID: {
// 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.
CHIP_ERROR TLVError = CHIP_NO_ERROR;
CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR;
expectArgumentCount = 1;
uint8_t percentageLiftValue;
bool argExists[1];
uint32_t validArgumentCount = 0;

memset(argExists, 0, sizeof argExists);

Expand Down Expand Up @@ -115,31 +119,18 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En
ChipLogProgress(Zcl, "Failed to decode TLV data: %" PRId32, TLVError);
}

// TODO(#5590) We should encode a response of status code for invalid TLV.
if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount)
{
// TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
emberAfWindowCoveringClusterWindowCoveringGoToLiftPercentageCallback(percentageLiftValue);
}
else
{
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);
return;
}
break;
}
case ZCL_WINDOW_COVERING_GO_TO_LIFT_VALUE_COMMAND_ID: {
// 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.
CHIP_ERROR TLVError = CHIP_NO_ERROR;
CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR;
expectArgumentCount = 1;
uint16_t liftValue;
bool argExists[1];
uint32_t validArgumentCount = 0;

memset(argExists, 0, sizeof argExists);

Expand Down Expand Up @@ -194,31 +185,18 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En
ChipLogProgress(Zcl, "Failed to decode TLV data: %" PRId32, TLVError);
}

// TODO(#5590) We should encode a response of status code for invalid TLV.
if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount)
{
// TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
emberAfWindowCoveringClusterWindowCoveringGoToLiftValueCallback(liftValue);
}
else
{
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);
return;
}
break;
}
case ZCL_WINDOW_COVERING_GO_TO_TILT_PERCENTAGE_COMMAND_ID: {
// 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.
CHIP_ERROR TLVError = CHIP_NO_ERROR;
CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR;
expectArgumentCount = 1;
uint8_t percentageTiltValue;
bool argExists[1];
uint32_t validArgumentCount = 0;

memset(argExists, 0, sizeof argExists);

Expand Down Expand Up @@ -273,31 +251,18 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En
ChipLogProgress(Zcl, "Failed to decode TLV data: %" PRId32, TLVError);
}

// TODO(#5590) We should encode a response of status code for invalid TLV.
if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount)
{
// TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
emberAfWindowCoveringClusterWindowCoveringGoToTiltPercentageCallback(percentageTiltValue);
}
else
{
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);
return;
}
break;
}
case ZCL_WINDOW_COVERING_GO_TO_TILT_VALUE_COMMAND_ID: {
// 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.
CHIP_ERROR TLVError = CHIP_NO_ERROR;
CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR;
expectArgumentCount = 1;
uint16_t tiltValue;
bool argExists[1];
uint32_t validArgumentCount = 0;

memset(argExists, 0, sizeof argExists);

Expand Down Expand Up @@ -352,43 +317,46 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En
ChipLogProgress(Zcl, "Failed to decode TLV data: %" PRId32, TLVError);
}

// TODO(#5590) We should encode a response of status code for invalid TLV.
if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount)
{
// TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
emberAfWindowCoveringClusterWindowCoveringGoToTiltValueCallback(tiltValue);
}
else
{
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);
return;
}
break;
}
case ZCL_WINDOW_COVERING_STOP_COMMAND_ID: {

// TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
emberAfWindowCoveringClusterWindowCoveringStopCallback();
return;
break;
}
case ZCL_WINDOW_COVERING_UP_OPEN_COMMAND_ID: {

// TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
emberAfWindowCoveringClusterWindowCoveringUpOpenCallback();
return;
break;
}
default: {
// Unrecognized command ID, error status will apply.
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;
return;
}
}
}

if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount == 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,
0, validArgumentCount, TLVError, TLVUnpackError);
}
}

} // namespace WindowCovering
Expand Down
Loading

0 comments on commit 3048cb0

Please sign in to comment.