From 9cbe486e1d5a830b835829e61fa19aad1881acd7 Mon Sep 17 00:00:00 2001 From: Fred Dushin Date: Fri, 1 Mar 2024 17:18:29 -0500 Subject: [PATCH] Add sntp sync handler to wifi example --- erlang/wifi/src/wifi.erl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/erlang/wifi/src/wifi.erl b/erlang/wifi/src/wifi.erl index 4358189..3af8658 100644 --- a/erlang/wifi/src/wifi.erl +++ b/erlang/wifi/src/wifi.erl @@ -45,10 +45,14 @@ start_network() -> {disconnected, fun disconnected/0} | maps:get(sta, config:get()) ]}, - {sntp, [{host, "pool.ntp.org"}]} + {sntp, [ + {host, "time-d-b.nist.gov"}, + {synchronized, fun sntp_synchronized/1} + ]} ], case network:start(Config) of {ok, _Pid} -> + io:format("Network started.~n"), timer:sleep(infinity); Error -> Error @@ -76,6 +80,9 @@ got_ip(IpInfo) -> disconnected() -> io:format("STA disconnected.~n"). +sntp_synchronized({TVSec, TVUsec}) -> + io:format("Synchronized time with SNTP server. TVSec=~p TVUsec=~p~n", [TVSec, TVUsec]). + verify_platform(esp32) -> ok; verify_platform(Platform) ->