Web Bluetooth BluetoothDevice.watchAdvertisements()
- Category
- Device
- Type
- New or changed feature
- Status
- No longer pursuing (Chrome No longer pursuing)
- Intent stage
- Prepare to ship
WPT details: Web platform tests will be added as this feature is implemented. The tests will use the Web Bluetooth testing API and will be added to the wpt/bluetooth directory. https://github.com/web-platform-tests/wpt/tree/master/bluetooth
Summary
The BluetoothDevice.watchAdvertisements() method will enable web apps to receive events when the system receives an advertisement packet from a watched device. Note: [10/31/2023] To clarify why the feature is no longer pursued, the function of `watchAdvertisement` will be integrated into `requestLEScan` with updated `BluetoothLEScanOptions`. With that change, the new flag `listenOnlyGrantedDevices` in the option could be used to listen to all granted bluetooth devices' advertisement events without iterating through each `BluetoothDevice`. Here is the explainer for more detail: https://github.com/WebBluetoothCG/web-bluetooth/blob/main/requestLEScan-for-granted-devices-explainer.md
Motivation
This API will allow web apps to detect whether a device is unresponsive because it has gone out of range by listening for advertisement packets from the device. Without this API, operations on the Bluetooth device would hang until the device was timed out on the system, causing a 'gattserverdisconnected' event to be fired. With persistent permissions for Web Bluetooth, watchAdvertisements() will enable web apps to check if a permitted device is in range of the system before attempting to connect to the device.
Standards & signals
- Specification: https://webbluetoothcg.github.io/web-bluetooth/
- Firefox: Negative
- Safari: No signal — https://bugs.webkit.org/show_bug.cgi?id=101034
- Web developers: No signals — No signal on BluetoothDevice.watchAdvertisements() API in particular, but it will be very useful with the getDevices() API.
- Tracking bug: https://crbug.com/654897
Ecosystem
- Web Platform Tests: https://wpt.fyi/results/?q=bluetooth
- Chrome Platform Showcase: https://chrome-platform-showcase.paulkinlan-ea.deno.net/features
- GenDN reference: https://gendn.paulkinlan-ea.deno.net/features
- chrome.dev demos search: https://www.google.com/search?q=site%3Achrome.dev+Web%20Bluetooth%20BluetoothDevice.watchAdvertisements()
- MDN Web Docs: https://developer.mozilla.org/en-US/search?q=Web%20Bluetooth%20BluetoothDevice.watchAdvertisements()
- Baseline status: https://webstatus.dev/?q=Web%20Bluetooth%20BluetoothDevice.watchAdvertisements()
Samples: https://googlechrome.github.io/samples/web-bluetooth/watch-advertisements.html https://googlechrome.github.io/samples/web-bluetooth/watch-advertisements-and-connect.html
Explainers: https://docs.google.com/document/d/1h3uAVXJARHrNWaNACUPiQhLt7XI-fFFQoARSs1WgMDM/edit#heading=h.jdnga4sjs82y