I am trying to make a simple controller that can be controlled over net (mobile/browser) .
As per suggestions, I would like to use a simple TCP server. I am pretty much a newb with Lua, so pointers would be appreciated!
Right now, I have managed to get it working from Putty, but after one command, the connection seems to close. The next stage would be to make a simple android button/widget for it.
This is what I have - how can I have some kind of basic access control(user/pass?)
outpin=4
gpio.mode(outpin,gpio.OUTPUT)
srv=net.createServer(net.TCP)
srv:listen(4040,function(conn)
conn:on("receive",function(conn,payload)
print(payload)
if string.find(payload,"ON") then
gpio.write(outpin,gpio.HIGH)
conn:send(gpio.read(outpin))
conn:send("Is it On?\n")
elseif string.find(payload,"OFF") then
gpio.write(outpin,gpio.LOW)
conn:send(gpio.read(outpin))
conn:send("Is it Off?\n")
end
end)
end)
Also, what is the suggested editor for LUa? I am using wordpad now, and it's a bit tedious.
Regards