WebBluetoothCG/web-bluetooth

requestDevice filters to exclude devices.

Closed this issue · 1 comments

Application developers may wish to filter OUT devices they know are not the correct ones. "I have an array with the names of some devices I don't want to get when I do navigator.bluetooth.requestDevice" - requested on Stack Overflow.

It would be reasonable to see filters that can exclude, such as by adding an excludeFilters the request call:

navigator.bluetooth.requestDevice({
  filters: [{services: [A, B]}],
  excludeFilters: [
    {namePrefix: "Unwanted"},
    {name: "Unique Name"},
    {name: "Unique Name2"},
  ]
})

Which, given many devices discovered:

Device Device Name Device Services
D1 <none> A
D2 <none> A, B
D3 "Unwanted thing" A, B
D4 "Unique Name2" A, B
D5 "Unique Name3" A, B

Would present only D2 and D5 to the user in the chooser to select.

I've started #600 to address this issue.