AsyncFsWebServer - WiFi behaviour

I've been using AsyncFsWebServer in a number of projects, and I've found it really useful.

I'd like to use it in a new project that I'm working on, but I need it to manage WiFi in a different way.

By default it attempts to connect to a WiFi network using stored credentials - if there are no stored credentials, or if the stored credentials timeout, it sets the ESP32 up as a WiFi Access Point (AP) to allow you to connect to it to configure WiFi.

As an AP it redirects all incoming requests to /setup ... great for setting up a connection to a new WiFi network, not so great if you want it to work as an AP / web server hosting a webpage.

Here's the code that does this (in AsyncFsWebServer.cpp):

        // No connection, start AP and then captive portal
        startCaptivePortal(m_apSSID.c_str(), m_apPsk.c_str(), "/setup");

Is it possible to use this library as an AP without this redirection?

Ideally, I'd like the ESP32 to run as an AP, scanning the available networks periodically, and connecting to a known network when it sees one ... is this possible?

TIA,
J.

Hi @jnik !
I am the developer of the library.
As you could read in the brief description of the library itself, AsyncEspFsWebserver is little more than a wrapper of the well-known ESPAsyncWebServer which brings together a series of common features when dealing with a webserver on ESP32 (WiFi manager, file upload, ACE web editor etc etc).

The WiFi connection functionality you described is a "convenience" that in my opinion can be useful in most cases, but it is not mandatory to use the library methods.

So, if you don't need the captive portal, you can simply initialize the WIFi in AP mode as shown in the example included in the ESP32 core and remove the stuffs related to WiFi connection performed by the library itself.

  // // Try to connect to stored SSID, start AP with captive portal if fails after timeout
  // IPAddress myIP = server.startWiFi(15000);
  // if (!myIP) {
  //   Serial.println("\n\nNo WiFi connection, start AP and Captive Portal\n");
  //   server.startCaptivePortal("ESP_AP", "123456789", "/setup");
  //   myIP = WiFi.softAPIP();
  // }

  Serial.println("Configuring access point...");
  if (!WiFi.softAP("ESP32_APMODE", "123456789")) {
    log_e("Soft AP creation failed.");
    while(1);
  }
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);

Excellent ... thanks for taking the time to answer my question.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.