From 0906bf580f639c17c4b899b9cb0828088ac239bd Mon Sep 17 00:00:00 2001 From: A C SREEDHAR REDDY Date: Wed, 10 Apr 2019 06:09:14 +0530 Subject: [PATCH] update getLocalTime(). (#2629) * update getLocalTime(). * change count to millis in getLocalTime * timeout logic. --- cores/esp32/esp32-hal-time.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/cores/esp32/esp32-hal-time.c b/cores/esp32/esp32-hal-time.c index 69ab3ff5..e64c764b 100644 --- a/cores/esp32/esp32-hal-time.c +++ b/cores/esp32/esp32-hal-time.c @@ -76,23 +76,15 @@ void configTzTime(const char* tz, const char* server1, const char* server2, cons bool getLocalTime(struct tm * info, uint32_t ms) { - uint32_t count = ms / 10; + uint32_t start = millis(); time_t now; - - time(&now); - localtime_r(&now, info); - - if(info->tm_year > (2016 - 1900)){ - return true; - } - - while(count--) { - delay(10); + while((millis()-start) <= ms) { time(&now); localtime_r(&now, info); if(info->tm_year > (2016 - 1900)){ return true; } + delay(10); } return false; }