Skip to content

Commit

Permalink
move getLocalTime to time.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
d-a-v committed Jan 3, 2022
1 parent b96338f commit dc62b19
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 39 deletions.
27 changes: 25 additions & 2 deletions cores/esp8266/time.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,28 @@
* synchronisation of the two through timeshift64
*/

#include <Arduino.h>

// https://github.com/espressif/arduino-esp32/blob/master/cores/esp32/esp32-hal-time.c

bool getLocalTime(struct tm * info, uint32_t ms)
{
uint32_t start = millis();
time_t now;
while((millis()-start) <= ms) {
time(&now);
localtime_r(&now, info);
if(info->tm_year > (2016 - 1900)){
return true;
}
delay(10);
}
return false;
}


#if !defined(CORE_MOCK)

#include <stdlib.h>
#include <../include/time.h> // See issue #6714
#include <sys/time.h>
Expand All @@ -33,7 +55,6 @@ extern "C" {
#include <coredecls.h>
#include <Schedule.h>

#include <Arduino.h> // configTime()

extern "C" {

Expand Down Expand Up @@ -257,4 +278,6 @@ int settimeofday(const struct timeval* tv, const struct timezone* tz)
return 0;
}

};
}; // extern "C"

#endif // !defined(CORE_MOCK)
37 changes: 0 additions & 37 deletions cores/esp8266/timehelper.cpp

This file was deleted.

0 comments on commit dc62b19

Please sign in to comment.