diff --git a/diet/webserver_diet.lua b/diet/webserver_diet.lua index df80b0a..ba330cf 100644 --- a/diet/webserver_diet.lua +++ b/diet/webserver_diet.lua @@ -265,4 +265,4 @@ a=nil print("Waiting in access point >wordclock< for Clients") print("Please visit 192.168.4.1") startWebServer() -collectgarbage() +collectgarbage() \ No newline at end of file diff --git a/tools/initialDietFlash.sh b/tools/initialDietFlash.sh new file mode 100755 index 0000000..f5ede3e --- /dev/null +++ b/tools/initialDietFlash.sh @@ -0,0 +1,82 @@ +#!/bin/bash + +TOOLDIR=tools/ +LUATOOL=${TOOLDIR}luatool.py + +DIET=bin/luasrcdiet + +DEVICE=$1 +BAUD=115200 + +# check environment +if [ ! -f $LUATOOL ]; then + echo "$LUATOOL not found" + echo "is the command prompt at the same level as the tools folder ?" + exit 1 +fi + +# check the serial connection + +if [ ! -c $DEVICE ]; then + echo "$DEVICE does not exist" + exit 1 +fi + +if [ $# -eq 0 ]; then + echo "" + echo "e.g. usage $0 []" + exit 1 +fi + +if [ $# -eq 1 ]; then + FILES="displayword.lua main.lua timecore.lua webpage.html webserver.lua telnet.lua wordclock.lua init.lua" +else + FILES=$2 +fi + +echo "Generate DIET version of the files" +OUTFILES="" +ROOTDIR=$PWD +cd $TOOLDIR +for f in $FILES; do + if [[ "$f" == *.lua ]] && [[ "$f" != init.lua ]]; then + echo "Compress $f ..." + out=$(echo "$f" | sed 's/.lua/_diet.lua/g') + $DIET ../$f -o ../diet/$out + OUTFILES="$OUTFILES diet/$out" + else + OUTFILES="$OUTFILES $f" + fi +done +FILES=$OUTFILES +cd $ROOTDIR + +if [ $# -eq 1 ]; then + # Format filesystem first + echo "Format the complete ESP" + python3 $LUATOOL -p $DEVICE -w -b $BAUD + if [ $? -ne 0 ]; then + echo "STOOOOP" + exit 1 + fi +fi + +echo "Start Flasing ..." +for f in $FILES; do + if [ ! -f $f ]; then + echo "Cannot find $f" + echo "place the terminal into the folder where the lua files are present" + exit 1 + fi + echo "------------- $f ------------" + python3 $LUATOOL -p $DEVICE -f $f -b $BAUD -t $f + if [ $? -ne 0 ]; then + echo "STOOOOP" + exit 1 + fi +done + +echo "Reboot the ESP" +echo "node.restart()" >> $DEVICE + +exit 0 diff --git a/tools/initialFlash.sh b/tools/initialFlash.sh index a4f58df..565cd83 100755 --- a/tools/initialFlash.sh +++ b/tools/initialFlash.sh @@ -26,7 +26,7 @@ if [ $# -eq 0 ]; then fi if [ $# -eq 1 ]; then - FILES="displayword.lua main.lua timecore.lua webpage.html webserver_diet.lua telnet.lua wordclock.lua init.lua" + FILES="displayword.lua main.lua timecore.lua webpage.html webserver.lua telnet.lua wordclock.lua init.lua" else FILES=$2 fi @@ -42,17 +42,6 @@ if [ $# -eq 1 ]; then fi fi -#stty -F $DEVICE $BAUD -#echo "Reboot the ESP" -#echo "node.restart()" >> $DEVICE -#sleep 1 -#for i in $(seq 0 5); do -# echo "Stop TMR $i" -# echo "tmr.stop($i)" >> $DEVICE -# sleep 1 -#done - -#echo echo "Start Flasing ..." for f in $FILES; do if [ ! -f $f ]; then