• Very happy with puck.js. I'm thinking about what I can do with it - keen to play with hue lights and sonos - with a Mac making http calls when it gets data from the puck.

    How do I reliably establish a connection from the command line?

    I've done npm install -g espruino and have noble installed, so I'm trying espruino -p cd:47:aa:41:44:2d

    Once in a while, this works and I can talk to the puck from my command line. Most often, though, it tries for 1.5 sec (this time interval?) and then says "Unable to connect!".

    I'm new to BLE but my understanding is that my puck is advertising itself every so often (?) and the 1.5 sec isn't long enough for my computer to "spot" it and establish a connection?

    I've reset the puck with the button held down and made sure my Mac has "forgotten" it after previously trying some HID stuff. Is this expected behaviour? It makes connecting to the thing very hit-and-miss.

  • Have you updated the firmware on you Puck.js? The original firmware didn't advertise that often, and could cause exactly this kind of problem. The new one is every 350ms or so, and is significantly more reliable to connect to.

    But as you say, the command-line app could wait for longer. I'd actually prefer to shorten the timeout you mention, and to then change the connection logic (that calls Espruino.Core.Serial.getPorts) so that it calls getPorts multiple times until it finds the port that's been specified.

    It'd make it a lot faster in the cases where Puck.js was advertising quickly, and also when connecting to USB devices where realistically it needn't scan at all.

  • Ah - no, I assumed as I'd purchased it recently it would have recent firmware. Off to http://www.espruino.com/Puck.js#firmware­-updates for me!

    I guess this is the same reason why things are slow connecting via Web Bluetooth? Connecting once takes many seconds and using the IDE is ok after that, but I tried developing my own web page app - reconnecting every time I hit refresh in the browser got pretty frustrating.

    Will report back and share progress if others are reading this.

  • Ah, I'm now on 1v91 and things are much more reliable. Connecting from Chrome seems much, much snappier too.

    I think this definitely warrants a mention on https://www.espruino.com/Puck.js+Quick+S­tart if devices with the older firmware are people's first experience.

    Huge thanks for the super quick and helpful response!

  • No problem! Yes, I'll add a mention to the Quick Start.

    It's amazing how you think you can have something with good firmware, and then 2000 people start using it and suddenly they find things that need to be fixed :)

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

[SOLVED] Unreliable connection from espruino command line tool to puck.js

Posted by Avatar for mozz100 @mozz100

Actions