You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Ok, just fixed - turns out there were two issues:

    • A memory leak in NRF.connect - I guess most times people use requestDevice so it hadn't been spotted.
    • A memory leak when an exception is thrown inside a rejected promise.

    If you use one of the latest builds from http://www.espruino.com/binaries/travis/­master/ then it should be fixed now.

    I'd modify the final bit of your code though to swap around the console.log and disconnect:

      // ...
        }).catch(function(e) {
          busy=false;      
          console.log("Write value error. ", e);
          if(gatt !== undefined)gatt.disconnect();
        });
    

    Disconnect can cause an error if the bluetooth operation had failed because the device got disconnected - so ideally you'd print the first error or disconnect will throw an exception which will stop the first error getting printed.

About

Avatar for Gordon @Gordon started