#!/bin/bash

cd ..

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

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

echo "Downloading FactoryTest for PLUS1 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

ls -ltr $bindir


