Skip to content

Commit

Permalink
Fix captive portal not showing after AP connect
Browse files Browse the repository at this point in the history
  • Loading branch information
justcallmekoko committed Jul 26, 2023
1 parent 70b0601 commit 105a23b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
- name: Install ESPAsyncWebServer
uses: actions/checkout@v2
with:
repository: justcallmekoko/ESPAsyncWebServer
repository: bigbrodude6119/ESPAsyncWebServer
ref: master
path: CustomESPAsyncWebServer

Expand Down
10 changes: 5 additions & 5 deletions esp32_marauder/EvilPortal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -203,7 +203,7 @@ bool EvilPortal::setAP(LinkedList<ssid>* ssids, LinkedList<AccessPoint>* 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;
Expand All @@ -215,10 +215,10 @@ bool EvilPortal::setAP(LinkedList<ssid>* ssids, LinkedList<AccessPoint>* 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");
Expand Down
28 changes: 14 additions & 14 deletions esp32_marauder/EvilPortal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -68,6 +59,18 @@ struct AccessPoint {
LinkedList<int>* 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:
Expand All @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion esp32_marauder/configs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 105a23b

Please sign in to comment.