I have a socket listener running - so that a phone all can send queries to the ESP-01 and I can respond accordingly. It works very well but of course the ESP-01 is very limited in what it can do in terms of I/O.
So what I'd like to do is take in text from the remote APP - and send it out of the serial line - I can do that already... but then I want any input from the serial line to be send straight out to the remote app over TCP/IP, rather than the LUA interpreter interpreting what I send into the serial line.
I'm sure it's simple but I have no idea how to do this.
So - my example...(without worrying about files at this point - just the basic function
sv=net.createServer(net.TCP, 30) -- that 30 seconds timeout doesn't seem to do anything
sv:listen(4000,function(c)
c:on("receive", function(sck, pl)
print(pl)
c:send("My response but how to wait for and grab this from the serial line???")
end)
end)
I tried this demo example from the web but the interpreter does not seem to like it....
io.write("continue with this operation (y/n)?")
answer=io.read()
if answer=="y" then
--(put what you want it to do if you say y here)
elseif answer=="n" then
--(put what you want to happen if you say n)
end
and this - both fail
local answer
repeat
io.write("continue with this operation (y/n)? ")
io.flush()
answer=io.read()
until answer=="y" or answer=="n"