- Tue May 03, 2016 2:24 pm
#46808
Greetings,
Thank you for your interest!
I gave
"wifi.eventmon.reg(wifi.eventmon.STA_GOT_IP, function() dofile("ntpSync.lua") end)" a try but the init script seem to stop when it hit that statement. I wonder if the event detection doesn't work because it is running in server mode??? I had tried a while loop using
wifi.sta.getip() to wait for the ip assignment but I couldn't get it to work either. It makes good logic sense to wait for the IP assignment using a callback.
A factor that added confusion is that even with a long delay after connection is confirmed I still need to send
sntp.sync('129.6.15.28') twice to get NTP sync. Since connection to my LAN is very quick the following pair of one shot timer statements at the end of the init file seem to provide a solution:
tmr.alarm(0,5000, tmr.ALARM_SINGLE, function() dofile("ntpSync.lua")end)
tmr.alarm(1,10000, tmr.ALARM_SINGLE, function() dofile("ntpSync.lua")end)
Thanks for your suggestion!
tma