Skip to content

Instantly share code, notes, and snippets.

@isevcik
Created December 12, 2017 22:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isevcik/9056a3d42b71dff47f59f559eeb11f37 to your computer and use it in GitHub Desktop.
Save isevcik/9056a3d42b71dff47f59f559eeb11f37 to your computer and use it in GitHub Desktop.
esp8266 nodeMCU script for scanning available Wifi APs
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