• I'm going nuts. Trying to discover devices, services, characteristics.
    When everything exists - no problem.
    But I'd like to handle that a service is not defined.

    This is my simplified code:

    NRF.requestDevice({filters: [{namePrefix: 'Puck.js'}]}).then(dev=>{
      console.log("device found", dev);
      return dev.gatt.connect();
    }).then(conn=>{
      console.log("connected", conn);
      return conn.getPrimaryService(0x464F);
    }).then(s=>{
      console.log("service found", s);
    },f=>{
      console.log("no service found", f);
    }).catch(e=>{
      console.log( "error:", e );
    });
    

    On execution neither f=>{ nor .catch(e=>{ are called:

    device found BluetoothDevice {
      "id": "f9:2d:30:24:38:a4 random",
      "rssi": -51,
      "services": [  ],
      "data": new ArrayBuffer([2, 1, 5, 13, 9, 80, 117, 99, 107, 46, 106, 115, 32, 51, 56, 97, 52]),
      "name": "Puck.js 38a4"
     }
    connected BluetoothRemoteGATTServer {
      "device": BluetoothDevice {
        "id": "f9:2d:30:24:38:a4 random",
        "rssi": -51,
        "services": [  ],
        "data": new ArrayBuffer([2, 1, 5, 13, 9, 80, 117, 99, 107, 46, 106, 115, 32, 51, 56, 97, 52]),
        "name": "Puck.js 38a4",
        "gatt":  ...
       },
      "connected": true }
    Uncaught Error: Unhandled promise rejection: No Services found
    

    Is this a bug or have I messed up my Promises?

About

Avatar for ChristianW @ChristianW started