note* if the payload is nothing then the current script just sends the current state of vars sw5 & sw6 which is exactly what I want, but at the moment the delay still slows up the callback.
Any help would be appreciated, thanks
pin=0
value=0
sw5,sw6=0,0
srv=net.createServer(net.TCP)
srv:listen(8080,function(conn)
conn:on("receive",function(conn,pl)
--add gpio's pin numbers like {3,4,5} to switch more pins
for v,i in pairs{5,6} do
gpio.mode(i,gpio.OUTPUT)
--Use Markus Gritsch trick to speed up read/write on GPIO
gpio_write = gpio.write
if string.find(pl,"gpio"..i.."=0") then gpio_write(i,1) pin=i value=0 end
if string.find(pl,"gpio"..i.."=1") then gpio_write(i,1) pin=i value=1 end
if pin==5 then sw5=value end
if pin==6 then sw6=value end
-- pulse delay
tmr.delay(3000000)
gpio_write(pin,0)
end
output = (sw5..","..sw6)
print("Send-Responce: ",output)
conn:send(output)
conn:on("sent",function(conn) conn:close() end)
-- x
end)
-- y
end)