node_info.lua 1.6 KB

123456789101112131415161718192021222324252627282930313233
  1. local function sendHeader(connection)
  2. <<<<<<< HEAD
  3. connection:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nCache-Control: private, no-store\r\n\r\n")
  4. =======
  5. connection:send("HTTP/1.0 200 OK\r\nContent-Type: text/html\rCache-Control: private, no-store\r\n\r\n")
  6. >>>>>>> 2357415466bb24cba8ee33109146f6a6a2df0282
  7. end
  8. local function sendAttr(connection, attr, val)
  9. connection:send("<li><b>".. attr .. ":</b> " .. val .. "<br></li>\n")
  10. end
  11. return function (connection, args)
  12. collectgarbage()
  13. sendHeader(connection)
  14. connection:send('<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><title>A Lua script sample</title></head>')
  15. connection:send('<body>')
  16. connection:send('<h1>Node info</h1>')
  17. majorVer, minorVer, devVer, chipid, flashid, flashsize, flashmode, flashspeed = node.info();
  18. sendAttr(connection, "majorVer" , majorVer)
  19. sendAttr(connection, "devVer" , devVer)
  20. sendAttr(connection, "chipid" , chipid)
  21. sendAttr(connection, "flashid" , flashid)
  22. sendAttr(connection, "flashsize" , flashsize)
  23. sendAttr(connection, "flashmode" , flashmode)
  24. sendAttr(connection, "flashspeed" , flashspeed)
  25. sendAttr(connection, "node.heap()" , node.heap())
  26. sendAttr(connection, 'Memory in use (KB)' , collectgarbage("count"))
  27. sendAttr(connection, 'IP address' , wifi.sta.getip())
  28. sendAttr(connection, 'MAC address' , wifi.sta.getmac())
  29. connection:send('</ul>')
  30. connection:send('</body></html>')
  31. end