WiFiManager icon indicating copy to clipboard operation
WiFiManager copied to clipboard

ARDUINO_EVENT_WIFI_STA_GOT_IP not catched when STA got IP

Open maxdd opened this issue 4 months ago • 2 comments

Is there anything wrong in doing so:

    WiFiManager wm;
    if(!wm.autoConnect(HOSTNAME, MDNS_NAME)) {
        Serial.println("Failed to connect");
        ESP.restart();
    }

    WiFi.onEvent([](WiFiEvent_t event, WiFiEventInfo_t info) {
        Serial.print("[I][ESP32]: WiFi connected. IP: ");
        Serial.println(IPAddress(info.got_ip.ip_info.ip.addr));

        init_stuff();

    },
        WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_GOT_IP);

    WiFi.onEvent([](WiFiEvent_t event, WiFiEventInfo_t info) {
        Serial.print("[I][ESP32]: WiFi lost connection. Reason: ");
        Serial.println(info.wifi_sta_disconnected.reason);
        ESP.restart();
    },
        WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED);

In my case the ARDUINO_EVENT_WIFI_STA_GOT_IP is never triggered, hence my application never starts (haven't tested ARDUINO_EVENT_WIFI_STA_DISCONNECTED yet)

maxdd avatar Aug 25 '25 07:08 maxdd

You are using autoconnect, do you have cp disabled and using non blocking?

tablatronix avatar Sep 04 '25 01:09 tablatronix

What is cp? Without the code from this library the two callback are called Some additional info, in this case the persistency was already filled with the wifi credentials

maxdd avatar Sep 04 '25 05:09 maxdd