diff --git a/build/chip/chip_codegen.cmake b/build/chip/chip_codegen.cmake index 708e144208417a..f7e4366a6d9aa8 100644 --- a/build/chip/chip_codegen.cmake +++ b/build/chip/chip_codegen.cmake @@ -161,7 +161,6 @@ function(chip_zapgen TARGET_NAME) # out links of template files and zap files and such SET(EXTRA_DEPENDENCIES "${CHIP_ROOT}/src/app/zap-templates/partials/header.zapt" - "${CHIP_ROOT}/src/app/zap-templates/partials/im_command_handler_cluster_commands.zapt" "${CHIP_ROOT}/src/app/zap-templates/templates/app/access.zapt" "${CHIP_ROOT}/src/app/zap-templates/templates/app/CHIPClusters.zapt" "${CHIP_ROOT}/src/app/zap-templates/templates/app/endpoint_config.zapt" diff --git a/build/chip/chip_codegen.gni b/build/chip/chip_codegen.gni index 1a6927bf4686f4..6d40f614fff71c 100644 --- a/build/chip/chip_codegen.gni +++ b/build/chip/chip_codegen.gni @@ -141,7 +141,6 @@ template("_chip_build_time_zapgen") { # out links of template files and zap files and such _extra_dependencies = [ "${_partials_dir}/header.zapt", - "${_partials_dir}/im_command_handler_cluster_commands.zapt", # Application templates, actually generating files "${_template_dir}/access.zapt", diff --git a/src/app/zap-templates/app-templates.json b/src/app/zap-templates/app-templates.json index d83717e1ba76f2..07434029be2120 100644 --- a/src/app/zap-templates/app-templates.json +++ b/src/app/zap-templates/app-templates.json @@ -17,10 +17,6 @@ { "name": "header", "path": "partials/header.zapt" - }, - { - "name": "im_command_handler_cluster_commands", - "path": "partials/im_command_handler_cluster_commands.zapt" } ], "templates": [ diff --git a/src/app/zap-templates/partials/im_command_handler_cluster_commands.zapt b/src/app/zap-templates/partials/im_command_handler_cluster_commands.zapt deleted file mode 100644 index 2f0b429f6a3337..00000000000000 --- a/src/app/zap-templates/partials/im_command_handler_cluster_commands.zapt +++ /dev/null @@ -1,91 +0,0 @@ -{{#if (isServer parent.clusterSide)}} -Commands::{{asUpperCamelCase commandName}}::DecodableType commandData; -TLVError = DataModel::Decode(aDataTlv, commandData); -if (TLVError == CHIP_NO_ERROR) { -wasHandled = emberAf{{asUpperCamelCase parent.clusterName}}Cluster{{asUpperCamelCase commandName}}Callback(apCommandObj, aCommandPath, commandData); -} -{{else}} -{{#if (zcl_command_arguments_count this.id)}} -expectArgumentCount = {{ zcl_command_arguments_count this.id }}; -{{#zcl_command_arguments}} - {{#if isArray}} - {{asUnderlyingZclType type}} {{asSymbol label}}; - {{else}} - {{#if_is_struct type}} - {{zapTypeToDecodableClusterObjectType type ns=parent.parent.clusterName}} {{asSymbol label}}; - {{else}} - {{asUnderlyingZclType type}} {{asSymbol label}}; - {{/if_is_struct}} - {{/if}} -{{/zcl_command_arguments}} -bool argExists[{{zcl_command_arguments_count this.id}}]; - -memset(argExists, 0, sizeof argExists); - -while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) -{ - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < {{zcl_command_arguments_count this.id}}) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_IB; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { -{{#zcl_command_arguments}} - case {{fieldIdentifier}}: -{{#if isArray}} - // Just for compatibility, we will add array type support in IM later. - TLVUnpackError = aDataTlv.GetDataPtr(const_cast({{asSymbol label}})); -{{else}} - {{#if_is_struct type}} - // Not supported, just error out. - TLVUnpackError = CHIP_ERROR_UNEXPECTED_TLV_ELEMENT; - {{else}} - TLVUnpackError = aDataTlv.Get({{asSymbol label}}); - {{/if_is_struct}} -{{/if}} - break; -{{/zcl_command_arguments}} - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } -} - -if (CHIP_END_OF_TLV == TLVError) -{ - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; -} -{{/if}} - -{{#if (zcl_command_arguments_count this.id)}} -if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && {{zcl_command_arguments_count this.id}} == validArgumentCount) -{ -{{/if}} -wasHandled = emberAf{{asUpperCamelCase parent.clusterName}}Cluster{{asUpperCamelCase commandName}}Callback(aCommandPath.mEndpointId, apCommandObj{{#zcl_command_arguments}}, {{asSymbol label}}{{/zcl_command_arguments}}); -{{#if (zcl_command_arguments_count this.id)}} -} -{{/if}} -{{/if}} diff --git a/src/app/zap-templates/templates/app/im-cluster-command-handler.zapt b/src/app/zap-templates/templates/app/im-cluster-command-handler.zapt index e41e9328fac98d..734f34ce184dcd 100644 --- a/src/app/zap-templates/templates/app/im-cluster-command-handler.zapt +++ b/src/app/zap-templates/templates/app/im-cluster-command-handler.zapt @@ -36,7 +36,12 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP { {{/first}} case Commands::{{asUpperCamelCase commandName}}::Id: { - {{> im_command_handler_cluster_commands}} + Commands::{{asUpperCamelCase commandName}}::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = emberAf{{asUpperCamelCase parent.clusterName}}Cluster{{asUpperCamelCase commandName}}Callback(apCommandObj, aCommandPath, commandData); + } break; } {{#last}}