Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNTP: backport espressif sntp api for lwip2 #7097

Merged
merged 3 commits into from
Feb 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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