Skip to content

Commit 7b53138

Browse files
committed
HTTP_Client: Increase timeout for each retry
No need for limitReached = false, retries already limited to 3
1 parent ac683af commit 7b53138

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

Firmware/RTK_Everywhere/HTTP_Client.ino

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,18 @@ bool httpClientConnectLimitReached()
9090

9191
// Retry the connection a few times
9292
limitReached = (httpClientConnectionAttempts >= MAX_HTTP_CLIENT_CONNECTION_ATTEMPTS);
93-
limitReached = false;
9493

9594
// Restart the HTTP client
96-
httpClientStop((!httpClientEnabled(nullptr)) || limitReached);
97-
98-
httpClientConnectionAttempts++;
95+
httpClientStop(limitReached || (!httpClientEnabled(nullptr)));
96+
97+
// Limit to max connection delay
98+
if (httpClientConnectionAttempts)
99+
httpClientConnectionAttemptTimeout = (5 * MILLISECONDS_IN_A_SECOND)
100+
<< (httpClientConnectionAttempts - 1);
101+
if (httpClientConnectionAttemptTimeout > RTK_MAX_CONNECTION_MSEC)
102+
httpClientConnectionAttemptTimeout = httpClientConnectionAttemptTimeout;
103+
else
104+
httpClientConnectionAttempts++;
99105
httpClientConnectionAttemptsTotal++;
100106
if (settings.debugHttpClientState)
101107
httpClientPrintStatus();

0 commit comments

Comments
 (0)