Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
27e9e6c0
Commit
27e9e6c0
authored
Feb 13, 2019
by
Lukáš Voborský
Committed by
Marcel Stör
Feb 13, 2019
Browse files
Fix to telnet Lua example and ftpserver Lua module in consequence of PR #2603 (#2654)
parent
0c7758a5
Changes
2
Hide whitespace changes
Inline
Side-by-side
lua_examples/telnet/telnet.lua
View file @
27e9e6c0
...
...
@@ -55,7 +55,7 @@ local function telnet_listener(socket)
-- debug("entering sendLine")
if
not
s
then
return
end
if
fifo2l
+
fifo1l
==
0
then
-- both FIFOs empty, so clear down s
if
fifo2l
+
fifo1l
==
0
then
-- both FIFOs empty, so clear down s
s
=
nil
-- debug("Q cleared")
return
...
...
@@ -67,7 +67,7 @@ local function telnet_listener(socket)
insert
(
fifo2
,
concat
(
fifo1
))
-- debug("flushing %u bytes / %u recs of FIFO1 into FIFO2[%u]", fifo1l, #fifo1, #fifo2)
fifo2l
,
fifo1
,
fifo1l
=
fifo2l
+
fifo1l
,
{},
0
end
end
-- send out first 4 FIFO2 recs (or all if #fifo2<5)
local
rec
=
remove
(
fifo2
,
1
)
..
(
remove
(
fifo2
,
1
)
or
''
)
..
...
...
@@ -134,6 +134,7 @@ local function telnet_listener(socket)
socket
:
on
(
"disconnection"
,
disconnect
)
socket
:
on
(
"sent"
,
sendLine
)
node
.
output
(
queueLine
,
0
)
print
((
"Welcome to NodeMCU world (%d mem free, %s)"
):
format
(
node
.
heap
(),
wifi
.
sta
.
getip
()))
end
local
listenerSocket
...
...
@@ -143,11 +144,13 @@ return {
wifi
.
setmode
(
wifi
.
STATION
,
false
)
wifi
.
sta
.
config
{
ssid
=
ssid
,
pwd
=
pwd
,
save
=
false
}
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
tmr
.
unregister
(
0
)
print
(
"Welcome to NodeMCU world"
,
node
.
heap
(),
wifi
.
sta
.
getip
())
net
.
createServer
(
net
.
TCP
,
180
):
listen
(
port
or
2323
,
telnet_listener
)
t
:
unregister
()
t
=
nil
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
uwrite
(
0
,
"."
)
end
...
...
lua_modules/ftp/ftpserver.lua
View file @
27e9e6c0
...
...
@@ -59,9 +59,11 @@ function FTP.open(user, pass, ssid, pwd, dbgFlag) -- upval: FTP (, wifi, tmr, pr
wifi
.
setmode
(
wifi
.
STATION
,
false
)
wifi
.
sta
.
config
{
ssid
=
ssid
,
pwd
=
pwd
,
save
=
false
}
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
tmr
.
unregister
(
0
)
t
:
unregister
()
t
=
nil
print
(
"Welcome to NodeMCU world"
,
node
.
heap
(),
wifi
.
sta
.
getip
())
return
FTP
.
createServer
(
user
,
pass
,
dbgFlag
)
else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment