@julian: Yes, it will take some time for the network interface to establish a connection with the access point; the E.init will trigger immediately after a power cycle (or save() invocation).
Change your code to this:
var Wifi = require('Wifi');
E.on("init", function () {
Wifi.on('connected', function(){
var http = require("http");
http.createServer(function (req, res) {
res.writeHead(200);
res.end("Hello World");
}).listen(8080);
});
});
The doc for the Wifi class has a number of events that are emitted on specific situations that you can utilize to your advantage.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
@julian: Yes, it will take some time for the network interface to establish a connection with the access point; the
E.init
will trigger immediately after a power cycle (orsave()
invocation).Change your code to this:
The doc for the
Wifi
class has a number of events that are emitted on specific situations that you can utilize to your advantage.