Skip to content

Wifi disconnection handler triggers but Wifi does not connect again #2174

Closed
@djoele

Description

@djoele

I am using latest Git version.

Lately the usage of Wifi.onEvent() was changed, see WiFi event handling refactoring #2119
The function that I am using to connect Wifi is working at boot time of ESP8266.

Then when I make Wifi disconnect by calling WiFi.disconnect(), I can see that the connectWifi() is triggered. Till so far that is as expected.

But what I notice is that Wifi is not picking the connection again.

Am I doing something wrong in the connectWifi() function?

I have registered a disconnection handler.

mDisconnectHandler = WiFi.onStationModeDisconnected(&onDisconnected);

void onDisconnected(const WiFiEventStationModeDisconnected& event)
    {
        connectWifi();
    }

I have the following connectWifi function.

void connectWifi() {
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(100);
    ESP.wdtFeed();
  }
  Serial.print(String("[WIFI] IP: "));
  Serial.println(WiFi.localIP());
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions