Wordclock/tools/remoteFlash.sh

57 lines
1.3 KiB
Bash
Raw Normal View History

2019-04-18 16:32:35 +02:00
#!/bin/bash
IP=$1
FLASHTOOL=./tools/tcpFlash.py
if [ ! -f $FLASHTOOL ]; then
echo "Execute the script in root folder of the project"
exit 2
fi
if [ "$IP" == "" ]; then
echo "IP address of ESP required"
echo "usage:"
echo "$0 <IP>"
echo "$0 192.168.0.2"
exit 1
fi
# check the connection
echo "Searching $IP ..."
ping $IP -c 2 >> /dev/null
if [ $? -ne 0 ]; then
echo "Entered IP address: $IP is NOT online"
exit 2
fi
echo "Upgrading $IP"
2019-04-18 20:34:28 +02:00
echo "stopWordclock()" > /tmp/wordClockCMD.txt
2019-04-18 21:37:55 +02:00
echo "uart.write(0, tostring(node.heap())" >> /tmp/wordClockCMD.txt
echo "c = string.char(0,0,128)" >> /tmp/wordClockCMD.txt
echo "w = string.char(0,0,0)" >> /tmp/wordClockCMD.txt
echo "ws2812.write(w:rep(4) .. c .. w:rep(15) .. c .. w:rep(9) .. c .. w:rep(30) .. c .. w:rep(41) .. c )" >> /tmp/wordClockCMD.txt
2019-04-18 20:34:28 +02:00
$FLASHTOOL -f /tmp/wordClockCMD.txt -t $IP -v
2019-04-18 19:31:48 +02:00
2019-04-18 16:32:35 +02:00
FILES="displayword.lua main.lua timecore.lua webpage.html webserver.lua wordclock.lua init.lua"
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 ------------"
$FLASHTOOL -t $IP -f $f
if [ $? -ne 0 ]; then
echo "STOOOOP"
exit 1
fi
done
2019-04-18 16:41:04 +02:00
echo "TODO: Reboot the ESP"
#echo "node.restart()" | nc $IP 80
2019-04-18 16:32:35 +02:00
exit 0