Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / app / zap-templates / templates / app / im-cluster-command-handler.zapt
1 {{> header}}
2
3 #include <cstdint>
4 #include <cinttypes>
5
6 #include "af-structs.h"
7 #include "call-command-handler.h"
8 #include "callback.h"
9 #include "cluster-id.h"
10 #include "command-id.h"
11 #include "app/util/util.h"
12
13 #include <app/InteractionModelEngine.h>
14
15 // Currently we need some work to keep compatible with ember lib.
16 #include <util/ember-compatibility-functions.h>
17
18 namespace chip {
19 namespace app {
20
21 // Cluster specific command parsing
22
23 namespace clusters {
24
25 {{#all_user_clusters}}
26 {{#if (user_cluster_has_enabled_command name side)}}
27 namespace {{asCamelCased name false}} {
28
29 void Dispatch{{asCamelCased side false}}Command(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
30 {
31     {{#if (user_cluster_has_enabled_manufacturer_command name side)}}
32     {{else}}
33     {{/if}}
34     {
35         switch (commandId)
36         {
37         {{#all_user_cluster_commands}}
38         {{#unless mfgCode}}
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}}
43             break;
44         }
45         {{/if}}
46         {{/if}}
47         {{/unless}}
48         {{/all_user_cluster_commands}}
49         default: {
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);
53             break;
54         }
55         }
56     }
57 }
58
59 }
60
61 {{/if}}
62 {{/all_user_clusters}}
63
64 } // namespace clusters
65
66 void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aCommandId, chip::EndpointId aEndPointId,
67                              chip::TLV::TLVReader & aReader, Command * apCommandObj)
68 {
69     ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx16 " Command=%" PRIx8 " Endpoint=%" PRIx8, aClusterId,
70                   aCommandId, aEndPointId);
71     Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId);
72     switch (aClusterId)
73     {
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);
79         break;
80     {{/unless}}
81     {{/if}}
82     {{/all_user_clusters}}
83     default:
84         // Unrecognized cluster ID, error status will apply.
85         // TODO: Encode response for Cluster not found
86         ChipLogError(Zcl, "Unknown cluster %" PRIx16, aClusterId);
87         break;
88     }
89     Compatibility::ResetEmberAfObjects();
90 }
91
92 } // namespace app
93 } // namespace chip