Skip to content

Commit ac2004b

Browse files
authored
Merge pull request #18 from atomvm/add-sntp-sync-callback
Add sntp sync handler to wifi example
2 parents f3e53cf + 9cbe486 commit ac2004b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

erlang/wifi/src/wifi.erl

+8-1
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,14 @@ start_network() ->
4545
{disconnected, fun disconnected/0}
4646
| maps:get(sta, config:get())
4747
]},
48-
{sntp, [{host, "pool.ntp.org"}]}
48+
{sntp, [
49+
{host, "time-d-b.nist.gov"},
50+
{synchronized, fun sntp_synchronized/1}
51+
]}
4952
],
5053
case network:start(Config) of
5154
{ok, _Pid} ->
55+
io:format("Network started.~n"),
5256
timer:sleep(infinity);
5357
Error ->
5458
Error
@@ -76,6 +80,9 @@ got_ip(IpInfo) ->
7680
disconnected() ->
7781
io:format("STA disconnected.~n").
7882

83+
sntp_synchronized({TVSec, TVUsec}) ->
84+
io:format("Synchronized time with SNTP server. TVSec=~p TVUsec=~p~n", [TVSec, TVUsec]).
85+
7986
verify_platform(esp32) ->
8087
ok;
8188
verify_platform(Platform) ->

0 commit comments

Comments
 (0)