You are reading a single comment by @ClearMemory041063 and its replies. Click here to read the full conversation.
  • In the code titled //UDP_TCPclient1.js //2 Oct 2016
    The following is the menu system.
    Entering a character zero 0 followed by a return should reset the USB.
    If you wrapped the code in an oninit() and saved it so it loads on boot,
    then power up the board, quickly connect with WebIDE and type 0 return in the left pane
    you should be able to reset the USB port.

    //Menus
    menu=function(){
     USB.print(" \n\r");
     USB.print("Select using digit and return key\n\r");
     USB.print("1 LED Off\n\r");
     USB.print("2 LED On\n\r");
     USB.print("0 Exit\n\r");
    };
    
    parsecmd=function(){
    USB.print("\n\r");
       switch(this.sst.charAt(0)){
        case "1"://LED off
         sst="";
         USB.print("LED Off\n\r");
         sendit("LED Off");
        break;
        case "2"://LED On
         USB.print("LED On\n\r");
         sst="";
         sendit("LED On");
        break;
        case"0"://Exit
         LoopbackA.print("USB.setConsole();\n\r");
         sst="";
         USB.print("Exit\n\r");
        break;
        default:
         menu();
        break;
      }//end switch sst
    };//end parsecmd
    
    //input cmd from terminal,send it to parsecmd()
    USB.on('data', function (data) {
     var i;
      sst+=data;
      USB.print(data);
      if(sst.length>0)
      if(sst.charAt(sst.length-1)==="\r")parsecmd();
    });
    
    //Espruino replies here
    LoopbackA.on('data',function(data){
      USB.print(data); //sending data to terminal
    });
    
    /////////////////////////
    setTimeout(function () {
    var x;
    console.log("Start");
      LoopbackB.setConsole();
    x=test();
    if(x!==0)console.log("Try again");//error seen
    
    if(x===0) console.log("Exit Seen");
    }, 1000);
    

    The left screen

    >echo(0);
    =undefined
    Start
    -> LoopbackB
    <- USB
    Start connection process
    Try again
    Reset the ESP8266
    Connecting to WiFi
    OKxx1
    OKxx2
    >0 I entered a zero return
    Exit
    <- LoopbackB
    =undefined
    =undefined
    >USB.setConsole();
    -> USB
    1       I entered a 1 return
    =1
    > 
    
About