[Core] Getting stuck in flashing green (disconnected) bug and fix

Wanted to share some findings with trying to create stable firmware for the Core.

The bug: If a core can’t connect to a WiFi AP for a long period of time ( >24h ) it will stay disconnected even if the wifi AP becomes available again. After a reset the Core will connect again.

This is pretty bad for long-term stability, since every time a Core’s WiFi network goes down for some time, it will need a reset to be able to connect to any network again. I suspect it’s an issue with the CC3000.

To reproduce the issue:

  1. Power up a core and reset all wifi creds, and upload only one set of credentials.
  2. Remove the WiFi AP so the Core has nothing to connect to.
  3. After 24h put the WiFi AP back up.
  4. The Core will not be able to connect to the network.

The fix:
Cycling WiFi.off / WiFi.on or WiFi.disconnect / WiFi.connect seems to solve the issue. You can include this chunk of code in your main loop if you’re concerned about this issue.

void loop() {
    static uint32_t wifi_ticks ;

    if( WiFi.ready() == true ){
        wifi_ticks   = millis() ;
    else{                   /* Wifi is not connected */

        if( 600000 < ( millis() - wifi_ticks )){  
            /* every 10 min when disconnected */
            /* cycle the WiFi power / connection */
            wifi_ticks   = split_ticks ;

            /* Option A : Toggle the disconnect/connect command */
            WiFi.disconnect() ;
            delay( 5000 ) ; 
            WiFi.connect() ; 

            /* Option B : Toggle power off/on wifi command */
            WiFi.off() ;
            delay( 10000 ) ;
            WiFi.on() ;
            delay( 2000 ) ;
            WiFi.connect() ;