• Postw6.js 2 Sep 2016
    This code encapsulates into objects and eliminates global variable, except for the configuration variables. It uses emit() and object.on() functions to signal that the WiFi is connected. The console is redirected so that a menu system appears on the USB port.
    The Hardware variable selects PICO or Espruino board hardware connected to an ESP8266.
    Select Espruino Bd or Pico hardware
    var Hardware=0; //Espruino board
    var Hardware =1; //PICO
    The IP variable contains the IP address of the server
    //setup IP address of server
    IP="192.168.1.5";
    The SSID and key variables identify the WiFi router acces information
    //setup WiFi access parameters
    var SSID="router name";
    var key= "router key";
    Start the HTMLserverA1.js
    The output:

    >echo(0);
    =undefined
    -> LoopbackB
     
    Select using digit and return key
    1 Connect
    0 Exit
    <- USB
    >1
    do connect
    Start connection process
    Waiting for ESP8266 response
    Reset the ESP8266
    Connecting to WiFi
    Wi-Fi Connected
     
    Select using digit and return key
    1 Good Message
    2 Bad Message
    0 Exit
    IP= 192.168.1.4
    null
    1
    Send Good Message
    80
    192.168.1.5
    send
    Closed: 0123456789012345678901234567890123456789­0123456789012345678901234567890123456789­
    ss 0123456789012345678901234567890123456789­0123456789012345678901234567890123456789­
     
    Select using digit and return key
    1 Good Message
    2 Bad Message
    0 Exit
    2
    Bad Message
    70
    192.168.1.5
    send
    Closed: 1234
    ss 1234
     
    Select using digit and return key
    1 Good Message
    2 Bad Message
    0 Exit
    0
    Exit
    <- LoopbackB
    =undefined
    =undefined
    >USB.setConsole();
    -> USB
    

    1 Attachment

About