Update node_info.lua

reducing overhead from extra sends probably well beneath buffer limits
This commit is contained in:
TJ Borromeo 2015-07-20 13:22:38 -07:00
parent 8acc6aa8ca
commit e52ca7731f

View File

@ -1,6 +1,6 @@
local function sendHeader(connection)
connection:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nCache-Control: private, no-store\r\n\r\n")
end
local function sendAttr(connection, attr, val)
@ -10,9 +10,7 @@ end
return function (connection, args)
collectgarbage()
sendHeader(connection)
connection:send('<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>A Lua script sample</title></head>')
connection:send('<body>')
connection:send('<h1>Node info</h1>')
connection:send('<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>A Lua script sample</title></head><body><h1>Node info</h1><ul>')
majorVer, minorVer, devVer, chipid, flashid, flashsize, flashmode, flashspeed = node.info();
sendAttr(connection, "NodeMCU version" , majorVer.."."..minorVer.."."..devVer)
sendAttr(connection, "chipid" , chipid)
@ -24,6 +22,5 @@ return function (connection, args)
sendAttr(connection, 'Memory in use (KB)' , collectgarbage("count"))
sendAttr(connection, 'IP address' , wifi.sta.getip())
sendAttr(connection, 'MAC address' , wifi.sta.getmac())
connection:send('</ul>')
connection:send('</body></html>')
connection:send('</ul></body></html>')
end