Increased webserver delay
This commit is contained in:
parent
f67f53d223
commit
e4c8118731
@ -68,7 +68,6 @@ function sendPage(conn, nameOfFile, replaceMap)
|
|||||||
conn:send(buf)
|
conn:send(buf)
|
||||||
print("Sent rest")
|
print("Sent rest")
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function fillDynamicMap()
|
function fillDynamicMap()
|
||||||
@ -151,38 +150,28 @@ function startWebServer()
|
|||||||
print("HTTP sending... be patient!")
|
print("HTTP sending... be patient!")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
if (payload:find("GET /") ~= nil) then
|
if (payload:find("GET /") ~= nil) then
|
||||||
httpSending=true
|
httpSending=true
|
||||||
--here is code for handling http request from a web-browser
|
|
||||||
collectgarbage()
|
|
||||||
stopWordclock()
|
stopWordclock()
|
||||||
|
|
||||||
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))
|
||||||
-- Start Time after 1 minute
|
-- Start Time after 3 minute
|
||||||
tmr.alarm(5, 60000, 0 ,function()
|
tmr.alarm(5, 180000, 0 ,function()
|
||||||
dependModules = { "timecore" , "wordclock", "displayword" }
|
dependModules = { "timecore" , "wordclock", "displayword" }
|
||||||
for _,mod in pairs(dependModules) do
|
for _,mod in pairs(dependModules) do
|
||||||
print("Loading " .. mod)
|
print("Loading " .. mod)
|
||||||
mydofile(mod)
|
mydofile(mod)
|
||||||
end
|
end
|
||||||
-- Start the time Thread
|
-- Start the time Thread again
|
||||||
displayTime()
|
|
||||||
-- Start the time Thread
|
|
||||||
tmr.alarm(1, 20000, 1 ,function()
|
tmr.alarm(1, 20000, 1 ,function()
|
||||||
displayTime()
|
displayTime()
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
-- send response after 100ms
|
|
||||||
tmr.alarm(4, 100, 0 ,function()
|
|
||||||
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) ...")
|
||||||
-- Load the sendPagewebcontent
|
-- Load the sendPagewebcontent
|
||||||
replaceMap=fillDynamicMap()
|
replaceMap=fillDynamicMap()
|
||||||
sendPage(conn, "webpage.html", replaceMap)
|
sendPage(conn, "webpage.html", replaceMap)
|
||||||
end
|
end
|
||||||
end)
|
|
||||||
else if (payload:find("POST /") ~=nil) then
|
else if (payload:find("POST /") ~=nil) then
|
||||||
--code for handling the POST-request (updating settings)
|
--code for handling the POST-request (updating settings)
|
||||||
_, postdatastart = payload:find("\r\n\r\n")
|
_, postdatastart = payload:find("\r\n\r\n")
|
||||||
@ -327,11 +316,9 @@ function startWebServer()
|
|||||||
global_c=nil
|
global_c=nil
|
||||||
end)
|
end)
|
||||||
print("Welcome to Word Clock")
|
print("Welcome to Word Clock")
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
conn:on("disconnection", function(c)
|
conn:on("disconnection", function(c)
|
||||||
print("Goodbye")
|
print("Goodbye")
|
||||||
node.output(nil) -- un-register the redirect output function, output goes to serial
|
node.output(nil) -- un-register the redirect output function, output goes to serial
|
||||||
|
Loading…
Reference in New Issue
Block a user