Created
December 12, 2017 22:33
-
-
Save isevcik/9056a3d42b71dff47f59f559eeb11f37 to your computer and use it in GitHub Desktop.
esp8266 nodeMCU script for scanning available Wifi APs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return function (connection, req, args) | |
dofile('httpserver-header.lc')(connection, 200, 'html') | |
function ca(payload) connection:send(payload) end | |
ca("<script>setTimeout(function(){window.location=window.location}, 4000)</script>") | |
aplist = aplist or {} | |
ca("<table>") | |
ca("<tr>") | |
ca("<th>ssid</th>") | |
ca("<th>authmode</th>") | |
ca("<th>rssi</th>") | |
ca("<th>channel</th>") | |
ca("</tr>") | |
for k,v in pairs(aplist) do | |
ca("<tr>") | |
ca("<td>"..k.."</td>") | |
ca("<td>"..v.authmode.."</td>") | |
ca("<td>"..v.rssi.."</td>") | |
ca("<td>"..v.channel.."</td>") | |
ca("</tr>") | |
end | |
ca("</table>") | |
function listap(t) -- (SSID : Authmode, RSSI, BSSID, Channel) | |
for ssid,v in pairs(t) do | |
local authmode, rssi, bssid, channel = string.match(v, "([^,]+),([^,]+),([^,]+),([^,]+)") | |
aplist[ssid] = aplist[ssid] or {} | |
aplist[ssid].rssi = rssi | |
aplist[ssid].authmode = authmode | |
aplist[ssid].channel = channel | |
end | |
end | |
wifi.sta.getap(listap) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment