@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 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 bleak || 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