Skip to content

Commit 75e361d

Browse files
committed
restore sntp_set_timezone_in_seconds()
fixes #6678
1 parent 60be2c9 commit 75e361d

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

cores/esp8266/coredecls.h

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ void esp_yield();
2020
void esp_schedule();
2121
void tune_timeshift64 (uint64_t now_us);
2222
void disable_extra4k_at_link_time (void) __attribute__((noinline));
23+
bool sntp_set_timezone_in_seconds(uint32_t timezone);
2324

2425
uint32_t sqrt32 (uint32_t n);
2526
uint32_t crc32 (const void* data, size_t length, uint32_t crc = 0xffffffff);

cores/esp8266/sntp-lwip2.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ extern "C" {
6565

6666
static const char stod14[] PROGMEM = "settimeofday() can't set time!\n";
6767
bool sntp_set_timezone(sint8 timezone);
68-
bool sntp_set_timezone_in_seconds(sint32 timezone)
68+
bool sntp_set_timezone_in_seconds(uint32_t timezone)
6969
{
7070
return sntp_set_timezone((sint8)(timezone/(60*60))); //TODO: move this to the same file as sntp_set_timezone() in lwip1.4, and implement correctly over there.
7171
}

cores/esp8266/sntp-lwip2.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
#ifndef __sntp_lwip2_h__
22
#define __sntp_lwip2_h__
33

4-
extern "C" {
5-
6-
bool sntp_set_timezone_in_seconds(sint32 timezone);
7-
8-
}
4+
#include <coredecls.h>
95

106
#endif

cores/esp8266/time.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ 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
83+
bool sntp_set_timezone_in_seconds (uint32_t timezone_sec)
84+
{
85+
configTime(timezone_sec, 0, sntp_getservername(0), sntp_getservername(1), sntp_getservername(2));
86+
return true;
87+
}
88+
#endif
89+
8190
time_t time(time_t * t)
8291
{
8392
if (t)

0 commit comments

Comments
 (0)