From 105a23b1f2d0141a266d96fab504051fccbbefeb Mon Sep 17 00:00:00 2001 From: Just Call Me Koko Date: Tue, 25 Jul 2023 21:04:17 -0400 Subject: [PATCH] Fix captive portal not showing after AP connect --- .github/workflows/build_push.yml | 2 +- esp32_marauder/EvilPortal.cpp | 10 +++++----- esp32_marauder/EvilPortal.h | 28 ++++++++++++++-------------- esp32_marauder/configs.h | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 885af5927..1ab4854b4 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -47,7 +47,7 @@ jobs: - name: Install ESPAsyncWebServer uses: actions/checkout@v2 with: - repository: justcallmekoko/ESPAsyncWebServer + repository: bigbrodude6119/ESPAsyncWebServer ref: master path: CustomESPAsyncWebServer diff --git a/esp32_marauder/EvilPortal.cpp b/esp32_marauder/EvilPortal.cpp index 0a5aba1c6..8cf73eb7f 100644 --- a/esp32_marauder/EvilPortal.cpp +++ b/esp32_marauder/EvilPortal.cpp @@ -31,7 +31,7 @@ String EvilPortal::get_password() { void EvilPortal::setupServer() { server.on("/", HTTP_GET, [this](AsyncWebServerRequest *request) { - request->send_P(200, "text/html", this->index_html); + request->send_P(200, "text/html", index_html); Serial.println("client connected"); #ifdef HAS_SCREEN this->sendToDisplay("Client connected to server"); @@ -90,7 +90,7 @@ bool EvilPortal::setHtml() { if (isPrintable(c)) html.concat(c); } - strncpy(this->index_html, html.c_str(), strlen(html.c_str())); + strncpy(index_html, html.c_str(), strlen(html.c_str())); this->has_html = true; Serial.println("html set"); html_file.close(); @@ -203,7 +203,7 @@ bool EvilPortal::setAP(LinkedList* ssids, LinkedList* access_ } if (ap_config != "") { - strncpy(this->apName, ap_config.c_str(), strlen(ap_config.c_str())); + strncpy(apName, ap_config.c_str(), strlen(ap_config.c_str())); this->has_ap = true; Serial.println("ap config set"); return true; @@ -215,10 +215,10 @@ bool EvilPortal::setAP(LinkedList* ssids, LinkedList* access_ void EvilPortal::startAP() { Serial.print("starting ap "); - Serial.println(this->apName); + Serial.println(apName); WiFi.mode(WIFI_AP); - WiFi.softAP(this->apName); + WiFi.softAP(apName); #ifdef HAS_SCREEN this->sendToDisplay("AP started"); diff --git a/esp32_marauder/EvilPortal.h b/esp32_marauder/EvilPortal.h index 22eccb6fd..1b6381507 100644 --- a/esp32_marauder/EvilPortal.h +++ b/esp32_marauder/EvilPortal.h @@ -39,17 +39,8 @@ extern Buffer buffer_obj; #define MAX_AP_NAME_SIZE 30 #define WIFI_SCAN_EVIL_PORTAL 30 -class CaptiveRequestHandler : public AsyncWebHandler { -public: - CaptiveRequestHandler() {} - virtual ~CaptiveRequestHandler() {} - - bool canHandle(AsyncWebServerRequest *request) { return true; } - - void handleRequest(AsyncWebServerRequest *request, char * index_html) { - request->send_P(200, "text/html", index_html); - } -}; +char apName[MAX_AP_NAME_SIZE] = "PORTAL"; +char index_html[MAX_HTML_SIZE] = "TEST"; struct ssid { String essid; @@ -68,6 +59,18 @@ struct AccessPoint { LinkedList* stations; }; +class CaptiveRequestHandler : public AsyncWebHandler { +public: + CaptiveRequestHandler() {} + virtual ~CaptiveRequestHandler() {} + + bool canHandle(AsyncWebServerRequest *request) { return true; } + + void handleRequest(AsyncWebServerRequest *request) { + request->send_P(200, "text/html", index_html); + } +}; + class EvilPortal { private: @@ -78,9 +81,6 @@ class EvilPortal { String user_name; String password; - char apName[MAX_AP_NAME_SIZE] = "PORTAL"; - char index_html[MAX_HTML_SIZE] = "TEST"; - bool has_html; bool has_ap; diff --git a/esp32_marauder/configs.h b/esp32_marauder/configs.h index 638c35f42..b20bcef5b 100644 --- a/esp32_marauder/configs.h +++ b/esp32_marauder/configs.h @@ -21,7 +21,7 @@ //#define XIAO_ESP32_S3 //// END BOARD TARGETS - #define MARAUDER_VERSION "v0.11.0-RC1" + #define MARAUDER_VERSION "v0.11.0-RC2" //// BOARD FEATURES #ifdef MARAUDER_M5STICKC