@@ -55,7 +55,7 @@ local function telnet_listener(socket)
55
55
-- debug("entering sendLine")
56
56
if not s then return end
57
57
58
- if fifo2l + fifo1l == 0 then -- both FIFOs empty, so clear down s
58
+ if fifo2l + fifo1l == 0 then -- both FIFOs empty, so clear down s
59
59
s = nil
60
60
-- debug("Q cleared")
61
61
return
@@ -67,7 +67,7 @@ local function telnet_listener(socket)
67
67
insert (fifo2 ,concat (fifo1 ))
68
68
-- debug("flushing %u bytes / %u recs of FIFO1 into FIFO2[%u]", fifo1l, #fifo1, #fifo2)
69
69
fifo2l , fifo1 , fifo1l = fifo2l + fifo1l , {}, 0
70
- end
70
+ end
71
71
72
72
-- send out first 4 FIFO2 recs (or all if #fifo2<5)
73
73
local rec = remove (fifo2 ,1 ) .. (remove (fifo2 ,1 ) or ' ' ) ..
@@ -134,6 +134,7 @@ local function telnet_listener(socket)
134
134
socket :on (" disconnection" , disconnect )
135
135
socket :on (" sent" , sendLine )
136
136
node .output (queueLine , 0 )
137
+ print ((" Welcome to NodeMCU world (%d mem free, %s)" ):format (node .heap (), wifi .sta .getip ()))
137
138
end
138
139
139
140
local listenerSocket
@@ -143,11 +144,12 @@ return {
143
144
wifi .setmode (wifi .STATION , false )
144
145
wifi .sta .config { ssid = ssid , pwd = pwd , save = false }
145
146
end
146
- tmr .alarm (0 , 500 , tmr .ALARM_AUTO , function ()
147
+ local t = tmr .create ()
148
+ t :alarm (500 , tmr .ALARM_AUTO , function ()
147
149
if (wifi .sta .status () == wifi .STA_GOTIP ) then
148
- tmr . unregister (0 )
149
- print ( " Welcome to NodeMCU world " , node . heap (), wifi . sta . getip ())
150
- net .createServer (net .TCP , 180 ):listen (port or 2323 , telnet_listener )
150
+ t : unregister ()
151
+ t = nil
152
+ net .createServer (net .TCP , 180 ):listen (port or 23 , telnet_listener )
151
153
else
152
154
uwrite (0 ," ." )
153
155
end
0 commit comments