-
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.
-
Having said that, this example from the Chrome team themselves doesn't appear to remember devices: https://googlechrome.github.io/samples/web-bluetooth/watch-advertisements-and-connect.html
Oh, it does for me. Clicked 'request device' selected Espruino device. Clicked 'connect to bluetooth devices' and it connected. Then I reloaded the page and clicked connect again and it remembered previous device and connected again.
EDIT: and btw about that security effort, here is issue https://github.com/WebBluetoothCG/web-bluetooth/issues/358 where they are pretty anal about showing the dialog with no way to circumvent/customize/prevent it but that is for first connection, here https://github.com/WebBluetoothCG/web-bluetooth/issues/164 it clearly says this should work
Hi! This is something I have been wondering about actually.
I think realistically to do it nicely, it could do with being integrated into the Puck.js/UART.js library itself (at https://github.com/espruino/EspruinoWebTools). I think long term the best thing would be to introduce the functionality to UART.js (which already has the ability to display a menu for >1 device), and then maybe just make Puck.js a stripped down version of UART.js that doesn't do Web Serial (it's getting stupid having two extremely similar libraries).
Yes, I was wondering about that. On Web Serial it works totally as expected, but it seems it doesn't on Web Bluetooth.
Having said that, this example from the Chrome team themselves doesn't appear to remember devices: https://googlechrome.github.io/samples/web-bluetooth/watch-advertisements-and-connect.html
But this one does - at least for me: https://googlechrome.github.io/samples/web-bluetooth/watch-advertisements-and-connect-async-await.html
But apart from the usage of promises vs. async/await I'm having trouble figuring out why!
However if we can figure that out I'd love to get the changes into the IDE so it does remember, and maybe get the relevant stuff added to UART.js