6 #include "af-structs.h"
7 #include "call-command-handler.h"
9 #include "cluster-id.h"
10 #include "command-id.h"
11 #include "app/util/util.h"
13 #include <app/InteractionModelEngine.h>
15 // Currently we need some work to keep compatible with ember lib.
16 #include <util/ember-compatibility-functions.h>
21 // Cluster specific command parsing
25 {{#all_user_clusters}}
26 {{#if (user_cluster_has_enabled_command name side)}}
27 namespace {{asCamelCased name false}} {
29 void Dispatch{{asCamelCased side false}}Command(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
31 {{#if (user_cluster_has_enabled_manufacturer_command name side)}}
37 {{#all_user_cluster_commands}}
39 {{#if (isStrEqual clusterName parent.name)}}
40 {{#if (isCommandAvailable parent.side incoming outgoing commandSource name)}}
41 case ZCL_{{asDelimitedMacro name}}_COMMAND_ID: {
42 {{> im_command_handler_cluster_commands}}
48 {{/all_user_cluster_commands}}
50 // Unrecognized command ID, error status will apply.
51 // TODO: Encode response for command not found
52 ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_{{asDelimitedMacro define}}_ID);
62 {{/all_user_clusters}}
64 } // namespace clusters
66 void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aCommandId, chip::EndpointId aEndPointId,
67 chip::TLV::TLVReader & aReader, Command * apCommandObj)
69 ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx16 " Command=%" PRIx8 " Endpoint=%" PRIx8, aClusterId,
70 aCommandId, aEndPointId);
71 Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId);
74 {{#all_user_clusters}}
75 {{#if (user_cluster_has_enabled_command name side)}}
76 {{#unless (isClient side) }}
77 case ZCL_{{asDelimitedMacro define}}_ID :
78 clusters::{{asCamelCased name false}}::Dispatch{{asCamelCased side false}}Command(apCommandObj, aCommandId, aEndPointId, aReader);
82 {{/all_user_clusters}}
84 // Unrecognized cluster ID, error status will apply.
85 // TODO: Encode response for Cluster not found
86 ChipLogError(Zcl, "Unknown cluster %" PRIx16, aClusterId);
89 Compatibility::ResetEmberAfObjects();