e.addEventListener(`change`, evt=> { console.log(`State change ${evt.priorState} -> ${evt.newState}`); if (evt.newState === `connected`) { // Do something when connected... } });
Reading incoming data:
// Parse incoming data as JSON s.addEventListener(`data`, evt=> { try { consto = JSON.parse(evt.data); // If we get this far, JSON is legit } catch (ex) { } });
Create a serial-connected Espruino device.
Options:
Listen for events:
Reading incoming data:
Writing to the microcontroller