- tools/python-embed/: embedded Python 3.12.10 runtime with bleak/pyserial preinstalled (git-ignored, fetched from the huaweicloud mirror); bats resolve Python in order: python-embed -> .venv-ble -> system - NSpyocd.exe + DFP pack copied into tools/ (git-ignored); flash_package.py prefers the in-tools copies - make_release.bat/ps1: one-click zip to out/mothercup_tools_<ts>.zip (staged in TEMP to avoid self-inclusion; zip excluded from git) - all bats converted to CRLF (LF-only breaks cmd block parsing and %~dp0) - verified: zip extracted outside the repo runs ble_ota --uart end-to-end (PASS, 27 kB/s) and flash_package via the bundled NSpyocd - docs: dev log section 49, AGENTS.md tools section + heap 18KB fix
57 lines
1.8 KiB
Batchfile
57 lines
1.8 KiB
Batchfile
@echo off
|
||
rem ============================================================
|
||
rem ble_cli.bat - BLE CLI test client for CAIIC-MCM devices
|
||
rem
|
||
rem ble_cli.bat interactive mode (rw characteristic ...0003)
|
||
rem ble_cli.bat help one-shot command over rw char
|
||
rem ble_cli.bat appset pwm 100
|
||
rem ble_cli.bat -f interactive, legacy framed protocol (notify)
|
||
rem ble_cli.bat -f help one-shot framed command
|
||
rem
|
||
rem One-shot mode sends the whole argument line as ONE command (multi-word ok).
|
||
rem Requires tools\.venv-ble (created automatically on first run).
|
||
rem ============================================================
|
||
setlocal
|
||
set TOOLS=%~dp0
|
||
rem 优先使用随包内嵌的 Python 运行时(tools\python-embed,免安装);
|
||
rem 没有则回退到自动创建的 .venv-ble(开发机)
|
||
set PYEXE=%TOOLS%python-embed\python.exe
|
||
if not exist "%PYEXE%" 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
|
||
)
|
||
|
||
set MODE=-rw
|
||
if "%~1"=="-f" (
|
||
set MODE=
|
||
shift
|
||
)
|
||
|
||
set ARGS=
|
||
:build
|
||
if "%~1"=="" goto :run
|
||
set ARGS=%ARGS% %1
|
||
shift
|
||
goto :build
|
||
|
||
:run
|
||
if "%ARGS%"=="" (
|
||
"%PYEXE%" "%TOOLS%ble_cli_test.py" %MODE% -i
|
||
) else (
|
||
"%PYEXE%" "%TOOLS%ble_cli_test.py" %MODE%%ARGS%
|
||
)
|
||
goto :eof
|
||
|
||
:fail
|
||
echo.
|
||
echo *** setup failed - check python installation ***
|
||
exit /b 1
|