a0006c7c102da4770994b8a69969406c87f55b30
[platform/upstream/connectedhomeip.git] / examples / temperature-measurement-app / esp32 / main / gen / IMClusterCommandHandler.cpp
1 /*
2  *
3  *    Copyright (c) 2021 Project CHIP Authors
4  *
5  *    Licensed under the Apache License, Version 2.0 (the "License");
6  *    you may not use this file except in compliance with the License.
7  *    You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *    Unless required by applicable law or agreed to in writing, software
12  *    distributed under the License is distributed on an "AS IS" BASIS,
13  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *    See the License for the specific language governing permissions and
15  *    limitations under the License.
16  */
17
18 // THIS FILE IS GENERATED BY ZAP
19
20 #include <cinttypes>
21 #include <cstdint>
22
23 #include "af-structs.h"
24 #include "call-command-handler.h"
25 #include "callback.h"
26 #include "cluster-id.h"
27 #include "command-id.h"
28 #include "util.h"
29
30 #include <app/InteractionModelEngine.h>
31
32 // Currently we need some work to keep compatible with ember lib.
33 #include <util/ember-compatibility-functions.h>
34
35 namespace chip {
36 namespace app {
37
38 // Cluster specific command parsing
39
40 namespace clusters {
41
42 namespace Basic {
43
44 void DispatchServerCommand(app::Command * command, CommandId commandId, EndpointId endpointId, TLV::TLVReader & dataTlv)
45 {
46     {
47         switch (commandId)
48         {
49         case ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID: {
50             // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks.
51             emberAfBasicClusterResetToFactoryDefaultsCallback();
52             break;
53         }
54         default: {
55             // Unrecognized command ID, error status will apply.
56             // TODO: Encode response for command not found
57             ChipLogError(Zcl, "Unknown command %" PRIx16 " for cluster %" PRIx16, commandId, ZCL_BASIC_CLUSTER_ID);
58             break;
59         }
60         }
61     }
62 }
63
64 } // namespace Basic
65
66 } // namespace clusters
67
68 void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aCommandId, chip::EndpointId aEndPointId,
69                                   chip::TLV::TLVReader & aReader, Command * apCommandObj)
70 {
71     ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx16 " Command=%" PRIx8 " Endpoint=%" PRIx8, aClusterId, aCommandId,
72                   aEndPointId);
73     Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId);
74     switch (aClusterId)
75     {
76     case ZCL_BASIC_CLUSTER_ID:
77         clusters::Basic::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader);
78         break;
79     default:
80         // Unrecognized cluster ID, error status will apply.
81         // TODO: Encode response for Cluster not found
82         ChipLogError(Zcl, "Unknown cluster %" PRIx16, aClusterId);
83         break;
84     }
85     Compatibility::ResetEmberAfObjects();
86 }
87
88 } // namespace app
89 } // namespace chip