From 10968245a41f969ef21b681616a9c4ec8648e0bd Mon Sep 17 00:00:00 2001 From: Vivien Nicolas Date: Tue, 1 Feb 2022 01:21:24 +0100 Subject: [PATCH] [chip-tool] Get chip-tool template to generate write commands for struct attributes now that complex types are supported (#14593) * [chip-tool] Get chip-tool template to generate write commands for struct attributes now that complex types are supported * Update generated content --- examples/chip-tool/templates/commands.zapt | 6 -- .../zap-generated/cluster/Commands.h | 72 +++++++++++++++++++ 2 files changed, 72 insertions(+), 6 deletions(-) diff --git a/examples/chip-tool/templates/commands.zapt b/examples/chip-tool/templates/commands.zapt index ef28606225bdb2..a9c2652ba08de2 100644 --- a/examples/chip-tool/templates/commands.zapt +++ b/examples/chip-tool/templates/commands.zapt @@ -58,8 +58,6 @@ private: {{/chip_cluster_commands}} {{#chip_server_cluster_attributes}} -{{! TODO: Various types (floats, structs) not supported here. }} -{{#unless (isStrEqual chipCallback.name "Unsupported")}} {{#if isWritableAttribute}} class Write{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}: public WriteAttribute { @@ -92,7 +90,6 @@ private: }; {{/if}} -{{/unless}} {{/chip_server_cluster_attributes}} {{/chip_client_clusters}} @@ -123,12 +120,9 @@ void registerCluster{{asUpperCamelCase name}}(Commands & commands, CredentialIss {{/chip_server_cluster_attributes}} make_unique(Id, credsIssuerConfig), // {{#chip_server_cluster_attributes}} - {{! TODO: Various types (floats, structs) not supported here. }} - {{#unless (isStrEqual chipCallback.name "Unsupported")}} {{#if isWritableAttribute}} make_unique(credsIssuerConfig), // {{/if}} - {{/unless}} {{/chip_server_cluster_attributes}} make_unique(Id, credsIssuerConfig), // {{#chip_server_cluster_attributes}} diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index 34c52c4357ca9a..5b3c32342db7d9 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -360,6 +360,29 @@ class AdministratorCommissioningRevokeCommissioning : public ClusterCommand | Events: | | \*----------------------------------------------------------------------------*/ +class WriteApplicationBasicApplicationApp : public WriteAttribute +{ +public: + WriteApplicationBasicApplicationApp(CredentialIssuerCommands * credsIssuerConfig) : + WriteAttribute("ApplicationApp", credsIssuerConfig), mComplex(&mValue) + { + AddArgument("attr-name", "application-app"); + AddArgument("attr-value", &mComplex); + WriteAttribute::AddArguments(); + } + + ~WriteApplicationBasicApplicationApp() {} + + CHIP_ERROR SendCommand(ChipDevice * device, chip::EndpointId endpointId) override + { + return WriteAttribute::SendCommand(device, endpointId, 0x0000050D, 0x00000004, mValue); + } + +private: + chip::app::Clusters::ApplicationBasic::Structs::ApplicationBasicApplication::Type mValue; + TypedComplexArgument mComplex; +}; + /*----------------------------------------------------------------------------*\ | Cluster ApplicationLauncher | 0x050C | |------------------------------------------------------------------------------| @@ -7211,6 +7234,29 @@ class WriteTestClusterEnumAttr : public WriteAttribute chip::app::Clusters::TestCluster::SimpleEnum mValue; }; +class WriteTestClusterStructAttr : public WriteAttribute +{ +public: + WriteTestClusterStructAttr(CredentialIssuerCommands * credsIssuerConfig) : + WriteAttribute("StructAttr", credsIssuerConfig), mComplex(&mValue) + { + AddArgument("attr-name", "struct-attr"); + AddArgument("attr-value", &mComplex); + WriteAttribute::AddArguments(); + } + + ~WriteTestClusterStructAttr() {} + + CHIP_ERROR SendCommand(ChipDevice * device, chip::EndpointId endpointId) override + { + return WriteAttribute::SendCommand(device, endpointId, 0x0000050F, 0x00000025, mValue); + } + +private: + chip::app::Clusters::TestCluster::Structs::SimpleStruct::Type mValue; + TypedComplexArgument mComplex; +}; + class WriteTestClusterRangeRestrictedInt8u : public WriteAttribute { public: @@ -7999,6 +8045,29 @@ class WriteTestClusterNullableEnumAttr : public WriteAttribute chip::app::DataModel::Nullable mValue; }; +class WriteTestClusterNullableStruct : public WriteAttribute +{ +public: + WriteTestClusterNullableStruct(CredentialIssuerCommands * credsIssuerConfig) : + WriteAttribute("NullableStruct", credsIssuerConfig), mComplex(&mValue) + { + AddArgument("attr-name", "nullable-struct"); + AddArgument("attr-value", &mComplex); + WriteAttribute::AddArguments(); + } + + ~WriteTestClusterNullableStruct() {} + + CHIP_ERROR SendCommand(ChipDevice * device, chip::EndpointId endpointId) override + { + return WriteAttribute::SendCommand(device, endpointId, 0x0000050F, 0x00008025, mValue); + } + +private: + chip::app::DataModel::Nullable mValue; + TypedComplexArgument> mComplex; +}; + class WriteTestClusterNullableRangeRestrictedInt8u : public WriteAttribute { public: @@ -9186,6 +9255,7 @@ void registerClusterApplicationBasic(Commands & commands, CredentialIssuerComman make_unique(Id, "attribute-list", Attributes::AttributeList::Id, credsIssuerConfig), // make_unique(Id, "cluster-revision", Attributes::ClusterRevision::Id, credsIssuerConfig), // make_unique(Id, credsIssuerConfig), // + make_unique(credsIssuerConfig), // make_unique(Id, credsIssuerConfig), // make_unique(Id, "vendor-name", Attributes::VendorName::Id, credsIssuerConfig), // make_unique(Id, "vendor-id", Attributes::VendorId::Id, credsIssuerConfig), // @@ -11713,6 +11783,7 @@ void registerClusterTestCluster(Commands & commands, CredentialIssuerCommands * make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // + make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // @@ -11749,6 +11820,7 @@ void registerClusterTestCluster(Commands & commands, CredentialIssuerCommands * make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // + make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), //