#!/bin/bash

# lib.sh を読み込んで curl オプション設定を利用
source lib.sh

bindir=FactoryTest/build/esp32.esp32.m5stack_stickc_plus2
mkdir -p "$bindir"
baseurl="https://cit.istlab.info/f/plus2/FactoryTest.ino."

echo "Downloading FactoryTest firmware files..."
for ext in bin bootloader.bin partitions.bin; do
    url="${baseurl}${ext}"
    echo "Downloading $url ..."
    curl $(lib_get_curl_options) -L -o "$bindir/FactoryTest.ino.${ext}" "$url"
    if [ $? -ne 0 ]; then
        echo "Failed to download $url"
        exit 1
    fi
done

