-
• #2
Still can't figure out why my own example doesn't work when I change some bits, but just a note that line 43 should read
if( typeof d.name !== "undefined" && d.name.indexOf( "Puck.js" ) === 0 ) {
as
typeof
returns a string and you're not coercing type. -
• #3
Thanks @trezm for pointing out. Just changed that bit.
One think I'd like to improve is checking some version number before updating a remote.
Then omit the update if the version is already there or higher.But without reading the response (not possible to receive notifications yet) this is tricky.
Some thoughts:- just execute some verification code and let the peripheral hang up itself. Like
if same or newer then disconnect()
. Problem here: how can the central see the disconnect and move on? Tried it and catch() was not called. Maybe a watchdog with timeout? - implement another service just for reading the version first. More complex and less elegant.
- waiting for a newer release so the UART response can be used.
Other ideas?
- just execute some verification code and let the peripheral hang up itself. Like
-
• #4
Hi @ChristianW, one idea would be to advertise the installed version number. So when scanning, the sender would skip the pucks which have the same or a higher version number. That's not completely fool proof, when two pucks are sending at the same time with different versions, the older version could in theory win. But it's better than nothing...
-
• #5
BTW: This is a seriously cool method to program many Pucks automatically! Very useful
-
• #6
Cool. I like it. Will recruit all nearby pucks:-)
Suggest that as well as being aware of versions it might benefit from 2 things:- A simple white list and/or blacklist to limit pucks of interest( perhaps with wildcard *)
- Ability to password protect each puck at the same time to prevent others from capturing your pucks in this way.
- A simple white list and/or blacklist to limit pucks of interest( perhaps with wildcard *)
-
• #7
Hi Gordon,
How can I get the optimized js code which is deployed on the Puck ?
This is required when doing mass deployment from Android device for example. Do you think that it is a good idea to have in the Espruino WebIDE "Get deployed code" button ?Thank you.
-
• #8
You might be able to get it as a string by looking in the 'console' under settings...
However if you install the command-line tools https://www.npmjs.com/package/espruino you can use
-o out.js
to output the code directly to a file. -
• #9
Thank you Gordon.
-
• #11
You need to have physical access to the Puck to put it in to bootloader mode - to do the steps shown here: http://www.espruino.com/Puck.js#firmware-updates
It's a security thing - by default I leave the Pucks open to make it easy for developers to get started, but allowing anybody to remotely change the interpreter software would be a recipe for disaster.
The bootloader is protected by a key, but because Espruino is Open Source and people want to be able to use their own firmware the key is public - so anybody can write whatever they want onto their Pucks.
-
• #13
Do you want to update Puck's interpreter firmware, or your JavaScript firmware?
You won't be able to fully update the interpreter firmware without any manual interaction - it'd be a massive security risk.
I think it would be possible to remotely send JS code that would totally reset a Puck.js device, and then all someone would have to do is hold the button down while the device reset. It could look like this:
- Send code to a Puck.js via Bluetooth
- press button - it could trigger a reset and start the bootloader process
- software on a PC looks for devices in Bootloader mode and programs them
- job done
However if you want a lot of new ones pre-programmed then you could get in touch and if there were enough I could arrange that they were shipped out to you.
Either that or potentially I could come up with a pogo-pin programmer for you so you'd peel off the silicone top, hold it onto the Puck for ~20 seconds and it'd be programmed.
- Send code to a Puck.js via Bluetooth
So this is it.
Thanks to a few hints from @Gordon my first self-propagating Puck.js code
(Kind of worm if you like)
Feedback and improvements welcome.
Output for 4 Pucks: