3 * Copyright (c) 2021 Project CHIP Authors
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 // THIS FILE IS GENERATED BY ZAP
22 #include "af-structs.h"
23 #include "call-command-handler.h"
25 #include "cluster-id.h"
26 #include "command-id.h"
31 EmberAfStatus emberAfOnOffClusterServerCommandParse(EmberAfClusterCommand * cmd);
33 static EmberAfStatus status(bool wasHandled, bool clusterExists, bool mfgSpecific)
37 return EMBER_ZCL_STATUS_SUCCESS;
41 return EMBER_ZCL_STATUS_UNSUP_MANUF_CLUSTER_COMMAND;
43 else if (clusterExists)
45 return EMBER_ZCL_STATUS_UNSUP_COMMAND;
49 return EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER;
53 // Main command parsing controller.
54 EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd)
56 EmberAfStatus result = status(false, false, cmd->mfgSpecific);
57 if (cmd->direction == (uint8_t) ZCL_DIRECTION_SERVER_TO_CLIENT &&
58 emberAfContainsClientWithMfgCode(cmd->apsFrame->destinationEndpoint, cmd->apsFrame->clusterId, cmd->mfgCode))
60 switch (cmd->apsFrame->clusterId)
63 // Unrecognized cluster ID, error status will apply.
67 else if (cmd->direction == (uint8_t) ZCL_DIRECTION_CLIENT_TO_SERVER &&
68 emberAfContainsServerWithMfgCode(cmd->apsFrame->destinationEndpoint, cmd->apsFrame->clusterId, cmd->mfgCode))
70 switch (cmd->apsFrame->clusterId)
72 case ZCL_ON_OFF_CLUSTER_ID:
73 result = emberAfOnOffClusterServerCommandParse(cmd);
76 // Unrecognized cluster ID, error status will apply.
83 // Cluster specific command parsing
85 EmberAfStatus emberAfOnOffClusterServerCommandParse(EmberAfClusterCommand * cmd)
87 bool wasHandled = false;
89 if (!cmd->mfgSpecific)
91 switch (cmd->commandId)
93 case ZCL_OFF_COMMAND_ID: {
94 wasHandled = emberAfOnOffClusterOffCallback();
97 case ZCL_ON_COMMAND_ID: {
98 wasHandled = emberAfOnOffClusterOnCallback();
101 case ZCL_TOGGLE_COMMAND_ID: {
102 wasHandled = emberAfOnOffClusterToggleCallback();
106 // Unrecognized command ID, error status will apply.
111 return status(wasHandled, true, cmd->mfgSpecific);