Commit 0906bf58 authored by A C SREEDHAR REDDY's avatar A C SREEDHAR REDDY Committed by Me No Dev

update getLocalTime(). (#2629)

* update getLocalTime().

* change count to millis in getLocalTime

* timeout logic.
parent 53a4bf33
...@@ -76,23 +76,15 @@ void configTzTime(const char* tz, const char* server1, const char* server2, cons ...@@ -76,23 +76,15 @@ void configTzTime(const char* tz, const char* server1, const char* server2, cons
bool getLocalTime(struct tm * info, uint32_t ms) bool getLocalTime(struct tm * info, uint32_t ms)
{ {
uint32_t count = ms / 10; uint32_t start = millis();
time_t now; time_t now;
while((millis()-start) <= ms) {
time(&now);
localtime_r(&now, info);
if(info->tm_year > (2016 - 1900)){
return true;
}
while(count--) {
delay(10);
time(&now); time(&now);
localtime_r(&now, info); localtime_r(&now, info);
if(info->tm_year > (2016 - 1900)){ if(info->tm_year > (2016 - 1900)){
return true; return true;
} }
delay(10);
} }
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment