5 #include "af-structs.h"
6 #include "call-command-handler.h"
8 #include "command-id.h"
13 {{#all_user_clusters}}
14 {{#if (isEnabled enabled)}}
15 EmberAfStatus emberAf{{asCamelCased name false}}Cluster{{asCamelCased side false}}CommandParse(EmberAfClusterCommand * cmd);
17 {{/all_user_clusters}}
20 static EmberAfStatus status(bool wasHandled, bool clusterExists, bool mfgSpecific)
24 return EMBER_ZCL_STATUS_SUCCESS;
28 return EMBER_ZCL_STATUS_UNSUP_MANUF_CLUSTER_COMMAND;
30 else if (clusterExists)
32 return EMBER_ZCL_STATUS_UNSUP_COMMAND;
36 return EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER;
41 // Main command parsing controller.
42 EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd)
44 EmberAfStatus result = status(false, false, cmd->mfgSpecific);
45 if (cmd->direction == (uint8_t) ZCL_DIRECTION_SERVER_TO_CLIENT &&
46 emberAfContainsClientWithMfgCode(cmd->apsFrame->destinationEndpoint, cmd->apsFrame->clusterId, cmd->mfgCode))
48 switch (cmd->apsFrame->clusterId)
50 {{#all_user_clusters}}
51 {{#if (isEnabled enabled)}}
52 {{#if (isClient side) }}
53 case ZCL_{{asDelimitedMacro define}}_ID :
54 result = emberAf{{asCamelCased name false}}Cluster{{asCamelCased side false}}CommandParse(cmd);
58 {{/all_user_clusters}}
60 // Unrecognized cluster ID, error status will apply.
64 else if (cmd->direction == (uint8_t) ZCL_DIRECTION_CLIENT_TO_SERVER &&
65 emberAfContainsServerWithMfgCode(cmd->apsFrame->destinationEndpoint, cmd->apsFrame->clusterId, cmd->mfgCode))
67 switch (cmd->apsFrame->clusterId)
69 {{#all_user_clusters}}
70 {{#if (isEnabled enabled)}}
71 {{#unless (isClient side) }}
72 case ZCL_{{asDelimitedMacro define}}_ID :
73 result = emberAf{{asCamelCased name false}}Cluster{{asCamelCased side false}}CommandParse(cmd);
77 {{/all_user_clusters}}
79 // Unrecognized cluster ID, error status will apply.
86 // Cluster specific command parsing
88 {{#all_user_clusters}}
89 {{#if (isEnabled enabled)}}
90 EmberAfStatus emberAf{{asCamelCased name false}}Cluster{{asCamelCased side false}}CommandParse(EmberAfClusterCommand * cmd)
92 bool wasHandled = false;
94 if (!cmd->mfgSpecific)
96 switch (cmd->commandId)
98 {{#all_user_cluster_commands}}
99 {{#if (isStrEqual clusterName parent.name)}}
100 {{#if (isCommandAvailable parent.side incoming outgoing commandSource name)}}
101 case ZCL_{{asDelimitedMacro name}}_COMMAND_ID: {
102 {{#if (zcl_command_arguments_count this.id)}}
103 uint32_t argOffset = 0;
104 {{#zcl_command_arguments}}
105 {{asUnderlyingType type}} * {{asSymbol label}} = ({{asUnderlyingType type}} *)(cmd->buffer + argOffset);
106 {{#unless (isLastElement index count)}}
107 argOffset+= sizeof({{asUnderlyingType type}});
109 {{/zcl_command_arguments}}
111 wasHandled = emberAf{{asCamelCased parent.name false}}Cluster{{asCamelCased name false}}Callback({{#zcl_command_arguments}} *{{asSymbol label}}{{#unless (isLastElement index count)}}, {{/unless}}{{/zcl_command_arguments}});
113 wasHandled = emberAf{{asCamelCased parent.name false}}Cluster{{asCamelCased name false}}Callback();
119 {{/all_user_cluster_commands}}
121 // Unrecognized command ID, error status will apply.
126 return status(wasHandled, true, cmd->mfgSpecific);
129 {{/all_user_clusters}}