-
I don't think this is related to the flag, as I can't run the examples without it, IIRC
.getDevices()
is not defined without the new permission backend flag.Interesting that Linux/macOS behave similarly, how can we check if this is a Chrome implementation issue? https://github.com/GoogleChrome/samples/issues does not appear to be monitoring new issues.
-
@Gordon: What is interesting is that the automatic reconnect works on Windows/CSR8510. Can you clarify which Browser/OS/Bluetooth combo you have where it doesn't? Still trying to find out if this is specific to OS or the Bluetooth chip.
-
It seems like the power requirement for the USB dongle permanently overwrites the (lower) power requirement for the integrated Bluetooth module. As a result the Bluetooth module thinks it is not supplied with sufficient power and shuts down.
Apparently there is a workaround with certain old Bluetooth 2.0 dongles with similar power requirements to the internal Bluetooth module, 2 I had lying around, which didn't work - I now bought a third one from eBay that I hope will fix this. Can't use the Puck.js until then and can't afford the time to have my MacBook shipped for repairs.
In the thread they are even shipping around old Bluetooth dongles via post to fix this.
-
I connected the CSR8510 to my MacBook Pro 16 to check if the difference is caused by Windows or the Bluetooth chip; as a result Bluetooth on my MacBook Pro 16 is now bricked and apparently needs a Logic Board replacement (https://discussions.apple.com/thread/250944058). 🤷
-
I can confirm your experience on Windows 10/CSR8510 (Win10 Bluetooth Driver)/Chrome 90:
- Go to https://googlechrome.github.io/samples/web-bluetooth/watch-advertisements-and-connect-async-await.html
- Request and pair your Espruino
- Close/Reopen Chrome and go to the same site
- Press "Connect"
- Wait (up to 10 seconds in my 5 runs)
Result:
Getting existing permitted Bluetooth devices... > Got 1 Bluetooth devices. Watching advertisements from "Puck.js c699"... > Received advertisement from "Puck.js c699"... Connecting to GATT Server from "Puck.js c699"... > Bluetooth device "Puck.js c699 connected.
On macOS I don't get a reconnect because no advertisement packets are received unless I explicitly trigger a scan or request a device.
- Go to https://googlechrome.github.io/samples/web-bluetooth/watch-advertisements-and-connect-async-await.html
-
@fanoush: Interesting, could you post details on your OS/Bluetooth/Browser/Espruino combo? Definitely doesn't work for me (macOS 10.15/Chrome 90 + flag:#enable-web-bluetooth-new-permissions-backend/Puck.js v2.09)
//Press Connect Getting existing permitted Bluetooth devices... > Got 1 Bluetooth device. Watching advertisements from "Puck.js c699"... //Stuck here, but if you now press Request and don't select a device: Requesting any Bluetooth device... > Received advertisement from "Puck.js c699"... Connecting to GATT Server from "Puck.js c699"... > Bluetooth device "Puck.js c699 connected. //Abort Request Argh! NotFoundError: User cancelled the requestDevice() chooser.
It seems like for some reason your Espruino is still sending advertisement packets even after it is connected? Do you have any Bluetooth device scanning tool running in the background/in parallel?
-
Thanks for the link.
https://googlechrome.github.io/samples/web-bluetooth/watch-advertisements-and-connect-async-await.html also gives me the
device is out of range
error, however, adding a call torequestLEScan()
or justrequestDevice()
seems to trigger advertisement packages, which will cause a reconnect without selecting a device in the dialog.However, the scanning/request dialog is still shown (and it doesn't disappear when a device is connected). Is there any option to close the scanning/request dialog programatically? It does not support AbortController signals.
-
-
I use https://www.puck-js.com/puck.js and
Puck.connect(callback);
to connect to Puck.js (v2.09) from my website. While developing, my website will reload upon code changes, which requires me to reselect my already paired Puck.js which is cumbersome.
I noticed that the WebIDE is capable of connecting to an already paired device without showing the navigator.bluetooth dialog, however it relies on EspruinoTools which I couldn't get to integrate nicely with my webpage.
let pairedDevices = await navigator.bluetooth.getDevices();
will provide currently paired devices, however forwarding such a device to the
connect()
method replacing the call tonavigator.bluetooth.requestDevice
was not successful, resulting in a "Bluetooth device is out of range error". I suspect this happens because the last advertisement packet is too old, so I waited onprepairedDevice.watchAdvertisements()
to fire first which took care of the "out of range error" but somehow introduced emptytxItem.data
items inpuck.writeProgress(txItem.maxLength - txItem.data.length, txItem.maxLength);
Is there a solution that avoids "re-pairing" my Puck.js on every page load, i.e. by adapting the puck.js file or somehow integrating parts of the WebIDE/EspruinoTools?
Thanks a lot for your help!
Thanks for the link to the issue tracker. So to summarize, reconnecting to already paired devices should be supported in Chrome when using
chrome://flags/#enable-web-bluetooth-new-permissions-backend
andchrome://flags/#enable-experimental-web-platform-features
and this code:However, at least on Linux and macOS, the event
advertisementreceived
is never triggered. Is that an issue with Chrome, the OS or the device? Looks like.watchAdvertisement
is supposed to trigger advertisement packages but it doesn't on Linux/macOS?