3 * Copyright (c) 2020 Project CHIP Authors
4 * Copyright (c) 2014-2017 Nest Labs, Inc.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 * This file defines default compile-time configuration constants
22 * for the CHIP Time Services profile.
29 * @def CHIP_CONFIG_TIME
32 * 1 (Default) If chip Time Services is needed/enabled.
33 * 0 If chip Time Services is not needed. Content of implementation files
34 * would be compiled out.
37 #ifndef CHIP_CONFIG_TIME
38 #define CHIP_CONFIG_TIME 1
39 #endif // CHIP_CONFIG_TIME
42 * @def CHIP_CONFIG_TIME_PROGRESS_LOGGING
45 * Disabled: 0, Enabled: 1. If enabled, the messages at PROGRESS
46 * level would be available in the log.
49 #ifndef CHIP_CONFIG_TIME_PROGRESS_LOGGING
50 #define CHIP_CONFIG_TIME_PROGRESS_LOGGING 1
51 #endif // CHIP_CONFIG_TIME_PROGRESS_LOGGING
54 * @def CHIP_CONFIG_TIME_ENABLE_CLIENT
57 * 1 (Default) Enable Client role in TimeSyncNode. Note that
58 * Coordinator also requires Client.
59 * 0 If not needed, Client-specific part would be compiled out.
62 #ifndef CHIP_CONFIG_TIME_ENABLE_CLIENT
63 #define CHIP_CONFIG_TIME_ENABLE_CLIENT (CHIP_CONFIG_TIME)
64 #endif // CHIP_CONFIG_TIME_ENABLE_CLIENT
67 * @def CHIP_CONFIG_TIME_ENABLE_SERVER
70 * 1 (Default) Enable Server role in TimeSyncNode. Note that
71 * Coordinator also requires Server.
72 * 0 If not needed, Server-specific part would be compiled out.
75 #ifndef CHIP_CONFIG_TIME_ENABLE_SERVER
76 #define CHIP_CONFIG_TIME_ENABLE_SERVER (CHIP_CONFIG_TIME)
77 #endif // CHIP_CONFIG_TIME_ENABLE_SERVER
80 * @def CHIP_CONFIG_TIME_ENABLE_COORDINATOR
83 * defined as combination of CHIP_CONFIG_TIME_ENABLE_SERVER and CHIP_CONFIG_TIME_ENABLE_CLIENT.
84 * if explicitly defined to be 1, set both CHIP_CONFIG_TIME_ENABLE_SERVER and
85 * CHIP_CONFIG_TIME_ENABLE_CLIENT to 1.
88 #ifndef CHIP_CONFIG_TIME_ENABLE_COORDINATOR
89 #define CHIP_CONFIG_TIME_ENABLE_COORDINATOR ((CHIP_CONFIG_TIME_ENABLE_CLIENT) && (CHIP_CONFIG_TIME_ENABLE_SERVER))
90 #endif // CHIP_CONFIG_TIME_ENABLE_COORDINATOR
92 #if (CHIP_CONFIG_TIME_ENABLE_COORDINATOR && !((CHIP_CONFIG_TIME_ENABLE_CLIENT) && (CHIP_CONFIG_TIME_ENABLE_SERVER)))
93 #error Time Sync Coordinator requires both Server and Client to be enabled
94 #endif // CHIP_CONFIG_TIME_ENABLE_COORDINATOR
97 * @def CHIP_CONFIG_TIME_NUM_UTC_OFFSET_RECORD
100 * Number of UTC offset records can be used for Time Zone calculation
103 #ifndef CHIP_CONFIG_TIME_NUM_UTC_OFFSET_RECORD
104 #define CHIP_CONFIG_TIME_NUM_UTC_OFFSET_RECORD 4
105 #endif // CHIP_CONFIG_TIME_NUM_UTC_OFFSET_RECORD
108 * @def CHIP_CONFIG_TIME_SERVER_TIMER_UNRELIABLE_AFTER_BOOT_MSEC
111 * This only applies to Time Sync Server/Coordinator roles. This is
112 * 'timer_unreliable_after_boot' in design spec. Number of msec for
113 * the Server/Coordinator to consider its own system time as unreliable
114 * after program starts. Default is 30 seconds.
117 #ifndef CHIP_CONFIG_TIME_SERVER_TIMER_UNRELIABLE_AFTER_BOOT_MSEC
118 #define CHIP_CONFIG_TIME_SERVER_TIMER_UNRELIABLE_AFTER_BOOT_MSEC (30 * 1000)
119 #endif // CHIP_CONFIG_TIME_SERVER_TIMER_UNRELIABLE_AFTER_BOOT_MSEC
122 * @def CHIP_CONFIG_TIME_CLIENT_SYNC_PERIOD_MSEC
125 * This only applies to Time Sync Client/Coordinator roles. This is
126 * the variable 'timer_sync_period' in design spec. Default number of msec for
127 * the Client/Coordinator to perform another unicast time sync operation,
128 * if not specified in the init code. The default is 30 minutes.
131 #ifndef CHIP_CONFIG_TIME_CLIENT_SYNC_PERIOD_MSEC
132 #define CHIP_CONFIG_TIME_CLIENT_SYNC_PERIOD_MSEC (30 * 60 * 1000)
133 #endif // CHIP_CONFIG_TIME_CLIENT_SYNC_PERIOD_MSEC
136 * @def CHIP_CONFIG_TIME_CLIENT_NOMINAL_DISCOVERY_PERIOD_MSEC
139 * This only applies to Time Sync Client/Coordinator roles. This is
140 * the variable 'timer_nominal_discovery_period' in design spec. Default
141 * number of msec for the Client/Coordinator to perform another multicast
142 * discover operation, when there is no communication error,
143 * if not specified in the init code. Default is 12 hours.
146 #ifndef CHIP_CONFIG_TIME_CLIENT_NOMINAL_DISCOVERY_PERIOD_MSEC
147 #define CHIP_CONFIG_TIME_CLIENT_NOMINAL_DISCOVERY_PERIOD_MSEC (12 * 3600 * 1000)
148 #endif // CHIP_CONFIG_TIME_CLIENT_NOMINAL_DISCOVERY_PERIOD_MSEC
151 * @def CHIP_CONFIG_TIME_CLIENT_MINIMUM_DISCOVERY_PERIOD_MSEC
154 * This only applies to Time Sync Client/Coordinator roles. This is
155 * the variable 'timer_minimum_discovery_period' in design spec. Default
156 * number of msec for the Client/Coordinator to perform another multicast
157 * discover operation, when there is some communication error,
158 * if not specified in the init call. It is not recommended to perform
159 * discover operation faster than the default value. Default is 30 minutes.
162 #ifndef CHIP_CONFIG_TIME_CLIENT_MINIMUM_DISCOVERY_PERIOD_MSEC
163 #define CHIP_CONFIG_TIME_CLIENT_MINIMUM_DISCOVERY_PERIOD_MSEC (30 * 60 * 1000)
164 #endif // CHIP_CONFIG_TIME_CLIENT_MINIMUM_DISCOVERY_PERIOD_MSEC
167 * @def CHIP_CONFIG_TIME_CLIENT_TIMER_MULTICAST_MSEC
170 * This only applies to Time Sync Client/Coordinator roles. This is
171 * the variable 'timer_wait_for_multicast_response' in design spec.
172 * Number of msec before the Client/Coordinator quits waiting for
173 * responses to the multicasted sync request. Default is 2 seconds.
176 #ifndef CHIP_CONFIG_TIME_CLIENT_TIMER_MULTICAST_MSEC
177 #define CHIP_CONFIG_TIME_CLIENT_TIMER_MULTICAST_MSEC (2 * 1000)
178 #endif // CHIP_CONFIG_TIME_CLIENT_TIMER_MULTICAST_MSEC
181 * @def CHIP_CONFIG_TIME_CLIENT_TIMER_UNICAST_MSEC
184 * This only applies to Time Sync Client/Coordinator roles. This is
185 * the variable 'timer_wait_for_unicast_response' in design spec.
186 * Number of msec before the Client/Coordinator quits waiting for
187 * response to the unicasted sync request. Default is 2 seconds.
190 #ifndef CHIP_CONFIG_TIME_CLIENT_TIMER_UNICAST_MSEC
191 #define CHIP_CONFIG_TIME_CLIENT_TIMER_UNICAST_MSEC (2 * 1000)
192 #endif // CHIP_CONFIG_TIME_CLIENT_TIMER_UNICAST_MSEC
195 * @def CHIP_CONFIG_TIME_CLIENT_TIMER_CLOUD_SERVICE_MSEC
198 * This only applies to Time Sync Client/Coordinator roles. This is
199 * the variable 'timer_wait_for_service_response' in design spec.
200 * Number of msec before the Client/Coordinator quits waiting for
201 * response to the unicasted sync request going through TCP.
202 * Default is 5 seconds.
205 #ifndef CHIP_CONFIG_TIME_CLIENT_TIMER_CLOUD_SERVICE_MSEC
206 #define CHIP_CONFIG_TIME_CLIENT_TIMER_CLOUD_SERVICE_MSEC (5 * 1000)
207 #endif // CHIP_CONFIG_TIME_CLIENT_TIMER_CLOUD_SERVICE_MSEC
210 * @def CHIP_CONFIG_TIME_CLIENT_MAX_RTT_USEC
213 * This only applies to Time Sync Client/Coordinator roles. This is
214 * the 'max round trip time for usable response' in design spec.
215 * Number of usec for the longest round trip time a Client/Coordinator
216 * would consider a response as valid/useful. Default is 10 seconds.
219 #ifndef CHIP_CONFIG_TIME_CLIENT_MAX_RTT_USEC
220 #define CHIP_CONFIG_TIME_CLIENT_MAX_RTT_USEC (10 * 1000000LL)
221 #endif // CHIP_CONFIG_TIME_CLIENT_MAX_RTT_USEC
224 * @def CHIP_CONFIG_TIME_CLIENT_MAX_NUM_CONTACTS
227 * This only applies to Time Sync Client/Coordinator roles. This is
228 * the 'list of known Time Coordinators and Servers' in design spec.
229 * Number of unicast contacts a Client/Coordinator can remember.
232 #ifndef CHIP_CONFIG_TIME_CLIENT_MAX_NUM_CONTACTS
233 #define CHIP_CONFIG_TIME_CLIENT_MAX_NUM_CONTACTS 4
234 #endif // CHIP_CONFIG_TIME_CLIENT_MAX_NUM_CONTACTS
237 * @def CHIP_CONFIG_TIME_CLIENT_FABRIC_LOCAL_DISCOVERY
240 * Disabled: 0, Enabled: 1. If enabled, the client would use
241 * UDP multicast to automatically discover available time servers
242 * and coordinators in the fabric. If disabled, contact information
243 * must be fed to the client through chip::Profiles::Time::TimeSyncNode::SyncWithNodes
246 #ifndef CHIP_CONFIG_TIME_CLIENT_FABRIC_LOCAL_DISCOVERY
247 #define CHIP_CONFIG_TIME_CLIENT_FABRIC_LOCAL_DISCOVERY 1
248 #endif // CHIP_CONFIG_TIME_CLIENT_FABRIC_LOCAL_DISCOVERY
251 * @def CHIP_CONFIG_TIME_CLIENT_CONNECTION_FOR_SERVICE
254 * Disabled: 0, Enabled: 1. If enabled, the client provides an API
255 * to go through a chip connection for time sync. If disabled,
256 * contact to cloud service must be fed to the client through chip::Profiles::Time::TimeSyncNode::SyncWithNodes
257 * and the transport would be UDP.
260 #ifndef CHIP_CONFIG_TIME_CLIENT_CONNECTION_FOR_SERVICE
261 #define CHIP_CONFIG_TIME_CLIENT_CONNECTION_FOR_SERVICE 1
262 #endif // CHIP_CONFIG_TIME_CLIENT_CONNECTION_FOR_SERVICE
265 * @def CHIP_CONFIG_TIME_CLIENT_MIN_OFFSET_FROM_SERVER_USEC
268 * This only applies to Time Sync Client/Coordinator roles. This is
269 * the 'min_time_offset_from_service' in design spec. If the absolute value
270 * of calculated correction from a Time Sync Server is smaller than this
271 * number of usec, the correction would be ignored. Default is 2 seconds.
274 #ifndef CHIP_CONFIG_TIME_CLIENT_MIN_OFFSET_FROM_SERVER_USEC
275 #define CHIP_CONFIG_TIME_CLIENT_MIN_OFFSET_FROM_SERVER_USEC (2 * 1000000LL)
276 #endif // CHIP_CONFIG_TIME_CLIENT_MIN_OFFSET_FROM_SERVER_USEC
279 * @def CHIP_CONFIG_TIME_CLIENT_REASONABLE_TIME_SINCE_LAST_SYNC_MIN
282 * This only applies to Time Sync Client/Coordinator roles. This is
283 * 'time since last sync for reliable response' in design spec.
284 * If a Server/Coordinator indicates that its system time has only been
285 * synced to some other reliable source longer than this number minutes
286 * ago, it would be counted as a stale/unreliable source.
287 * Default is 2 hours.
289 #ifndef CHIP_CONFIG_TIME_CLIENT_REASONABLE_TIME_SINCE_LAST_SYNC_MIN
290 #define CHIP_CONFIG_TIME_CLIENT_REASONABLE_TIME_SINCE_LAST_SYNC_MIN 120
291 #endif // CHIP_CONFIG_TIME_CLIENT_REASONABLE_TIME_SINCE_LAST_SYNC_MIN
294 * @def CHIP_CONFIG_TIME_COORDINATOR_THRESHOLD_TO_SEND_NOTIFICATION_USEC
297 * This only applies to Time Sync Coordinator role. This specifies
298 * threshold to trigger sending out of time change notification.
299 * If the system time is corrected on a Coordinator for more than this
300 * number of usec, it would multicast a Time Change Notification.
301 * Default is 2 seconds.
303 #ifndef CHIP_CONFIG_TIME_COORDINATOR_THRESHOLD_TO_SEND_NOTIFICATION_USEC
304 #define CHIP_CONFIG_TIME_COORDINATOR_THRESHOLD_TO_SEND_NOTIFICATION_USEC (2 * 1000000LL)
305 #endif // CHIP_CONFIG_TIME_COORDINATOR_THRESHOLD_TO_SEND_NOTIFICATION_USEC