Hi - the issue is you've got two places where you can execute JavaScript - in the Web Browser, and in Puck.js itself. You're running code that's meant for Puck.js in the web browser.
The usage of the Puck name for Puck.write and Puck.eval is a bit confusing, but basically Puck.write/eval go in the Web Browser. Puck.mag/etc (or anything on http://www.espruino.com/Reference#Puck) runs in Puck.js.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hi - the issue is you've got two places where you can execute JavaScript - in the Web Browser, and in Puck.js itself. You're running code that's meant for Puck.js in the web browser.
The usage of the
Puck
name forPuck.write
andPuck.eval
is a bit confusing, but basicallyPuck.write/eval
go in the Web Browser. Puck.mag/etc (or anything on http://www.espruino.com/Reference#Puck) runs in Puck.js.If you want to get this working, use the two-way communication example from https://www.espruino.com/Web%20Bluetooth#two-way-communications
Then replace:
with:
... and you probably want to change the
onLine
handler to do something else with the data.What's then happening is you're using
.write
to send the program (as a string) to Puck.js for execution, rather that running it on the PC