-
Salut @azer, what's your status?
-
-
-
-
0018000902-AI03
I'm ordering a USB-TTL converter and will upgrade. Thanks. I read the ESP page too fast:
If you don't have the 0018000902-AI03 firmware version, make sure you
change the baud rate and Module Name in the code examples below.So I concluded that it was all right for me.
But now I see in the table is written for 0018000902-AI03:
This was the version sent on boards that came with the Espruino Pico
KickStarter. It's quite old now, and is known have quite a few bugs.Thank you @DrAzzy
-
Hi,
I am still trying to have my Pico+ESP8266 act as simple HTTP server. It has been working last week (inconvenient of having this only as a hobby project :/ ) but now I keep getting this error.
I used http://www.espruino.com/Interactive+Web+UI to kick start my code. It still is pretty close to it. The first request I make works, but the second always triggers this error:
Here, as seen in the Web IDE's console:
GET /
GET /
ERROR: Socket error -1 while sending
Uncaught Error: > not registered at line 2 col 64 ...Error(key+" not
registered");
^
in function "unregister" called from line 7 col 26
at.unregister('>');
^
in function "callback" called from line 4 col 40
if (callback && (n=callback(d))) {
^
in function "lineCallback" called from line 29 col 27
lineCallback(l);
^
in function called from systemCode:
var wifi; function connectWifi(){ Serial2.setup(9600, { rx: A3, tx : A2 }); wifi = require("ESP8266WiFi").connect(Serial2, function(err) { if (err) throw err; wifi.reset(function(err) { if (err) throw err; console.log("Connecting to WiFi"); wifi.connect(WIFI_NAME, WIFI_PASS, function(err) { if (err) throw err; console.log("Connected"); // print IP address wifi.getIP(console.log); // Create a server require("http").createServer(pageHandler).listen(80); }); }); }); } function pageHandler(req, res) { console.log(req.method,req.url); if (req.method=="POST") { res.writeHead(200); res.end('POSTHOME'); } else if (req.method=="GET") { if (req.url=="/") { res.writeHead(200); res.end('GEThome'); } else { res.writeHead(404); res.end("404: Not found"); } } else if (req.method=="OPTIONS") { if (req.url=="/") { res.writeHead(404); res.end(); } } } connectWifi();
I spent several hours looking for the origin of the error, as well as its cause with no luck. Does someone recognise it?
-
res.on('close', fn)
works. Thank you @Gordon. -
-
Hmm, I didn't know that was even possible - it feels a bit iffy - for
instance if you're trying to serve up a file containing a JS function,
if you try and serve up a variable containing the function rather than
a variable containing a string representing the function, it'll get
executed :sI'm not sure to understand what you mean. The callback is always the latest of the given arguments. If
end(a)
,a()
will be called. Ifend(a,b)
,b()
... The type does not matter to tell which argument is what.I'm pretty sure you can just use the 'close' event though?
I will try this.
If you're interested, source of the HTTP module is here - it it's in C.
Thanks. It will spare me to ask useless questions :)
-
Oh thank you @Spocki !
-
Is that normal that a function as only parameter of response.end is not called. I was expecting the same behavior as on Node .
http.createServer(function (req, res) { //... res.end(function(){ // never called console.log('GET done.'); digitalWrite(LED2,0); }); }
I don't find the sources of http module. But it seems to always consider first arg as data.
Is there another way to achieve this?
-
Hi, I'm still in my first step with Pico, and electronic in general. (Therefore the soldering job may not have been the cleanest)
I put together an ESP8266 on my Pico and made it a basic HTTP server. It is working smoothly when it is plugged-in USB and the code is uploaded with the WebIDE. Even if I then (after having uplaoded and run the code) deconnect the WebIDE: the Pico is still responding to requests.
But when I just plug in the Pico to USB, or plug in a battery (+ go to BAT IN, right?), it is never responding. The Pico and ESP8266 are blinking like if it was correctly initialising though.What am I missing?
-
-
-
-
-
-
-
Ok, thanks 👍