WiFiManager
WiFiManager copied to clipboard
ARDUINO_EVENT_WIFI_STA_GOT_IP not catched when STA got IP
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)
You are using autoconnect, do you have cp disabled and using non blocking?
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