41 lines
1011 B
PowerShell
41 lines
1011 B
PowerShell
param(
|
|
[string]$Firmware = "",
|
|
[string]$Name = "RLCD-Metrics",
|
|
[int]$ChunkSize = 180,
|
|
[double]$ChunkDelay = 0.01,
|
|
[switch]$WriteWithResponse
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
|
$venvDir = Join-Path $scriptDir ".venv-ble"
|
|
$venvPythonExe = Join-Path $venvDir "Scripts\python.exe"
|
|
$requirements = Join-Path $scriptDir "requirements-ble.txt"
|
|
$otaScript = Join-Path $scriptDir "ble-ota.py"
|
|
|
|
if (-not $Firmware) {
|
|
$Firmware = Join-Path (Split-Path -Parent (Split-Path -Parent $scriptDir)) "build\rlcd_clock.bin"
|
|
}
|
|
|
|
if (-not (Test-Path $venvPythonExe)) {
|
|
python -m venv $venvDir
|
|
& $venvPythonExe -m pip install --upgrade pip
|
|
& $venvPythonExe -m pip install -r $requirements
|
|
}
|
|
|
|
$args = @(
|
|
"-u",
|
|
$otaScript,
|
|
"--firmware", $Firmware,
|
|
"--name", $Name,
|
|
"--chunk-size", $ChunkSize,
|
|
"--chunk-delay", $ChunkDelay
|
|
)
|
|
|
|
if ($WriteWithResponse) {
|
|
$args += "--write-with-response"
|
|
}
|
|
|
|
& $venvPythonExe @args
|