Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / app / util / config.h
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  * @brief This file is the main configuration settings
37  *for the Zigbee app. The zigbee app can become a Home
38  *Automation (HA) device, a Smart Energy (SE) device,
39  *or a Custom Zigbee device.
40  *
41  * This application can be configured using
42  *AppBuilder. AppBuilder generates a file containing
43  *defines that setup what pieces of the code is used
44  *(which clusters, security settings, zigbee device
45  *type, serial port, etc). These defines are added to
46  *a new file and included by setting
47  *ZA_GENERATED_HEADER to the new filename so these
48  *defines are sourced first.
49  *
50  * This file also contains default values for the
51  *defines so some can be set by the user but defaults
52  *are always available.
53  *******************************************************************************
54  * # License
55  * <b>Copyright 2018 Silicon Laboratories, Inc.
56  *www.silabs.com</b>
57  *******************************************************************************
58  *
59  * The licensor of this software is Silicon
60  *Laboratories Inc.  Your use of this software is
61  *governed by the terms of  Silicon Labs Master
62  *Software License Agreement (MSLA) available at
63  * www.silabs.com/about-us/legal/master-software-license-agreement.
64  *This software  is distributed to you in Source Code
65  *format and is governed by the sections of the MSLA
66  *applicable to Source Code.
67  *
68  ******************************************************************************/
69
70 #pragma once
71
72 // include generated configuration information from AppBuilder.
73 // ZA_GENERATED_HEADER is defined in the project file
74 #ifdef ZA_GENERATED_HEADER
75 #include ZA_GENERATED_HEADER
76 #else
77 #include "gen/gen_config.h"
78 #endif
79
80 #ifdef ATTRIBUTE_STORAGE_CONFIGURATION
81 #include ATTRIBUTE_STORAGE_CONFIGURATION
82 #else
83 #include "gen/endpoint_config.h"
84 #endif
85
86 #include "gen/gen_tokens.h" // For GENERATED_TOKEN_LOADER/SAVER macros
87
88 // *******************************************************************
89 // pre-defined Devices
90 //
91 // use these to determine which type of device the current application is.
92 // do not use the EMBER_* versions from ember-types.h as these are in an
93 // enum and are not available at preprocessor time. These need to be set
94 // before the devices are loaded from ha-devices.h and se-devices.h
95 #define ZA_COORDINATOR 1
96 #define ZA_ROUTER 2
97 #define ZA_END_DEVICE 3
98 #define ZA_SLEEPY_END_DEVICE 4
99
100 // A subtle distniction:
101 //   EMBER_AF_MANUFACTURER_CODE is the MFG code set by AppBuilder
102 //     for use in the App Framework (AF).  If not set by AppBuilder we default
103 //     it to 0x0000. The customer should be setting this value.
104 //   EMBER_COMPANY_MANUFACTURER_CODE is the Ember Corporation's Manufacturer
105 //     ID allocated by the Zigbee alliance.  This shall not change.
106 #define EMBER_COMPANY_MANUFACTURER_CODE 0x1002
107 #ifndef EMBER_AF_MANUFACTURER_CODE
108 #define EMBER_AF_MANUFACTURER_CODE 0x0000
109 #endif
110
111 // This file determines the security profile used, and from that various
112 // other security parameters.
113 // #include "app/framework/security/security-config.h"
114
115 // *******************************************************************
116 // Application configuration of RAM for cluster usage
117 //
118 // This section defines constants that size the tables used by the cluster
119 // code.
120
121 // This is the max hops that the network can support - used to determine
122 // the max source route overhead and broadcast radius
123 // if we havent defined MAX_HOPS then define based on profile ID
124 #ifndef ZA_MAX_HOPS
125 #define ZA_MAX_HOPS 12
126 #endif
127
128 #ifndef EMBER_AF_SOURCE_ROUTING_RESERVED_PAYLOAD_LENGTH
129 #define EMBER_AF_SOURCE_ROUTING_RESERVED_PAYLOAD_LENGTH 0
130 #endif
131
132 // The maximum APS payload, not including any APS options.  This value is also
133 // available from emberMaximumApsPayloadLength() or ezspMaximumPayloadLength().
134 // See http://portal.ember.com/faq/payload for more information.
135 #define EMBER_AF_MAXIMUM_APS_PAYLOAD_LENGTH 82 - EMBER_AF_SOURCE_ROUTING_RESERVED_PAYLOAD_LENGTH
136
137 // Max PHY size = 128
138 //   -1 byte for PHY length
139 //   -2 bytes for MAC CRC
140 #define EMBER_AF_MAXIMUM_INTERPAN_LENGTH 125
141
142 // The additional overhead required for APS encryption (security = 5, MIC = 4).
143 #define EMBER_AF_APS_ENCRYPTION_OVERHEAD 9
144
145 // The additional overhead required for APS fragmentation.
146 #define EMBER_AF_APS_FRAGMENTATION_OVERHEAD 2
147
148 // The additional overhead required for network source routing (relay count = 1,
149 // relay index = 1).  This does not include the size of the relay list itself.
150 #define EMBER_AF_NWK_SOURCE_ROUTE_OVERHEAD 2
151
152 // The additional overhead required per relay address for network source
153 // routing.  This is in addition to the overhead defined above.
154 #define EMBER_AF_NWK_SOURCE_ROUTE_PER_RELAY_ADDRESS_OVERHEAD 2
155
156 // defines the largest size payload allowed to send and receive. This
157 // affects the payloads generated from the CLI and the payloads generated
158 // as responses.
159 // Maximum payload length.
160 // If fragmenation is enabled, and fragmentation length is bigger than default, then use that
161 #if defined(EMBER_AF_PLUGIN_FRAGMENTATION) && (EMBER_AF_PLUGIN_FRAGMENTATION_BUFFER_SIZE > EMBER_AF_MAXIMUM_APS_PAYLOAD_LENGTH)
162 #define EMBER_AF_MAXIMUM_SEND_PAYLOAD_LENGTH EMBER_AF_PLUGIN_FRAGMENTATION_BUFFER_SIZE
163 #define EMBER_AF_INCOMING_BUFFER_LENGTH EMBER_AF_PLUGIN_FRAGMENTATION_BUFFER_SIZE
164 #else
165 #define EMBER_AF_MAXIMUM_SEND_PAYLOAD_LENGTH EMBER_AF_MAXIMUM_APS_PAYLOAD_LENGTH
166 #define EMBER_AF_INCOMING_BUFFER_LENGTH EMBER_AF_MAXIMUM_APS_PAYLOAD_LENGTH
167 #endif
168
169 // *******************************************************************
170 // Application configuration of Flash
171 //
172 // This section gives the application options for turning on or off
173 // features that affect the amount of flash used.
174
175 // *******************************************************************
176 // Defines needed for enabling security
177 //
178
179 // Our stack profile is 2 (ZigBee Pro).
180 #define EMBER_STACK_PROFILE 2
181
182 // *******************************************************************
183 // Application Handlers
184 //
185 // By default, a number of stub handlers are automatically provided
186 // that have no effect.  If the application would like to implement any
187 // of these handlers itself, it needs to define the appropriate macro
188
189 #define EMBER_APPLICATION_HAS_REMOTE_BINDING_HANDLER
190 #define EMBER_APPLICATION_HAS_ENERGY_SCAN_RESULT_HANDLER
191 #define EMBER_APPLICATION_HAS_GET_ENDPOINT
192 #define EMBER_APPLICATION_HAS_TRUST_CENTER_JOIN_HANDLER
193 #define EMBER_APPLICATION_HAS_BUTTON_HANDLER
194 #define EMBER_APPLICATION_HAS_ZIGBEE_KEY_ESTABLISHMENT_HANDLER
195
196 #define EZSP_APPLICATION_HAS_ENERGY_SCAN_RESULT_HANDLER
197 #define EZSP_APPLICATION_HAS_INCOMING_SENDER_EUI64_HANDLER
198 #define EZSP_APPLICATION_HAS_TRUST_CENTER_JOIN_HANDLER
199 #define EZSP_APPLICATION_HAS_BUTTON_HANDLER
200 #define EZSP_APPLICATION_HAS_ZIGBEE_KEY_ESTABLISHMENT_HANDLER
201
202 #ifndef EMBER_AF_MESSAGE_SENT_CALLBACK_TABLE_SIZE
203 #define EMBER_AF_MESSAGE_SENT_CALLBACK_TABLE_SIZE EMBER_APS_UNICAST_MESSAGE_COUNT
204 #endif // EMBER_AF_MESSAGE_SENT_CALLBACK_TABLE_SIZE
205
206 #define EMBER_APPLICATION_HAS_COMMAND_ACTION_HANDLER
207
208 // *******************************************************************
209 // Default values for required defines
210 //
211
212 // define the serial port that the application uses to be 1 if this is not set
213 #ifndef HAL_CONFIG // HAL Config handles serial port allocation
214 #ifndef APP_SERIAL
215 #define APP_SERIAL 1
216 #endif
217 #ifdef EMBER_TEST
218 #include "app/util/ezsp/uart-simulation-remap.h"
219 #endif
220 #endif
221
222 // The address table plugin is enabled by default. If it gets disabled for some
223 // reason, we still need to define these #defines to some default value.
224 #ifndef EMBER_AF_PLUGIN_ADDRESS_TABLE
225 #define EMBER_AF_PLUGIN_ADDRESS_TABLE_SIZE 2
226 #define EMBER_AF_PLUGIN_ADDRESS_TABLE_TRUST_CENTER_CACHE_SIZE 2
227 #endif
228
229 // The total size of the address table is the size of the section used by the
230 // application plus the size of section used for the trust center address cache.
231 // The NCP allows each section to be sized independently, but the SOC requires
232 // a single configuration for the whole table.
233 #ifndef EMBER_ADDRESS_TABLE_SIZE
234 #define EMBER_ADDRESS_TABLE_SIZE (EMBER_AF_PLUGIN_ADDRESS_TABLE_SIZE + EMBER_AF_PLUGIN_ADDRESS_TABLE_TRUST_CENTER_CACHE_SIZE)
235 #endif
236
237 #ifndef EMBER_AF_DEFAULT_APS_OPTIONS
238 // BUGZID 12261: Concentrators use MTORRs for route discovery and should not
239 // enable route discovery in the APS options.
240 #ifdef EMBER_AF_PLUGIN_CONCENTRATOR
241 #define EMBER_AF_DEFAULT_APS_OPTIONS (EMBER_APS_OPTION_RETRY | EMBER_APS_OPTION_ENABLE_ADDRESS_DISCOVERY)
242 #else
243 #define EMBER_AF_DEFAULT_APS_OPTIONS                                                                                               \
244     (EMBER_APS_OPTION_RETRY | EMBER_APS_OPTION_ENABLE_ROUTE_DISCOVERY | EMBER_APS_OPTION_ENABLE_ADDRESS_DISCOVERY)
245 #endif
246 #endif
247
248 // *******************************************************************
249 // // Default values for required defines
250 // //
251
252 #ifdef EMBER_AF_DEFAULT_RESPONSE_POLICY_NEVER
253 #define EMBER_AF_DEFAULT_RESPONSE_POLICY_REQUESTS ZCL_DISABLE_DEFAULT_RESPONSE_MASK
254 #define EMBER_AF_DEFAULT_RESPONSE_POLICY_RESPONSES ZCL_DISABLE_DEFAULT_RESPONSE_MASK
255 #elif defined(EMBER_AF_DEFAULT_RESPONSE_POLICY_CONDITIONAL)
256 #define EMBER_AF_DEFAULT_RESPONSE_POLICY_REQUESTS 0
257 #define EMBER_AF_DEFAULT_RESPONSE_POLICY_RESPONSES ZCL_DISABLE_DEFAULT_RESPONSE_MASK
258 #else
259 #define EMBER_AF_DEFAULT_RESPONSE_POLICY_REQUESTS 0
260 #define EMBER_AF_DEFAULT_RESPONSE_POLICY_RESPONSES 0
261 #endif // EMBER_AF_DEFAULT_RESPONSE_POLICY_NEVER
262
263 #ifdef EMBER_AF_CUSTOM_NETWORK_INIT_OPTIONS
264 #ifdef EMBER_AF_USE_STANDARD_NETWORK_INIT
265 #error "Custom options cannot be used with the standard network init"
266 #endif
267 #else
268 // We always want to store our parent info in a token. This prevents doing an
269 // orphan scan upon reboot, which can suffer from the multiple-parent-
270 // responses issue
271 #define EMBER_AF_CUSTOM_NETWORK_INIT_OPTIONS (EMBER_NETWORK_INIT_PARENT_INFO_IN_TOKEN | Z3_NETWORK_INIT_BEHAVIOR)
272 #endif // EMBER_AF_CUSTOM_NETWORK_INIT_OPTIONS
273
274 /**
275  * @brief CHIP uses millisecond ticks
276  */
277 #define MILLISECOND_TICKS_PER_SECOND 1000