cangrow.sh - add setup, to setup cangrow build environment

This commit is contained in:
Marcus 2024-06-15 23:59:00 +02:00
parent 52abf8e483
commit f4556f75d4
3 changed files with 60 additions and 7 deletions

View file

@ -278,7 +278,7 @@ void loop() {
* - PumpOnTime (int) in sec
* - PumpInterval (int) in days
* - SoilmoistureLow (int) in %
*
* - PumpLastOn (long) timestamp
*
*/

View file

@ -1,5 +1,5 @@
/* CanGrow_Version.h gets generated from cangrow.sh */
const char* CanGrowVer = "0.1-dev";
const char* CanGrowBuild = "e524826";
const char* CanGrowBuild = "52abf8e";

View file

@ -6,15 +6,66 @@ test -z $IP && IP="192.168.30.212"
test -z $VER && VER="0.1-dev"
BUILD="$(git rev-parse --short HEAD)"
ACLI="$HOME/.local/bin/arduino-cli"
ACLI_CMD="$ACLI --config-file arduino-cli.yml"
function help() {
echo "$0 [build|upload|webupload|monitor]"
echo "$0 [setup|build|upload|webupload|monitor]"
exit 1
}
function check_acli() {
if [ ! -x $ACLI ]
then
echo "$ACLI does not exist nor is executable. Please run '$0 setup' first"
exit 1
fi
}
test -z $1 && help
case $1 in
s|setup)
ACLI_DIR="$(dirname $ACLI)"
declare -a LIBS=( "Adafruit SSD1306" "Adafruit BME280 Library" "ArduinoJson" "NTPClient" "Time" )
echo ":: Setting up build environment for CanGrow Firmware."
echo " This will download the binary for arduino-cli and install"
echo " the packages for the arduino ide from the debian repository."
echo ""
echo ":: Press Enter to continue"
read
echo ":: Ensure directory ${ACLI_DIR} is present"
test -d ${ACLI_DIR} || mkdir -p ${ACLI_DIR}
echo ":: Please ensure ${ACLI_DIR} is in your \$PATH, I wont do it."
echo ""
echo ":: Downloading arduino-cli 1.0.0 into ${ACLI_DIR}/"
wget -O - "https://github.com/arduino/arduino-cli/releases/download/v1.0.0/arduino-cli_1.0.0_Linux_64bit.tar.gz" | tar -C ${ACLI_DIR} -zxvf - arduino-cli
chmod +x ${ACLI}
echo ""
echo ":: installing Arduino IDE packages with apt, please enter sudo password:"
sudo apt update
sudo apt install arduino
echo ""
echo ":: Installing ESP8266 core for Arduino"
${ACLI_CMD} core install esp8266:esp8266
echo ":: Installing Arduino libraries"
for lib in ${!LIBS[@]}
do
echo " - ${LIBS[$lib]}"
done
for lib in ${!LIBS[@]}
do
${ACLI_CMD} lib install "${LIBS[$lib]}"
done
echo ""
echo ":: Setup build environment done! You can now build the firmware"
echo " with: $0 build"
;;
b|build)
check_acli
echo "building firmware $VER $BUILD, target dir: $(pwd)/build/"
test -d build || mkdir build
echo "/* CanGrow_Version.h gets generated from cangrow.sh */
@ -22,21 +73,23 @@ case $1 in
const char* CanGrowVer = \"${VER}\";
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
${ACLI_CMD} --no-color compile -b esp8266:esp8266:d1_mini_clone "Arduino/CanGrow/CanGrow.ino" --output-dir build/ || exit 1
cp build/CanGrow.ino.bin build/CanGrow_v${VER}_${BUILD}.bin
;;
u|upload)
check_acli
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"
${ACLI_CMD} --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"
curl -v http://$IP/system/applyUpdate -X POST -H 'Content-Type: multipart/form-data' -F "file=@$(pwd)/build/CanGrow.ino.bin"
echo
;;
m|mon|monitor)
check_acli
echo "open monitor $TTY"
~/.local/bin/arduino-cli monitor -c baudrate=115200 -p $TTY
${ACLI_CMD} monitor -c baudrate=115200 -p $TTY
;;
*)
help