Hello,
After power up, it takes a while for Linino to boot, connect to wifi and then make the first connection to the NTP server to get the current date/time. During this period, the date/time that the Linino reports is wrong.
Is there a way to figure out from an Arduino sketch when the first NTP server update has been completed successfully ?
Just FYI, I found a solution via the "ping" command. If I can ping the NTP servers then I'm assuming that the date/time are set correctly. It is still possible that there is some lag between the first successful ping and the moment the ntpd process sets the date/time correctly but it's usually just a few seconds and I'm willing to live with that.
For example :
import re
import subprocess
import time
def getDayTime(format):
s = subprocess.Popen(["ping", "-c", "1", "-q", "0.openwrt.pool.ntp.org"], stdout = subprocess.PIPE)
for x in s.stdout:
if re.search("0% packet loss", x):
return time.strftime(format)
return ""