Commit 27e9e6c0 authored by Lukáš Voborský's avatar Lukáš Voborský Committed by Marcel Stör
Browse files

Fix to telnet Lua example and ftpserver Lua module in consequence of PR #2603 (#2654)

parent 0c7758a5
...@@ -134,6 +134,7 @@ local function telnet_listener(socket) ...@@ -134,6 +134,7 @@ local function telnet_listener(socket)
socket:on("disconnection", disconnect) socket:on("disconnection", disconnect)
socket:on("sent", sendLine) socket:on("sent", sendLine)
node.output(queueLine, 0) node.output(queueLine, 0)
print(("Welcome to NodeMCU world (%d mem free, %s)"):format(node.heap(), wifi.sta.getip()))
end end
local listenerSocket local listenerSocket
...@@ -143,11 +144,13 @@ return { ...@@ -143,11 +144,13 @@ return {
wifi.setmode(wifi.STATION, false) wifi.setmode(wifi.STATION, false)
wifi.sta.config { ssid = ssid, pwd = pwd, save = false } wifi.sta.config { ssid = ssid, pwd = pwd, save = false }
end end
tmr.alarm(0, 500, tmr.ALARM_AUTO, function() local t = tmr.create()
t:alarm(500, tmr.ALARM_AUTO, function()
if (wifi.sta.status() == wifi.STA_GOTIP) then if (wifi.sta.status() == wifi.STA_GOTIP) then
tmr.unregister(0) t:unregister()
print("Welcome to NodeMCU world", node.heap(), wifi.sta.getip()) t=nil
net.createServer(net.TCP, 180):listen(port or 2323, telnet_listener) print(("Telnet server started (%d mem free, %s)"):format(node.heap(), wifi.sta.getip()))
net.createServer(net.TCP, 180):listen(port or 23, telnet_listener)
else else
uwrite(0,".") uwrite(0,".")
end end
......
...@@ -59,9 +59,11 @@ function FTP.open(user, pass, ssid, pwd, dbgFlag) -- upval: FTP (, wifi, tmr, pr ...@@ -59,9 +59,11 @@ function FTP.open(user, pass, ssid, pwd, dbgFlag) -- upval: FTP (, wifi, tmr, pr
wifi.setmode(wifi.STATION, false) wifi.setmode(wifi.STATION, false)
wifi.sta.config { ssid = ssid, pwd = pwd, save = false } wifi.sta.config { ssid = ssid, pwd = pwd, save = false }
end end
tmr.alarm(0, 500, tmr.ALARM_AUTO, function() local t = tmr.create()
t:alarm(500, tmr.ALARM_AUTO, function()
if (wifi.sta.status() == wifi.STA_GOTIP) then if (wifi.sta.status() == wifi.STA_GOTIP) then
tmr.unregister(0) t:unregister()
t=nil
print("Welcome to NodeMCU world", node.heap(), wifi.sta.getip()) print("Welcome to NodeMCU world", node.heap(), wifi.sta.getip())
return FTP.createServer(user, pass, dbgFlag) return FTP.createServer(user, pass, dbgFlag)
else else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment