Skip to content

Commit 71aa1b1

Browse files
maass-hamburgkartben
authored andcommitted
net: config: sntp: add option for failure try interval
add option for a different resync interval, that is applied when the sntp request fails. Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
1 parent fd818d7 commit 71aa1b1

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

subsys/net/lib/config/Kconfig

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,18 @@ config NET_CONFIG_SNTP_INIT_RESYNC
244244
Perform an SNTP request over networking periodically to get and
245245
absolute wall clock time, and resync system time from it.
246246

247+
if NET_CONFIG_SNTP_INIT_RESYNC
248+
247249
config NET_CONFIG_SNTP_INIT_RESYNC_INTERVAL
248250
int "SNTP resync interval (sec)"
249-
depends on NET_CONFIG_SNTP_INIT_RESYNC
250251
default 3600
251252

253+
config NET_CONFIG_SNTP_INIT_RESYNC_ON_FAILURE_INTERVAL
254+
int "SNTP resync interval (sec) on failure"
255+
default NET_CONFIG_SNTP_INIT_RESYNC_INTERVAL
256+
help
257+
If the SNTP request fails, then this is the interval to wait
258+
before trying again.
259+
260+
endif # NET_CONFIG_SNTP_INIT_RESYNC
252261
endif # NET_CONFIG_CLOCK_SNTP_INIT

subsys/net/lib/config/init_clock_sntp.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,10 @@ int net_init_clock_via_sntp(void)
5454

5555
end:
5656
#ifdef CONFIG_NET_CONFIG_SNTP_INIT_RESYNC
57-
k_work_reschedule(&sntp_resync_work_handle,
58-
K_SECONDS(CONFIG_NET_CONFIG_SNTP_INIT_RESYNC_INTERVAL));
57+
k_work_reschedule(
58+
&sntp_resync_work_handle,
59+
(res < 0) ? K_SECONDS(CONFIG_NET_CONFIG_SNTP_INIT_RESYNC_ON_FAILURE_INTERVAL)
60+
: K_SECONDS(CONFIG_NET_CONFIG_SNTP_INIT_RESYNC_INTERVAL));
5961
#endif
6062
return res;
6163
}

0 commit comments

Comments
 (0)