From 38e591d06123bac44912b1a9872cc7a4e04832d1 Mon Sep 17 00:00:00 2001 From: ollo Date: Fri, 30 Dec 2016 14:23:34 +0100 Subject: [PATCH] Clear memory when safing configuration --- webpage.lua | 89 --------------------------------------------------- webserver.lua | 1 + 2 files changed, 1 insertion(+), 89 deletions(-) delete mode 100644 webpage.lua diff --git a/webpage.lua b/webpage.lua deleted file mode 100644 index cf0fcba..0000000 --- a/webpage.lua +++ /dev/null @@ -1,89 +0,0 @@ -------------- ---- The webpage for the Webserver -function sendWebPage(conn,answertype) - - if (ssid == nil) then - ssid="Not set" - end - if (sntpserverhostname == nil) then - sntpserverhostname="ptbtime1.ptb.de" - end - if (timezoneoffset == nil) then - timezoneoffset=1 - end - -- Set the default color, if nothing is set - if (color == nil) then - color=string.char(0,0,250) - end - if (color1 == nil) then - color1=color - end - if (color2 == nil) then - color2=color - end - if (color3 == nil) then - color3=color - end - if (color4 == nil) then - color4=color - end - local hexColor = "#" .. string.format("%02x",string.byte(color,1)) .. string.format("%02x",string.byte(color,2)) .. string.format("%02x",string.byte(color,3)) - local hexColor1 = "#" .. string.format("%02x",string.byte(color1,1)) .. string.format("%02x",string.byte(color1,2)) .. string.format("%02x",string.byte(color1,3)) - local hexColor2 = "#" .. string.format("%02x",string.byte(color2,1)) .. string.format("%02x",string.byte(color2,2)) .. string.format("%02x",string.byte(color2,3)) - local hexColor3 = "#" .. string.format("%02x",string.byte(color3,1)) .. string.format("%02x",string.byte(color3,2)) .. string.format("%02x",string.byte(color3,3)) - local hexColor4 = "#" .. string.format("%02x",string.byte(color4,1)) .. string.format("%02x",string.byte(color4,2)) .. string.format("%02x",string.byte(color4,3)) - - - - - local buf="HTTP/1.1 200 OK\nServer: NodeMCU\nContent-Type: text/html\n\n" - if (node.heap() < 8000) then - buf = buf .. "

Busy, please come later again

" - endOfPage=true - else - - -- hack for the second part of the page - buf=nil - if (answertype==10) then - buf = "1. Minute Color" - buf = buf .."2. Minute Color" - buf = buf .."3. Minute Color" - buf = buf .."4. Minute Color" - buf = buf .."Three quaterDreiviertel Joa/nei" - --buf = buf .."ColorModeIf checked, words are dark, rest is colored" - buf = buf .. "
" - buf = buf .. "
" - buf = buf .."" - conn:send(buf) - buf=nil - collectgarbage() - -- Code will only be added once the page is loaded - endOfPage=true - return - end - - buf = buf .. "" - buf = buf .. "WordClock Setup Page" - buf = buf .. "\n" - buf = buf .. "

Welcome to the WordClock

" - buf = buf .."
" - buf = buf .."" - buf = buf .."" - buf = buf .."" - buf = buf .."" - buf = buf .."" - buf = buf .."" - - if answertype==2 then - buf = buf .. "

New configuration saved" - elseif answertype==3 then - buf = buf .. "

ERROR" - elseif answertype==4 then - buf = buf .. "

Not all parameters set" - end - buf = buf .. "\n" - end - conn:send(buf) - buf=nil - collectgarbage() -end diff --git a/webserver.lua b/webserver.lua index 8dd6526..15c80e0 100644 --- a/webserver.lua +++ b/webserver.lua @@ -203,6 +203,7 @@ function startWebServer() file.write("threequater=nil\n") -- unset threequater end file.close() + collectgarbage() sec=nil file.remove(configFile) print("Rename config")

WIFI-SSID
WIFI-Password
SNTP Serverntp server to sync the time
Offset to UTC timeDefine the offset to UTC time in hours. E.g +1
Color