From 020047b0f9739457f5ea46571d890ca0dea70102 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Tue, 23 Nov 2021 13:02:49 +0100 Subject: [PATCH] Examples/lwip: sntp example - Make SNTP server configurable Also updates NTP example test to allow more attempts --- examples/protocols/sntp/example_test.py | 2 +- examples/protocols/sntp/main/Kconfig.projbuild | 6 ++++++ examples/protocols/sntp/main/sntp_example_main.c | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/examples/protocols/sntp/example_test.py b/examples/protocols/sntp/example_test.py index 79d0880849..ff9b888670 100644 --- a/examples/protocols/sntp/example_test.py +++ b/examples/protocols/sntp/example_test.py @@ -15,7 +15,7 @@ def test_examples_sntp(env, extra_data): dut.expect_all('Time is not set yet. Connecting to WiFi and getting time over NTP.', 'Initializing SNTP', - 'Waiting for system time to be set... (1/10)', + re.compile(r'Waiting for system time to be set... \(\d+/\d+\)'), 'Notification of a time synchronization event', timeout=60) diff --git a/examples/protocols/sntp/main/Kconfig.projbuild b/examples/protocols/sntp/main/Kconfig.projbuild index 45e1737413..490365acb3 100644 --- a/examples/protocols/sntp/main/Kconfig.projbuild +++ b/examples/protocols/sntp/main/Kconfig.projbuild @@ -1,5 +1,11 @@ menu "Example Configuration" + config SNTP_TIME_SERVER + string "SNTP server name" + default "pool.ntp.org" + help + Hostname of the main SNTP server. + choice SNTP_TIME_SYNC_METHOD prompt "Time synchronization method" default SNTP_TIME_SYNC_METHOD_IMMED diff --git a/examples/protocols/sntp/main/sntp_example_main.c b/examples/protocols/sntp/main/sntp_example_main.c index d3679082cf..e5e81f800a 100644 --- a/examples/protocols/sntp/main/sntp_example_main.c +++ b/examples/protocols/sntp/main/sntp_example_main.c @@ -183,8 +183,8 @@ static void initialize_sntp(void) #endif /* LWIP_IPV6 */ #else /* LWIP_DHCP_GET_NTP_SRV && (SNTP_MAX_SERVERS > 1) */ - // otherwise use DNS address from a pool - sntp_setservername(0, "pool.ntp.org"); + // otherwise, use DNS address from a pool + sntp_setservername(0, CONFIG_SNTP_TIME_SERVER); #endif sntp_set_time_sync_notification_cb(time_sync_notification_cb);