#!/bin/bash # TTY="/dev/ttyUSB0" IP="192.168.30.212" VER="0.1-dev" function help() { echo "$0 [build|upload|webupload|monitor]" exit 1 } test -z $1 && help case $1 in b|build) echo "building firmware binary into $(pwd)/build/" test -d build || mkdir build echo "/* CanGrow_Version.h gets generated from cangrow.sh */ const char* CanGrowVer = \"${VER}\"; const char* CanGrowBuild = \"$(git rev-parse --short HEAD)\"; " > 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 ;; u|upload) echo "uploading to $TTY" ~/.local/bin/arduino-cli --no-color compile -v -b esp8266:esp8266:d1_mini_clone -u -p $TTY "Arduino/CanGrow/CanGrow.ino" ;; 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" echo ;; m|mon|monitor) echo "open monitor $TTY" ~/.local/bin/arduino-cli monitor -c baudrate=115200 -p $TTY ;; *) help ;; esac