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

Device Filtering by Service #61

Open
buggzd opened this issue Jan 19, 2024 · 1 comment
Open

Device Filtering by Service #61

buggzd opened this issue Jan 19, 2024 · 1 comment

Comments

@buggzd
Copy link

buggzd commented Jan 19, 2024

image
How can I filter devices during a search based on the services they provide?
This is a packet I captured in Wireshark, and I would like to filter devices that only include the 'heartrate' service class UUID.
I apologize as I am still a beginner in Bluetooth development.

@adabru
Copy link
Owner

adabru commented Jan 24, 2024

This is what ChatGPT suggests:

If you want to use DeviceWatcher with an Advanced Query String (AQS) filter to specifically filter devices based on a GATT (Generic Attribute Profile) service UUID, you can use the System.Devices.Aep.ProtocolId property in the AQS filter. Here's an example:

using System;
using Windows.Devices.Enumeration;

class Program
{
    static void Main()
    {
        // Specify the GATT service UUID you're interested in (e.g., Heart Rate service)
        string serviceUuid = "{0000180D-0000-1000-8000-00805F9B34FB}";

        // Construct the AQS filter for GATT services
        string aqsFilter = $"System.Devices.Aep.ProtocolId:=\"{serviceUuid}\"";

        // Create a DeviceWatcher with the specified AQS filter
        DeviceWatcher deviceWatcher = DeviceInformation.CreateWatcher(aqsFilter);
...

Taking from here: https://learn.microsoft.com/en-us/windows/uwp/devices-sensors/aep-service-class-ids the default protocol identifier is "all ble services".

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

2 participants