A place users can post their projects. If you have a small project and would like your own dedicated place to post and have others chat about it then this is your spot.

User avatar
By ziadbak
#12352 Hi there. I m new to using esp module. I would like to run it as an AP and connect it to my laptop (Which I managed to do). but I would like to send some bytes to it from my laptop. These bytes will be read serially by a microcontroller connected to esp.
can someone plz. Tell me the sequence of AT command?
Tx
User avatar
By hakha4
#14280 Hi
I wan't to do the same as you. Googling for days without finding any straght answers. Is it possible to connect a server on port x and at the same time listen to port y ?? Did you manage to get this to work? If so please share
Hucke
User avatar
By jesusangel
#15012
hakha4 wrote:Hi
I wan't to do the same as you. Googling for days without finding any straght answers. Is it possible to connect a server on port x and at the same time listen to port y ?? Did you manage to get this to work? If so please share
Hucke


With nodemcu firmware you just can set one server, but you can listen to one port and talk to another with a client.

Server:

Code: Select alllocal SERVER = "192.168.1.25"
local PORT = "2222"
local socket = nil

function senddata()
    socket = net.createConnection(net.TCP,0)
    socket:on("connection",connected)
    socket:connect(PORT,SERVER)
end
function connected()
    local MY_IP_ADDRESS = wifi.sta.getip()
    socket:send("MY IP IS "..MY_IP_ADDRESS.."\r\n")
end

srv=net.createServer(net.TCP)
srv:listen(1111,function(conn)
    conn:on("receive", function(client,request)
     
        if(request == "Connect")then
          senddata()
        end
       
    end)
end)



Image

Regards