Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / app / util / process-cluster-message.cpp
1 /**
2  *
3  *    Copyright (c) 2020 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 /**
19  *
20  *    Copyright (c) 2020 Silicon Labs
21  *
22  *    Licensed under the Apache License, Version 2.0 (the "License");
23  *    you may not use this file except in compliance with the License.
24  *    You may obtain a copy of the License at
25  *
26  *        http://www.apache.org/licenses/LICENSE-2.0
27  *
28  *    Unless required by applicable law or agreed to in writing, software
29  *    distributed under the License is distributed on an "AS IS" BASIS,
30  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31  *    See the License for the specific language governing permissions and
32  *    limitations under the License.
33  */
34 /***************************************************************************/
35 /**
36  * @file
37  * @brief This file contains a function that processes
38  *cluster-specific ZCL message.
39  *******************************************************************************
40  ******************************************************************************/
41
42 // this file contains all the common includes for clusters in the zcl-util
43 #include "app/util/common.h"
44
45 // for pulling in defines dealing with EITHER server or client
46 #include "af-main.h"
47
48 #include "gen/cluster-id.h"
49
50 // the EM260 host needs to include the config file
51 #ifdef EZSP_HOST
52 #include "config.h"
53 #endif
54
55 //------------------------------------------------------------------------------
56
57 bool emAfProcessClusterSpecificCommand(EmberAfClusterCommand * cmd)
58 {
59     EmberAfStatus status;
60
61     // if we are disabled then we can only respond to read or write commands
62     // or identify cluster (see device enabled attr of basic cluster)
63     if (!emberAfIsDeviceEnabled(cmd->apsFrame->destinationEndpoint) && cmd->apsFrame->clusterId != ZCL_IDENTIFY_CLUSTER_ID)
64     {
65         emberAfCorePrintln("%pd, dropping ep 0x%x clus 0x%2x cmd 0x%x", "disable", cmd->apsFrame->destinationEndpoint,
66                            cmd->apsFrame->clusterId, cmd->commandId);
67         emberAfSendDefaultResponse(cmd, EMBER_ZCL_STATUS_FAILURE);
68         return true;
69     }
70
71 #ifdef ZCL_USING_KEY_ESTABLISHMENT_CLUSTER_CLIENT
72     if (cmd->apsFrame->clusterId == ZCL_KEY_ESTABLISHMENT_CLUSTER_ID && cmd->direction == ZCL_DIRECTION_SERVER_TO_CLIENT &&
73         emberAfKeyEstablishmentClusterClientCommandReceivedCallback(cmd))
74     {
75         return true;
76     }
77 #endif
78 #ifdef ZCL_USING_KEY_ESTABLISHMENT_CLUSTER_SERVER
79     if (cmd->apsFrame->clusterId == ZCL_KEY_ESTABLISHMENT_CLUSTER_ID && cmd->direction == ZCL_DIRECTION_CLIENT_TO_SERVER &&
80         emberAfKeyEstablishmentClusterServerCommandReceivedCallback(cmd))
81     {
82         return true;
83     }
84 #endif
85
86 #ifdef ZCL_USING_OTA_BOOTLOAD_CLUSTER_CLIENT
87     if (cmd->apsFrame->clusterId == ZCL_OTA_BOOTLOAD_CLUSTER_ID && cmd->direction == ZCL_DIRECTION_SERVER_TO_CLIENT &&
88         emberAfOtaClientIncomingMessageRawCallback(cmd))
89     {
90         return true;
91     }
92 #endif
93 #ifdef ZCL_USING_OTA_BOOTLOAD_CLUSTER_SERVER
94     if (cmd->apsFrame->clusterId == ZCL_OTA_BOOTLOAD_CLUSTER_ID && cmd->direction == ZCL_DIRECTION_CLIENT_TO_SERVER &&
95         emberAfOtaServerIncomingMessageRawCallback(cmd))
96     {
97         return true;
98     }
99 #endif
100
101     // Pass the command to the generated command parser for processing
102     status = emberAfClusterSpecificCommandParse(cmd);
103     if (status != EMBER_ZCL_STATUS_SUCCESS)
104     {
105         emberAfSendDefaultResponse(cmd, status);
106     }
107
108     return true;
109 }