170 lines
5.2 KiB
TOML
170 lines
5.2 KiB
TOML
# ═══════════════════════════════════════════════════════════
|
|
# Klubhaus Doorbell — Multi-Target Build Harness
|
|
# ═══════════════════════════════════════════════════════════
|
|
|
|
# Required tools
|
|
[tools]
|
|
hk = "latest"
|
|
pkl = "latest"
|
|
# screen = "latest" # Install via system package manager (brew install screen / apt install screen)
|
|
# zellij = "latest" # Install manually if needed (brew install zellij)
|
|
|
|
# Usage:
|
|
# BOARD=esp32-32e-4 mise run compile # compile
|
|
# BOARD=esp32-32e-4 mise run upload # upload
|
|
# BOARD=esp32-32e-4 mise run monitor # monitor
|
|
# BOARD=esp32-32e-4 mise run monitor-screen # shows tio command to run manually
|
|
#
|
|
# Valid BOARD: esp32-32e, esp32-32e-4, esp32-s3-lcd-43
|
|
# Board config lives in: boards/{BOARD}/board-config.sh
|
|
|
|
[tasks.compile]
|
|
description = "Compile (uses BOARD env var)"
|
|
run = """
|
|
source ./boards/$BOARD/board-config.sh
|
|
arduino-cli compile --fqbn "$FQBN" --libraries ./libraries $LIBS --build-property "compiler.cpp.extra_flags=$OPTS" --warnings default ./boards/$BOARD
|
|
"""
|
|
|
|
[tasks.upload]
|
|
description = "Upload (uses BOARD env var)"
|
|
run = """
|
|
source ./boards/$BOARD/board-config.sh
|
|
source ./scripts/lockfile.sh
|
|
FORCE=1 TASK_NAME=upload acquire_lock || exit 1
|
|
|
|
PORT="${PORT:-$PORT}"
|
|
arduino-cli compile --fqbn "$FQBN" --libraries ./libraries $LIBS --build-property "compiler.cpp.extra_flags=$OPTS" --warnings default ./boards/$BOARD && \
|
|
arduino-cli upload --fqbn "$FQBN" --port "$PORT" ./boards/$BOARD
|
|
"""
|
|
|
|
[tasks.monitor-raw]
|
|
run = """
|
|
source ./boards/$BOARD/board-config.sh
|
|
source ./scripts/lockfile.sh
|
|
acquire_lock || exit 1
|
|
|
|
PORT="${PORT:-$PORT}"
|
|
TARGET="$(readlink -f "$PORT" 2>/dev/null || echo "$PORT")"
|
|
arduino-cli monitor -p "$TARGET" --config baudrate=115200
|
|
"""
|
|
|
|
[tasks.monitor-tio]
|
|
description = "Show tio command to run in separate terminal"
|
|
run = """
|
|
source ./boards/$BOARD/board-config.sh
|
|
source ./scripts/lockfile.sh
|
|
acquire_lock || exit 1
|
|
|
|
PORT="${PORT:-$PORT}"
|
|
TARGET="$(readlink -f "$PORT" 2>/dev/null || echo "$PORT")"
|
|
tio --map INLCRNL "$TARGET" -e
|
|
"""
|
|
|
|
[tasks.kill]
|
|
description = "Kill running monitor/upload for BOARD"
|
|
run = """
|
|
source ./scripts/lockfile.sh
|
|
kill_locked
|
|
"""
|
|
|
|
[tasks.monitor]
|
|
description = "Monitor agent with JSON log + command pipe (Python-based)"
|
|
run = """
|
|
python3 ./scripts/monitor-agent.py "$BOARD"
|
|
"""
|
|
|
|
[tasks.log-tail]
|
|
description = "Tail the logs with human-readable formatting"
|
|
run = '''
|
|
tail -f "/tmp/doorbell-$BOARD.jsonl" | while read -r line; do
|
|
ts=$(echo "$line" | python3 -c "import sys,json; print(json.load(sys.stdin)['ts'])" 2>/dev/null)
|
|
txt=$(echo "$line" | python3 -c "import sys,json; print(json.load(sys.stdin)['line'])" 2>/dev/null)
|
|
if [[ "$txt" == *"[STATE]"* ]]; then
|
|
echo -e "\\033[1;35m[$ts]\\033[0m $txt"
|
|
elif [[ "$txt" == *"[ADMIN]"* ]]; then
|
|
echo -e "\\033[1;36m[$ts]\\033[0m $txt"
|
|
elif [[ "$txt" == *"[TOUCH]"* ]]; then
|
|
echo -e "\\033[1;33m[$ts]\\033[0m $txt"
|
|
elif [[ "$txt" == *"ALERT"* ]]; then
|
|
echo -e "\\033[1;31m[$ts]\\033[0m $txt"
|
|
else
|
|
echo "[$ts] $txt"
|
|
fi
|
|
done
|
|
'''
|
|
|
|
[tasks.cmd]
|
|
description = "Send command to device (COMMAND=dashboard mise run cmd)"
|
|
run = """
|
|
echo -n "$COMMAND" > "/tmp/doorbell-$BOARD-cmd.fifo"
|
|
echo "[SENT] $COMMAND"
|
|
"""
|
|
|
|
[tasks.state]
|
|
description = "Show current device state"
|
|
run = """
|
|
cat "/tmp/doorbell-$BOARD-state.json"
|
|
"""
|
|
|
|
[tasks.install-libs-shared]
|
|
description = "Install shared Arduino libraries"
|
|
run = """
|
|
./scripts/install-shared.sh
|
|
"""
|
|
|
|
[tasks.install]
|
|
description = "Install libraries for BOARD (shared + board-specific)"
|
|
run = """
|
|
./scripts/install-shared.sh
|
|
./boards/$BOARD/install.sh
|
|
"""
|
|
|
|
# Convenience
|
|
|
|
[tasks.clean]
|
|
description = "Remove build artifacts"
|
|
run = """
|
|
rm -rf vendor/
|
|
rm -rf boards/esp32-32e/build
|
|
rm -rf boards/esp32-32e-4/build
|
|
rm -rf boards/esp32-s3-lcd-43/build
|
|
echo "[OK] Build artifacts cleaned"
|
|
"""
|
|
|
|
[tasks.arduino-clean]
|
|
description = "Clean Arduino CLI cache (staging + packages)"
|
|
run = """
|
|
echo "Checking ~/.arduino15..."
|
|
du -sh ~/.arduino15/staging 2>/dev/null || echo "No staging folder"
|
|
du -sh ~/.arduino15/packages 2>/dev/null || echo "No packages folder"
|
|
read -p "Delete staging + packages folders? [y/N] " -n 1 -r
|
|
echo
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
rm -rf ~/.arduino15/staging
|
|
rm -rf ~/.arduino15/packages
|
|
echo "[OK] Arduino staging + packages cleared"
|
|
else
|
|
echo "Aborted"
|
|
fi
|
|
"""
|
|
|
|
[tasks.format]
|
|
run = """
|
|
clang-format -i --style=file \
|
|
boards/esp32-32e/*.cpp \
|
|
boards/esp32-32e/*.h \
|
|
boards/esp32-32e/*.ino \
|
|
boards/esp32-32e-4/*.cpp \
|
|
boards/esp32-32e-4/*.h \
|
|
boards/esp32-32e-4/*.ino \
|
|
boards/esp32-s3-lcd-43/*.cpp \
|
|
boards/esp32-s3-lcd-43/*.h \
|
|
boards/esp32-s3-lcd-43/*.ino \
|
|
libraries/KlubhausCore/src/*.cpp \
|
|
libraries/KlubhausCore/src/*.h \
|
|
libraries/KlubhausCore/*.properties
|
|
"""
|
|
|
|
[env]
|
|
BOARD = "esp32-32e-4"
|