From c431d93895cdb73158cc93dbaa45fee2d9d8e008 Mon Sep 17 00:00:00 2001 From: ollo Date: Mon, 16 May 2016 13:54:42 +0200 Subject: [PATCH] NTP integrated --- main.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.lua b/main.lua index 4d19599..9273e10 100644 --- a/main.lua +++ b/main.lua @@ -1,4 +1,7 @@ dofile("wlancfg.lua") +dofile("timecore.lua") + +timezoneoffset=1 -- Wait to be connect to the WiFi access point. tmr.alarm(0, 100, 1, function() @@ -11,7 +14,7 @@ tmr.alarm(0, 100, 1, function() print('IP: ',wifi.sta.getip()) --ptbtime1.ptb.de - sntp.sync('192.53.103.108', + sntp.sync('ptbtime1.ptb.de', function(sec,usec,server) print('sync', sec, usec, server) end, @@ -26,6 +29,8 @@ end) tmr.alarm(1, 1000, 1 ,function() sec, usec = rtctime.get() + time = getTime(sec, timezoneoffset) print("Time : " , sec) + print("Local time : " .. time.year .. "-" .. time.month .. "-" .. time.day .. " " .. time.hour .. ":" .. time.minute .. ":" .. time.second) end)