Error handling for puck.js communication

Posted on
  • Hi,

    I am trying to add puckjs support for the Open Source AsTeRICS Grid AAC software in order to have an IR device or to remote controll battery-powerd toys using the FET output (see PR#340).

    Is there a way to handle bluetooth disconnect or write error when using Puck.writefunction?
    I would like to notify the user in such a case and maybe trigger a reconnect.

    I also tried to use Puck.connect(), but this always forces me to reconnect to the device. If there was a previous successful connection, I would like to reuse it, not having to ask the user again.

    Thanks for you help.

  • You mean using the Puck.js library? (source at https://github.com/espruino/EspruinoWebT­ools/blob/master/puck.js)

    I believe you can use Puck. /getConnection() to get the currently active connection (you can use Puck.connect if not) and then you can do connection.on('close', function(d) { ... }) on that?

  • Hi Gordon,

    Thanks for the hint, we have finally managed it by doing some modifications in our fork:
    https://github.com/asterics/EspruinoWebT­ools

    Your Espruino devices and the fact that you can easily program then via Web Bluetooth and Javascript are really awesome. This enables also a lot of possibilities for people with disabilities in combination with our AAC software AsTeRICS Grid.
    We have added a UART action which allows to communicate with your devices and enable interfacing accessible toys or using the puckmote webpage and the IR-database to do environmental control for people with disabilities:
    https://www.asterics.eu/manuals/asterics­-grid/05_actions.html#uart-action

    We will also use new feature this week in a series of workshops in Nairobi in Kenia.
    I would be happy, if you could share the AsTeRICS Grid integration also in your platforms.

    Thanks
    Martin

  • Hi,

    That's great! It's really good to see it used for this kind of thing.

    It looks like the changes in your fork aren't something I could pull back as they delete a bunch of stuff and change the API, but if you did want to contribute something back that added connectBluetooth/etc without changing the rest then I'd be happy to pull that in.

  • Hi,

    Oh, I was primarily thinking of adding a tutorial about accessibility use cases to the puck-js documentation.
    Here are 2 documented tutorials:
    https://www.asterics.eu/manuals/asterics­-grid/514_uart-action-tutorials.html#uar­t-action-tutorials

    It's up to you!
    Martin

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Error handling for puck.js communication

Posted by Avatar for user155724 @user155724

Actions