Problems with libraries (OneWire, DallasTemperature) and WiFiStationDisconnected

Hi there,

I have problems using the OneWire and DallasTemperature libraries with the ESP32
I have some projects still using the espressiv32 environment (version 3.0.0) and tried to access the sensor first with this version, but to no avail. I could not even detect the number of devices connected, whereas the same code worked perfectly in the Arduino IDE. So I tried newer versions of the espressif libraries and found out that my code worked flawlessly with version 4.0.0 of the espressif libraries.

However when I wanted to integrate this in my project I found out that there are changes when I try to detect if Wifi was disconnected.

I use the following code for detecting if the Wifi has been disconnected:

void WiFiStationDisconnected(WiFiEvent_t event, WiFiEventInfo_t info)
{
Serial.println(“Disconnected from WiFi access point”);
Serial.print("WiFi lost connection. Reason: ");
Serial.println(info.disconnected.reason);
Serial.println(“Trying to Reconnect”);
connectionLostHandler(WIFI_CONNECTION_LOST, info.disconnected.reason);
}

However this does no longer work with version 4.0.0 and higher, since the disconnected member is no longer available. I get the following error message:

‘union arduino_event_info_t’ has no member named ‘disconnected’; did you mean ‘eth_connected’?

What is the correct way to detect if Wifi has been lost as of version 4.0.0 of the espressif libraries?
What can I do to solve this problem?

I’d appreciate it if somebody could help me since I am stuck.

Rudi

It looks like you are using Arduino core on top of IDF. I believe the WiFi event callback signature changed when arduino-esp32 went from 1.0.6 → 2.0.0. Signature now looks like this:
void WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
if(event==ARDUINO_EVENT_WIFI_STA_DISCONNECTED) {
}

}

If you need more help I recommend posting to Issues · espressif/arduino-esp32 · GitHub .

Thanks a lot for your help, everythings working now like before.

Rudi