ixfx
Helper functions can be used depending on the device you have:
For example:
import { Espruino } from 'https://unpkg.com/ixfx/dist/io.js' function connect() { // Prompt to connect, filtering for a particular Puck const e = await Espruino.puck({ name:`Puck.js a123` }); // Received something e.addEventListener(`data`, d => console.log(d.data)); // Monitor connection state e.addEventListener(`change`, c => console.log(`${d.priorState} -> ${d.newState}`)); // Write code to run on Espruino e.write(`digitalPulse(LED1,1,[10,500,10,500,10]);\n`); // Run some code and get the result const result = await e.eval(`2+2\n`);}) // Bluetooth connections need to be initiated from a UI eventdocument.getElementById(`btnConnect`).addEventListener(`click`, connect);
Official resources