You are reading a single comment by @MaBe and its replies. Click here to read the full conversation.
  • Did some test with two pucks, Puck.js f5b9 and Puck.js 4820, using NRF.requestDevice and try to create a AND for id and manufacturerData.

    d9:c7:0b:0a:48:20 - Puck.js 4820 (RSSI -59)
    f0:d8:ef:29:f5:b9 - Puck.js f5b9 (RSSI -58)

    // advertise code for both Puck.js
    function onInit(){
          var data = {a:"1",b:2};
          NRF.setAdvertising({},{
                showName:true,
                manufacturer:0x0590,
                manufacturerData:JSON.stringify(data)
          });
    }
    setTimeout(save,1E3);
    

    Then run this simple code

    // manufacturerData and name as AND?
    filter = [{manufacturerData:{0x0590:{}}},{name:"P­uck.js 4820"}];
    
    // some times this 
    >NRF.requestDevice({ filters: filter}).then(function(d){console.log(d)­;});
    =Promise: {  }
    BluetoothDevice: {
      "id": "f0:d8:ef:29:f5:b9 random",   <-- wrong device
      "rssi": -61,
      "data": new Uint8Array([2, 1, 6, 18, 255, 144, 5, 123, 34, 97, 34, 58, 34, 49, 34, 44, 34, 98, 34, 58, 50, 125, 8, 8, 80, 117, 99, 107, 46, 106, 115]).buffer,
      "manufacturer": 1424,
      "manufacturerData": new Uint8Array([123, 34, 97, 34, 58, 34, 49, 34, 44, 34, 98, 34, 58, 50, 125]).buffer,
      "shortName": "Puck.js"
     }
    
    // and some times that
    >NRF.requestDevice({ filters: filter}).then(function(d){console.log(d)­;});
    =Promise: {  }
    BluetoothDevice: {
      "id": "d9:c7:0b:0a:48:20 random",   <-- correct device
      "rssi": -44,
      "data": new Uint8Array([2, 1, 6, 18, 255, 144, 5, 123, 34, 97, 34, 58, 34, 49, 34, 44, 34, 98, 34, 58, 50, 125, 8, 8, 80, 117, 99, 107, 46, 106, 115]).buffer,
      "manufacturer": 1424,
      "manufacturerData": new Uint8Array([123, 34, 97, 34, 58, 34, 49, 34, 44, 34, 98, 34, 58, 50, 125]).buffer,
      "shortName": "Puck.js"
     }
    

    Try different filter possibility

    // manufacturerData and name as AND ?
    filter = [[{manufacturerData:{0x0590:{}}}],[{name­:"Puck.js 4820"}]];
    
    // some times this
    >NRF.requestDevice({ filters: filter}).then(function(d){console.log(d)­;});
    =Promise: {  }
    BluetoothDevice: {
      "id": "d9:c7:0b:0a:48:20 random",
      "rssi": -44,
      "data": new Uint8Array([2, 1, 6, 18, 255, 144, 5, 123, 34, 97, 34, 58, 34, 49, 34, 44, 34, 98, 34, 58, 50, 125, 8, 8, 80, 117, 99, 107, 46, 106, 115]).buffer,
      "manufacturer": 1424,
      "manufacturerData": new Uint8Array([123, 34, 97, 34, 58, 34, 49, 34, 44, 34, 98, 34, 58, 50, 125]).buffer,
      "shortName": "Puck.js"
     }
    
    // or sometimes this
    >NRF.requestDevice({ filters: filter}).then(function(d){console.log(d)­;});
    =Promise: {  }
    BluetoothDevice: {
      "id": "de:30:d5:92:80:7f random",
      "rssi": -54,
      "data": new Uint8Array([2, 1, 6, 13, 9, 77, 68, 66, 84, 52, 50, 81, 32, 56, 48, 55, 102]).buffer,
      "name": "MDBT42Q 807f"
     }
    // or sometimes this 
    >NRF.requestDevice({ filters: filter}).then(function(d){console.log(d)­;});
    =Promise: {  }
    BluetoothDevice: {
      "id": "f0:d8:ef:29:f5:b9 random",
      "rssi": -60,
      "data": new Uint8Array([2, 1, 6, 18, 255, 144, 5, 123, 34, 97, 34, 58, 34, 49, 34, 44, 34, 98, 34, 58, 50, 125, 8, 8, 80, 117, 99, 107, 46, 106, 115]).buffer,
      "manufacturer": 1424,
      "manufacturerData": new Uint8Array([123, 34, 97, 34, 58, 34, 49, 34, 44, 34, 98, 34, 58, 50, 125]).buffer,
      "shortName": "Puck.js"
     }
    
    

    Hmm, not sure about filters any more.....

About

Avatar for MaBe @MaBe started