• There are still a few kinks to iron out, but if you upload this code to your Espruino WiFi board:

    var WIFI_NAME = "...";
    var WIFI_PASS = "...";
    function onPageRequest(req, res) {
      res.writeHead(200, {'Content-Type': 'text/html'});
    <body style="margin:0px"> 
    <iframe id="ideframe" src="https://www.espruino.com/ide/" style="width:100%;height:100%;border:0px­;"></iframe>
    <script src="https://www.espruino.com/ide/embed.­js"></script>
      var ws = new WebSocket("ws://" + location.host + "/ws", "serial");
      var Espruino = EspruinoIDE(document.getElementById('ide­frame'));
      Espruino.onports = function() {
        return [{path:'local', description:'Local Device', type : "net"}];
      Espruino.onready = function(data) { Espruino.connect("local");};
      Espruino.onwrite = function(data) { ws.send(data); }
      ws.onmessage = function (event) { Espruino.received(event.data); };
      ws.onclose = function (event) { Espruino.disconnect(); };
    /* Quick hack to ensure that on older builds,
    process.env fits into available buffers */
    if (process.env.EXPORTS) {
      process.env = process.env;
      delete process.env.EXPORTS;
    /* Hack to ensure that `reset` won't cause us problems */
    global.reset = function() {
      console.log("Ignoring reset() request");
    var wifi = require("Wifi");
    wifi.connect(WIFI_NAME, { password : WIFI_PASS }, function(err) {
      if (err) {
        console.log("Connection error: "+err);
      var server = require('ws').createServer(onPageRequest­);
      server.on("websocket", function(ws) {
        ws.on('message',function(msg) { LoopbackA.write(msg); });
        LoopbackA.on('data',function(msg) { ws.send(msg); }); 
        ws.on('close', function() { 

    Then you can connect to the displayed IP address and get a full Web IDE that you can upload code from!

    Obviously if you reset() the board then the WiFi connection is lost and the IDE stops responding so that has been disabled (and also large print statements will be lost) but otherwise it's actually pretty usable. I'd recommend you use one of the latest Espruino firmwares though.

    This should also work on other devices with pretty minimal changes (eg. USB->Serial1 on disconnect) - I'd be interested to hear how you get on.


Avatar for Gordon @Gordon started