CanGrow/cangrow.sh

45 lines
1.2 KiB
Bash
Raw Normal View History

2024-06-15 01:02:44 +02:00
#!/bin/bash
#
test -z $TTY && TTY="/dev/ttyUSB0"
test -z $IP && IP="192.168.30.212"
test -z $VER && VER="0.1-dev"
2024-06-15 15:24:42 +02:00
BUILD="$(git rev-parse --short HEAD)"
2024-06-15 01:02:44 +02:00
function help() {
2024-06-15 01:17:44 +02:00
echo "$0 [build|upload|webupload|monitor]"
2024-06-15 01:02:44 +02:00
exit 1
}
test -z $1 && help
case $1 in
b|build)
2024-06-15 15:24:42 +02:00
echo "building firmware $VER $BUILD, target dir: $(pwd)/build/"
2024-06-15 01:02:44 +02:00
test -d build || mkdir build
echo "/* CanGrow_Version.h gets generated from cangrow.sh */
const char* CanGrowVer = \"${VER}\";
2024-06-15 15:24:42 +02:00
const char* CanGrowBuild = \"${BUILD}\";
" > Arduino/CanGrow/CanGrow_Version.h
~/.local/bin/arduino-cli --no-color compile -b esp8266:esp8266:d1_mini_clone "Arduino/CanGrow/CanGrow.ino" --output-dir build/ || exit 1
2024-06-15 15:24:42 +02:00
cp build/CanGrow.ino.bin build/CanGrow_v${VER}_${BUILD}.bin
2024-06-15 01:02:44 +02:00
;;
u|upload)
2024-06-15 01:17:44 +02:00
echo "uploading to $TTY"
2024-06-15 01:02:44 +02:00
~/.local/bin/arduino-cli --no-color compile -v -b esp8266:esp8266:d1_mini_clone -u -p $TTY "Arduino/CanGrow/CanGrow.ino"
;;
2024-06-15 01:17:44 +02:00
w|webupload)
echo "uploading to $IP"
curl -v http://$IP/system/applyUpdate -X POST -H 'Content-Type: multipart/form-data' -F "image=@$(pwd)/build/CanGrow.ino.bin"
2024-06-15 01:17:44 +02:00
echo
;;
2024-06-15 01:02:44 +02:00
m|mon|monitor)
2024-06-15 01:17:44 +02:00
echo "open monitor $TTY"
2024-06-15 01:02:44 +02:00
~/.local/bin/arduino-cli monitor -c baudrate=115200 -p $TTY
;;
*)
help
;;
esac