Refactorisé la gestion du btn verbose. Le telnet reverse fonctionne bien maintenant \o/
This commit is contained in:
@@ -2,24 +2,25 @@
|
||||
-- Très intéressant la techno utilisée ici pour enlever les rebonds du micro switch
|
||||
-- dans la variable b se trouve l'heure à laquelle l'interruption est arrivée, il suffit juste alors de lui mettre un petit délai de 300mS
|
||||
|
||||
print("\n 0_btn_flipflop.lua zf200119.1527 \n")
|
||||
print("\n 0_btn_flipflop.lua zf200216.1457 \n")
|
||||
|
||||
gpio.write(zLED,1)
|
||||
gpio.mode(zLED,gpio.OUTPUT)
|
||||
gpio.write(zLED,1) gpio.mode(zLED,gpio.OUTPUT)
|
||||
gpio.mode(zBTN,gpio.INT)
|
||||
|
||||
d=tmr.now()
|
||||
|
||||
function zled (a,b,c)
|
||||
if verbose then print("a: "..a..",b: "..b..",c: "..c) end
|
||||
--print("a: "..a..",b: "..b..",c: "..c)
|
||||
if b-d > 300*1000 then
|
||||
if verbose then
|
||||
gpio.write(zLED,1) verbose=false
|
||||
gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH)
|
||||
verbose=false
|
||||
else
|
||||
gpio.write(zLED,0) verbose=true
|
||||
gpio.write(zLED, gpio.LOW) tmr.delay(200000) gpio.write(zLED, gpio.HIGH)
|
||||
verbose=true
|
||||
end
|
||||
if verbose then print(gpio.read(zLED)) end
|
||||
d=b
|
||||
print("verbose:",verbose)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
-- tests connection reverse telnet
|
||||
-- commande à faire tourner sur le serveur
|
||||
--[[
|
||||
tests connection reverse telnet
|
||||
commande à faire tourner sur le serveur
|
||||
|
||||
1ere console
|
||||
socat TCP-LISTEN:23002,fork,reuseaddr STDIO
|
||||
socat TCP-LISTEN:23002,reuseaddr,fork TCP-LISTEN:24002,reuseaddr,bind=127.0.0.1
|
||||
|
||||
2e console
|
||||
telnet -r localhost 24002
|
||||
]]
|
||||
|
||||
print("\n 0_tst3_socat.lua zf200209.1924 \n")
|
||||
|
||||
|
||||
|
||||
|
||||
print("\n 0_tst3_socat.lua zf200216.1521 \n")
|
||||
|
||||
local node, table, tmr, wifi, uwrite, tostring =
|
||||
node, table, tmr, wifi, uart.write, tostring
|
||||
@@ -83,6 +84,8 @@ local function telnet_listener(socket)
|
||||
local function disconnect(s)
|
||||
fifo1, fifo1l, fifo2, fifo2l, s = {}, 0, {}, 0, nil
|
||||
node.output(nil)
|
||||
---srv_rt=nil
|
||||
print("disconnected...")
|
||||
end
|
||||
|
||||
--zzz
|
||||
@@ -97,39 +100,39 @@ 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("c'est connected...")
|
||||
print("connected...")
|
||||
telnet_listener(sck)
|
||||
end)
|
||||
|
||||
srv_rt:connect(console_port,console_host)
|
||||
|
||||
|
||||
|
||||
print("Telnet server running...\nUsage: telnet -rN ip\n")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
tmr_socat1=tmr.create()
|
||||
tmr_socat1:alarm(3*1000, tmr.ALARM_AUTO , function()
|
||||
|
||||
gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH)
|
||||
if verbose then gpio.write(zLED, gpio.LOW) tmr.delay(10000) gpio.write(zLED, gpio.HIGH) end
|
||||
if console_port == srv_rt:getpeer() then
|
||||
gpio.write(zLED, gpio.LOW)
|
||||
if verbose then gpio.write(zLED, gpio.LOW) end
|
||||
else
|
||||
gpio.write(zLED, gpio.HIGH)
|
||||
print("trying...")
|
||||
if verbose then
|
||||
gpio.write(zLED, gpio.HIGH)
|
||||
print("trying connect "..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)
|
||||
end
|
||||
|
||||
|
||||
end)
|
||||
|
||||
|
||||
@@ -138,63 +141,9 @@ end)
|
||||
|
||||
|
||||
|
||||
|
||||
--[[
|
||||
|
||||
srv_rt = net.createConnection(net.TCP, 0)
|
||||
|
||||
srv_rt:on("connection", function(sck)
|
||||
|
||||
print("c'est connected...")
|
||||
|
||||
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)
|
||||
print("c'est disconnected...")
|
||||
--unregist redirect output function, output goes to serial
|
||||
end)
|
||||
|
||||
|
||||
|
||||
sck:on("reconnection",function(c)
|
||||
print("c'est reconnection...")
|
||||
end)
|
||||
|
||||
|
||||
|
||||
|
||||
print("Welcome to NodeMcu world.")
|
||||
end)
|
||||
|
||||
|
||||
tmr_socat1=tmr.create()
|
||||
tmr_socat1:alarm(3*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)
|
||||
]]
|
||||
|
||||
--[[
|
||||
for k,v in pairs(_G) do print(k,v) end
|
||||
|
||||
print(srv_rt:getpeer())
|
||||
|
||||
|
||||
@@ -1,16 +1,12 @@
|
||||
# Quelques commandes remote (luatool) à envoyer avec le plugin Atom-IDE-terminal de l'éditeur Atom
|
||||
# zf200119.1043
|
||||
# zf200216.1523
|
||||
|
||||
|
||||
Todo à faire pour ce projet !
|
||||
|
||||
- faire que send_data et read_temp soient lancés à la volée afin d'économiser de la RAM quand ce n'est pas utilisé
|
||||
- arrêter de demander de connecter le WIFI automatiquement en mode station juste après le boot dans la config wifiinit (automatic connect)
|
||||
- lancement ou arrêt du WEBIDE via la home page
|
||||
- le wifi setup ne fonctionne toujours pas quand il y a déjà un ap de connecté (problème du reboot quand adrs ip ok)!
|
||||
- trouver un moyen pour configurer la lED dans initz.lua sans le rendre dangereux en cas de problème (éviter le reflashing en cas de reboot loop)
|
||||
- utiliser le bouton pour piloter le verbose
|
||||
|
||||
- mettre le numéro jaune du nodemcu dans les secrets projet et prendre 23000+num_jaune comme numéro de port pour le reverse telnet
|
||||
- regarder pour faire tourner en MEME temps le reverse et le forward telnet
|
||||
- z lancement ou arrêt du WEBIDE via la home page
|
||||
v- ajouter fonction restart dans z_index.html (ATTENTION avec un argument restart, pas besoin de faire une page restart.html !)
|
||||
v- ajouter l'affichage du node_id dans z_index.html
|
||||
v- ajouter le web_srv2 dans boot au lieu de boot2
|
||||
@@ -18,20 +14,26 @@ v- ajouter un état du RELAY et de la LED dans z_index.html
|
||||
v- ajouter une page affichage variables globales
|
||||
v- améliorer api_sonoff.html, il faut ajouter 'home' sur la page
|
||||
v- améliorer le résultat de api_sonoff.html, il faut sortir l'état des IO lors d'un changement comme confirmation
|
||||
v- arrêter de demander de connecter le WIFI automatiquement en mode station juste après le boot dans la config wifiinit (automatic connect)
|
||||
v- clignoter la led à chaque mesure en fonction de verbose
|
||||
v- copier secrets_project et secrets_wifi dans _secrets_project_ _secrets_wifi_ pour la documentation
|
||||
v- déplacer le mode AP dans wifi_init
|
||||
v- enlever la ligne wifi init dans z_index.html
|
||||
v- faire la page web service pour allumer la LED
|
||||
v- faire la page web service pour allumer le relay
|
||||
v- faire que send_data et read_temp soient lancés à la volée afin d'économiser de la RAM quand ce n'est pas utilisé
|
||||
v- garder variable node_id pour identification après poweron général, reattribution adrs ip sur modem 4G
|
||||
v- if verbose print partout dans *.lua
|
||||
v- le wifi setup ne fonctionne toujours pas quand il y a déjà un ap de connecté (problème du reboot quand adrs ip ok)!
|
||||
v- passer à 10 secondes la seconde chance
|
||||
v- passer à 15x les tentatives de connexions au WIFI
|
||||
v- terminer la page .html affichage de la température et de l'humidité
|
||||
v- terminer le reverse telnet ;-)
|
||||
v- trouver un moyen pour configurer la lED dans initz.lua sans le rendre dangereux en cas de problème (éviter le reflashing en cas de reboot loop)
|
||||
v- utiliser le bouton pour piloter le verbose
|
||||
v- vérifier le fonctionnement d'allumer la LED, car ne marche plus !
|
||||
x- ajouter argument ok dans wifi_init.html (sécurité)
|
||||
x- mettre ZLED2 et ZRELAY dans secrets_project
|
||||
x-ajouter argument ok dans wifi_init.html (sécurité)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
-- Scripts à charger après le boot pour démarrer son projet
|
||||
|
||||
print("\n boot.lua zf200216.1332 \n")
|
||||
print("\n boot.lua zf200216.1455 \n")
|
||||
|
||||
function boot()
|
||||
verbose = true
|
||||
@@ -11,10 +11,13 @@ function boot()
|
||||
--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
|
||||
|
||||
print("verbose:",verbose)
|
||||
print("boot lancé...")
|
||||
print(node.heap()) collectgarbage() print(node.heap())
|
||||
f=nil boot=nil
|
||||
end
|
||||
boot()
|
||||
|
||||
Reference in New Issue
Block a user