Intent to Prototype and Ship: Web Bluetooth manufacturer data filter

393 views
Skip to first unread message

François Beaufort 🇫🇷

unread,
May 5, 2021, 5:00:26 AM5/5/21
to blink-dev, Reilly Grant

Contact emails

fbea...@chromium.org 

rei...@chromium.org


Explainer

https://github.com/WebBluetoothCG/web-bluetooth/blob/main/data-filters-explainer.md

This is a small addition to the existing filtering feature which is quite documented with examples.

Spec

https://webbluetoothcg.github.io/web-bluetooth/#dictdef-bluetoothmanufacturerdatafilterinit


TAG review

Web Bluetooth API: https://github.com/w3ctag/design-reviews/issues/139

Changes since TAG review: https://github.com/WebBluetoothCG/web-bluetooth/blob/main/data-filters-explainer.md#spec-changes-since-tag-review


Summary:

Being able to filter based on manufacturer specific data (such as vendor ID and product ID) will enable e.g. manufacturer.example.com to configure/select only its own Bluetooth devices and present them to users, instead of showing unrelated Bluetooth devices in the browser picker.


Motivation:

Today, developers can prompt users through a browser picker to select a nearby Bluetooth device that matches their advertised name and services. However it’s not possible for them to filter nearby Bluetooth devices based on advertised manufacturer specific data, used in advertising packets to add custom data (always starting with a Bluetooth company identifier).


The Web Bluetooth spec always had manufacturer data filter support but it wasn’t implemented due to the lack of developer need when it shipped. This is no longer the case. See the “Web / Framework developers” signal section.


// Simplest form.

let manufacturerData = [{ companyIdentifier: 0xffff }];

navigator.bluetooth.requestDevice({ filters: [{ manufacturerData }] });

 

// Filter on manufacturer data starting with [0x01, 0x02].

let manufacturerData = [{

  companyIdentifier: 0xffff,

  dataPrefix: new Uint8Array([0x91, 0xaa]), // 10010001 10101010

  mask: new Uint8Array([0x0f, 0x57])        // 00001111 01010111

}];

navigator.bluetooth.requestDevice({ filters: [{ manufacturerData }] });



Is this feature supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?

No. It will be supported on all platforms that Web Bluetooth supports currently. This excludes Android WebView. See https://github.com/WebBluetoothCG/web-bluetooth/blob/main/implementation-status.md

Demo link

https://googlechrome.github.io/samples/web-bluetooth/manufacturer-data-filter.html


Debuggability

No extra DevTools support is needed. Developers can use the about:bluetooth-internals page to debug their Bluetooth devices.


Measurement

The WebBluetoothManufacturerDataFilter WebFeature will track the presence of manufacturer data filters.


Risks


Interoperability and Compatibility
This small addition to the existing filtering feature does not change the overall status of Web Bluetooth interoperability or compatibility.. 


Signals from other implementations (Gecko, WebKit): 

Gecko: No Signal [1]

WebKit: No Signal [1]

Web / Framework developers: Positive


[1] Both Gecko and Webkit are unlikely to object to this specifically, but object to the overall Web Bluetooth API as a whole, hence doesn't make sense to bug them with specific questions on this.

Ergonomics:

N/A


Activation:

It should be fairly trivial for developers to adopt this new manufacturer data filter as it’s just another filter to the existing options in navigator.bluetooth.requestDevice(). If backwards compatibility with older browsers is desired though, developers will have to use some fallback options as the new manufacturer data filter will be considered empty.

let manufacturerData = [{ companyIdentifier: 0x00e0 }];

navigator.bluetooth.requestDevice({ filters: [{ manufacturerData }] })

.catch((error) => {

  if (error.name != "TypeError") return;

  let fallbackOptions = { acceptAllDevices: true };

  return navigator.bluetooth.requestDevice(fallbackOptions);

});



Is this feature fully tested by web-platform-tests? Link to test suite results from wpt.fyi.
Yes. This feature will be fully tested at https://wpt.fyi/results/bluetooth


Entry on the feature dashboard

https://www.chromestatus.com/feature/5684530360877056




Yoav Weiss

unread,
May 5, 2021, 8:35:18 AM5/5/21
to François Beaufort 🇫🇷, blink-dev, Reilly Grant
LGTM1

This seems like a small and useful addition to the existing API.


--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAPpwU5J%2BHd%2B6_pf4yqgNaTVs2Rh29KM79pf8FiWW_RdVUtu%3DdQ%40mail.gmail.com.

Rick Byers

unread,
May 5, 2021, 4:22:01 PM5/5/21
to Yoav Weiss, François Beaufort 🇫🇷, blink-dev, Reilly Grant

Chris Harrelson

unread,
May 5, 2021, 4:27:42 PM5/5/21
to Rick Byers, Yoav Weiss, François Beaufort 🇫🇷, blink-dev, Reilly Grant
Reply all
Reply to author
Forward
0 new messages