From 57461f4e48bf8a948ebd57dc673a0ed56073580a Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Mon, 17 Feb 2020 04:29:27 +0100 Subject: [PATCH] =?UTF-8?q?Refactoris=C3=A9=20un=20peu=20le=20script=20rev?= =?UTF-8?q?erse=20telnet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Mesures/ADC/ADS1115/0_tst3_socat.lua | 38 ++++++++++++---------------- Mesures/ADC/ADS1115/_zremote_cmd.txt | 3 ++- Mesures/ADC/ADS1115/boot.lua | 4 +-- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/Mesures/ADC/ADS1115/0_tst3_socat.lua b/Mesures/ADC/ADS1115/0_tst3_socat.lua index d247c00..f394e9e 100644 --- a/Mesures/ADC/ADS1115/0_tst3_socat.lua +++ b/Mesures/ADC/ADS1115/0_tst3_socat.lua @@ -10,7 +10,7 @@ socat TCP-LISTEN:23047,reuseaddr,fork TCP-LISTEN:24047,reuseaddr,bind=127.0.0.1 telnet -r localhost 24047 ]] -print("\n 0_tst3_socat.lua zf200216.1653 \n") +print("\n 0_tst3_socat.lua zf200217.0423 \n") local node, table, tmr, wifi, uwrite, tostring = node, table, tmr, wifi, uart.write, tostring @@ -100,22 +100,21 @@ local function telnet_listener(socket) node.output(queueLine, 0) end - --net.createServer(net.TCP, 180):listen(23, telnet_listener) ---print("Telnet server running...\nUsage: telnet -rN ip\n") - - -srv_rt = net.createConnection(net.TCP, 0) -srv_rt:on("connection", function(sck) - print("connected...") - telnet_listener(sck) -end) -srv_rt:connect(console_port,console_host) - - - print("Telnet server running...\nUsage: telnet -rN ip\n") + + +function rt_connect() + srv_rt = net.createConnection(net.TCP, 0) + srv_rt:on("connection", function(sck) + if verbose then print("connected on "..console_host..":"..console_port) end + telnet_listener(sck) + print("Welcome to NodeMCU world.") + end) + srv_rt:connect(console_port,console_host) +end + tmr_socat1=tmr.create() tmr_socat1:alarm(3*1000, tmr.ALARM_AUTO , function() if verbose then gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) end @@ -124,18 +123,13 @@ tmr_socat1:alarm(3*1000, tmr.ALARM_AUTO , function() else if verbose then gpio.write(zLED, gpio.HIGH) - print("trying connect "..console_host..":"..console_port) + print("trying connect to "..console_host..":"..console_port) end - srv_rt = net.createConnection(net.TCP, 0) - srv_rt:on("connection", function(sck) - if verbose then print("connected on "..console_host..":"..console_port) end - telnet_listener(sck) - end) - srv_rt:connect(console_port,console_host) + rt_connect() end end) - +rt_connect() diff --git a/Mesures/ADC/ADS1115/_zremote_cmd.txt b/Mesures/ADC/ADS1115/_zremote_cmd.txt index 0fe200a..4ea42ba 100644 --- a/Mesures/ADC/ADS1115/_zremote_cmd.txt +++ b/Mesures/ADC/ADS1115/_zremote_cmd.txt @@ -1,9 +1,10 @@ # Quelques commandes remote (luatool) à envoyer avec le plugin Atom-IDE-terminal de l'éditeur Atom -# zf200216.1702 +# zf200217.0429 Todo à faire pour ce projet ! +- ajouter la variable yellow_tag avec le numéro de l'étiquette jaune du NodeMCU - regarder pour mettre "Welcome to NodeMCU world." quand connected, en fait quand on arrive dans le telnet_listener après la redirection du port série ! - ajouter l'adresse du zdyndns dans les secrets projets - se connecter sur le zdyndns avec le numéro du port du telnet reverse utilisé diff --git a/Mesures/ADC/ADS1115/boot.lua b/Mesures/ADC/ADS1115/boot.lua index c4864ab..3a68f1b 100644 --- a/Mesures/ADC/ADS1115/boot.lua +++ b/Mesures/ADC/ADS1115/boot.lua @@ -1,6 +1,6 @@ -- Scripts à charger après le boot pour démarrer son projet -print("\n boot.lua zf200216.1757 \n") +print("\n boot.lua zf200217.0423 \n") function boot() verbose = true @@ -13,7 +13,7 @@ function boot() --f="0_cron.lua" if file.exists(f) then dofile(f) end f="0_btn_flipflop.lua" if file.exists(f) then dofile(f) end - --f="0_tst3_socat.lua" if file.exists(f) then dofile(f) end + f="0_tst3_socat.lua" if file.exists(f) then dofile(f) end --f = "web_ide2.lua" if file.exists(f) then dofile(f) end print("verbose:",verbose)