fix: retry 3 попытки + таймаут 2с для sendCommand

This commit is contained in:
Aleksei
2026-06-17 11:01:59 +00:00
parent cf5b241fe2
commit cc206278c0
+13 -7
View File
@@ -19,7 +19,7 @@
#define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT #define ETH_CLK_MODE ETH_CLOCK_GPIO17_OUT
#define AP_SSID "Barrier-Setup" #define AP_SSID "Barrier-Setup"
#define FW_VERSION "1.5" #define FW_VERSION "1.6"
#define AP_PASS "barrier123" #define AP_PASS "barrier123"
Preferences prefs; Preferences prefs;
@@ -102,12 +102,18 @@ void sendCommand(String ip) {
Serial.println("Нет сети!"); Serial.println("Нет сети!");
return; return;
} }
HTTPClient http; int code = -1;
http.begin("http://" + ip + "/open"); for (int attempt = 1; attempt <= 3; attempt++) {
http.addHeader("X-Token", cfg_token); HTTPClient http;
int code = http.GET(); http.setTimeout(2000);
Serial.println("Ответ от " + ip + ": " + String(code)); http.begin("http://" + ip + "/open");
http.end(); http.addHeader("X-Token", cfg_token);
code = http.GET();
http.end();
Serial.println("Ответ от " + ip + " (попытка " + String(attempt) + "): " + String(code));
if (code == 200) break;
delay(300);
}
} }
String currentIP() { String currentIP() {