Skip to content

Commit 2989bfc

Browse files
committed
Rewrite calculation of reconnection retry delay for better readability.
1 parent fde634d commit 2989bfc

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/ArduinoIoTCloudTCP.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,8 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectMqttBroker()
358358
}
359359

360360
_last_connection_attempt_cnt++;
361-
unsigned long const reconnection_retry_delay = min(static_cast<unsigned long>(AIOT_CONFIG_MAX_RECONNECTION_RETRY_DELAY_ms), static_cast<unsigned long>(pow(2, _last_connection_attempt_cnt) * AIOT_CONFIG_RECONNECTION_RETRY_DELAY_ms));
361+
unsigned long reconnection_retry_delay = pow(2, _last_connection_attempt_cnt) * AIOT_CONFIG_RECONNECTION_RETRY_DELAY_ms;
362+
reconnection_retry_delay = min(reconnection_retry_delay, static_cast<unsigned long>(AIOT_CONFIG_MAX_RECONNECTION_RETRY_DELAY_ms));
362363
_next_connection_attempt_tick = millis() + reconnection_retry_delay;
363364

364365
DEBUG_ERROR("ArduinoIoTCloudTCP::%s could not connect to %s:%d", __FUNCTION__, _brokerAddress.c_str(), _brokerPort);

0 commit comments

Comments
 (0)