• Hi! I'm just going to move this to the Bluetooth section of the forum - I think it makes more sense there...

    I've realised that the Bangle.js 1 I have often doesn't find the BLE device

    Were you connected to Blueooth to the Bangle at the time you did this? Because usually when you're connected you're in high speed mode so sending packets to the Bangle every 7.5ms - this makes it hard for it to scan for advertisements as reliably because

    connection multiple peripherals at the same time is not possible

    Yes. You can have one connection IN and one connection OUT at the same time, but that's it.

    the callback I register for characteristicvaluechanged has no idea which BLE device

    Just define a variable in the connect function, like:

    function connect() {
      nrfbusy = true;
      var mydevice;
      NRF.requestDevice({ timeout:4000,
                          filters: [{ namePrefix: NAME_PREFIX }] }).then(function(device) {
      mydevice = device;
      // ...

    I'm seeking an example of robustly maintaining a connection to a BLE device

    When you first get the device, register device.on('gattserverdisconnected', ...) and that should help you detect when the connection fails, and hopefully do a reconnect (wait ~1 sec first just in case)


Avatar for Gordon @Gordon started