• Hi!

    I've had a look through the apps and examples, apologies if I missed it:

    I'm seeking an example of robustly maintaining a connection to a BLE device so we can receive characteristicvaluechanged events.

    I have this so far, but it lacks retrying everything, handling failures, and so on. I'm unfamiliar with JavaScript. If there's no off-the-shelf example of how to be robust, I'll give it a go and share back here...

    NRF.requestDevice({ filters: [{ namePrefix: 'XXXX' }] }).then(function(device) {
      return device.gatt.connect();
    }).then(function(g) {
      gatt = g;
      return gatt.getPrimaryService(
    }).then(function(service) {
      console.log("Got Service");
      return service.getCharacteristic(
    }).then(function (c) {
      console.log("Got Characteristic");
      characteristic = c;
      characteristic.on('characteristicvaluech­anged', function(event) {
        console.log("Got event");
      return characteristic.startNotifications();

Avatar for user145265 @user145265 started