Asynchronous Bluetooth device discovery in UWP using 32Feet Bluetooth library

58 views Asked by At

In my UWP app I'm creating a Bluetooth device search where it would scan and display a list of Bluetooth devices in range:

Cool screenshot of my UI B^)

I'm using in the inthehand/32feet Bluetooth library and am having trouble implementing async device discovery. According to the Wiki:

Asynchronous Device Discovery

We have new support in version 3 for ‘live’ discovery that’s where the application can get notification of each in-range device as it is discovered, instead of just getting the list of device at completion (as was previously provided by the DiscoveryDevices and End-/BeginDiscoveryDevices methods). The new method is provided on class BluetoothComponent with events DiscoverDevicesProgress and DiscoverDevicesComplete and method DiscoverDevicesAsync.

Sadly, according to this issue, this method won't work on the newest version of the library I think because it doesn't work with UWP:

peterfoot commented on Jul 3, 2020

I'm currently looking at this as an enhancement. The old v3.x version of the library did introduce a Begin* End* async pattern which fitted with the Win32 Sockets approach at the time but this is no longer recommended and doesn't apply easily to other platforms.

https://github.com/inthehand/32feet/issues/72#issuecomment-653493127

So now I've reached a dead end, I want to be able to load devices into the list as they are discovered, but the library doesn't support this in UWP. I can see 2 ways forward from here:

  • Switch to Winui3 which should provide access to Win32 APIs (I think, not exactly sure). But I'd rather not do this because I like using the Visual Studio designer and I've read that there are performance issues and missing features that still need to be fixed.

  • Suck it up and have to wait ~10-20 seconds of loading while bluetooth devices are scanned for.

So my question is, is there any way I can asynchronously scan for Bluetooth devices and display them as they are discovered in UWP (preferably using the 32 Feet Bluetooth library)?

Thanks :)

0

There are 0 answers