Skip to content

Commit e52ca77

Browse files
committed
Update node_info.lua
reducing overhead from extra sends probably well beneath buffer limits
1 parent 8acc6aa commit e52ca77

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

http/node_info.lua

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
local function sendHeader(connection)
22
connection:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nCache-Control: private, no-store\r\n\r\n")
3-
3+
44
end
55

66
local function sendAttr(connection, attr, val)
@@ -10,9 +10,7 @@ end
1010
return function (connection, args)
1111
collectgarbage()
1212
sendHeader(connection)
13-
connection:send('<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>A Lua script sample</title></head>')
14-
connection:send('<body>')
15-
connection:send('<h1>Node info</h1>')
13+
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>')
1614
majorVer, minorVer, devVer, chipid, flashid, flashsize, flashmode, flashspeed = node.info();
1715
sendAttr(connection, "NodeMCU version" , majorVer.."."..minorVer.."."..devVer)
1816
sendAttr(connection, "chipid" , chipid)
@@ -24,6 +22,5 @@ return function (connection, args)
2422
sendAttr(connection, 'Memory in use (KB)' , collectgarbage("count"))
2523
sendAttr(connection, 'IP address' , wifi.sta.getip())
2624
sendAttr(connection, 'MAC address' , wifi.sta.getmac())
27-
connection:send('</ul>')
28-
connection:send('</body></html>')
25+
connection:send('</ul></body></html>')
2926
end

0 commit comments

Comments
 (0)