From dc62b198804c3a6c3c113353b0ff54f0510e13b6 Mon Sep 17 00:00:00 2001 From: david gauchard Date: Mon, 3 Jan 2022 22:12:59 +0100 Subject: [PATCH] move getLocalTime to time.cpp --- cores/esp8266/time.cpp | 27 ++++++++++++++++++++++++-- cores/esp8266/timehelper.cpp | 37 ------------------------------------ 2 files changed, 25 insertions(+), 39 deletions(-) delete mode 100644 cores/esp8266/timehelper.cpp diff --git a/cores/esp8266/time.cpp b/cores/esp8266/time.cpp index 8e997c72d5..d8308e62d7 100644 --- a/cores/esp8266/time.cpp +++ b/cores/esp8266/time.cpp @@ -20,6 +20,28 @@ * synchronisation of the two through timeshift64 */ +#include + +// 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 #include <../include/time.h> // See issue #6714 #include @@ -33,7 +55,6 @@ extern "C" { #include #include -#include // configTime() extern "C" { @@ -257,4 +278,6 @@ int settimeofday(const struct timeval* tv, const struct timezone* tz) return 0; } -}; +}; // extern "C" + +#endif // !defined(CORE_MOCK) diff --git a/cores/esp8266/timehelper.cpp b/cores/esp8266/timehelper.cpp deleted file mode 100644 index 7e57af1d04..0000000000 --- a/cores/esp8266/timehelper.cpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * timehelper.c - generic time functions - * Copyright (c) 2021 esp8266/Arduino. All rights reserved. - * This file is part of the esp8266 core for Arduino environment. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU Lesser General Public License for more details. - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - */ - - -#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; -}