def periodic_tasks():
# Called every few seconds
# Check if the time has been set.
epoch = time.mktime((2016,1,1,0,0,0,0,0,0))
time_is_set = ( time.time() > epoch )
if not time_is_set:
# Check if the network STA is configured.
sta = network.WLAN(network.STA_IF)
if sta.isconnected():
#Trying to sync with ntp
try:
ntptime.settime()
except OSError:
print("Failed to sync with ntp")
评论列表
文章目录