Skip to content

Commit dc62b19

Browse files
committed
move getLocalTime to time.cpp
1 parent b96338f commit dc62b19

File tree

2 files changed

+25
-39
lines changed

2 files changed

+25
-39
lines changed

cores/esp8266/time.cpp

+25-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,28 @@
2020
* synchronisation of the two through timeshift64
2121
*/
2222

23+
#include <Arduino.h>
24+
25+
// https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-time.c
26+
27+
bool getLocalTime(struct tm * info, uint32_t ms)
28+
{
29+
uint32_t start = millis();
30+
time_t now;
31+
while((millis()-start) <= ms) {
32+
time(&now);
33+
localtime_r(&now, info);
34+
if(info->tm_year > (2016 - 1900)){
35+
return true;
36+
}
37+
delay(10);
38+
}
39+
return false;
40+
}
41+
42+
43+
#if !defined(CORE_MOCK)
44+
2345
#include <stdlib.h>
2446
#include <../include/time.h> // See issue #6714
2547
#include <sys/time.h>
@@ -33,7 +55,6 @@ extern "C" {
3355
#include <coredecls.h>
3456
#include <Schedule.h>
3557

36-
#include <Arduino.h> // configTime()
3758

3859
extern "C" {
3960

@@ -257,4 +278,6 @@ int settimeofday(const struct timeval* tv, const struct timezone* tz)
257278
return 0;
258279
}
259280

260-
};
281+
}; // extern "C"
282+
283+
#endif // !defined(CORE_MOCK)

cores/esp8266/timehelper.cpp

-37
This file was deleted.

0 commit comments

Comments
 (0)