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

Filtering service uuids in parameters for startScanning() is not reliable.

Open pursual opened this issue 4 years ago • 3 comments

The noble lib allows you to provide two parameters to startScanning() (an array of service uuids, and a boolean for allow duplicates).

This binding does not discover anything when an array of service ids is passed?

pursual avatar Aug 31 '20 15:08 pursual

It looks like it works when the array only contains one item?

This might be miscoded. Instead of matching any of the service uuids, it might be trying to match only advertisements which contain ALL of them. I do not have a device that broadcasts moret than 1 service uuid, so unable to confirm.

Regardless it does not work with more than one service uuid. noble_uwp and other bindings do.

pursual avatar Aug 31 '20 16:08 pursual

@pursual You're right currently we pass the service uuids as filter to the AdvertismentWatcher.

The alternative would be to watch for all and filter the advertisement manually once we receive it.

If anyone wants to provide a PR for this the steps would be:

  • remove the advertisment filter https://github.com/Timeular/noble-winrt/blob/master/src/ble_manager.cc#L119-L127
  • save serviceUUIDs in a class field mAdvertiementServiceUUIDs (similar to mAllowDuplicates)
  • check if the received advertisement's serviceUUIDs contain any of the saved mAdvertiementServiceUUIDs https://github.com/Timeular/noble-winrt/blob/master/src/ble_manager.cc#L139

geovie avatar Sep 01 '20 19:09 geovie

Fixed in https://github.com/tony-gutierrez/noble-winrt/tree/servicefilter which is based off of https://github.com/fido-alliance/noble-winrt

tony-gutierrez avatar Oct 28 '20 21:10 tony-gutierrez