From 773e039ad8a7c10aa8e6623d03884b9682c2b6b7 Mon Sep 17 00:00:00 2001 From: Christian Zufferey Date: Sat, 29 Feb 2020 14:40:03 +0100 Subject: [PATCH] =?UTF-8?q?Am=C3=A9lior=C3=A9=20ma=20proc=C3=A9dure=20wifi?= =?UTF-8?q?=5Finit=20afin=20d'=C3=A9viter=20qu'il=20parte=20en=20wifi=20se?= =?UTF-8?q?tup=20si=20il=20n'y=20a=20momentam=C3=A9ment=20plus=20de=20wifi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Mesures/ADC/ADS1115/0_cron.lua | 8 ++++++-- Mesures/ADC/ADS1115/boot.lua | 7 ++++--- Mesures/ADC/ADS1115/wifi_init.lua | 9 ++++++--- rtelnet.sh | 12 ++++++++---- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Mesures/ADC/ADS1115/0_cron.lua b/Mesures/ADC/ADS1115/0_cron.lua index b43d674..39351b2 100644 --- a/Mesures/ADC/ADS1115/0_cron.lua +++ b/Mesures/ADC/ADS1115/0_cron.lua @@ -1,18 +1,22 @@ -- Petit script pour faire office de crontab pour les mesures -print("\n 0_cron.lua zf200119.1436 \n") +print("\n 0_cron.lua zf200228.1727 \n") cron1=tmr.create() cron1:alarm(20*1000, tmr.ALARM_AUTO, function() if verbose then print("cron1........................") end if verbose then gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) end - f = "0_htu21d.lua" if file.exists(f) then dofile(f) end + f = "0_zdyndns.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 ztemp1=nil zhum1=nil +]] if verbose then print(node.heap()) end collectgarbage() diff --git a/Mesures/ADC/ADS1115/boot.lua b/Mesures/ADC/ADS1115/boot.lua index 90334f3..c288fea 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 zf200221.1133 \n") +print("\n boot.lua zf200228.1730 \n") function boot() verbose = true @@ -10,9 +10,10 @@ function boot() --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="0_cron.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 diff --git a/Mesures/ADC/ADS1115/wifi_init.lua b/Mesures/ADC/ADS1115/wifi_init.lua index 5755391..f95c92c 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 zf200216.1348 \n") + print("\n wifi_init.lua zf200229.1438 \n") f= "secrets_wifi.lua" if file.exists(f) then dofile(f) end f= "secrets_project.lua" if file.exists(f) then dofile(f) end @@ -34,6 +34,9 @@ function wifi_init() tmr_wifi_init4:alarm(0.1*1000, tmr.ALARM_AUTO , function() gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) end) + tmr.create():alarm(90*1000, tmr.ALARM_SINGLE, function() + node.restart() + end) enduser_setup.start(function() print("on est sortit du setup wifi et on restart !") node.restart() @@ -56,9 +59,9 @@ function wifi_init() tmr_wifi_init1:alarm(1*1000, tmr.ALARM_AUTO , function() gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) if wifi.sta.getip() == nil then - print("Connecting to AP...") + print(i,"Connecting to AP...") i=i+1 - if i > 15 then + if i > 20 then print("pas de wifi :-(") file.putcontents("_setup_wifi_", "toto") print("on restart pour le setup wifi") diff --git a/rtelnet.sh b/rtelnet.sh index 779855b..162dff0 100755 --- a/rtelnet.sh +++ b/rtelnet.sh @@ -1,6 +1,6 @@ #!/bin/bash # petit script provisoire pour se connecter sur les NodeMCU en reverse telnet -# zf200221.1336 +# zf200228.1857 #test si l'argument est vide @@ -10,6 +10,7 @@ if [ -z "$1" ] ./rtelnet.sh socket ./rtelnet.sh 23047 +./rtelnet.sh 23056 " exit @@ -24,17 +25,20 @@ killall -9 ssh # on établit le serveur reverse telnet +# ssh ubuntu@www.zuzutest.ml socat TCP-LISTEN:$1,reuseaddr,fork TCP-LISTEN:23000,reuseaddr,bind=127.0.0.1 & watch -n 1 'ssh ubuntu@www.zuzutest.ml netstat -nat |grep 230' - +sleep 1 # on crée le tunnel sur la console du NodeMCU ssh -N -L 23000:localhost:23000 ubuntu@www.zuzutest.ml & +sleep 1 -ça ne marche pas bien ici :-( + +#ça ne marche pas bien ici :-( @@ -47,5 +51,5 @@ read -p "Voulez-vous tuer la connexion ?" # on tue le serveur reverse telnet ssh ubuntu@www.zuzutest.ml killall -9 socat -# on tue le tunnel +# on tue le tunnel sur sa machine (ATTENTION, tue tous les ssh !) killall -9 ssh