From 53d5028a727ece0c0cbf06d778d802bf9aab29fd Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Sun, 9 Feb 2020 16:37:35 +0100 Subject: [PATCH] =?UTF-8?q?Ca=20commence=20=C3=A0=20marcher=20en=20reconne?= =?UTF-8?q?xion=20automatique,=20mais=20maintenant=20c'est=20mon=20'serveu?= =?UTF-8?q?r'=20telnet=20local=20qui=20est=20trop=20simpliste=20:-(?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Mesures/ADC/ADS1115/0_tst2_socat.lua | 46 +++++++++++++--------------- Mesures/ADC/ADS1115/goodies/cat.lua | 8 ++++- 2 files changed, 28 insertions(+), 26 deletions(-) diff --git a/Mesures/ADC/ADS1115/0_tst2_socat.lua b/Mesures/ADC/ADS1115/0_tst2_socat.lua index 86408db..8a06f66 100644 --- a/Mesures/ADC/ADS1115/0_tst2_socat.lua +++ b/Mesures/ADC/ADS1115/0_tst2_socat.lua @@ -5,10 +5,10 @@ socat TCP-LISTEN:23002,fork,reuseaddr STDIO 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:connect(console_port,console_host) + srv_rt:on("connection", function(sck) print("c'est connected...") @@ -30,7 +30,20 @@ srv_rt:on("connection", function(sck) --unregist redirect output function, output goes to serial end) 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) @@ -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) else gpio.write(zLED, gpio.HIGH) 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) ]] diff --git a/Mesures/ADC/ADS1115/goodies/cat.lua b/Mesures/ADC/ADS1115/goodies/cat.lua index 8a2e29c..469899f 100644 --- a/Mesures/ADC/ADS1115/goodies/cat.lua +++ b/Mesures/ADC/ADS1115/goodies/cat.lua @@ -1,5 +1,5 @@ -- 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() local zline = "" @@ -15,7 +15,13 @@ function cat(zfile) zf = file.open(zfile, "r") while true do zline = zread_line() if zline == nil then break end + + tmr.delay(100*1000) + print(zline) + + + end zf:close() print("-------------------------------")