Skip to content

Commit f69e404

Browse files
authored
SNTP: backport espressif sntp api for lwip2 (#7097)
1 parent e6decac commit f69e404

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

cores/esp8266/time.cpp

+20-2
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,31 @@ int clock_gettime(clockid_t unused, struct timespec *tp)
7878
#define sntp_real_timestamp sntp_get_current_timestamp()
7979
#endif
8080

81-
#if LWIP_VERSION_MAJOR == 2
82-
// backport api
81+
#if LWIP_VERSION_MAJOR != 1
82+
83+
// backport Espressif api
84+
8385
bool sntp_set_timezone_in_seconds (int32_t timezone_sec)
8486
{
8587
configTime(timezone_sec, 0, sntp_getservername(0), sntp_getservername(1), sntp_getservername(2));
8688
return true;
8789
}
90+
91+
bool sntp_set_timezone(sint8 timezone_in_hours)
92+
{
93+
return sntp_set_timezone_in_seconds(3600 * ((int)timezone_in_hours));
94+
}
95+
96+
char* sntp_get_real_time(time_t t)
97+
{
98+
return ctime(&t);
99+
}
100+
101+
uint32 sntp_get_current_timestamp()
102+
{
103+
return sntp_real_timestamp;
104+
}
105+
88106
#endif
89107

90108
time_t time(time_t * t)

0 commit comments

Comments
 (0)