1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-27 18:02:17 +03:00

handle tv.tv_usec in settimeofday() (#4001)

optional settimeofday()'s callback
fix #1679
This commit is contained in:
david gauchard
2017-12-24 21:48:25 +01:00
committed by Develo
parent d5bb4a99f6
commit 9913e52107
4 changed files with 49 additions and 23 deletions

View File

@ -12,9 +12,10 @@
This example code is in the public domain.
*/
#include <ESP8266WiFi.h>
#include <time.h> // time() ctime()
#include <sys/time.h> // struct timeval
#include <ESP8266WiFi.h>
#include <coredecls.h> // settimeofday_cb()
////////////////////////////////////////////////////////
@ -32,8 +33,19 @@
#define TZ_SEC ((TZ)*3600)
#define DST_SEC ((DST_MN)*60)
timeval cbtime; // time set in callback
bool cbtime_set = false;
void time_is_set (void)
{
gettimeofday(&cbtime, NULL);
cbtime_set = true;
Serial.println("------------------ settimeofday() was called ------------------");
}
void setup() {
Serial.begin(115200);
settimeofday_cb(time_is_set);
#if NTP0_OR_LOCAL1
// local