Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

watchAdvertisements() should return a "sentinel" object #591

Open
reillyeon opened this issue Jul 19, 2022 · 4 comments
Open

watchAdvertisements() should return a "sentinel" object #591

reillyeon opened this issue Jul 19, 2022 · 4 comments

Comments

@reillyeon
Copy link
Contributor

reillyeon commented Jul 19, 2022

The requestLeScan() object returns a "sentinel" object that allows the developer to observe the status of the scan operation and stop it. This is important because some platform Bluetooth stacks enforce a limitation on how long a scanning session can be active and so it is important for a site to know whether to expect to receive more advertisementreceived events or not so it can keep its UI up to date.

Right now watchAdvertisements() just takes an AbortSignal which can be used to stop the scan but this was based on a pattern copied from the Screen Wake Lock API which we eventually decided against, instead adding the WakeLockSentinel interface. We should make this change to the Web Bluetooth API as well.

Right now BluetoothLEScan doesn't provide an event when the scanning session is stopped (only an attribute) but it could be updated to fire a stop event or something similar.

@niklasdahlheimer
Copy link

Any news on this topic?

After calling watchAdvertisements() on a selected device (filter has keepRepeatedDevices= true) the advertisementreceived-eventListener stops after a few seconds (tested with Chrome 112.0.5615.137 on MacBook Pro 2021).
Afterwards the device object still has watchingAdvertisements = true set, but thats obviously wrong. Further calls to watchAdvertisements() have no effect. So it's not possible to monitor advertisement parameters of bluetooth devices continuously.

@reillyeon
Copy link
Contributor Author

Thanks for pointing out the problem with the watchingAdvertisements attribute as well.

We're tracking this on the implementation side as Chromium issue 1345995 which is blocking marking watchAdvertisements() as a stable API.

@niklasdahlheimer
Copy link

niklasdahlheimer commented Apr 24, 2023

Thanks for referencing the issue @reillyeon !

So, is there currently any way to scan continuously or in regular intervals with this API at all?

I didn't received any scan results using requestLeScan() which I assume is caused by this issue.

@reillyeon
Copy link
Contributor Author

Scan frequency will always be limited by what the underlying platform allows but the idea of providing a sentinel object is to make that visible to the application so that it can restart the scan session after an interval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants