wifi.setmode(wifi.STATION)
wifi.sta.config("telecentro","bamboklat")
wifi.sta.connect()
tmr.alarm(1, 1000, 1, function()
if wifi.sta.getip()== nil then
print("IP no disponible, esperando...")
else
tmr.stop(1)
print("Config hecha, IP: "..wifi.sta.getip())
end
end)
tmr.alarm(2, 4000, 1, function()
if (wifi.sta.getip() ~= nil) then
sk = net.createConnection(net.TCP, 0)
sk:connect(80,'184.106.153.149') -- server ESP IP
sk:on("connection", function(sk)
sk:send('GET /channels/44665/fields/1/last?key=O2R7O7BYS6M7ES10')
end )
sk:on("receive", function(sk, receivedData)
print("received: " .. receivedData)
sk:close()
end)
else
print("no connection...")
end
end)
I used this secuence to comunicate 2 esp8266 and I could recieve the server answer, any idas of what I am doing wrong?
Thanks in advence!