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

User avatar
By mcfly777
#39111 Hello
In my project I put into the init.lua a small TCP server that listens on port 2323 and posts to the terminal (taken from the nodemcu website example). How can I use this to upload files to the module? Since I have access to the terminal just like a serial monitor, I think this should be possible.

Code: Select all s=net.createServer(net.TCP,180)
s:listen(2323,function(c)
    function s_output(str)
      if(c~=nil)
        then c:send(str)
      end
    end
    node.output(s_output, 0)   
    -- re-direct output to function s_ouput.
    c:on("receive",function(c,l)
      node.input(l)           
      --like pcall(loadstring(l)), support multiple separate lines
    end)
    c:on("disconnection",function(c)
      node.output(nil)       
      --unregist redirect output function, output goes to serial
    end)
    print("Welcome to NodeMCU world.")
end)

thanks
Leo
User avatar
By gsker
#39119 I deleted my response -- it really only works for linux shell environment with zsh which isn't going to help many people. There are better tools out there. If I get a chance I'll dig one up.

Sorry for misleading.
Last edited by gsker on Mon Jan 18, 2016 7:05 pm, edited 2 times in total.
User avatar
By devsaurus
#39168
mcfly777 wrote:In my project I put into the init.lua a small TCP server that listens on port 2323 and posts to the terminal (taken from the nodemcu website example).

Please note that the old telnet server example suffers from buffering issues with newer SDK versions. Consider to upgrade to the latest example: telnet.lua.