From 82f7407f69a1812c9091625f1d1772b2a27cd698 Mon Sep 17 00:00:00 2001 From: funshine Date: Thu, 8 Jan 2015 17:06:50 +0800 Subject: [PATCH] add example webap_toggle_pin.lua from #53. fix #53 --- lua_examples/webap_toggle_pin.lua | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 lua_examples/webap_toggle_pin.lua diff --git a/lua_examples/webap_toggle_pin.lua b/lua_examples/webap_toggle_pin.lua new file mode 100644 index 00000000..37896263 --- /dev/null +++ b/lua_examples/webap_toggle_pin.lua @@ -0,0 +1,32 @@ +wifi.setmode(wifi.SOFTAP); +wifi.ap.config({ssid="test",pwd="12345678"}); +gpio.mode(1, gpio.OUTPUT) +srv=net.createServer(net.TCP) +srv:listen(80,function(conn) + conn:on("receive", function(client,request) + local buf = ""; + local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP"); + if(method == nil)then + _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP"); + end + local _GET = {} + if (vars ~= nil)then + for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do + _GET[k] = v + end + end + buf = buf.."

Hello, NodeMcu.

Turn PIN1
"; + client:send(buf); + client:close(); + collectgarbage(); + end) +end)