mothercup/tools/ble_ota.bat
evan.liu dd218addce tools: add requirements-ble.txt for the (git-ignored) .venv-ble
The venv is a per-machine artifact and stays out of git; the bats
auto-create it on first run but only installed bleak - pyserial
(required by UART OTA) was missing on a fresh machine. Both bats now
install from requirements-ble.txt (bleak==3.0.2, pyserial==3.5).
2026-09-05 10:07:14 +08:00

37 lines
1.3 KiB
Batchfile

@echo off
rem ============================================================
rem ble_ota.bat - BLE OTA updater for CAIIC-MCM devices
rem
rem ble_ota.bat [mothercup_ble_ota.bin] BLE channel (...e0005)
rem ble_ota.bat --uart COM4 [mothercup_ble_ota.bin] UART channel
rem default pkg: tools\out\mothercup_ble_ota.bin
rem
rem The combined package holds both bank-linked payloads; the script
rem reads the current bank (info item 0x07 CUR_BANK) and downloads
rem the payload for the opposite bank, then verifies the reboot.
rem Requires tools\.venv-ble (created automatically on first run).
rem ============================================================
setlocal
set TOOLS=%~dp0
set PYEXE=%TOOLS%.venv-ble\Scripts\python.exe
if not exist "%PYEXE%" (
echo [setup] creating venv %TOOLS%.venv-ble ...
set PYREAL=
if exist "%LOCALAPPDATA%\Programs\Python\Python312\python.exe" set PYREAL="%LOCALAPPDATA%\Programs\Python\Python312\python.exe"
if not defined PYREAL (
py -3 --version >nul 2>&1 && set PYREAL=py -3
)
if not defined PYREAL set PYREAL=python
%PYREAL% -m venv "%TOOLS%.venv-ble" || goto :fail
"%PYEXE%" -m pip install --quiet -r "%TOOLS%requirements-ble.txt" || goto :fail
)
"%PYEXE%" "%TOOLS%ble_ota_update.py" %1 %2 %3
goto :eof
:fail
echo.
echo *** setup failed - check python installation ***
exit /b 1