Ver código fonte

Merge pull request #1 from RobotHacker/patch-1

Add more info items, change sta.status to use API constants.
moononournation 7 anos atrás
pai
commit
cc1c91d716
1 arquivos alterados com 37 adições e 8 exclusões
  1. 37 8
      bin/system-info.lua

+ 37 - 8
bin/system-info.lua

@@ -16,7 +16,9 @@ return function (connection, req, args)
 
   local remaining, used, total = file.fsinfo()
   connection:send('<p><b>File System Usage:</b> '..used..' / '..total..' bytes</p>')
-  connection:send('<p><b>Wifi MAC Address:</b> '..wifi.sta.getmac()..'</p>')
+
+  connection:send('<p><b>Wifi STA MAC Address:</b> '..wifi.sta.getmac()..'</p>')
+  connection:send('<p><b>Wifi AP MAC Address:</b> '..wifi.ap.getmac()..'</p>')
 
   connection:send('<p><b>WiFi Channel:</b> '..wifi.getchannel()..'</p>')
 
@@ -31,6 +33,20 @@ return function (connection, req, args)
     connection:send('<p><b>WiFi Mode:</b> NULLMODE</p>')
   end
 
+  if (wifimode == wifi.STATIONAP) or (wifimode == wifi.SOFTAP) then
+    local ip, netmask, gateway = wifi.ap.getip()
+    connection:send('<p><b>AP IP:</b> '..ip..'</p>')
+    connection:send('<p><b>AP netmask:</b> '..netmask..'</p>')
+    connection:send('<p><b>AP gateway:</b> '..gateway..'</p>')
+
+    connection:send('<p><b>AP client list:</b> ')
+    local clients = wifi.ap.getclient()
+    for mac, ip in pairs(clients) do
+      connection:send('<p><b>'..mac..':</b> '..ip..'</p>')
+    end
+    connection:send('</p>')
+  end
+
   local wifiphymode = wifi.getphymode()
   if wifiphymode == wifi.PHYMODE_B then
     connection:send('<p><b>WiFi Physical Mode:</b> B</p>')
@@ -41,19 +57,32 @@ return function (connection, req, args)
   end
 
   local status = wifi.sta.status()
-  if status == 0 then
+  if status == wifi.STA_IDLE then
     connection:send('<p><b>wifi.sta.status:</b> STA_IDLE</p>')
-  elseif status == 1 then
+  elseif status == wifi.STA_CONNECTING then
     connection:send('<p><b>wifi.sta.status:</b> STA_CONNECTING</p>')
-  elseif status == 2 then
+  elseif status == wifi.STA_WRONGPWD then
     connection:send('<p><b>wifi.sta.status:</b> STA_WRONGPWD</p>')
-  elseif status == 3 then
+  elseif status == wifi.STA_APNOTFOUND then
     connection:send('<p><b>wifi.sta.status:</b> STA_APNOTFOUND</p>')
-  elseif status == 4 then
+  elseif status == wifi.STA_FAIL then
     connection:send('<p><b>wifi.sta.status:</b> STA_FAIL</p>')
-  elseif status == 5 then
+  elseif status == wifi.STA_GOTIP then
     connection:send('<p><b>wifi.sta.status:</b> STA_GOTIP</p>')
-    connection:send('<p><b>IP:</b> '..wifi.sta.getip())
+    connection:send('<p><b>Hostname:</b> '..wifi.sta.gethostname()..'</p>')
+
+    local ip, netmask, gateway = wifi.sta.getip()
+    connection:send('<p><b>STA IP:</b> '..ip..'</p>')
+    connection:send('<p><b>STA netmask:</b> '..netmask..'</p>')
+    connection:send('<p><b>STA gateway:</b> '..gateway..'</p>')
+
+    local ssid, password, bssid_set, bssid = wifi.sta.getconfig()
+    connection:send('<p><b>SSID:</b> '..ssid..'</p>')
+    -- connection:send('<p><b>password:</b> '..password..'</p>') -- not sure if it should be shown.
+    connection:send('<p><b>BSSID set:</b> '..bssid_set..'</p>')
+    connection:send('<p><b>BSSID:</b> '..bssid..'</p>')
+
+    connection:send('<p><b>STA Broadcast IP:</b> '..wifi.sta.getbroadcast()..'</p>')
     connection:send('<p><b>RSSI:</b> '..wifi.sta.getrssi()..' dB</p>')
   end
   connection:send('</body></html>')