Skip to content

Commit

Permalink
Add sntp sync handler to wifi example
Browse files Browse the repository at this point in the history
  • Loading branch information
fadushin committed Mar 1, 2024
1 parent f3e53cf commit 9cbe486
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion erlang/wifi/src/wifi.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) ->
Expand Down

0 comments on commit 9cbe486

Please sign in to comment.