Skip to content

Commit d9f8fec

Browse files
author
dingo35
committed
network.cpp: try worldtimeapi multiple times
1 parent 12875c1 commit d9f8fec

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

SmartEVSE-3/src/network.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,19 @@ void setTimeZone(void * parameter) {
670670
// lookup current timezone
671671
httpClient.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
672672
httpClient.begin("http://worldtimeapi.org/api/ip");
673-
int httpCode = httpClient.GET(); //Make the request
673+
int httpCode, i;
674+
for (i=0; i<15; i++) {
675+
httpCode = httpClient.GET(); //Make the request
676+
// only handle 200/301, fail on everything else
677+
if ( httpCode != HTTP_CODE_OK && httpCode != HTTP_CODE_MOVED_PERMANENTLY ) { //fail
678+
//httpClient.end();
679+
_LOG_A("Error on HTTP request (httpCode=%i), try=%i.\n", httpCode, i);
680+
delay(1000);
681+
//httpClient.begin("http://worldtimeapi.org/api/ip");
682+
} else {
683+
break;
684+
}
685+
}
674686

675687
// only handle 200/301, fail on everything else
676688
if( httpCode != HTTP_CODE_OK && httpCode != HTTP_CODE_MOVED_PERMANENTLY ) {

0 commit comments

Comments
 (0)