← Back to release summary

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

Ecosystem

Docs: https://docs.google.com/document/d/1h3uAVXJARHrNWaNACUPiQhLt7XI-fFFQoARSs1WgMDM/edit#heading=h.jdnga4sjs82y

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

View on chromestatus.com