This tool allows for code to be uploaded remotely to Espruino hardware devices from a web browser. The uploader works by fetching a file containing valid espruino code, then writes to a connected espruino device using the UART.js library.
The uploader can write to both flash or RAM storage, and will check code currently stored on the device to prevent redundent writes.
This tool relies upon web bluetooth to work, and as such requires a supported device/browser to work. You can find a list of supported browsers here.
Source code for the uploader is available here
Further documentation along with interactive demos are available here
The package can be installed via npm using:
npm i remote-uploader --save
Alternatively, you can include the following script tag:
<script src="https://unpkg.com/remote-uploader@3.0.0/dist/remote.min.js"></script>
To create a new connection:
let connection = new Remote();
connection.connect();
To upload code to a connected device. Important to note that the upload function will have a delay before returning whilst code is being written to the device:
connection.upload(url).then(success => {
if(success){
//...
} else {
//...
}
})
Additionally, you can specify true to upload code directly to flash storage (flash uploading does not work for bangle devices):
connection.upload(url,true).then(success => {
if(success){
//...
} else {
//...
}
})
Retrieve device type (e.g. pixl, bangle, puck):
connection.getDeviceType().then(result => {
//...
})
You can retrieve code stored on the device using:
connection.dump().then((result) => {
//...
})
To reset the device (removes all code currently stored on the device):
connection.reset();
To disconnect the device from the current webpage:
connection.disconnect();
You can execute methods written to the device using:
connection.call(foo)
where foo is a string representing the function being called on the device. For example, to call foo you would use:
connection.call("foo();");
You can retrieve a value from the device using:
connection.eval(foo).then((result => {
//...
}))
Where foo is a string representing the function being called on the device.