jasongin / noble-uwp

Noble (Node.js Bluetooth LE) with Windows 10 UWP bindings
MIT License
83 stars 45 forks source link

advertisement discovery is really slow #69

Open ghost opened 6 years ago

ghost commented 6 years ago

Using the advertisment-discovery.js script from examples enabling allowDuplicates in startScanning i get results between say 5 and 12 seconds for a device that advertises once every 500ms. I get much quicker responses when using the hci-socket binding.

I'm using a BCM20702A based dongle and node 10.6.0

Can anybody else replicate this sort of behavior?

ghost commented 6 years ago

I guess this is related https://stackoverflow.com/questions/37307301/ble-scan-interval-windows-10/37328965. It suggests a hack of using DeviceIoControl

ghost commented 6 years ago

and DeviceIoControl isn't allowed in uwp apps?

jasongin commented 6 years ago

DeviceIOControl isn't allowed in UWP apps published to the store. (Although developer / sideloaded UWP apps can call any Win32 APIs.) Even if it was allowed, it would be difficult to call from JavaScript, since the NodeRT bindings only expose WinRT APIs.

What about adjusting the BluetoothLEAdvertisementWatcher.MinSamplingInterval property... I don't see that discussed on that stackoverflow page, but it seems like maybe it could help?

ghost commented 6 years ago

what's the default sampling interval? I tried reading the docs, but I couldn't see what the defaults for any of those properties in BluetoothLEAdvertisementWatcher

I admit I'm rather new to Windows so maybe I missed it.

jasongin commented 6 years ago

The UWP API docs are nearly worthless. :( But I just realized MinSamplingInterval is a read-only property, so that's not going to help.

This seems like a very unfortunate limitation of the UWP BluetoothLEAdvertisementWatcher class, for which we don't have any workaround.

ghost commented 6 years ago

Can you tell me about what kind of numbers you see? and what settings your peripherals have?

jasongin commented 6 years ago

I'm actually on vacation now, I won't be able to really look into this for at least a couple weeks.

tony-gutierrez commented 3 years ago

Did anyone get a way to get better scan timings in UWP?