ESP32
A sometimes error message occurs when serving a web page.
>E (36271) wifi: pp.c 3126
Is there a reference where this can be found?
The program:
//ESP32wifiDweetServec.js
// 6 Feb2018
// http://www.espruino.com/Reference#Wifi
var ssid="myssid";
var key="mypassword";
var port = 8080;
//set DweetID to a unique value
var DweetID="lovelyDay898"; // make up your own phrase
// Use the following to get the Dweet containing the IP address
// https://dweet.io/get/latest/dweet/for/lovelyDay898
/////////////////////
// Some globals
var tasknumber=0;
var IP;
var MAC;
var myinterval;
var Clock = require("clock").Clock;
var date=new Date();
//console.log(date);
//console.log(date.toString());
var clk=new Clock(date.toString());
console.log(clk.getDate().toString());
var wifi = require('Wifi');
function putDweet(dweet_name, a, callback) {
var data = "";
for (var n in a) {
if (data.length) data+="&";
data += encodeURIComponent(n)+"="+encodeURIComponent(a[n]);
}
var options = {
host: 'dweet.io',
port: '80',
path:'/dweet/for/'+dweet_name+"?"+data,
method:'POST'
};
// console.log(options);
var http=require("http");
console.log(options);
require("http").request(options, function(res) {
var d = "";
res.on('errpr',function(e){console.log("err ",e);});
res.on('data', function(dta) { d+=dta;});
res.on('close', function(dta) {
d+=dta;
// console.log("d= ",d);
if (callback) callback(d);
});
}).end();
}
function mytask1(){
console.log("Mytask 1");
putDweet(DweetID, {IP:IP}, function(d) {
// console.log(d);
var L = JSON.parse(d);
// console.log(L);
var x1= L.with.created;
// console.log("x1=",x1);
clk.setClock(Date.parse(x1));
console.log(clk.getDate().toString());
tasknumber=1;
wifi.disconnect();
});//end putDweet
//// end user code
}//end my task1
//////////////////////////////////////////////////////
var page1 = "<!DOCTYPE html>\r\n<html>\r\n<body>\r\n\r\n<h1>My First Web Page</h1>\r\n<p>My first paragraph.";
var page2="</p>\r\n\r\n<script>\r\ndocument.write(5 + 6);\r\n</script>\r\n\r\n</body>\r\n</html>";
function mytask2(){
console.log("Mytask 2");
//// Various user code can go here a simple hello page server
//// is given as an example
var http=require('http').createServer(function (req, res) {
res.writeHead(200);
console.log("hello");
res.write(page1);
res.write(clk.getDate().toString());
res.write(page2);
res.end();
res.on('close', function() {console.log("resclose"); });
req.on('data',function(data){console.log("req=",data);});
req.on('error',function(){console.log("reqerr");});
req.on('close',function(){console.log("reqcls");});
}).listen(8080); //end server
//// end user code
}//end my task2
function mytask(){
switch (tasknumber){
case 0:
mytask1();
break;
case 1:
clearInterval( myinterval);
mytask2();
break;
default:
tasknumber=0;
}//end switch
}//end mytask
var onWiFiConnect=function(){
var IPobject= wifi.getIP();
IPobject= wifi.getIP();
//var
IP = IPobject.ip;
//var
MAC = IPobject.mac;
console.log("IP:");
console.log(IP);
console.log("MAC:");
console.log(MAC);
mytask();
};
wifi.on('disconnected', function(details) {
console.log("disconnected");
wifi.connect(ssid, {password: key},onWiFiConnect());
});
setTimeout(function () {
console.log("start");
// wifi.disconnect();
wifi.connect(ssid, {password: key},onWiFiConnect());
}, 3000);
And the output with tasknumber=1 to skip the dweet code
1v95 Copyright 2017 G.Williams
Espruino is Open Source. Our work is supported
only by sales of official boards and donations:
http://espruino.com/Donate
>Thu Jan 1 1970 00:00:00 GMT+0000
>
=undefined
start
IP:
0.0.0.0
MAC:
24:0a:c4:00:97:2a
Mytask 2
hello
reqcls
t2close
hello
reqcls
t2close
>E (36271) wifi: pp.c 3126
It serves the page, sometimes several times and then dies with this error.
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.
ESP32
A sometimes error message occurs when serving a web page.
Is there a reference where this can be found?
The program:
And the output with tasknumber=1 to skip the dweet code
It serves the page, sometimes several times and then dies with this error.