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 emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd);
32 EmberAfStatus emberAfTemperatureMeasurementClusterServerCommandParse(EmberAfClusterCommand * cmd);
34 static EmberAfStatus status(bool wasHandled, bool clusterExists, bool mfgSpecific)
38 return EMBER_ZCL_STATUS_SUCCESS;
42 return EMBER_ZCL_STATUS_UNSUP_MANUF_CLUSTER_COMMAND;
44 else if (clusterExists)
46 return EMBER_ZCL_STATUS_UNSUP_COMMAND;
50 return EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER;
54 // Main command parsing controller.
55 EmberAfStatus emberAfClusterSpecificCommandParse(EmberAfClusterCommand * cmd)
57 EmberAfStatus result = status(false, false, cmd->mfgSpecific);
58 if (cmd->direction == (uint8_t) ZCL_DIRECTION_SERVER_TO_CLIENT &&
59 emberAfContainsClientWithMfgCode(cmd->apsFrame->destinationEndpoint, cmd->apsFrame->clusterId, cmd->mfgCode))
61 switch (cmd->apsFrame->clusterId)
64 // Unrecognized cluster ID, error status will apply.
68 else if (cmd->direction == (uint8_t) ZCL_DIRECTION_CLIENT_TO_SERVER &&
69 emberAfContainsServerWithMfgCode(cmd->apsFrame->destinationEndpoint, cmd->apsFrame->clusterId, cmd->mfgCode))
71 switch (cmd->apsFrame->clusterId)
73 case ZCL_BASIC_CLUSTER_ID:
74 result = emberAfBasicClusterServerCommandParse(cmd);
76 case ZCL_TEMP_MEASUREMENT_CLUSTER_ID:
77 // No commands are enabled for cluster Temperature Measurement
78 result = status(false, true, cmd->mfgSpecific);
81 // Unrecognized cluster ID, error status will apply.
88 // Cluster specific command parsing
90 EmberAfStatus emberAfBasicClusterServerCommandParse(EmberAfClusterCommand * cmd)
92 bool wasHandled = false;
94 if (!cmd->mfgSpecific)
96 switch (cmd->commandId)
98 case ZCL_RESET_TO_FACTORY_DEFAULTS_COMMAND_ID: {
99 wasHandled = emberAfBasicClusterResetToFactoryDefaultsCallback();
103 // Unrecognized command ID, error status will apply.
108 return status(wasHandled, true, cmd->mfgSpecific);