- Thu Oct 15, 2015 5:52 pm
#31460
Hi!
I ordered an nodemc, flashed the latest espruino binary.
I uploaded this code:
Code: Select all
var connectToWifi= function()
{
var ssid="ssid";
var pass="pass";
console.log('connecting to wifi');
ESP8266WiFi.init();
ESP8266WiFi.connect(
ssid,
pass,
function()
{
console.log('connected to wifi');
var ipInfo = ESP8266WiFi.getIPInfo();
print("Current IP address is: " + ESP8266WiFi.getAddressAsString(ipInfo.ip)+':'+ ESP8266WiFi.getAddressAsString(ipInfo.netmask));
print("starting webserver");
startWebServer();
}
);
};
var startWebServer = function()
{
var GPIO2 = new Pin(2);
var http = require("http");
var httpSrv = http.createServer(function(request, response) {
print(process.memory());
response.write("<html><body>");
if (request.url == "/on") {
response.write("<b>LED os on</b>");
digitalWrite(GPIO2, 0);
print ("led on");
} else if (request.url == "/off") {
response.write("<b>LED os off</b>");
print ("led off");
digitalWrite(GPIO2, 1);
} else {
response.write("Welcome to ESP with JS");
}
response.end("<br><a href='/on'>Led ON</a><br><a href='/off'>Led OFF</a></body></html>");
});
httpSrv.listen(80);
};
connectToWifi();
What is started to work, but it is crashing when I press the led on or off button. I got this log:
Code: Select all _____ _
| __|___ ___ ___ _ _|_|___ ___
| __|_ -| . | _| | | | | . |
|_____|___| _|_| |___|_|_|_|___|
|_| http://espruino.com
1v81.592 Copyright 2015 G.Williams
>echo(0);
connecting to wifi
=undefined
connected to wifi
Current IP address is: 192.168.1.67:255.255.255.0
starting webserver
{ "free": 511, "usage": 512, "total": 1023, "history": 203 }
>
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x40100000, len 29896, room 16
tail 8
chksum 0xf3
load 0x3ffe8000, len 2108, room 0
tail 12
chksum 0x71
ho 0 tail 12 room 4
load 0x3ffe8840, len 28936, room 12
tail 12
chksum 0x27
csum 0x27
nçsys=67740 rtc=6204297
don't use rtc mem data
sdr$ßãb$ùLoading 864 bytes from flash...
>
Disconnected
>
My code is wrong? Or it is an esp8266 espruino error?
This is the good place, where I can post bug reports?
regards
HyGy