feat: integrate N7Cockpit remote mode control

This commit is contained in:
vee
2026-08-13 10:36:24 +08:00
parent fd3c219c39
commit 78d758d3fb
108 changed files with 23150 additions and 16 deletions
+31
View File
@@ -0,0 +1,31 @@
[CmdletBinding()]
param(
[string]$ConfigPath = ''
)
$ErrorActionPreference = 'Stop'
$projectRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
if (-not $ConfigPath) { $ConfigPath = Join-Path $projectRoot 'config\migration.psd1' }
if (-not [System.IO.Path]::IsPathRooted($ConfigPath)) {
$ConfigPath = Join-Path $projectRoot $ConfigPath
}
$config = Import-PowerShellDataFile -LiteralPath $ConfigPath
$tokenPath = [string]$config.TokenFile
if (-not [System.IO.Path]::IsPathRooted($tokenPath)) {
$tokenPath = Join-Path $projectRoot $tokenPath
}
$token = (Get-Content -LiteralPath $tokenPath -Raw).Trim()
$baseUrl = ([string]$config.ServerAUrl).TrimEnd('/')
$vehicleId = ([string]$config.VehicleId).Trim()
$headers = @{ Authorization = "Bearer $token" }
$catalog = Invoke-RestMethod -Uri "$baseUrl/api/v1/vehicles/$vehicleId/modes" `
-Headers $headers -TimeoutSec 10
$events = Invoke-RestMethod -Uri "$baseUrl/api/v1/vehicles/$vehicleId/events?after=0" `
-Headers $headers -TimeoutSec 10
[pscustomobject]@{
Passed = $true
ServerA = $baseUrl
VehicleId = $catalog.vehicle_id
PresetModes = @($catalog.modes | Where-Object { $_.origin -eq 'preset' }).Count
EventSequence = $events.next_sequence
}