You are reading a single comment by @maze1980 and its replies. Click here to read the full conversation.
  • I guess there is a better way: Do not create new timer every 1000ms, but only once. Just to quote one function:

    //get wifi status every second
    function iw1() {
      wifi_stat = Wifi.getDetails().status;
      //set led blink rate
      if(wifi_stat !== "connected") {led_speed = 100;}
      else {led_speed=500;}
      setTimeout(iw1,1000);
    }
    iw1();
    

    And how to do it better:

    //get wifi status every second
    function iw1() {
      wifi_stat = Wifi.getDetails().status;
      //set led blink rate
      if(wifi_stat !== "connected") {led_speed = 100;}
      else {led_speed=500;}
    }
    iw1();
    setInterval(iw1,1000);
    

    While there is a garbage collection, it might be called too late, or not working properly - I didn't look into it. But if you call setTimeout every 1000ms instead of setInterval once there's a really high chance it'll allocate a new block of memory for a new timer every 1000ms.
    The other functions shall be modified accordingly.

About

Avatar for maze1980 @maze1980 started