Skip to content

Commit 5b50eee

Browse files
author
dingo35
committed
network.cpp: have 2nd ip-api fallback site
1 parent d9f8fec commit 5b50eee

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

SmartEVSE-3/src/network.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -669,16 +669,16 @@ void setTimeZone(void * parameter) {
669669
};
670670
// lookup current timezone
671671
httpClient.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
672-
httpClient.begin("http://worldtimeapi.org/api/ip");
673-
int httpCode, i;
674-
for (i=0; i<15; i++) {
672+
String host[2] = { "http://worldtimeapi.org/api/ip", "http://ip-api.com/json"};
673+
int httpCode;
674+
for (int i=0; i<15; i++) {
675+
httpClient.begin(host[i%2]);
675676
httpCode = httpClient.GET(); //Make the request
676677
// only handle 200/301, fail on everything else
677678
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);
679+
httpClient.end();
680+
_LOG_A("Error on HTTP request (httpCode=%i), host=%s, try=%i.\n", httpCode, host[i%2].c_str(), i);
680681
delay(1000);
681-
//httpClient.begin("http://worldtimeapi.org/api/ip");
682682
} else {
683683
break;
684684
}

0 commit comments

Comments
 (0)