diff --git a/http/index.html b/http/index.html
index 4170487..27ab9fd 100644
--- a/http/index.html
+++ b/http/index.html
@@ -28,7 +28,7 @@
Arguments: Parses arguments passed in the URL and prints them. (Lua)
Post: A form that uses POST method. Displays different content based on HTTP method. (Lua)
Garage door opener: Control GPIO lines via the server. Or try this simpler and nicer UI. (Lua)
- NodeMCU info: Shows some basic NodeMCU(Lua)
+ NodeMCU info: Display basic NodeMCU information. (Lua)
List all server files: Displays a list of all the server files. (Lua)
Upload: Update, remove, list files on the server. Beware security implications. By ATAMAH.
Foo: A file that doesn't exist. Should error (404 error)
diff --git a/http/node_info.lua b/http/node_info.lua
index 4bd2502..e143ca2 100644
--- a/http/node_info.lua
+++ b/http/node_info.lua
@@ -1,5 +1,15 @@
-local function sendAttr(connection, attr, val)
- connection:send("".. attr .. ": " .. (val or "nil") .. "
\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("".. attr .. ": " .. val .. unit .. "
\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('