Skip to content

Commit

Permalink
SNTP: backport espressif sntp api for lwip2 (#7097)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-a-v committed Feb 22, 2020
1 parent e6decac commit f69e404
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions cores/esp8266/time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,31 @@ int clock_gettime(clockid_t unused, struct timespec *tp)
#define sntp_real_timestamp sntp_get_current_timestamp()
#endif

#if LWIP_VERSION_MAJOR == 2
// backport api
#if LWIP_VERSION_MAJOR != 1

// backport Espressif api

bool sntp_set_timezone_in_seconds (int32_t timezone_sec)
{
configTime(timezone_sec, 0, sntp_getservername(0), sntp_getservername(1), sntp_getservername(2));
return true;
}

bool sntp_set_timezone(sint8 timezone_in_hours)
{
return sntp_set_timezone_in_seconds(3600 * ((int)timezone_in_hours));
}

char* sntp_get_real_time(time_t t)
{
return ctime(&t);
}

uint32 sntp_get_current_timestamp()
{
return sntp_real_timestamp;
}

#endif

time_t time(time_t * t)
Expand Down

0 comments on commit f69e404

Please sign in to comment.