From f3c5023b93b081c752e8919d77487d98c85f73be Mon Sep 17 00:00:00 2001 From: A C SREEDHAR REDDY Date: Mon, 1 Apr 2019 19:05:58 +0530 Subject: [PATCH 1/3] update getLocalTime(). --- cores/esp32/esp32-hal-time.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/cores/esp32/esp32-hal-time.c b/cores/esp32/esp32-hal-time.c index 69ab3ff526b..9e6edf1036f 100644 --- a/cores/esp32/esp32-hal-time.c +++ b/cores/esp32/esp32-hal-time.c @@ -78,21 +78,13 @@ bool getLocalTime(struct tm * info, uint32_t ms) { uint32_t count = ms / 10; time_t now; - - time(&now); - localtime_r(&now, info); - - if(info->tm_year > (2016 - 1900)){ - return true; - } - while(count--) { - delay(10); time(&now); localtime_r(&now, info); if(info->tm_year > (2016 - 1900)){ return true; } + delay(10); } return false; } From ef5e9b92d80a3e5e10b3b4cc5ffc845022d09906 Mon Sep 17 00:00:00 2001 From: a-c-sreedhar-reddy Date: Thu, 4 Apr 2019 00:07:23 +0530 Subject: [PATCH 2/3] change count to millis in getLocalTime --- cores/esp32/esp32-hal-time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cores/esp32/esp32-hal-time.c b/cores/esp32/esp32-hal-time.c index 9e6edf1036f..e1b8752e70c 100644 --- a/cores/esp32/esp32-hal-time.c +++ b/cores/esp32/esp32-hal-time.c @@ -76,9 +76,9 @@ 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; - while(count--) { + while((millis()-start) > ms) { time(&now); localtime_r(&now, info); if(info->tm_year > (2016 - 1900)){ From c271d3f4c57e089a16b63b7dc7b5c8b6508cab76 Mon Sep 17 00:00:00 2001 From: A C SREEDHAR REDDY Date: Thu, 4 Apr 2019 00:09:21 +0530 Subject: [PATCH 3/3] timeout logic. --- cores/esp32/esp32-hal-time.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/esp32-hal-time.c b/cores/esp32/esp32-hal-time.c index e1b8752e70c..e64c764b478 100644 --- a/cores/esp32/esp32-hal-time.c +++ b/cores/esp32/esp32-hal-time.c @@ -78,7 +78,7 @@ bool getLocalTime(struct tm * info, uint32_t ms) { uint32_t start = millis(); time_t now; - while((millis()-start) > ms) { + while((millis()-start) <= ms) { time(&now); localtime_r(&now, info); if(info->tm_year > (2016 - 1900)){