| {{> header}} |
| |
| #pragma once |
| |
| #include <cstdint> |
| #include <string> |
| #include <type_traits> |
| |
| #include <app-common/zap-generated/cluster-objects.h> |
| #include <commands/clusters/ComplexArgument.h> |
| #include <commands/clusters/ClusterCommand.h> |
| #include <commands/clusters/ReportCommand.h> |
| #include <commands/clusters/WriteAttributeCommand.h> |
| |
| {{> clusters_header}} |
| |
| {{#zcl_clusters}} |
| {{> cluster_header}} |
| |
| {{#zcl_commands_source_client}} |
| /* |
| * Command {{asUpperCamelCase name}} |
| */ |
| class {{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}: public ClusterCommand |
| { |
| public: |
| {{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}(CredentialIssuerCommands * credsIssuerConfig): ClusterCommand("{{cleanse_label_as_kebab_case name}}", credsIssuerConfig){{#zcl_command_arguments}}{{#if_chip_complex}}, mComplex_{{asUpperCamelCase label}}(&mRequest.{{asLowerCamelCase label}}){{/if_chip_complex}}{{/zcl_command_arguments}} |
| { |
| {{#zcl_command_arguments}} |
| {{#if_chip_complex}} |
| AddArgument("{{asUpperCamelCase label}}", &mComplex_{{asUpperCamelCase label}}); |
| {{else if (isString type)}} |
| AddArgument("{{asUpperCamelCase label}}", &mRequest.{{asLowerCamelCase label}}); |
| {{else}} |
| AddArgument("{{asUpperCamelCase label}}", {{as_type_min_value type language='c++'}}, {{as_type_max_value type language='c++'}}, &mRequest.{{asLowerCamelCase label}}); |
| {{/if_chip_complex}} |
| {{/zcl_command_arguments}} |
| ClusterCommand::AddArguments(); |
| } |
| |
| CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector<chip::EndpointId> endpointIds) override |
| { |
| ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) command ({{asHex code 8}}) on endpoint %u", endpointIds.at(0)); |
| |
| return ClusterCommand::SendCommand(device, endpointIds.at(0), {{asHex parent.code 8}}, {{asHex code 8}}, mRequest); |
| } |
| |
| CHIP_ERROR SendGroupCommand(chip::GroupId groupId, chip::FabricIndex fabricIndex) override |
| { |
| ChipLogProgress(chipTool, "Sending cluster ({{asHex parent.code 8}}) command ({{asHex code 8}}) on Group %u", groupId); |
| |
| return ClusterCommand::SendGroupCommand(groupId, fabricIndex, {{asHex parent.code 8}}, {{asHex code 8}}, mRequest); |
| } |
| |
| private: |
| chip::app::Clusters::{{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase name}}::Type mRequest; |
| {{#zcl_command_arguments}} |
| {{#if_chip_complex}} |
| TypedComplexArgument<{{zapTypeToEncodableClusterObjectType type ns=parent.parent.name}}> mComplex_{{asUpperCamelCase label}}; |
| {{/if_chip_complex}} |
| {{/zcl_command_arguments}} |
| }; |
| |
| {{/zcl_commands_source_client}} |
| |
| {{/zcl_clusters}} |
| |
| /*----------------------------------------------------------------------------*\ |
| | Register all Clusters commands | |
| \*----------------------------------------------------------------------------*/ |
| {{#zcl_clusters}} |
| void registerCluster{{asUpperCamelCase name}}(Commands & commands, CredentialIssuerCommands * credsIssuerConfig) |
| { |
| using namespace chip::app::Clusters::{{asUpperCamelCase name}}; |
| |
| const char * clusterName = "{{asUpperCamelCase name}}"; |
| |
| commands_list clusterCommands = { |
| // |
| // Commands |
| // |
| make_unique<ClusterCommand>(Id, credsIssuerConfig), // |
| {{#zcl_commands_source_client}} |
| make_unique<{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}>(credsIssuerConfig), // |
| {{/zcl_commands_source_client}} |
| // |
| // Attributes |
| // |
| make_unique<ReadAttribute>(Id, credsIssuerConfig), // |
| {{#zcl_attributes_server}} |
| make_unique<ReadAttribute>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", Attributes::{{asUpperCamelCase name}}::Id, credsIssuerConfig), // |
| {{/zcl_attributes_server}} |
| make_unique<WriteAttribute<>>(Id, credsIssuerConfig), // |
| {{#zcl_attributes_server}} |
| {{#if_chip_complex}} |
| make_unique<WriteAttributeAsComplex<{{zapTypeToEncodableClusterObjectType type ns=parent.name forceNotOptional=true}}>>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", Attributes::{{asUpperCamelCase name}}::Id, WriteCommandType::k{{#unless isWritable}}Force{{/unless}}Write, credsIssuerConfig), // |
| {{else if (isString type)}} |
| make_unique<WriteAttribute<{{zapTypeToEncodableClusterObjectType type ns=parent.name forceNotOptional=true}}>>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", Attributes::{{asUpperCamelCase name}}::Id, WriteCommandType::k{{#unless isWritable}}Force{{/unless}}Write, credsIssuerConfig), // |
| {{else}} |
| make_unique<WriteAttribute<{{zapTypeToEncodableClusterObjectType type ns=parent.name forceNotOptional=true}}>>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", {{as_type_min_value type language='c++'}}, {{as_type_max_value type language='c++'}}, Attributes::{{asUpperCamelCase name}}::Id, WriteCommandType::k{{#unless isWritable}}Force{{/unless}}Write, credsIssuerConfig), // |
| {{/if_chip_complex}} |
| {{/zcl_attributes_server}} |
| make_unique<SubscribeAttribute>(Id, credsIssuerConfig), // |
| {{#zcl_attributes_server}} |
| make_unique<SubscribeAttribute>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", Attributes::{{asUpperCamelCase name}}::Id, credsIssuerConfig), // |
| {{/zcl_attributes_server}} |
| // |
| // Events |
| // |
| make_unique<ReadEvent>(Id, credsIssuerConfig), // |
| {{#zcl_events}} |
| make_unique<ReadEvent>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", Events::{{asUpperCamelCase name}}::Id, credsIssuerConfig), // |
| {{/zcl_events}} |
| make_unique<SubscribeEvent>(Id, credsIssuerConfig), // |
| {{#zcl_events}} |
| make_unique<SubscribeEvent>(Id, "{{cleanse_label_as_kebab_case (asUpperCamelCase name)}}", Events::{{asUpperCamelCase name}}::Id, credsIssuerConfig), // |
| {{/zcl_events}} |
| }; |
| |
| commands.RegisterCluster(clusterName, clusterCommands); |
| } |
| {{/zcl_clusters}} |
| |
| void registerClusterAny(Commands & commands, CredentialIssuerCommands * credsIssuerConfig) |
| { |
| const char * clusterName = "Any"; |
| |
| commands_list clusterCommands = { |
| make_unique<ClusterCommand>(credsIssuerConfig), // |
| make_unique<ReadAttribute>(credsIssuerConfig), // |
| make_unique<WriteAttribute<>>(credsIssuerConfig), // |
| make_unique<SubscribeAttribute>(credsIssuerConfig), // |
| make_unique<ReadEvent>(credsIssuerConfig), // |
| make_unique<SubscribeEvent>(credsIssuerConfig), // |
| make_unique<ReadAll>(credsIssuerConfig), // |
| make_unique<SubscribeAll>(credsIssuerConfig), // |
| }; |
| |
| commands.RegisterCommandSet(clusterName, clusterCommands, "Commands for sending IM messages based on cluster id, not cluster name."); |
| } |
| |
| void registerClusters(Commands & commands, CredentialIssuerCommands * credsIssuerConfig) |
| { |
| registerClusterAny(commands, credsIssuerConfig); |
| {{#zcl_clusters}} |
| registerCluster{{asUpperCamelCase name}}(commands, credsIssuerConfig); |
| {{/zcl_clusters}} |
| } |