5 #include "af-structs.h"
6 #include "call-command-handler.h"
8 #include "cluster-id.h"
9 #include "command-id.h"
10 #include "app/util/util.h"
14 {{#all_user_clusters}}
15 {{#if (isEnabled enabled)}}
16 EmberAfStatus emberAf{{asCamelCased name false}}Cluster{{asCamelCased side false}}CommandParse(EmberAfClusterCommand * cmd);
18 {{/all_user_clusters}}
21 static EmberAfStatus status(bool wasHandled, bool clusterExists, bool mfgSpecific)
25 return EMBER_ZCL_STATUS_SUCCESS;
29 return EMBER_ZCL_STATUS_UNSUP_MANUF_CLUSTER_COMMAND;
31 else if (clusterExists)
33 return EMBER_ZCL_STATUS_UNSUP_COMMAND;
37 return EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER;
42 // Main command parsing controller.
43 EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd)
45 EmberAfStatus result = status(false, false, cmd->mfgSpecific);
46 if (cmd->direction == (uint8_t) ZCL_DIRECTION_SERVER_TO_CLIENT &&
47 emberAfContainsClientWithMfgCode(cmd->apsFrame->destinationEndpoint, cmd->apsFrame->clusterId, cmd->mfgCode))
49 switch (cmd->apsFrame->clusterId)
51 {{#all_user_clusters}}
52 {{#if (isClient side) }}
53 case ZCL_{{asDelimitedMacro define}}_ID :
54 {{#if (user_cluster_has_enabled_command name side)}}
55 result = emberAf{{asCamelCased name false}}Cluster{{asCamelCased side false}}CommandParse(cmd);
57 // No commands are enabled for cluster {{name}}
58 result = status(false, true, cmd->mfgSpecific);
62 {{/all_user_clusters}}
64 // Unrecognized cluster ID, error status will apply.
68 else if (cmd->direction == (uint8_t) ZCL_DIRECTION_CLIENT_TO_SERVER &&
69 emberAfContainsServerWithMfgCode(cmd->apsFrame->destinationEndpoint, cmd->apsFrame->clusterId, cmd->mfgCode))
71 switch (cmd->apsFrame->clusterId)
73 {{#all_user_clusters}}
74 {{#unless (isClient side) }}
75 case ZCL_{{asDelimitedMacro define}}_ID :
76 {{#if (user_cluster_has_enabled_command name side)}}
77 result = emberAf{{asCamelCased name false}}Cluster{{asCamelCased side false}}CommandParse(cmd);
79 // No commands are enabled for cluster {{name}}
80 result = status(false, true, cmd->mfgSpecific);
84 {{/all_user_clusters}}
86 // Unrecognized cluster ID, error status will apply.
93 // Cluster specific command parsing
95 {{#all_user_clusters}}
96 {{#if (user_cluster_has_enabled_command name side)}}
97 EmberAfStatus emberAf{{asCamelCased name false}}Cluster{{asCamelCased side false}}CommandParse(EmberAfClusterCommand * cmd)
99 bool wasHandled = false;
101 {{#if (user_cluster_has_enabled_manufacturer_command name side)}}
102 if (cmd->mfgSpecific)
104 {{#all_user_cluster_commands}}
106 {{#if (isStrEqual clusterName parent.name)}}
107 {{#if (isCommandAvailable parent.side incoming outgoing commandSource name)}}
108 if (cmd->mfgCode == {{mfgCode}} && cmd->commandId == ZCL_{{asDelimitedMacro name}}_COMMAND_ID)
110 {{> command_handler_cluster_commands}}
115 {{/all_user_cluster_commands}}
119 if (!cmd->mfgSpecific)
122 switch (cmd->commandId)
124 {{#all_user_cluster_commands}}
126 {{#if (isStrEqual clusterName parent.name)}}
127 {{#if (isCommandAvailable parent.side incoming outgoing commandSource name)}}
128 case ZCL_{{asDelimitedMacro name}}_COMMAND_ID: {
129 {{> command_handler_cluster_commands}}
135 {{/all_user_cluster_commands}}
137 // Unrecognized command ID, error status will apply.
142 return status(wasHandled, true, cmd->mfgSpecific);
145 {{/all_user_clusters}}