From 3356c590cde625123c88bf66559c0fad7defc1f8 Mon Sep 17 00:00:00 2001 From: xyzroe Date: Sat, 25 May 2024 19:39:25 +0200 Subject: [PATCH] 20240525.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix mDNS error. Thanks @chrizy66 and @charrus 🚀 #30 - Keep working on cz.json. Thanks @leroyloren 🚀 #31 - Add Discord community link --- src/web.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/web.cpp b/src/web.cpp index 87fee71..cc09b9d 100644 --- a/src/web.cpp +++ b/src/web.cpp @@ -79,6 +79,8 @@ extern struct MqttConfigStruct mqttCfg; extern LEDControl ledControl; +extern IPAddress apIP; + bool wifiWebSetupInProgress = false; bool eventOK = false; @@ -241,21 +243,25 @@ void initWebServer() LOGD("done"); } -IPAddress apIP2(192, 168, 1, 1); +// IPAddress apIP2(192, 168, 1, 1); bool captivePortal() { - IPAddress ip; - if (!ip.fromString(serverWeb.hostHeader())) + if (vars.apStarted) { - LOGD("Request redirected to captive portal"); - serverWeb.sendHeader("Location", String("http://") + apIP2.toString(), true); - serverWeb.send(302, "text/plain", ""); - serverWeb.client().stop(); - return true; + IPAddress ip; + if (!ip.fromString(serverWeb.hostHeader())) + { + LOGD("Request redirected to captive portal"); + serverWeb.sendHeader("Location", String("http://") + apIP.toString(), true); + serverWeb.send(302, "text/plain", ""); + serverWeb.client().stop(); + return true; + } } return false; } + /* void handleNotFound() {