Move the complete logic of the http server into webserver.lua

This commit is contained in:
Ollo 2021-02-07 17:51:57 +01:00
parent 716b31303f
commit fbbecd0b6d
3 changed files with 27 additions and 25 deletions

View File

@ -45,6 +45,10 @@ function mydofile(mod)
dofile( mod .. ".lua")
elseif (file.open(mod .. ".lc")) then
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
dofile(mod)
else
@ -62,7 +66,7 @@ initTimer:register(5000, tmr.ALARM_SINGLE, function (t)
(file.open("timecore.lua")) or
(file.open("wordclock.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("ds18b20.lua")) or
(file.open("telnet.lua"))
@ -83,7 +87,7 @@ initTimer:register(5000, tmr.ALARM_SINGLE, function (t)
dofile("config.lua")
normalOperation()
else
mydofile("websrv_diet")
mydofile("webserver")
-- Logic for inital setup
startSetupMode()
end

View File

@ -26,7 +26,7 @@ if [ $# -eq 0 ]; then
fi
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
FILES=$2
fi

View File

@ -292,26 +292,24 @@ function startWebServer()
end
function startSetupMode()
-- start the webserver module
collectgarbage()
wifi.setmode(wifi.SOFTAP)
cfg={}
cfg.ssid="wordclock"
cfg.pwd="wordclock"
wifi.ap.config(cfg)
-- start the webserver module
collectgarbage()
wifi.setmode(wifi.SOFTAP)
cfg={}
cfg.ssid="wordclock"
cfg.pwd="wordclock"
wifi.ap.config(cfg)
-- Write the buffer to the LEDs
local color=string.char(0,128,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)
ws2812.write(ledBuf)
color=nil
white=nil
ledBuf=nil
-- Write the buffer to the LEDs
local color=string.char(0,128,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)
ws2812.write(ledBuf)
color=nil
white=nil
ledBuf=nil
print("Waiting in access point >wordclock< for Clients")
print("Please visit 192.168.4.1")
startWebServer()
collectgarbage()
end
print("Waiting in access point >wordclock< for Clients")
print("Please visit 192.168.4.1")
startWebServer()
collectgarbage()