-->
Page 1 of 1

ESP AS AP TO READ AND SEND COMMANDS

PostPosted: Fri Mar 20, 2015 3:52 pm
by ziadbak
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

Re: ESP AS AP TO READ AND SEND COMMANDS

PostPosted: Sun Apr 12, 2015 9:13 am
by hakha4
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

Re: ESP AS AP TO READ AND SEND COMMANDS

PostPosted: Sun Apr 19, 2015 4:34 am
by jesusangel
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

Re: ESP AS AP TO READ AND SEND COMMANDS

PostPosted: Sun Apr 19, 2015 1:59 pm
by hakha4
Thank's alot for reply. I haven't tryed nodemcu yet,using the standard firmware. I'll upgrade firmware and see if I can get things to work
Regards HÃ¥kan