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,function(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);
}
});
}
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
under else if statement: Still clearing the setTimeout even though it is run after clearInterval