Ca commence à marcher en reconnexion automatique, mais maintenant c'est mon 'serveur' telnet local qui est trop simpliste :-(
This commit is contained in:
@@ -5,10 +5,10 @@ socat TCP-LISTEN:23002,fork,reuseaddr STDIO
|
|||||||
socat TCP-LISTEN:23002,reuseaddr,fork TCP-LISTEN:24002,reuseaddr
|
socat TCP-LISTEN:23002,reuseaddr,fork TCP-LISTEN:24002,reuseaddr
|
||||||
]]
|
]]
|
||||||
|
|
||||||
print("\n 0_tst2_socat.lua zf200209.1442 \n")
|
print("\n 0_tst2_socat.lua zf200209.1615 \n")
|
||||||
|
|
||||||
srv_rt = net.createConnection(net.TCP, 0)
|
srv_rt = net.createConnection(net.TCP, 0)
|
||||||
srv_rt:connect(console_port,console_host)
|
|
||||||
srv_rt:on("connection", function(sck)
|
srv_rt:on("connection", function(sck)
|
||||||
|
|
||||||
print("c'est connected...")
|
print("c'est connected...")
|
||||||
@@ -30,7 +30,20 @@ srv_rt:on("connection", function(sck)
|
|||||||
--unregist redirect output function, output goes to serial
|
--unregist redirect output function, output goes to serial
|
||||||
end)
|
end)
|
||||||
print("Welcome to NodeMcu world.")
|
print("Welcome to NodeMcu world.")
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
|
tmr_socat1=tmr.create()
|
||||||
|
tmr_socat1:alarm(1*1000, tmr.ALARM_AUTO , function()
|
||||||
|
|
||||||
|
gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH)
|
||||||
|
if console_port == srv_rt:getpeer() then
|
||||||
|
gpio.write(zLED, gpio.LOW)
|
||||||
|
else
|
||||||
|
gpio.write(zLED, gpio.HIGH)
|
||||||
|
print("trying...")
|
||||||
|
srv_rt:connect(console_port,console_host)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end)
|
end)
|
||||||
@@ -38,35 +51,18 @@ end)
|
|||||||
|
|
||||||
--[[
|
--[[
|
||||||
|
|
||||||
print(srv:getpeer())
|
print(srv_rt:getpeer())
|
||||||
|
|
||||||
if console_port == srv:getpeer() then
|
srv_rt:connect(console_port,console_host)
|
||||||
|
|
||||||
|
gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH)
|
||||||
|
if console_port == srv_rt:getpeer() then
|
||||||
gpio.write(zLED, gpio.LOW)
|
gpio.write(zLED, gpio.LOW)
|
||||||
else
|
else
|
||||||
gpio.write(zLED, gpio.HIGH)
|
gpio.write(zLED, gpio.HIGH)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
|
||||||
]]
|
]]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
-- fonction cat() pour afficher le contenu d'un fichier dans la flash
|
-- fonction cat() pour afficher le contenu d'un fichier dans la flash
|
||||||
print("\n cat.lua zf191124.2204 \n")
|
print("\n cat.lua zf200209.1630 \n")
|
||||||
|
|
||||||
function zread_line()
|
function zread_line()
|
||||||
local zline = ""
|
local zline = ""
|
||||||
@@ -15,7 +15,13 @@ function cat(zfile)
|
|||||||
zf = file.open(zfile, "r")
|
zf = file.open(zfile, "r")
|
||||||
while true do
|
while true do
|
||||||
zline = zread_line() if zline == nil then break end
|
zline = zread_line() if zline == nil then break end
|
||||||
|
|
||||||
|
tmr.delay(100*1000)
|
||||||
|
|
||||||
print(zline)
|
print(zline)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
zf:close()
|
zf:close()
|
||||||
print("-------------------------------")
|
print("-------------------------------")
|
||||||
|
|||||||
Reference in New Issue
Block a user