You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • It's hard to tell from the indenting, but it looks like maybe you could be calling setWatch multiple times? If so, it'd mean that after a few runs you're going to end up so that you press the button once, and flag is called multiple times?

    One thing that could help as well - you have gattserverdisconnected but it's not being used right now. Try:

    device.on('gattserverdisconnected', function() {
      uart = undefined; // setting this to undefined tells us that we've disconnected
    });
    

    Then instead of just uart.disconnect(); do:

    if (uart) uart.disconnect();
    uart = undefined; // we already asked to disconnect
    
About

Avatar for Gordon @Gordon started