Move the complete logic of the http server into webserver.lua
This commit is contained in:
parent
716b31303f
commit
fbbecd0b6d
8
init.lua
8
init.lua
@ -45,6 +45,10 @@ function mydofile(mod)
|
|||||||
dofile( mod .. ".lua")
|
dofile( mod .. ".lua")
|
||||||
elseif (file.open(mod .. ".lc")) then
|
elseif (file.open(mod .. ".lc")) then
|
||||||
dofile(mod .. ".lc")
|
dofile(mod .. ".lc")
|
||||||
|
elseif (file.open(mod .. "_diet.lc")) then
|
||||||
|
dofile(mod .. "_diet.lc")
|
||||||
|
elseif (file.open(mod .. "_diet.lua")) then
|
||||||
|
dofile(mod .. "_diet.lua")
|
||||||
elseif (file.open(mod)) then
|
elseif (file.open(mod)) then
|
||||||
dofile(mod)
|
dofile(mod)
|
||||||
else
|
else
|
||||||
@ -62,7 +66,7 @@ initTimer:register(5000, tmr.ALARM_SINGLE, function (t)
|
|||||||
(file.open("timecore.lua")) or
|
(file.open("timecore.lua")) or
|
||||||
(file.open("wordclock.lua")) or
|
(file.open("wordclock.lua")) or
|
||||||
(file.open("displayword.lua")) or
|
(file.open("displayword.lua")) or
|
||||||
(file.open("websrv_diet.lua")) or
|
(file.open("webserver.lua")) or
|
||||||
(file.open("mqtt.lua")) or
|
(file.open("mqtt.lua")) or
|
||||||
(file.open("ds18b20.lua")) or
|
(file.open("ds18b20.lua")) or
|
||||||
(file.open("telnet.lua"))
|
(file.open("telnet.lua"))
|
||||||
@ -83,7 +87,7 @@ initTimer:register(5000, tmr.ALARM_SINGLE, function (t)
|
|||||||
dofile("config.lua")
|
dofile("config.lua")
|
||||||
normalOperation()
|
normalOperation()
|
||||||
else
|
else
|
||||||
mydofile("websrv_diet")
|
mydofile("webserver")
|
||||||
-- Logic for inital setup
|
-- Logic for inital setup
|
||||||
startSetupMode()
|
startSetupMode()
|
||||||
end
|
end
|
||||||
|
@ -26,7 +26,7 @@ if [ $# -eq 0 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $# -eq 1 ]; then
|
if [ $# -eq 1 ]; then
|
||||||
FILES="displayword.lua main.lua timecore.lua webpage.html websrv_diet.lua telnet.lua wordclock.lua init.lua"
|
FILES="displayword.lua main.lua timecore.lua webpage.html webserver_diet.lua telnet.lua wordclock.lua init.lua"
|
||||||
else
|
else
|
||||||
FILES=$2
|
FILES=$2
|
||||||
fi
|
fi
|
||||||
|
@ -292,26 +292,24 @@ function startWebServer()
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function startSetupMode()
|
-- start the webserver module
|
||||||
-- start the webserver module
|
collectgarbage()
|
||||||
collectgarbage()
|
wifi.setmode(wifi.SOFTAP)
|
||||||
wifi.setmode(wifi.SOFTAP)
|
cfg={}
|
||||||
cfg={}
|
cfg.ssid="wordclock"
|
||||||
cfg.ssid="wordclock"
|
cfg.pwd="wordclock"
|
||||||
cfg.pwd="wordclock"
|
wifi.ap.config(cfg)
|
||||||
wifi.ap.config(cfg)
|
|
||||||
|
|
||||||
-- Write the buffer to the LEDs
|
-- Write the buffer to the LEDs
|
||||||
local color=string.char(0,128,0)
|
local color=string.char(0,128,0)
|
||||||
local white=string.char(0,0,0)
|
local white=string.char(0,0,0)
|
||||||
local ledBuf= white:rep(6) .. color .. white:rep(7) .. color:rep(3) .. white:rep(44) .. color:rep(3) .. white:rep(50)
|
local ledBuf= white:rep(6) .. color .. white:rep(7) .. color:rep(3) .. white:rep(44) .. color:rep(3) .. white:rep(50)
|
||||||
ws2812.write(ledBuf)
|
ws2812.write(ledBuf)
|
||||||
color=nil
|
color=nil
|
||||||
white=nil
|
white=nil
|
||||||
ledBuf=nil
|
ledBuf=nil
|
||||||
|
|
||||||
print("Waiting in access point >wordclock< for Clients")
|
print("Waiting in access point >wordclock< for Clients")
|
||||||
print("Please visit 192.168.4.1")
|
print("Please visit 192.168.4.1")
|
||||||
startWebServer()
|
startWebServer()
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
end
|
|
Loading…
Reference in New Issue
Block a user