--kaiguan.lua
LED=3
gpio.mode(LED,gpio.OUTPUT)
svr=net.createServer(net.TCP, 30)
function receiver(sck,data)
if (data=="ON")
then
gpio.write(LED,gpio.LOW)
sck:send("LED is ON")
else
gpio.write(LED,gpio.HIGH)
sck:send("LED is OFF")
end
print("Receive: "..data)
-- sck:close()
end
if svr then
svr:listen(80,function(conn)
conn:on("receive",receiver)
conn:send("Hell world,my LED Light")
end)
end
|