[GH-ISSUE #1833] ARDUINO_EVENT_WIFI_STA_GOT_IP not catched when STA got IP #1540

Open
opened 2026-02-28 01:30:28 +03:00 by kerem · 2 comments
Owner

Originally created by @maxdd on GitHub (Aug 25, 2025).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1833

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)

Originally created by @maxdd on GitHub (Aug 25, 2025). Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/1833 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)
Author
Owner

@tablatronix commented on GitHub (Sep 4, 2025):

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

<!-- gh-comment-id:3251329174 --> @tablatronix commented on GitHub (Sep 4, 2025): You are using autoconnect, do you have cp disabled and using non blocking?
Author
Owner

@maxdd commented on GitHub (Sep 4, 2025):

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

<!-- gh-comment-id:3251893853 --> @maxdd commented on GitHub (Sep 4, 2025): 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
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#1540
No description provided.