• For the wiznet, this is what I use:

    function onInit() {
      // Ethernet Card
      SPI2.setup({ mosi:B15, miso:B14, sck:B13 });
      var eth = require("WIZnet").connect(SPI2, B10);
      eth.setIP();
      global.eth = eth;
      
      // Prevent reset
      function softreset() {
        clearInterval();
        clearWatch();
        Object.keys(global).forEach(function(n) {
          if(n!="onInit" && n!="Ethernet" && n!="Server" && n!="Socket" && n!="Serial" && n!="Pipe" && n!="LoopbackA" && n!="LoopbackB" && n!="eth" && n!="fullreset" && n!="reset") {
            delete global[n];
          }
        });
        console.log("Can't reset properly - we'd break the network. Use fullreset() instead.");
      }
    
      // Telnet Server
      require("net").createServer(function (connection) {
        connection.pipe(LoopbackA);
        LoopbackA.pipe(connection);
        LoopbackB.setConsole();
        if(!global.fullreset) {
          global.fullreset = global.reset;
          global.reset = softreset;
        }
      }).listen(23);
    }
    
    //save();
    

    (Updated with Gordon's tip)

About

Avatar for heri16 @heri16 started