diff --git a/init.lua b/init.lua index ea1bd71..183922f 100644 --- a/init.lua +++ b/init.lua @@ -60,6 +60,25 @@ initTimer:register(5000, tmr.ALARM_SINGLE, function (t) normalOperation() else -- Logic for inital setup + 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") + -- start the webserver module mydofile("webserver") end end) diff --git a/main.lua b/main.lua index 5d3da9c..852184e 100644 --- a/main.lua +++ b/main.lua @@ -109,6 +109,7 @@ function normalOperation() rgbBuffer:set(55, color) -- P end elseif (setupCounter > 3) then + if (web == nil) then -- Here the WLAN is found, and something is done mydofile("mqtt") rgbBuffer:fill(0,0,0) -- disable all LEDs @@ -124,6 +125,10 @@ function normalOperation() print("NO Mqtt found") mydofile("telnet") end + else + -- start the webserver module + mydofile("webserver") + end setupCounter=setupCounter-1 elseif (setupCounter > 2) then if (startTelnetServer ~= nil) then diff --git a/webserver.lua b/webserver.lua index a6d0dfc..f92a444 100644 --- a/webserver.lua +++ b/webserver.lua @@ -131,6 +131,7 @@ function startWebServer() ws2812.write(string.char(0,0,0):rep(56) .. color:rep(2) .. string.char(0,0,0):rep(4) .. color:rep(2) .. string.char(0,0,0):rep(48)) if (sendPage ~= nil) then print("Sending webpage.html (" .. tostring(node.heap()) .. "B free) ...") + mydofile("config.lua") -- Load the sendPagewebcontent replaceMap=fillDynamicMap() sendPage(conn, "webpage.html", replaceMap) @@ -273,25 +274,5 @@ function startWebServer() end - --- 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()