From fd43d0c64f34d76af403bd69d0658b85ac9aaa1d Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Mon, 3 Feb 2020 18:44:44 +0100 Subject: [PATCH] =?UTF-8?q?Commenc=C3=A9=20mes=20tests=20de=20telnet=20rev?= =?UTF-8?q?erse,=20cela=20commence=20=C3=A0=20super=20bien=20avancer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Blink_Led/blink_led2.lua | 4 +- Mesures/ADC/ADS1115/0_tst1_socat.lua | 23 +++++++++++ Mesures/ADC/ADS1115/0_tst2_socat.lua | 59 ++++++++++++++++++++++++++++ Mesures/ADC/ADS1115/boot.lua | 10 ++--- Mesures/ADC/ADS1115/wifi_init.lua | 4 +- 5 files changed, 91 insertions(+), 9 deletions(-) create mode 100644 Mesures/ADC/ADS1115/0_tst1_socat.lua create mode 100644 Mesures/ADC/ADS1115/0_tst2_socat.lua diff --git a/Blink_Led/blink_led2.lua b/Blink_Led/blink_led2.lua index 70fa251..228a7c0 100644 --- a/Blink_Led/blink_led2.lua +++ b/Blink_Led/blink_led2.lua @@ -1,13 +1,13 @@ -- programme pour faire clignoter une LED version simplifiée -print("\n blink_led2.lua zf181015.1138 \n") +print("\n blink_led2.lua zf200203.1823 \n") zLED=0 gpio.mode(zLED, gpio.OUTPUT) ztmr_LED = tmr.create() value = true -tmr.alarm(ztmr_LED, 100, tmr.ALARM_AUTO, function () +ztmr_LED:alarm(100, tmr.ALARM_AUTO, function () if value then gpio.write(zLED, gpio.HIGH) else diff --git a/Mesures/ADC/ADS1115/0_tst1_socat.lua b/Mesures/ADC/ADS1115/0_tst1_socat.lua new file mode 100644 index 0000000..bdffb8a --- /dev/null +++ b/Mesures/ADC/ADS1115/0_tst1_socat.lua @@ -0,0 +1,23 @@ +-- a simple telnet server +print("\n 0_tst_socat.lua zf200203.1701 \n") + + +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/0_tst2_socat.lua b/Mesures/ADC/ADS1115/0_tst2_socat.lua new file mode 100644 index 0000000..52a1e9d --- /dev/null +++ b/Mesures/ADC/ADS1115/0_tst2_socat.lua @@ -0,0 +1,59 @@ +-- tests connection reverse telnet +-- commande à faire tourner sur le serveur +-- socat TCP-LISTEN:4444,fork,reuseaddr STDIO + +print("\n 0_tst2_socat.lua zf200203.1734 \n") + + +srv = net.createConnection(net.TCP, 0) + +srv:connect(4444,"192.168.0.184") + +srv:on("connection", function(sck) + + function s_output(str) + if(sck~=nil) + then sck:send(str) + end + end + node.output(s_output, 0) + -- re-direct output to function s_ouput. + sck:on("receive",function(c,l) + node.input(l) + --like pcall(loadstring(l)), support multiple separate lines + end) + sck:on("disconnection",function(c) + node.output(nil) + --unregist redirect output function, output goes to serial + end) + print("Welcome to NodeMcu world.") + + + +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/boot.lua b/Mesures/ADC/ADS1115/boot.lua index 6b881d8..f59aa59 100644 --- a/Mesures/ADC/ADS1115/boot.lua +++ b/Mesures/ADC/ADS1115/boot.lua @@ -1,16 +1,16 @@ -- Scripts à charger après le boot pour démarrer son projet -print("\n boot.lua zf20019.1438 \n") +print("\n boot.lua zf200203.1423 \n") function boot() verbose = true print("booooooooooot...") print(node.heap()) collectgarbage() print(node.heap()) - f="0_htu21d.lua" if file.exists(f) then dofile(f) end - zurl=thingspeak_url.."field1="..tostring(ztemp1).."&field2="..tostring(zhum1) - f="0_send_data.lua" if file.exists(f) then dofile(f) end - f="0_cron.lua" if file.exists(f) then dofile(f) end + --f="0_htu21d.lua" if file.exists(f) then dofile(f) end + --zurl=thingspeak_url.."field1="..tostring(ztemp1).."&field2="..tostring(zhum1) + --f="0_send_data.lua" if file.exists(f) then dofile(f) end + --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 = "web_ide2.lua" if file.exists(f) then dofile(f) end diff --git a/Mesures/ADC/ADS1115/wifi_init.lua b/Mesures/ADC/ADS1115/wifi_init.lua index ffffb05..48612b1 100644 --- a/Mesures/ADC/ADS1115/wifi_init.lua +++ b/Mesures/ADC/ADS1115/wifi_init.lua @@ -1,7 +1,7 @@ -- Petit script pour initaliser la couche WIFI function wifi_init() - print("\n wifi_init.lua zf200111.1219 \n") + print("\n wifi_init.lua zf200203.1414 \n") function wifi_init_end() wifi_init1:unregister() i=nil @@ -9,7 +9,7 @@ function wifi_init() f=nil secrets_wifi=nil cli_pwd=nil cli_ssid=nil wifi_init1=nil wifi_init=nil print(node.heap()) collectgarbage() print(node.heap()) - f= "telnet_srv2.lua" if file.exists(f) then dofile(f) end +-- f= "telnet_srv2.lua" if file.exists(f) then dofile(f) end f= "web_srv2.lua" if file.exists(f) then dofile(f) end print(node.heap()) collectgarbage() print(node.heap()) zdelay=1 if reset_reason=="seconde_chance" then zdelay=20 end