[PR #1531] [CLOSED] Async webserver #1773

Closed
opened 2026-02-28 02:12:57 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/tzapu/WiFiManager/pull/1531
Author: @joba-1
Created: 12/14/2022
Status: Closed

Base: masterHead: async-webserver


📝 Commits (2)

  • 473f306 async webserver for esp32 (untested)
  • 860919b adapt for esp8266

📊 Changes

2 files changed (+151 additions, -136 deletions)

View changed files

📝 WiFiManager.cpp (+124 -107)
📝 WiFiManager.h (+27 -29)

📄 Description

Not meant for merge, just as a heads up. Probably better to allow a choice...

  • Basic functionality works on ESP32 - only faster.
  • OTA is disabled, hints to make it work welcome.
  • Compiles for ESP8266.

tested with

#include <Arduino.h>

// include WiFiManager before ESPAsyncWebServer!
#include <WiFiManager.h>
#include <ESPAsyncWebServer.h>

AsyncWebServer web_server(80);

void manageWifi() {
  const char *host;
  #if defined(ESP32)
    host = WiFi.getHostname();
  #else
    host = WiFi.hostname().c_str();
  #endif
  WiFiManager wm;
  // wm.resetSettings();
  if (!wm.autoConnect(host, host)) {
    ESP.restart();
    while (true)
      ;
  }
}

void setup() {
  Serial.begin(115200);
  Serial.println("\nWifi");

  if (!WiFi.mode(WIFI_STA)) Serial.println("WiFi.mode(WIFI_STA) failed");
  if (!WiFi.hostname("AsyncWiFiManager")) Serial.println("WiFi.hostname() failed");

  Serial.println("Manager");
  manageWifi();

  Serial.println("Webserver");
  web_server.on("/", []( AsyncWebServerRequest *request ) {
    Serial.println("Serve");
    request->send(200, "text/html", 
      "<html>"
        "<head><title>Woooosh!</title></head>"
        "<body>"
          "<h1>Async WiFiManager Test</h1>"
          "<form method=\"post\" action=\"/wipe\">"
            "<input type=\"submit\" value=\"Wipe Wlan Config\"/>"
          "</form>"
          "<form method=\"post\" action=\"/reset\">"
            "<input type=\"submit\" value=\"Reset\"/>"
          "</form>"
        "</body>"
      "<html>");
  });

  web_server.on("/wipe", HTTP_POST, []( AsyncWebServerRequest *request ) { 
    Serial.println("Wipe");
    WiFiManager wm;
    wm.resetSettings();
    request->redirect("/");
  });

  web_server.on("/reset", HTTP_POST, []( AsyncWebServerRequest *request ) { 
    request->redirect("/");
    Serial.println("Reset");
    Serial.flush();
    ESP.restart();
  });

  web_server.begin();

  Serial.println("Done");
}

void loop() {
}

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/tzapu/WiFiManager/pull/1531 **Author:** [@joba-1](https://github.com/joba-1) **Created:** 12/14/2022 **Status:** ❌ Closed **Base:** `master` ← **Head:** `async-webserver` --- ### 📝 Commits (2) - [`473f306`](https://github.com/tzapu/WiFiManager/commit/473f3063a132f7074830bb5eb3ab3c283c21197f) async webserver for esp32 (untested) - [`860919b`](https://github.com/tzapu/WiFiManager/commit/860919b5e1ef0380ac2b3e20d60cfe7899673ca5) adapt for esp8266 ### 📊 Changes **2 files changed** (+151 additions, -136 deletions) <details> <summary>View changed files</summary> 📝 `WiFiManager.cpp` (+124 -107) 📝 `WiFiManager.h` (+27 -29) </details> ### 📄 Description Not meant for merge, just as a heads up. Probably better to allow a choice... * Basic functionality works on ESP32 - only faster. * OTA is disabled, hints to make it work welcome. * Compiles for ESP8266. tested with ```cpp #include <Arduino.h> // include WiFiManager before ESPAsyncWebServer! #include <WiFiManager.h> #include <ESPAsyncWebServer.h> AsyncWebServer web_server(80); void manageWifi() { const char *host; #if defined(ESP32) host = WiFi.getHostname(); #else host = WiFi.hostname().c_str(); #endif WiFiManager wm; // wm.resetSettings(); if (!wm.autoConnect(host, host)) { ESP.restart(); while (true) ; } } void setup() { Serial.begin(115200); Serial.println("\nWifi"); if (!WiFi.mode(WIFI_STA)) Serial.println("WiFi.mode(WIFI_STA) failed"); if (!WiFi.hostname("AsyncWiFiManager")) Serial.println("WiFi.hostname() failed"); Serial.println("Manager"); manageWifi(); Serial.println("Webserver"); web_server.on("/", []( AsyncWebServerRequest *request ) { Serial.println("Serve"); request->send(200, "text/html", "<html>" "<head><title>Woooosh!</title></head>" "<body>" "<h1>Async WiFiManager Test</h1>" "<form method=\"post\" action=\"/wipe\">" "<input type=\"submit\" value=\"Wipe Wlan Config\"/>" "</form>" "<form method=\"post\" action=\"/reset\">" "<input type=\"submit\" value=\"Reset\"/>" "</form>" "</body>" "<html>"); }); web_server.on("/wipe", HTTP_POST, []( AsyncWebServerRequest *request ) { Serial.println("Wipe"); WiFiManager wm; wm.resetSettings(); request->redirect("/"); }); web_server.on("/reset", HTTP_POST, []( AsyncWebServerRequest *request ) { request->redirect("/"); Serial.println("Reset"); Serial.flush(); ESP.restart(); }); web_server.begin(); Serial.println("Done"); } void loop() { } ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-28 02:12:57 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/WiFiManager#1773
No description provided.