• Hi, a bit of progress. By increasing the scan I now can find the device:

    NRF.findDevices(function(devices) {
      console.log(devices);
    }, 30000);
    
    [
    
    // Apple TV
      BluetoothDevice: {
        "id": "08:66:98:c6:75:50 public",
        "rssi": -90,
        "data": new Uint8Array([2, 1, 26, 10, 255, 76, 0, 16, 5, 1, 16, 104, 16, 8]).buffer,
        "manufacturer": 76,
        "manufacturerData": new Uint8Array([16, 5, 1, 16, 104, 16, 8]).buffer
       },
    // Red Tilt
      BluetoothDevice: {
        "id": "04:a3:16:9a:af:cc public",
        "rssi": -92,
        "data": new Uint8Array([26, 255, 76, 0, 2, 21, 164, 149, 187, 16, 197, 177, 75, 68, 181, 18, 19, 112, 240, 45, 116, 222, 0, 62, 3, 239, 197]).buffer,
        "manufacturer": 76,
        "manufacturerData": new Uint8Array([2, 21, 164, 149, 187, 16, 197, 177, 75, 68, 181, 18, 19, 112, 240, 45, 116, 222, 0, 62, 3, 239, 197]).buffer
       }
     ]
    

    I can connect by service, by adding the timeout of 20000:

    var gatt;
    NRF.requestDevice({ timeout: 20000,filters: [{ "services": [
         'a495ff10-c5b1-4b44-b512-1370f02d74de'
         ]}] }).then(function(device) {
       console.log(device);
      return device.gatt.connect();
     }).then(function(g) {
      gatt = g;
      return gatt.getPrimaryService("a495ff10-c5b1-4b­44-b512-1370f02d74de");
    }).then(function(service) {
      console.log({service:service});
    }).then(function() {
      gatt.disconnect();
      console.log("Done!");
    });
    
    =Promise: {  }
    BluetoothDevice: {
      "id": "04:a3:16:9a:af:cc public",
      "rssi": -88,
      "data": new Uint8Array([2, 1, 6, 17, 6, 222, 116, 45, 240, 112, 19, 18, 181, 68, 75, 177, 197, 16, 255, 149, 164, 2, 10, 0]).buffer,
      "services": [
        "a495ff10-c5b1-4b44-b512-1370f02d74de"
       ],
      "manufacturer": undefined, "manufacturerData": undefined }
    Uncaught Error: Unhandled promise rejection: Disconnected
    > 
    
    1. The getPrimaryService never gets fulfilled. Not sure what is going on here? There does not seem to be a way of adding a timeout?

    2. The manufacturer data in the first code block - seems to wrong - as 76 is apple and the previous devices is an apple tv- and in the 2nd block of code - it is undefined for the Tilt - so I'm wondering if the previous values are getting set?

    3. What is data in BluetoothDevice: structure?

    4. Can the device name be included in the BluetoothDevice: structure?

About

Avatar for Wilberforce @Wilberforce started