This commit is contained in:
Christian Zufferey
2019-10-20 20:12:53 +02:00
parent 0a161206d1
commit 85966e9a08
8 changed files with 99 additions and 22 deletions

View File

@@ -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

View File

@@ -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()

View File

@@ -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)

View File

@@ -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...")

View File

@@ -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)

View File

@@ -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

View File

@@ -0,0 +1,3 @@
print("c'est toto !")
boottimer1:unregister()

View File

@@ -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