diff --git a/IDE_remote/SocketIDE/luatool/boot.lua b/IDE_remote/SocketIDE/luatool/boot.lua index bc3a7fd..8714d28 100644 --- a/IDE_remote/SocketIDE/luatool/boot.lua +++ b/IDE_remote/SocketIDE/luatool/boot.lua @@ -1,6 +1,6 @@ -- Scripts à charger après le boot pour démarrer le core system -print("\n boot.lua zf190916.2359 \n") +print("\n boot.lua zf191020.1928 \n") -- charge ses propres secrets f= "secrets_energy.lua" if file.exists(f) then dofile(f) end @@ -11,5 +11,5 @@ f= "wifi_ap_stop.lua" if file.exists(f) then dofile(f) end f= "wifi_cli_conf.lua" if file.exists(f) then dofile(f) end f= "wifi_cli_start.lua" if file.exists(f) then dofile(f) end f= "telnet_srv2.lua" if file.exists(f) then dofile(f) end -f= "web_ide2.lua" if file.exists(f) then dofile(f) end -f= "web_srv2.lua" if file.exists(f) then dofile(f) end +--f= "web_ide2.lua" if file.exists(f) then dofile(f) end +--ff= "web_srv2.lua" if file.exists(f) then dofile(f) end diff --git a/IDE_remote/SocketIDE/luatool/boot2.lua b/IDE_remote/SocketIDE/luatool/boot2.lua index c4c1b70..f819826 100644 --- a/IDE_remote/SocketIDE/luatool/boot2.lua +++ b/IDE_remote/SocketIDE/luatool/boot2.lua @@ -1,6 +1,6 @@ -- Scripts à charger après le boot pour démarrer son appli -print("\n boot2.lua zf190917.0030 \n") +print("\n boot2.lua zf191020.1840 \n") second_chance=nil function heartbeat() @@ -13,10 +13,10 @@ function heartbeat() end) end -f= "0_get_data.lua" if file.exists(f) then dofile(f) end -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_get_data.lua" if file.exists(f) then dofile(f) end +--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=nil -heartbeat=nil ---heartbeat() +--heartbeat=nil +heartbeat() diff --git a/IDE_remote/SocketIDE/luatool/luatool.py b/IDE_remote/SocketIDE/luatool/luatool.py index 36581fe..6927c49 100755 --- a/IDE_remote/SocketIDE/luatool/luatool.py +++ b/IDE_remote/SocketIDE/luatool/luatool.py @@ -1,6 +1,6 @@ #!/usr/bin/env python2 # -*- coding: utf-8 -*- -version = "0.6.5 zf191020.1804" +version = "0.6.5 zf191020.1932" print("luatool.py ver " + version) @@ -354,6 +354,7 @@ if __name__ == '__main__': # restart or dofile if args.restart: transport.writeln("node.restart()\r") + if args.dofile: # never exec if restart=1 transport.writeln("dofile(\"" + args.dest + "\")\r", 0) diff --git a/IDE_remote/SocketIDE/luatool/telnet_srv.lua b/IDE_remote/SocketIDE/luatool/telnet_srv.lua new file mode 100644 index 0000000..32e2cf0 --- /dev/null +++ b/IDE_remote/SocketIDE/luatool/telnet_srv.lua @@ -0,0 +1,42 @@ +-- a simple telnet server + +-- restart server if needed +if telnet_srv ~= nil then + telnet_srv:close() +end +telnet_srv = net.createServer(net.TCP, 180) + +telnet_srv:listen(23, function(socket) + local fifo = {} + local fifo_drained = true + + local function sender(c) + if #fifo > 0 then + c:send(table.remove(fifo, 1)) + else + fifo_drained = true + end + end + + local function s_output(str) + table.insert(fifo, str) + if socket ~= nil and fifo_drained then + fifo_drained = false + sender(socket) + end + end + + node.output(s_output, 0) -- re-direct output to function s_ouput. + + socket:on("receive", function(c, l) + node.input(l) -- works like pcall(loadstring(l)) but support multiple separate line + end) + socket:on("disconnection", function(c) + node.output(nil) -- un-regist the redirect output function, output goes to serial + end) + socket:on("sent", sender) + + print("Welcome to NodeMCU world.") +end) + +print("Telnet server running...") diff --git a/IDE_remote/SocketIDE/luatool/telnet_srv2.lua b/IDE_remote/SocketIDE/luatool/telnet_srv2.lua index 821358c..19920f2 100644 --- a/IDE_remote/SocketIDE/luatool/telnet_srv2.lua +++ b/IDE_remote/SocketIDE/luatool/telnet_srv2.lua @@ -1,7 +1,7 @@ -- Serveur telnet pour connexion en remote WIFI, NOUVELLE VERSION ! -- source: https://github.com/nodemcu/nodemcu-firmware/blob/master/lua_examples/telnet/telnet.lua -print("\n telnet_srv2.lua zf181215.1326 \n") +print("\n telnet_srv2.lua zf191020.1932 \n") local node, table, tmr, wifi, uwrite, tostring = node, table, tmr, wifi, uart.write, tostring @@ -77,6 +77,12 @@ local function telnet_listener(socket) node.output(nil) end + --zzz + local function zconnection(s) + print("Welcome to NodeMCU world.") + end + + socket:on("connection", zconnection) socket:on("receive", receiveLine) socket:on("disconnection", disconnect) socket:on("sent", sendLine) diff --git a/IDE_remote/SocketIDE/luatool/test_toto.sh b/IDE_remote/SocketIDE/luatool/test_toto.sh new file mode 100755 index 0000000..7b44c7a --- /dev/null +++ b/IDE_remote/SocketIDE/luatool/test_toto.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# Petit script pour tester tout le binz via le WIFI +#zf191020.1954 + +# S'il y a des erreurs lors d'un téléchargement, il faut simplement augmenter un peu le délai ! + +IP="192.168.0.157" + +chmod +x luatool.py + +./luatool.py --ip $IP -l +read -p "continue ?" +./luatool.py --ip $IP --delete toto.lua +read -p "continue ?" +./luatool.py --ip $IP -l +read -p "continue ?" +./luatool.py --ip $IP -f toto.lua -d +read -p "continue ?" +./luatool.py --ip $IP -l +read -p "continue ?" +./luatool.py --ip $IP --delete toto.lua +read -p "continue ?" +./luatool.py --ip $IP -l diff --git a/IDE_remote/SocketIDE/luatool/toto.lua b/IDE_remote/SocketIDE/luatool/toto.lua new file mode 100644 index 0000000..6678736 --- /dev/null +++ b/IDE_remote/SocketIDE/luatool/toto.lua @@ -0,0 +1,3 @@ +print("c'est toto !") + +boottimer1:unregister() diff --git a/IDE_remote/SocketIDE/luatool/upload.sh b/IDE_remote/SocketIDE/luatool/upload.sh index 5c786d9..8b5267c 100755 --- a/IDE_remote/SocketIDE/luatool/upload.sh +++ b/IDE_remote/SocketIDE/luatool/upload.sh @@ -1,6 +1,6 @@ #!/bin/bash # Petit script pour télécharger facilement tout le binz -#zf191020.1837 +#zf191020.1957 # S'il y a des erreurs lors d'un téléchargement, il faut simplement augmenter un peu le délai ! @@ -8,14 +8,16 @@ chmod +x luatool.py ./luatool.py --port /dev/cu.wchusbserial1410 -l ./luatool.py --port /dev/cu.wchusbserial1410 -w ./luatool.py --port /dev/cu.wchusbserial1410 -l -./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.001 -f boot.lua -./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.001 -f boot2.lua -./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.03 -f flash_led_xfois.lua -./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.001 -f initz.lua -./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.001 -f secrets_energy.lua -./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.001 -f wifi_ap_stop.lua -./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.001 -f wifi_cli_conf.lua -./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.001 -f wifi_cli_start.lua -./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.001 -f wifi_info.lua -./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.04 -f telnet_srv2.lua +./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.001 --src boot.lua +./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.001 --src boot2.lua +./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.03 --src flash_led_xfois.lua +./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.001 --src initz.lua --dest init.lua +./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.001 --src secrets_energy.lua +./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.001 --src wifi_ap_stop.lua +./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.001 --src wifi_cli_conf.lua +./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.001 --src wifi_cli_start.lua +./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.001 --src wifi_info.lua +./luatool.py --port /dev/cu.wchusbserial1410 --delay 0.06 --src telnet_srv2.lua ./luatool.py --port /dev/cu.wchusbserial1410 -l + +#./luatool.py --port /dev/cu.wchusbserial1410 -r