-
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
-
@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?
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