Merge pull request #910 from devsaurus/dev-gcfix

Remove superfluous collectgarbage() in webap example
This commit is contained in:
Terry Ellison 2016-01-07 22:50:45 +00:00
commit 94402443f2
1 changed files with 20 additions and 21 deletions

View File

@ -1,13 +1,13 @@
wifi.setmode(wifi.SOFTAP); wifi.setmode(wifi.SOFTAP)
wifi.ap.config({ssid="test",pwd="12345678"}); wifi.ap.config({ssid="test",pwd="12345678"})
gpio.mode(1, gpio.OUTPUT) gpio.mode(1, gpio.OUTPUT)
srv=net.createServer(net.TCP) srv=net.createServer(net.TCP)
srv:listen(80,function(conn) srv:listen(80,function(conn)
conn:on("receive", function(client,request) conn:on("receive", function(client,request)
local buf = ""; local buf = ""
local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP"); local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP")
if(method == nil)then if(method == nil)then
_, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP"); _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP")
end end
local _GET = {} local _GET = {}
if (vars ~= nil)then if (vars ~= nil)then
@ -15,18 +15,17 @@ srv:listen(80,function(conn)
_GET[k] = v _GET[k] = v
end end
end end
buf = buf.."<h1> Hello, NodeMcu.</h1><form src=\"/\">Turn PIN1 <select name=\"pin\" onchange=\"form.submit()\">"; buf = buf.."<h1> Hello, NodeMcu.</h1><form src=\"/\">Turn PIN1 <select name=\"pin\" onchange=\"form.submit()\">"
local _on,_off = "","" local _on,_off = "",""
if(_GET.pin == "ON")then if(_GET.pin == "ON")then
_on = " selected=true"; _on = " selected=true"
gpio.write(1, gpio.HIGH); gpio.write(1, gpio.HIGH)
elseif(_GET.pin == "OFF")then elseif(_GET.pin == "OFF")then
_off = " selected=\"true\""; _off = " selected=\"true\""
gpio.write(1, gpio.LOW); gpio.write(1, gpio.LOW)
end end
buf = buf.."<option".._on..">ON</opton><option".._off..">OFF</option></select></form>"; buf = buf.."<option".._on..">ON</opton><option".._off..">OFF</option></select></form>"
client:send(buf); client:send(buf)
client:close();
collectgarbage();
end) end)
conn:on("sent", function (c) c:close() end)
end) end)