• 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 to navigator.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 on prepairedDevice.watchAdvertisements() to fire first which took care of the "out of range error" but somehow introduced empty txItem.data items in puck.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!

  • 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

    The WebIDE at https://www.espruino.com/ide/ can keep previous connection info and reconnect, however it is also lost when you reload the page. I think this is by design and is some sort of security so devices are not silently accessed across different pages.

About

Avatar for fanoush @fanoush started