fix: relayPending флаг — реле срабатывает после отправки redirect

This commit is contained in:
Aleksei
2026-06-17 09:10:25 +00:00
parent 5166a155f6
commit 075e4d6c22
+6 -1
View File
@@ -26,6 +26,7 @@ WebServer server(80);
bool ethConnected = false;
bool wifiConnected = false;
bool staticIpApplied = false;
bool relayPending = false;
String cfg_ssid = "";
String cfg_pass = "";
@@ -195,9 +196,9 @@ void setupRoutes() {
// Открытие через браузер (POST + redirect — обновление страницы не повторяет команду)
server.on("/open", HTTP_POST, []() {
relayPending = true;
server.sendHeader("Location", "/?ok=1");
server.send(302);
triggerRelay();
});
// Открытие от контроллера (GET + токен)
@@ -298,5 +299,9 @@ void setup() {
void loop() {
server.handleClient();
if (relayPending) {
relayPending = false;
triggerRelay();
}
delay(10);
}