[SYS] Add connection fallback capability (#1950)

This feature enable to rotate among the connection parameters index to find a valid one when the current MQTT connection is not working
This commit is contained in:
Florian authored and GitHub committed 2024-05-22 05:48:48 -05:00
1 parent 819d3c2d91
commit 0db67f75aa
3 files changed
+25 -1

No files matched your search

+19
View File
@@ -886,7 +886,26 @@ void connectMQTT() {
delayWithOTA(5000);
ErrorIndicatorOFF();
delayWithOTA(5000);
// If we have failed to connect to the MQTT broker, we will try to connect to the next set of connection parameters
if (failure_number_mqtt > maxRetryWatchDog) {
#ifndef ESPWifiManualSetup
// Look for the next valid connection
for (int i = 0; i < cnt_parameters_array_size; i++) {
cnt_index++;
if (cnt_index >= cnt_parameters_array_size) {
cnt_index = 0;
}
if (cnt_parameters_array[cnt_index].validConnection) {
Log.notice(F("Connection %d valid, switching" CR), cnt_index);
saveConfig();
break;
} else {
Log.notice(F("Connection %d not valid" CR), cnt_index);
}
}
#endif
unsigned long millis_since_last_ota;
while (
// When