• I've been using building an android app to communicate with my puck over UART and that has been going quite well.
    However, it is too slow and unreliable for sending large scripts.
    Due to the limitations of writing to Bluetooth characteristics, I have to write them in this way (excuse the pseudo-code):

    Goto 10;

    The problems with this are:

    1. It often takes longer to send (especially compared to the Espruino WebIDE).
    2. If the puck is in the middle of outputting something, the channel gets very confused.

    Is there a way to write these longer scripts without using the UART?

  • There's no better option than the BLE UART if you want to do it wirelessly. You could implement your own characteristics, but it'd be just as slow - if not more so.

    The issues with writing while Puck.js is transmitting could just be a buffer overflow - if it's waiting to send data while also receiving stuff.

    When you're writing code I'd definitely try doing what the IDE does though, which is to send character code 16 at the start of line for each new declaration (which disables echo for that line). You can get the espruino NPM package (the CLI tools) to output the exact characters it would have sent to a file, which might help you there.

    Otherwise you can just send "echo(0)\n" before everything to totally turn echo off for all commands.

    I'm afraid I'm not up to speed on the Android BLE APIs so I don't know if there's a faster way to do BLE - but I guess there must be if Web Bluetooth can do it. It might be worth looking at the sourcecode for the Nordic UART app and seeing if they do something different?

  • Thank you, Gordon. I didn't know about the "echo(0)\n", should come in handy.

  • @Gordon Just coming back to say echo (0) and prepending char(16) has been VERY helpful!
    Thanks again.

  • No problem - thanks for letting me know!

  • Guys, please send some JS code samples for learning how it works on puck.js.

    Charlie at Intellijoule, Inc.

  • Specifically what are you after? Interfacing from Android, or just generally?

    There are already a bunch of examples for using Web Bluetooth, Python or JavaScript to interface to Espruino here: http://www.espruino.com/Interfacing#blue­tooth-le

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

Deploy Javascript files to a Puck from native code

Posted by Avatar for chustar @chustar