• You can't have code in Espruino that is called each time an advertising packet is sent, but probably the best method is just to use setTimeout?

    var idleTimer;
    
    function updateBluetooth() {
      // setAdvertising...
    }
    
    function newDataPulse() {
      power = ...;
      updateBluetooth();
      if (idleTimer) clearTimeout(idleTimer);
      idleTimer = setTimeout(idleHandler, 60000);
    }
    
    function idleHandler() {
      idleTimer = undefined;
      power = 0;
      updateBluetooth();
    }
    
About

Avatar for Gordon @Gordon started