• I'm loving my Espruino Wifi. However, I'm currently trying to do something very simple but can't see why it's not working. I'm simply trying to create a server and listen on port 80. I've written a simple script based on the examples:

    var WIFI_NAME = "Kraken";
    var WIFI_OPTIONS = { password : "xxx" };
    
    var wifi;
    var config = {
      'Title': 'Test Piece',
      'Network': WIFI_NAME,
      'macaddress': '',
      'ipaddress': ''
    };
    
    function onInit() {
      wifi = require("EspruinoWiFi");
      wifi.connect(WIFI_NAME, WIFI_OPTIONS, function(e) { 
        if (e) {
          console.log("Connection Error: "+e);
          return;
        }
        wifi.getIP(function(f,ip) {
          config.macaddress = ip.mac;
          config.ipaddress = ip.ip;
          console.log("Connected: ",config);
        });
        require("http").createServer(function(re­q,res) {
          console.log(req);
          res.writeHead(200);
          res.end("Hello World");
        }).listen(80);
      });
    }
    
    onInit();
    

    But get this error when I try to connect to the device from Chrome:

    >
     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v91 Copyright 2016 G.Williams
    >
    =undefined
    Connected:  {
      "Title": "Test Piece",
      "Network": "Kraken",
      "macaddress": "5c:cf:7f:c0:f4:85",
      "ipaddress": "192.168.1.111"
     }
    >Uncaught Error: CIPSERVER failed (Timeout)
     at line 1 col 53
    throw Error("CIPSERVER failed ("+(a?a:"Timeout")+")");
                                                        ^
    in function called from system
     
    

    You'll see it's connecting to wifi OK. I did discover that the examples I were using needed to be modified to work with the Espruino Wifi chip, but what else am I missing?

    Thanks,

    Sean

About

Avatar for seanclark @seanclark started