Skip to content

Commit

Permalink
update getLocalTime(). (#2629)
Browse files Browse the repository at this point in the history
* update getLocalTime().

* change count to millis in getLocalTime

* timeout logic.
  • Loading branch information
a-c-sreedhar-reddy authored and me-no-dev committed Apr 10, 2019
1 parent 53a4bf3 commit 0906bf5
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions cores/esp32/esp32-hal-time.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 0906bf5

Please sign in to comment.