scargill wrote:So I did some more tests this morning.
Examples from here: https://github.com/nodemcu/nodemcu-firmware
The TELNET example does not work and results in the module resetting every time..
The Web page example looks exciting at first.. but I noticed the browser returned the result "Hello NodeMCU but was constantly busy... and as browsers do, it retries the page.. and after 5 retries, the ESP-01 resets. Here's the output I monitored on the serial.
So here is the power up sequence and my init file getting an address from the router - all of that works..
Pete's LUA module 0.1
NodeMcu 0.9.2 build 20141120 powered by Lua 5.1.4
> c_GORSvfJSz.JSzfn
Pete's LUA module 0.1
NodeMcu 0.9.2 build 20141120 powered by Lua 5.1.4
>
Loading functions
Connecting
Connected to.loft-east.IP:.192.168.0.22
OK
and then here is where I add in the web page example
> srv=net.createServer(net.TCP)
> srv:listen(80,function(conn)
>> conn:on("receive",function(conn,payload)
>> print(payload)
>> conn:send("<h1> Hello, NodeMcu.</h1>")
>> end)
>> end)
>
and then here is the result...
> GET / HTTP/1.1
Host: 192.168.0.22
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Linux; Android 5.0; Nexus 10 Build/LRX21P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.59 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
but then wait... the browser of course gets the page again... and again. and....
GET / HTTP/1.1
Host: 192.168.0.22
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Linux; Android 5.0; Nexus 10 Build/LRX21P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.59 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
PANIC: unprotected error in call to Lua API (attempt to call a nil value)
c_GORSvf
SzfJSzfn
Pete's LUA module 0.1
NodeMcu 0.9.2 build 20141120 powered by Lua 5.1.4
>
Loading functions
Connecting
Connected to.loft-east.IP:.192.168.0.22
OK
So a quick test suggests it works - but in fact after a few refreshes - the unprotected error occurs and the board resets.
I got the same error, after 10+ refreshes.
sorry, some examples need more tests, before it's writen in the doc.
the code below disconnect with client when payload is sent. may be it's better, still little tests made.
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive",function(conn,payload)
print(payload) print(node.heap())
conn:send("<h1> Hello, NodeMcu.</h1>")
end)
conn:on("sent",function(conn) conn:close() end)
end)