From fbbecd0b6dcb552efcbd9d4958c53233ca2bd626 Mon Sep 17 00:00:00 2001 From: Ollo Date: Sun, 7 Feb 2021 17:51:57 +0100 Subject: [PATCH] Move the complete logic of the http server into webserver.lua --- init.lua | 8 ++++++-- tools/initialFlash.sh | 2 +- webserver.lua | 42 ++++++++++++++++++++---------------------- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/init.lua b/init.lua index 3ea263e..69e5349 100644 --- a/init.lua +++ b/init.lua @@ -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 diff --git a/tools/initialFlash.sh b/tools/initialFlash.sh index ce22f43..a4f58df 100755 --- a/tools/initialFlash.sh +++ b/tools/initialFlash.sh @@ -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 diff --git a/webserver.lua b/webserver.lua index f8b6f2f..77b87fd 100644 --- a/webserver.lua +++ b/webserver.lua @@ -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 - - print("Waiting in access point >wordclock< for Clients") - print("Please visit 192.168.4.1") - startWebServer() - collectgarbage() -end \ No newline at end of file +-- 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() \ No newline at end of file