Skip to content

Commit 0906bf5

Browse files
a-c-sreedhar-reddyme-no-dev
authored andcommitted
update getLocalTime(). (#2629)
* update getLocalTime(). * change count to millis in getLocalTime * timeout logic.
1 parent 53a4bf3 commit 0906bf5

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

Diff for: cores/esp32/esp32-hal-time.c

+3-11
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,15 @@ void configTzTime(const char* tz, const char* server1, const char* server2, cons
7676

7777
bool getLocalTime(struct tm * info, uint32_t ms)
7878
{
79-
uint32_t count = ms / 10;
79+
uint32_t start = millis();
8080
time_t now;
81-
82-
time(&now);
83-
localtime_r(&now, info);
84-
85-
if(info->tm_year > (2016 - 1900)){
86-
return true;
87-
}
88-
89-
while(count--) {
90-
delay(10);
81+
while((millis()-start) <= ms) {
9182
time(&now);
9283
localtime_r(&now, info);
9384
if(info->tm_year > (2016 - 1900)){
9485
return true;
9586
}
87+
delay(10);
9688
}
9789
return false;
9890
}

0 commit comments

Comments
 (0)