Improve node info.lua (#95)
* Handle "nil", add more info * Split up subnet mask, move unit to the end.
This commit is contained in:
parent
7cdbe0ffd0
commit
2bdb2d458c
@ -28,7 +28,7 @@
|
||||
<li><a href="args.lua">Arguments</a>: Parses arguments passed in the URL and prints them. (Lua)</li>
|
||||
<li><a href="post.lua">Post</a>: A form that uses POST method. Displays different content based on HTTP method. (Lua)</li>
|
||||
<li><a href="garage_door.html">Garage door opener</a>: Control GPIO lines via the server. Or try this <a href="garage_door_control.html">simpler and nicer UI</a>. (Lua)</li>
|
||||
<li><a href="node_info.lua">NodeMCU info</a>: Shows some basic NodeMCU(Lua)</li>
|
||||
<li><a href="node_info.lua">NodeMCU info</a>: Display basic NodeMCU information. (Lua)</li>
|
||||
<li><a href="file_list.lua">List all server files</a>: Displays a list of all the server files. (Lua)</li>
|
||||
<li><a href="upload.html">Upload</a>: Update, remove, list files on the server. Beware security implications. By <a href="https://github.com/ATAMAH">ATAMAH</a>.</li>
|
||||
<li><a href="foo.html">Foo</a>: A file that doesn't exist. Should error (404 error)</li>
|
||||
|
||||
@ -1,5 +1,15 @@
|
||||
local function sendAttr(connection, attr, val)
|
||||
connection:send("<li><b>".. attr .. ":</b> " .. (val or "nil") .. "<br></li>\n")
|
||||
local function sendAttr(connection, attr, val, unit)
|
||||
--Avoid error when Nil is in atrib=val pair.
|
||||
if not attr or not val then
|
||||
return
|
||||
else
|
||||
if unit then
|
||||
unit = ' ' .. unit
|
||||
else
|
||||
unit = ''
|
||||
end
|
||||
connection:send("<li><b>".. attr .. ":</b> " .. val .. unit .. "<br></li>\n")
|
||||
end
|
||||
end
|
||||
|
||||
return function (connection, req, args)
|
||||
@ -9,12 +19,14 @@ return function (connection, req, args)
|
||||
sendAttr(connection, "NodeMCU version" , majorVer.."."..minorVer.."."..devVer)
|
||||
sendAttr(connection, "chipid" , chipid)
|
||||
sendAttr(connection, "flashid" , flashid)
|
||||
sendAttr(connection, "flashsize" , flashsize)
|
||||
sendAttr(connection, "flashsize" , flashsize, 'Kb')
|
||||
sendAttr(connection, "flashmode" , flashmode)
|
||||
sendAttr(connection, "flashspeed" , flashspeed)
|
||||
sendAttr(connection, "node.heap()" , node.heap())
|
||||
sendAttr(connection, 'Memory in use (KB)' , collectgarbage("count"))
|
||||
sendAttr(connection, 'IP address' , wifi.sta.getip())
|
||||
sendAttr(connection, "flashspeed" , flashspeed / 1000000 , 'MHz')
|
||||
sendAttr(connection, "heap free" , node.heap() , 'bytes')
|
||||
sendAttr(connection, 'Memory in use' , collectgarbage("count") , 'KB')
|
||||
ip, subnetMask = wifi.sta.getip()
|
||||
sendAttr(connection, 'Station IP address' , ip)
|
||||
sendAttr(connection, 'Station subnet mask' , subnetMask)
|
||||
sendAttr(connection, 'MAC address' , wifi.sta.getmac())
|
||||
connection:send('</ul></body></html>')
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user