Skip to content
This repository was archived by the owner on Feb 4, 2023. It is now read-only.
This repository was archived by the owner on Feb 4, 2023. It is now read-only.

how to close the AP after successfully connecting to the configured WiFi? #87

@slaesh

Description

@slaesh

the AP is still "there", even after connecting to the WiFi! :)
Even on every new reset with stored (and valid) SSID/pass!

void wifimanager_setup()
{
    delay(500);

    Serial.print("\nStarting Async_AutoConnect_ESP32_minimal on " + String(ARDUINO_BOARD));
    Serial.println(ESP_ASYNC_WIFIMANAGER_VERSION);

#if (USING_ESP32_S2 || USING_ESP32_C3)
    ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, NULL, HOSTNAME);
#else
    ESPAsync_WiFiManager ESPAsync_wifiManager(&webServer, &dnsServer, HOSTNAME);
#endif

    ESPAsync_wifiManager.setDebugOutput(true);

    // We can't use WiFi.SSID() in ESP32 as it's only valid after connected.
    // SSID and Password stored in ESP32 wifi_ap_record_t and wifi_config_t are also cleared in reboot
    // Have to create a new function to store in EEPROM/SPIFFS for this purpose
    String Router_SSID = ESPAsync_wifiManager.WiFi_SSID();
    String Router_Pass = ESPAsync_wifiManager.WiFi_Pass();

    // Remove this line if you do not want to see WiFi password printed
    Serial.println("ESP Self-Stored: SSID = " + Router_SSID + ", Pass = " + Router_Pass);

    // ESPAsync_wifiManager.resetSettings();   //reset saved settings
    ESPAsync_wifiManager.setAPStaticIPConfig(IPAddress(192, 168, 132, 1), IPAddress(192, 168, 132, 1), IPAddress(255, 255, 255, 0));
    ESPAsync_wifiManager.autoConnect(AP_NAME);

    if (WiFi.status() == WL_CONNECTED)
    {
        Serial.print(F("Connected. Local IP: "));
        Serial.println(WiFi.localIP());

        // ESPAsync_wifiManager.stopConfigPortal = true;
    }
    else
    {
        Serial.println(ESPAsync_wifiManager.getStatus(WiFi.status()));
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    SupportLibrary support

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions