-
Notifications
You must be signed in to change notification settings - Fork 20
/
init.lua
46 lines (39 loc) · 1.07 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
-- Copyright (c) 2015 Sebastian Hodapp
-- https://github.com/sebastianhodapp/ESPbootloader
-- Improved by Simonarde Jr.
-- https://github.com/simonardejr/ESPbootloader
-- Change ssid and password of AP in configuration mode
ssid = "ESP" ..node.chipid()
psw = "espconfig"
-- If GPIO0 changes during the countdown, launch config
gpio.mode(3, gpio.INT)
gpio.trig(3,"both",function()
tmr.stop(0)
dofile("run_config.lua")
end)
local countdown = 5
tmr.alarm(1, 5000, 1, function()
if wifi.sta.getip() == nil then
print("IP unavailable, waiting.")
else
tmr.stop(1)
print("Connected, IP is "..wifi.sta.getip())
dofile("run_program.lua")
end
end)
tmr.alarm(0,1000,1,function()
print(countdown)
countdown = countdown -1
if (countdown == 0) then
gpio.mode(3,gpio.FLOAT)
tmr.stop(0)
if pcall(function ()
dofile("config.lc")
end) then
dofile("run_program.lua")
else
print("Enter configuration mode")
dofile("run_config.lua")
end
end
end)