Websever can be started at runtime
This commit is contained in:
parent
db3a1e5e20
commit
ad9beccadc
19
init.lua
19
init.lua
@ -60,6 +60,25 @@ initTimer:register(5000, tmr.ALARM_SINGLE, function (t)
|
|||||||
normalOperation()
|
normalOperation()
|
||||||
else
|
else
|
||||||
-- Logic for inital setup
|
-- 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")
|
mydofile("webserver")
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
5
main.lua
5
main.lua
@ -109,6 +109,7 @@ function normalOperation()
|
|||||||
rgbBuffer:set(55, color) -- P
|
rgbBuffer:set(55, color) -- P
|
||||||
end
|
end
|
||||||
elseif (setupCounter > 3) then
|
elseif (setupCounter > 3) then
|
||||||
|
if (web == nil) then
|
||||||
-- Here the WLAN is found, and something is done
|
-- Here the WLAN is found, and something is done
|
||||||
mydofile("mqtt")
|
mydofile("mqtt")
|
||||||
rgbBuffer:fill(0,0,0) -- disable all LEDs
|
rgbBuffer:fill(0,0,0) -- disable all LEDs
|
||||||
@ -124,6 +125,10 @@ function normalOperation()
|
|||||||
print("NO Mqtt found")
|
print("NO Mqtt found")
|
||||||
mydofile("telnet")
|
mydofile("telnet")
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
-- start the webserver module
|
||||||
|
mydofile("webserver")
|
||||||
|
end
|
||||||
setupCounter=setupCounter-1
|
setupCounter=setupCounter-1
|
||||||
elseif (setupCounter > 2) then
|
elseif (setupCounter > 2) then
|
||||||
if (startTelnetServer ~= nil) then
|
if (startTelnetServer ~= nil) then
|
||||||
|
@ -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))
|
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
|
if (sendPage ~= nil) then
|
||||||
print("Sending webpage.html (" .. tostring(node.heap()) .. "B free) ...")
|
print("Sending webpage.html (" .. tostring(node.heap()) .. "B free) ...")
|
||||||
|
mydofile("config.lua")
|
||||||
-- Load the sendPagewebcontent
|
-- Load the sendPagewebcontent
|
||||||
replaceMap=fillDynamicMap()
|
replaceMap=fillDynamicMap()
|
||||||
sendPage(conn, "webpage.html", replaceMap)
|
sendPage(conn, "webpage.html", replaceMap)
|
||||||
@ -273,25 +274,5 @@ function startWebServer()
|
|||||||
|
|
||||||
end
|
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()
|
startWebServer()
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
|
Loading…
Reference in New Issue
Block a user