New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WiFi events are not executed #2545
Comments
You aren't saving the handle obtained from WiFi.onStationModeGotIP, so the event handler is automatically unsubscribed. You need to hold the handle in order for the handler to be called. |
Yes, it works so. |
Not necessarily global. They can be members of an object which is receiving the event callback. That's the point — lifetime of the callback is bound to the lifetime of the object. Once the object is deleted, event handler is automatically unsubscribed. |
Now I understand. Thank you! |
This bug maybe back again or some variant of it... onStationModeConnected and onStationModeGotIP event handlers never fire. Used the NTPClientLib example for ESP8266 (see git for code https://github.com/gmag11/NtpClient/tree/master/examples/NTPClientESP8266) and only event handler that consistently fires is the onStationModeDisconnected handler and it fires over and over when a valid active WiFi connection already exists. Keep getting reason code 201 when status is checked, which seems completely wrong when active Wifi connect present. |
I second this, I'm getting a strange behaviour of |
Cant get working onStationModeGotIP, it never fires, onStationModeDisconnected works great. |
I'm seeing a reliable firing of What it should look like:
What it sometimes looks like:
|
If onStationModeGotIP is reliable, can't it be assumed that when an IP is got, a connection must have previously been enabled ? |
Is that true for the device or the session? And furthermore, I'm not confident that if a connection is disconnected and re-established, that a new IP will have been got. Overall, I'd like to see more documentation into the lifecycle of a WiFi connection which will hopefully illuminate why I'm seeing what I'm seeing. |
This is a closed issue. |
Damn, I have wasted tens of minutes trying to find out the reason. I have never seen a requirement of saving the result of an callback subscription function as a global variable in other languages, so I never thought of that could be the reason before reading this comment. |
Basic Infos
Hardware
Hardware: ESP-12
Core Version: Last commit as 2nd sept 2016
Description
Specific WiFi events seem not to be executed, only onEvent handler does run. I've debugged code and found that if I change this line in ESP8266WiFiGeneric.cpp from
WiFiEventHandler &handler = *it;
toWiFiEventHandler handler = *it;
events handlers trigger correctly.I've tried commit that first implemented specific event wifi handlers and it behaves the same. I've seen it working before so I do not know if I am doing something wrong. My code is on my NTPClient repository
Settings in IDE
Module: Generic ESP8266 Module
Flash Size: 4MB/1MB
CPU Frequency: 80Mhz
Flash Mode: qio
Flash Frequency: 40Mhz
Upload Using: SERIAL
Reset Method: nodemcu
Sketch
Debug Messages
Debug Messages after making suggested change
In this line in ESP8266WiFiGeneric.cpp
The text was updated successfully, but these errors were encountered: