I am using Arduino IDE 1.6.5 with esp8266 v. 2.3.0 on a NodeMCU 1.0.
My sketch does a number of analog reads, checks to see if WiFi is connected (pauses 100 ms and turns on an led if not) then handles client requests to report the analog read values. It is set up in station mode and contains this line in the Setup: wifi_set_sleep_type(NONE_SLEEP_T);
It is connecting to a dlink DIR-601 router, which is attached to my access point. It connects fine, and works flawlessly (no reboots)--until the router sends out WPA rekey requests. Often, it misses the router's rekey handshake. The router retries, but if the NodeMCU misses four times in a row, it is deauthenticated.
Usually, the NodeMCU realizes it is diconnected and then reconnects, but not always. When it doesn't reconnect, it continues to loop (I have it flash an led every 15 sec), but it isn't connected to wifi. Rebooting the router, or the NodeMCU reconnects it.
I've attached an example router log with a 10 minute rekey cycle for anyone interested. Does anyone have any ideas what could be causing it to miss the handshake so often and not reconnect sometimes?
Is there some other command I can put in the loop to check to check for a real connection to the router. Right now, I am using: if ( WiFi.status() != WL_CONNECTED )...
Thanks for any thoughts on this.