Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter on ScanForDevicesAsync or RequestDeviceAsync with Service UUID - Different results #423

Open
ddurkee-badgermeter opened this issue Jun 24, 2024 · 3 comments

Comments

@ddurkee-badgermeter
Copy link

ddurkee-badgermeter commented Jun 24, 2024

#389
This above issue talks about this, but it still does not work for ScanForDevicesAsync on 4.0.36, even though in the linked issue it was marked resolved and this is implemented in 4.0.36.

library: InTheHand.Net.BluetoothLE version 4.0.36.
framework: .net 7
target version: 10.0.22621.0
target os: windows
application: Console (eventually WPF)

Basically I work for a hardware company that manufactures devices that speak serial or bluetooth. We have already developed a MAUI mobile app to speak to these devices via BLE. Also a desktop app to speak to these devices serially. The new wanted functionality is the switch-swap between the two, Bluetooth on desktop, Serial on mobile.

I have a Service UUID (unique for this device) that certainly connects on Android and iOS BLE connecting in our mobile app, now I'm trying to do the same in Desktop using 32Feet. I'll include my console app that I'm using to connect:

(replacing the unique service GUID with all 0's for the code snippet provided in this issue...)

Guid deviceguid = new Guid("00000000-0000-0000-0000-000000000000");
BluetoothUuid deviceuuid = BluetoothUuid.FromGuid(deviceguid);

var device = await Bluetooth.RequestDeviceAsync(new RequestDeviceOptions
{
    Filters = { new BluetoothLEScanFilter { Services = { deviceuuid } } }
});

var devices = await Bluetooth.ScanForDevicesAsync(new RequestDeviceOptions
{
    Filters = { new BluetoothLEScanFilter { Services = { deviceuuid } } }
});

on RequestDeviceAsync -> the normal Windows bluetooth device list window appears but shows no device was found. So apparantly this filter is being applied but my device just isn't being discovered (despite this being the exact way I do it in the mobile app, set a filter on the scan using the service UUID and now we only see our company devices)

RequestDeviceAsync_FilterResult

on ScanForDevicesAsync -> just returns ALL BLE devices in range despite the filter. Like the filter isn't even there... which was said to be fixed in this version from the linked issue, as mentioned before.

More information:

After selecting my device from the RequestDeviceAsync window, I'm able to discover services/characteristics with other unique UUIDs for this Bluetooth module. So it's just an issue with RequestDeviceAsync/ScanForDevicesAsync that do not filter based on a correct UUID.

@mt09sp
Copy link

mt09sp commented Aug 15, 2024

I have to ask... Is this using the nuget package?

There's a whole heap of changes to the underlying Bluetooth.windows.cs implementation that enable the filters that I don't believe have been bundled up yet.

The commit is back in march 2024.

@peterfoot
Copy link
Member

Latest NuGet 4.0.37 has a number of code updates added since the last release.

@endyb66
Copy link

endyb66 commented Sep 22, 2024

I have the same issue here with the latest NuGet, the filter seems to get applied, but the list within the device chooser is empty. Is there any fix we can work around?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants