-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathenduser.lua
More file actions
57 lines (46 loc) · 1.42 KB
/
enduser.lua
File metadata and controls
57 lines (46 loc) · 1.42 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
--[[ *********************************************************
ENDUSER.lua
Se chegou aqui, é pra configurar wifi e mandar de volta pro arq. que testa.
********************************************************* --]]
print("ENDUSER: Inicando procedimentos para configuração via AP.")
wifi.setmode(wifi.STATIONAP)
_cfg1 = {
ssid = "SetupESP" .. node.chipid(),
auth = wifi.OPEN,
hidden = false,
save = false}
_cfg2 = {
ip = "192.168.4.1",
netmask = "255.255.255.0",
gateway = "192.168.4.1"
}
print("ENDUSER: Procure uma rede com o nome " .. _cfg1.ssid .. " e acesse o IP " .. _cfg2.ip .. ".")
wifi.ap.setip(_cfg2)
wifi.ap.config(_cfg1)
enduser_setup.manual(false)
tmr.create():alarm(5000, tmr.ALARM_SINGLE, function() start_enduser() end)
function setup_ok()
print("ENDUSER: Sucesso. Chamando programa principal em 10 segundos (por segurança).")
--enduser_setup.stop()
tmr.create():alarm(10000, tmr.ALARM_SINGLE, function() dofile("main.lua") end)
end
function setup_error(err, str)
print("ENDUSER: Erro #" .. err .. " - " .. str .. ". Chamando programa de teste de wifi novamente.")
--enduser_setup.stop()
dofile("wifi_ok.lua")
end
function setup_debug(str)
print("ENDUSER: Debug: " .. str .. ".")
end
function start_enduser()
print("ENDUSER: Aguardando configuração do usuário.")
enduser_setup.start(
function()
setup_ok()
end,
function(err, str)
setup_error(err, str)
end,
print
)
end