I have an ESP8266 NodeMCU board. I have loaded the NodeMCU Lua based firmware on it and need accurate time keeping for scheduling few functions. I built the binary using their cloud service with following modules: rtctime, sntp, cron amongst others.
How can I set the local time using sntp module? My local time has an offset of 19800 (5.5 hours IST) from UTC.
I am unable to set this offset in sntp.setoffset(offset) call
> sntp.setoffset(19800)
> sntp.getoffset()
88
>
why does getoffset print 88?
Update =====> It prints 88 because the offset data type in the C code is unsigned byte and instead of using this offset for time zone handling we must use zone files from Linux (example here)
Update: Setting the RTC to local time by using rtctime.set(seconds_since_unix_epoch) in the success callback of sntp.sync() works fine.
function sntp_sync_time()
sntp.sync(nil, function(sec, usec, server, info) rtctime.set(sec + 19800) end, sntp_sync_time, 1)
end
Also I'm calling the same function recursively in the failure callback until successful synchronization doesn't happen.
Thanks