noble-uwp icon indicating copy to clipboard operation
noble-uwp copied to clipboard

startScanning() does not filter by service UUID

Open jasongin opened this issue 8 years ago • 10 comments

Reported at https://github.com/sandeepmistry/noble/pull/646#issuecomment-314676439

jasongin avatar Jul 12 '17 07:07 jasongin

I will dig into it……just find that native binding never get uuid filter arg

VinciShark avatar Jul 12 '17 07:07 VinciShark

@jasongin Don't know what dataType transfer need to use just try

BluetoothLEAdvertisement = (function () {
  var cls = function BluetoothLEAdvertisement() {
    this.localName = new String();
    this.flags = new BluetoothLEAdvertisementFlags();
    this.dataSections = new Object();
    this.manufacturerData = new Object();
    this.serviceUuids = [0x0000000000001000800000805f9b34fb];
  };
……

but nothing change

VinciShark avatar Jul 12 '17 09:07 VinciShark

What's the type of this.serviceUuids? Seems like new Objcet() is not the real type accepted by Windows BLE binding.

nykma avatar Jul 12 '17 10:07 nykma

In the Windows API it is an IList<Guid>. However NodeRT projects GUIDs to JS as strings. So serviceUuids should be a list of strings, with the UUIDs formatted as GUID strings: {00000000-0000-0000-0000-000000000000}

So I think the fix in startScanning() should include something like this:

serviceUuids.forEach(uuid => {
  var uuidString = // format uuid as GUID string
  this._advertisementWatcher.advertisementFilter.advertisement.serviceUuids.add(uuidString);
});
this._advertisementWatcher.start();

jasongin avatar Jul 12 '17 17:07 jasongin

Note bluetooth uuids can be in short (uint32) and long (guid) form. I recently discovered there is a BluetoothUuidHelper class that can convert between them. That could be useful here, and probably should have been used in the existing formatUuid() function.

jasongin avatar Jul 13 '17 17:07 jasongin

give up cause failed to understand code NodeRT generated

VinciShark avatar Jul 22 '17 10:07 VinciShark

@VinciShark OK, I'll pick this up.

jasongin avatar Jul 24 '17 16:07 jasongin

This is implemented now, in version 0.5.0. Can someone confirm that it works how you expect?

jasongin avatar Jul 28 '17 04:07 jasongin

@jasongin Will test it today, just finish holiday

VinciShark avatar Jul 28 '17 18:07 VinciShark

This might not be working correctly, according to https://github.com/sandeepmistry/noble/pull/646#issuecomment-324438544

jasongin avatar Aug 26 '17 19:08 jasongin