-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontrollers.lua
More file actions
35 lines (27 loc) · 882 Bytes
/
controllers.lua
File metadata and controls
35 lines (27 loc) · 882 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
routes['GET /'] = function(socket, params)
local function list_ap(t) -- (BSSID : SSID, RSSI, auth mode, channel)
redes = {}
for bssid, v in pairs(t) do
local ssid, rssi, auth_mode, channel =
string.match(v, '([^,]+),([^,]+),([^,]+),([^,]*)')
table.insert(redes, {bssid=bssid, ssid=ssid, rssi=rssi})
end
table.sort(redes, function(a, b) return a.rssi < b.rssi end)
status_map = {
[0]='disponible',
[1]='conectando...',
[2]='contraseña inválida',
[3]='red no encontrada',
[4]='fallo',
[5]='conectado'
}
status = status_map[wifi.sta.status()]
render(socket, 'index.html')
end
wifi.sta.getap(1, list_ap)
end
routes['POST /'] = function(socket, params)
wifi.sta.config(params)
--print(params['red'], params['contraseña'], wifi.sta.getip())
routes['GET /'](socket, params)
end