You are reading a single comment by @Cale and its replies. Click here to read the full conversation.
  • under else if statement: Still clearing the setTimeout even though it is run after clearInterval

    function espStatus(callback){
      wifi.at.cmd('AT+CIPSTATUS\r\n',1000,funcĀ­tion(d){
        console.log('ESP8266 '+d);
        var status = d.slice(-1);//get the last character
        if(status == 2){//connection is good
          console.log('good connection');
          wifiTry=0;
        }else if(wifiTry>3){
          clearInterval();//clearInterval clears both intervals and timeouts!!
          wifiTry=0;
          setTimeout(startServer,500);
        }else{//connection is bad and we need to reconnect
          wifiTry++;
          console.log('bad connection');
          //need timeout to give esp8266 time to think.
          setTimeout(connectWifi,500);
        }
      });
    }
    
About

Avatar for Cale @Cale started