I'm messing around with the ESP - 01, trying to achieve a serial -> TCP/IP -> serial communication.
So far i'm happy with the results. I can successfully transmit and receive short messages (<255). I believe that is a limitation from the uart.on function, as is described on the API.
Saying that i need to send a larger message, how would I be able to overcome this? Should it be done outside the ESP, like splitting the message in several 255 bytes chunks?
Here is my code so far:
Client side:
wifi.setmode(wifi.STATION)
wifi.sta.config("ESP","123456789")
uart.setup(0,115200,8,0,1,1)
function send(data)
sk = net.createConnection(net.TCP, 0)
sk:connect(80, "192.168.4.1")
sk:send(data)
sk:on("sent", function() sk:close() end)
end
uart.on("data", 0,
function(data)
send(data)
end, 0)
Server side:
wifi.setmode(wifi.STATIONAP)
cfg={}
cfg.ssid="ESP"
cfg.pwd="123456789"
wifi.ap.config(cfg)
uart.setup(0,115200,8,0,1,1)
server = net.createServer(net.TCP)
server:listen(80, function(conn)
conn:on("receive", function(conn, receivedData)
uart.write(0, receivedData ..'\r'..'\n')
end)
end)