Cela commence enfin à fonctionner correctement, j'ai encore le problème du reboot après 10mn à vérifier
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
-- Petit script pour envoyer en // es valeurs sur un serveur WEB (InfluxDB)
|
||||
-- via un http POST à travers un FIFO
|
||||
|
||||
if verbose then print("\n 0_http_post.lua zf200621.1238 \n") end
|
||||
if verbose then print("\n 0_http_post.lua zf200621.2320 \n") end
|
||||
|
||||
t_zurl={} t_zarg={} f_zpost=false
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
-- script telnet pour le socat
|
||||
|
||||
function telnet_listener(socket)
|
||||
print("\n 0_rtelnet1.lua zf200621.1943 \n")
|
||||
print("\n 0_rtelnet1.lua zf200621.2309 \n")
|
||||
|
||||
-- node, table, tmr, uwrite, tostring =
|
||||
-- node, table, tmr, uart.write, tostring
|
||||
@@ -31,7 +31,9 @@ function telnet_listener(socket)
|
||||
rec = table.remove(fifo2,1)..(table.remove(fifo2,1) or '') ..(table.remove(fifo2,1) or '') .. (table.remove(fifo2,1) or '')
|
||||
fifo2l = fifo2l - #rec
|
||||
flushGarbage()
|
||||
s:send(rec)
|
||||
if srv_rt:getpeer()~=nil then
|
||||
s:send(rec)
|
||||
end
|
||||
end
|
||||
|
||||
local F1_SIZE = 256
|
||||
@@ -71,6 +73,12 @@ function telnet_listener(socket)
|
||||
if socket~=nil then
|
||||
-- if http_post~=nil then http_post(influxdb_url,"energy,memory=srv_rt_no_nil_"..yellow_id.." ram="..node.heap()) end
|
||||
print("................disconnect 2e", socket, socket:getpeer())
|
||||
socket:on("connection", nil)
|
||||
socket:on("reconnection", nil)
|
||||
socket:on("disconnection", nil)
|
||||
socket:on("receive", nil)
|
||||
socket:on("sent", nil)
|
||||
|
||||
socket=nil
|
||||
end
|
||||
|
||||
@@ -92,6 +100,8 @@ function telnet_listener(socket)
|
||||
-- zconnection = nil
|
||||
-- disconnect = nil
|
||||
-- -- telnet_listener=nil
|
||||
|
||||
|
||||
|
||||
fifo1, fifo1l, fifo2, fifo2l = nil, nil, nil, nil
|
||||
rec = nil
|
||||
@@ -111,7 +121,7 @@ function telnet_listener(socket)
|
||||
|
||||
|
||||
-- collectgarbage()
|
||||
-- rt_connect()
|
||||
rt_connect()
|
||||
end
|
||||
|
||||
--zzz
|
||||
|
||||
@@ -26,7 +26,7 @@ ou sur MAC
|
||||
telnet -rN localhost 23000
|
||||
]]
|
||||
|
||||
print("\n 0_tst5_socat.lua zf200621.1944 \n")
|
||||
print("\n 0_tst5_socat.lua zf200621.2330 \n")
|
||||
|
||||
function rt_connect()
|
||||
print("................rt_connect")
|
||||
@@ -34,7 +34,7 @@ function rt_connect()
|
||||
local zlaps=tmr.now()/1000000-ztime_connect
|
||||
print("time of retry connect... "..zlaps)
|
||||
-- if debug_rec~=nil then debug_rec("time of retry connect... "..zlaps..", "..node.heap()) end
|
||||
if zlaps>1.5 then
|
||||
if zlaps>1 then
|
||||
local zstr="trying connect to "..console_host..":"..console_port..", "..node.heap()
|
||||
-- if debug_rec~=nil then debug_rec(zstr) end
|
||||
if verbose==verbose then
|
||||
@@ -53,7 +53,7 @@ function rt_connect()
|
||||
collectgarbage()
|
||||
-- if verbose then
|
||||
gpio.write(zLED, gpio.LOW)
|
||||
print("connected on "..console_host..":"..console_port)
|
||||
print("connected on "..console_host..":"..console_port..", "..node.heap())
|
||||
print(node.heap())
|
||||
-- end
|
||||
if http_post~=nil then http_post(influxdb_url,"energy,memory=socat_connected_"..yellow_id.." ram="..node.heap()) end
|
||||
@@ -62,6 +62,25 @@ function rt_connect()
|
||||
print("Welcome to NodeMCU world.")
|
||||
end)
|
||||
|
||||
srv_rt:on("reconnection", function(sck)
|
||||
print(";;;;;;;;;;;;;;;;reconnection")
|
||||
srv_rt:on("connection", nil)
|
||||
srv_rt:on("reconnection", nil)
|
||||
end)
|
||||
|
||||
-- srv_rt:on("disconnection", function(sck)
|
||||
-- print(";;;;;;;;;;;;;;;;disconnection")
|
||||
-- end)
|
||||
--
|
||||
-- srv_rt:on("receive", function(sck)
|
||||
-- print(";;;;;;;;;;;;;;;;receive")
|
||||
-- end)
|
||||
--
|
||||
-- srv_rt:on("sent", function(sck)
|
||||
-- print(";;;;;;;;;;;;;;;;sent")
|
||||
-- end)
|
||||
|
||||
|
||||
srv_rt:connect(console_port,console_host)
|
||||
else
|
||||
print("on ne se reconnecte pas vite 1x...")
|
||||
@@ -89,11 +108,8 @@ end
|
||||
-- tmr_socat1:alarm(15*1000, tmr.ALARM_AUTO , rt_launch)
|
||||
|
||||
|
||||
ztime_connect=tmr.now()/1000000-10
|
||||
|
||||
|
||||
|
||||
ztime_connect=tmr.now()/1000000
|
||||
|
||||
-- rt_launch()
|
||||
rt_launch()
|
||||
|
||||
print("Revers telnet server running...\n")
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
zf200621.1125
|
||||
zf200621.2337
|
||||
|
||||
srv_rt:on("connection", nil)
|
||||
|
||||
|
||||
|
||||
|
||||
=node.heap()
|
||||
rt_connect()
|
||||
|
||||
node, table, tmr, uwrite, tostring = nil, nil, nil, nil, nil
|
||||
insert, remove, concat, heap, gc = nil, nil, nil, nil, nil
|
||||
fifo1, fifo1l, fifo2, fifo2l = nil, nil, nil, nil
|
||||
rec = nil
|
||||
k = nil
|
||||
l = nil
|
||||
s = nil
|
||||
chunk = nil
|
||||
socket = nil
|
||||
flushGarbage = nil
|
||||
sendLine = nil
|
||||
@@ -16,7 +22,8 @@ rt_connect()
|
||||
zconnection = nil
|
||||
disconnect = nil
|
||||
telnet_listener=nil
|
||||
|
||||
srv_rt=nil
|
||||
=node.heap()
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Quelques commandes remote (luatool) à envoyer avec le plugin Atom-IDE-terminal de l'éditeur Atom
|
||||
# zf200621.1154
|
||||
# zf200621.2312
|
||||
|
||||
|
||||
Todo à faire pour ce projet !
|
||||
@@ -40,7 +40,7 @@ for k,v in pairs(_G) do print(k,v) end
|
||||
# pour les tests en direct sur la gateway
|
||||
ssh ubuntu@www.zuzu-test.ml
|
||||
socat TCP-LISTEN:23064,fork,reuseaddr STDIO
|
||||
|
||||
################################
|
||||
# pour les tests en remote
|
||||
killall -9 ssh
|
||||
ssh ubuntu@www.zuzu-test.ml killall -9 socat
|
||||
|
||||
Reference in New Issue
Block a user