Getting device names ... fails?

Posted on
  • Hi again,

    I want my puck to wait a little longer before going into code that changes its name and advertising behaviour. But want it to wait only if a certain device is around (e.g. my iPhone).
    So I tried to do a scan or a request ... but this never returns ANY names of the devices, even with higher timeouts and "active" being true?!
    "namePrefix" does not make a difference when using findDevices – it just lists all, regardless of what I set. "namePrefix" does the opposite when using requestDevice – it never finds any, even if I just set one letter. Yes, I can see plenty of devices around using nRF-Connect including the ones I want the Puck to find.
    This is what I have tried:

    NRF.findDevices(function(devices) { console.log(devices);}, {timeout : 5000, active : true, filters : [{ manufacturerData:{0x004c:{}} }] });
    

    --> puts out a rather large list, but without names

    NRF.findDevices(function(devices) { console.log(devices);}, {timeout : 5000, active : true, filter : [{ namePrefix: 'S' }] });
    

    --> shows the same full list without names, although only two devices would fit.

    NRF.requestDevice({timeout : 5000, active : true, filters : [{ namePrefix: 'S' }] });
    

    --> times out without any result

    I have tried setting timeout to 10 or even 30 seconds – no difference. I must be doing something fundamentally wrong. Please advise.

  • for me the namePrefix works, in one place you have filter not filters so maybe that was it

  • Thanks, makes no difference unfortunately ... this is what the list looks like (filter set to 4C):

    [
      BluetoothDevice: {
    	"id": "68:8e:9f:41:ed:04 private-resolvable",
    	"rssi": -85,
    	"data": new Uint8Array([2, 1, 26, 2, 10, 12, 12, 255, 76, 0, 16, 7, 61, 31, 172, 239, 186, 118, 120]).buffer,
    	"manufacturer": 76,
    	"manufacturerData": new Uint8Array([16, 7, 61, 31, 172, 239, 186, 118, 120]).buffer
       },
      BluetoothDevice: {
    	"id": "55:9d:8f:7b:45:a1 private-resolvable",
    	"rssi": -62,
    	"data": new Uint8Array([2, 1, 26, 26, 255, 76, 0, 12, 14, 8, 3, 143, 238, 224, 193, 184, 184, 230, 42, 244, 112, 20, 89, 16, 5, 75, 28, 13, 209, 32]).buffer,
    	"manufacturer": 76,
    	"manufacturerData": new Uint8Array([12, 14, 8, 3, 143, 238, 224, 193, 184, 184, 230, 42, 244, 112, 20, 89, 16, 5, 75, 28, 13, 209, 32]).buffer
       },
      BluetoothDevice: {
    	"id": "31:7e:10:d1:55:67 private-nonresolvable",
    	"rssi": -45,
    	"data": new Uint8Array([2, 1, 26, 11, 255, 76, 0, 9, 6, 3, 58, 192, 168, 20, 104]).buffer,
    	"manufacturer": 76,
    	"manufacturerData": new Uint8Array([9, 6, 3, 58, 192, 168, 20, 104]).buffer
       },
      BluetoothDevice: {
    	"id": "36:c2:b6:c2:32:23 private-nonresolvable",
    	"rssi": -90,
    	"data": new Uint8Array([2, 1, 26, 11, 255, 76, 0, 9, 6, 3, 5, 192, 168, 1, 47]).buffer,
    	"manufacturer": 76,
    	"manufacturerData": new Uint8Array([9, 6, 3, 5, 192, 168, 1, 47]).buffer
       },
      BluetoothDevice: {
    	"id": "54:24:6f:a9:f3:a0 private-resolvable",
    	"rssi": -49,
    	"data": new Uint8Array([2, 1, 26, 2, 10, 12, 10, 255, 76, 0, 16, 5, 71, 28, 200, 62, 162]).buffer,
    	"manufacturer": 76,
    	"manufacturerData": new Uint8Array([16, 5, 71, 28, 200, 62, 162]).buffer
       },
      BluetoothDevice: {
    	"id": "73:c9:92:18:1f:b6 private-resolvable",
    	"rssi": -28,
    	"data": new Uint8Array([2, 1, 26, 2, 10, 7, 11, 255, 76, 0, 16, 6, 87, 30, 133, 239, 171, 122]).buffer,
    	"manufacturer": 76,
    	"manufacturerData": new Uint8Array([16, 6, 87, 30, 133, 239, 171, 122]).buffer
       },
      BluetoothDevice: {
    	"id": "e5:a2:61:4d:88:81 random",
    	"rssi": -28,
    	"data": new Uint8Array([7, 255, 76, 0, 18, 2, 0, 3]).buffer,
    	"manufacturer": 76,
    	"manufacturerData": new Uint8Array([18, 2, 0, 3]).buffer
       },
      BluetoothDevice: {
    	"id": "74:be:34:49:3d:37 private-resolvable",
    	"rssi": -28,
    	"data": new Uint8Array([2, 1, 26, 13, 255, 76, 0, 22, 8, 0, 143, 10, 199, 38, 46, 176, 112]).buffer,
    	"manufacturer": 76,
    	"manufacturerData": new Uint8Array([22, 8, 0, 143, 10, 199, 38, 46, 176, 112]).buffer
       },
      BluetoothDevice: {
    	"id": "c4:b1:75:d5:55:41 random",
    	"rssi": -47,
    	"data": new Uint8Array([30, 255, 76, 0, 18, 25, 32, 249, 117, 54, 221, 67, 90, 101, 94, 4, 49, 34, 203, 36, 161, 116, 116, 86, 147, 200, 222, 188, 59, 1, 65]).buffer,
    	"manufacturer": 76,
    	"manufacturerData": new Uint8Array([18, 25, 32, 249, 117, 54, 221, 67, 90, 101, 94, 4, 49, 34, 203, 36, 161, 116, 116, 86, 147, 200, 222, 188, 59, 1, 65]).buffer
       },
      BluetoothDevice: {
    	"id": "de:c3:1d:ad:f1:ed random",
    	"rssi": -47,
    	"data": new Uint8Array([7, 255, 76, 0, 18, 2, 36, 0]).buffer,
    	"manufacturer": 76,
    	"manufacturerData": new Uint8Array([18, 2, 36, 0]).buffer
       },
      BluetoothDevice: {
    	"id": "f4:36:f6:2b:1d:7b random",
    	"rssi": -56,
    	"data": new Uint8Array([7, 255, 76, 0, 18, 2, 0, 3]).buffer,
    	"manufacturer": 76,
    	"manufacturerData": new Uint8Array([18, 2, 0, 3]).buffer
       },
      BluetoothDevice: {
    	"id": "6d:8f:cd:d6:fb:9f private-resolvable",
    	"rssi": -88,
    	"data": new Uint8Array([2, 1, 26, 2, 10, 4, 11, 255, 76, 0, 16, 6, 77, 29, 159, 243, 222, 40]).buffer,
    	"manufacturer": 76,
    	"manufacturerData": new Uint8Array([16, 6, 77, 29, 159, 243, 222, 40]).buffer
       },
      BluetoothDevice: {
    	"id": "fe:ab:ab:74:da:31 random",
    	"rssi": -85,
    	"data": new Uint8Array([7, 255, 76, 0, 18, 2, 0, 0]).buffer,
    	"manufacturer": 76,
    	"manufacturerData": new Uint8Array([18, 2, 0, 0]).buffer
       },
      BluetoothDevice: {
    	"id": "48:f0:f4:6b:28:58 private-resolvable",
    	"rssi": -85,
    	"data": new Uint8Array([2, 1, 26, 13, 255, 76, 0, 22, 8, 0, 129, 159, 50, 7, 139, 249, 66]).buffer,
    	"manufacturer": 76,
    	"manufacturerData": new Uint8Array([22, 8, 0, 129, 159, 50, 7, 139, 249, 66]).buffer
       }
     ]
    

    How come there is no "name" at all?

  • that looks like correct output for filters : [{ manufacturerData:{0x004c:{}} }] - all of them manufacturer 76 = 0x4c
    name is optional, lot of devices do not have any name, when using here I see a lot of devices without name but some do have it

  • Just wondering if a solution was found for this? I am in the same situation. I have a Puck.js that I am trying to connect to an Adafruit Feather. I can see a lot of devices on a scan - but can not tell which is which based on the returned data from Puck (which looks like the screen shot above of the original poster).

    Were you able to filter to find the device?

  • I have given up on trying this, simply wasn't reliable enough.

  • since 2.22 there are scan window and interval parameters, default is 100 for both
    https://www.espruino.com/Reference#l_NRF_requestDevice
    I wonder if it could improve if you set them both to something larger like 200-500
    It says how long the Puck scans each advertising channel before moving to next one (there are 3 advertising channels)
    If there are lots of devices around I wonder if with active scan the Puck has enough time to ask each found device for scan response packet before the window for this channel is over and it needs to stop and switch to next channel. In next channel it may again manage to find only some subset of devices and so on and never actually complete the scan for all devices in any channel. This is however just a random guess, it may not help at all.

  • Maybe if you can find the Feather on the nRF Connect app, then take a screenshot we can find a way to detect it.

    Potentially it may advertise the service UUID for Nordic UART or something like that?

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Getting device names ... fails?

Posted by Avatar for DanDyse @DanDyse

Actions