As the title says... Chat on...

User avatar
By bilbolodz
#87404 I'd to build TCP to serial bridge. ESP8266 is working as "server" connected to serial of other devices.
Not a big deal using:
Code: Select allsrv=net.createServer(net.TCP, 28800)
srv:listen(port,function(conn)
        uart.on("data", 0, function(data)
            conn:send(data)
        end, 0)
       
        conn:on("receive",function(conn,payload)
            uart.write(0, payload)
        end)
       
        conn:on("disconnection",function(c)
            uart.on("data")
        end)
    end)


But I need to "do something" (reset other device) on every NEW connection to TCP (after reset device presents it's firmware revision etc). I've tried to use:
Code: Select allconn:on("connection",function(c)
            do_reset()

but looks that it's NOT working (never enters into "do_reset()" function).
I can add "reset_needed flag" and do something on "receive" callback but it's called when something will arrive on TCP so it's NOT a solution. Any ideas how to do it?