Ajouté la possibilité de demander le setup wifi en appuyant sur le btn entre 5s et 10s après le reset

This commit is contained in:
Christian Zufferey
2020-05-30 12:22:16 +02:00
parent 34a72130f0
commit 8c6860a2c0
5 changed files with 25 additions and 11 deletions

View File

@@ -27,7 +27,7 @@ telnet -rN localhost 23000
]]
print("\n 0_tst3_socat.lua zf200525.1528 \n")
print("\n 0_tst3_socat.lua zf200530.1132 \n")
local node, table, tmr, uwrite, tostring =
node, table, tmr, uart.write, tostring
@@ -154,7 +154,7 @@ end
tmr_socat1=tmr.create()
tmr_socat1:alarm(15*1000, tmr.ALARM_AUTO , function()
rt_retry=1
if verbose then gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) end
-- if verbose then gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) end
if srv_rt~=nil then
if console_port == srv_rt:getpeer() then

View File

@@ -1,5 +1,5 @@
# Quelques commandes remote (luatool) à envoyer avec le plugin Atom-IDE-terminal de l'éditeur Atom
# zf200527.1844
# zf200527.1853
Todo à faire pour ce projet !
@@ -80,16 +80,18 @@ ssh ubuntu@www.zuzu-test.ml killall -9 socat
killall -9 ssh
ssh ubuntu@www.zuzu-test.ml socat TCP-LISTEN:23043,reuseaddr,fork TCP-LISTEN:23000,reuseaddr,bind=127.0.0.1 &
watch -n 1 'ssh ubuntu@www.zuzu-test.ml netstat -nat |grep 230'
CTRL+C
ALT+CMD+F CTRL+C ALT+CMD+F
ssh -N -L 23000:localhost:23000 ubuntu@www.zuzu-test.ml &
export zIP="localhost"
export zport="23000"
telnet -rN $zIP $zport
verbose=false
for k,v in pairs(_G) do print(k,v) end
verbose=true
~.
zdyn
#zdyn
./luatool.py --ip $zIP:$zport -f boot.lua
./luatool.py --ip $zIP:$zport -f z_index.html

View File

@@ -1,11 +1,11 @@
-- Scripts à charger après le boot pour démarrer son projet
print("\n boot.lua zf200525.1809 \n")
print("\n boot.lua zf200530.1211 \n")
-- function ztime_stamp() return tmr.now()/1000000 end
function boot()
verbose = true
verbose = false
print("On lance le boot...")
print(node.heap()) collectgarbage() print(node.heap())
@@ -22,8 +22,8 @@ function boot()
f="0_cron.lua" if file.exists(f) then dofile(f) end
print("verbose:",verbose)
print("boot lancé...")
print("verbose:",verbose) print("boot lancé...")
gpio.write(zLED, gpio.HIGH)
f=nil boot=nil
print(node.heap()) collectgarbage() print(node.heap())
end

View File

@@ -3,7 +3,7 @@
-- le script repair.lua pendant xx secondes avant de continuer
--Source: https://nodemcu.readthedocs.io/en/master/en/modules/node/#nodebootreason
print("\n init.lua zf200118.1507 \n")
print("\n init.lua zf200530.1207 \n")
function initz()
@@ -18,6 +18,17 @@ function initz()
function hvbouton()
gpio.trig(zswitch, "none") zswitch=nil
print("hvbouton...")
print(tmr.now())
if tmr.now() > 5000000 then
file.putcontents("_setup_wifi_", "toto")
print("on demande le setup wifi !")
end
initalarme1:unregister() initalarme1=nil second_chance=nil
gpio.write(zLED, gpio.HIGH) zLED=nil
reset_reason="hvbouton"

View File

@@ -1,7 +1,7 @@
-- Petit script pour initaliser la couche WIFI
function wifi_init()
print("\n wifi_init.lua zf200525.1801 \n")
print("\n wifi_init.lua zf200530.1142 \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
@@ -19,6 +19,7 @@ function wifi_init()
zdelay=1 if reset_reason=="seconde_chance" then zdelay=20 end
tmr_wifi_init3=tmr.create()
tmr_wifi_init3:alarm(zdelay*1000, tmr.ALARM_SINGLE, function()
gpio.write(zLED, gpio.LOW)
f= "boot.lua" if file.exists(f) then dofile(f) end
tmr_wifi_init3:unregister() tmr_wifi_init3=nil wifi_init_end=nil
reset_reason=nil zdelay=nil