-
I have an app which displays the list of bluetooth devices, allows selecting one of many specific named services, connects and brings in data. It is working except for needing a filter on RequestDeviceAsync which is currently using AcceptAllDevices = true. Need to set a Filter to a specific Name as in "Nordic_UART_Service" using: public sealed class RequestDeviceOptions /// Filters which define the services or attributes the remote device must support. /// public IList Filters { get; } = new List(); } public sealed partial class BluetoothLEScanFilter { /// /// If present requires a device to exactly match the supplied name. /// public string Name { get; set; } } I can create the list and add an element with Name property but get stuck because of the readonly property of "Filters" when setting it in RequestDeviceOptions. can someone help me (not an expert C# programmer) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi, the implementation of filters is not fully there yet on all platforms - only Windows processes the filter uuids currently. However the Filters property is read-only because it is a collection which you can add multiple filters to - it's a bit odd looking because each filter can specify a name or name prefix as well as one or more services - it follows the WebBluetooth standard. For a simple required service you would do something like:-
|
Beta Was this translation helpful? Give feedback.
-
For anyone wanting to know how to filter by name prefix it only works for Bluetooth.ScanForDevicesAsync(options) :(
The query by gatt service (accepted answer) doesn't work at all if the service is one defined by a guid UUID such as a NMEA UART Service UUID... Or perhaps it just doesn't work at all. The query by name does work when called using Bluetooth.RequestDeviceAsync but you have to have the exact name
|
Beta Was this translation helpful? Give feedback.
Hi, the implementation of filters is not fully there yet on all platforms - only Windows processes the filter uuids currently. However the Filters property is read-only because it is a collection which you can add multiple filters to - it's a bit odd looking because each filter can specify a name or name prefix as well as one or more services - it follows the WebBluetooth standard. For a simple required service you would do something like:-