-
Notifications
You must be signed in to change notification settings - Fork 3.1k
/
Copy pathinit.lua
34 lines (32 loc) · 889 Bytes
/
init.lua
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
-- init.lua example, with wifi portal
--
-- Waits 10 sec to allow stopping the boot process, and get wifi activated
-- When wifi not activated, setup a portal to select a network
-- In all cases, wifi ends up activated and the main task main.lua is executed
--
-- module needed: enduser_setup
print("Waiting 10sec... use t:stop() to cancel init.lua")
t=tmr.create()
t:alarm(10000,tmr.ALARM_SINGLE,function ()
t=nil -- free the timer
if wifi.sta.getip() then
print("Wifi activated",wifi.sta.getip())
dofile("main.lua")
else
print("No Wifi. Starting portal...")
enduser_setup.start(
"SuperBidule",
function()
wifi.sta.autoconnect(1)
print("Wifi activated",wifi.sta.getip())
dofile("main.lua")
end,
function(err, str)
print("enduser_setup: Err #" .. err .. ": " .. str)
end,
function(str)
print("Debug " .. str)
end
)
end
end)