Kia EU: fix commands on legacy (non-CCS2) vehicles#34
Merged
Conversation
Mirrors the three legacy-path bugs Nachtlatscher fixed for Hyundai EU in schmidtwmark#32 — flagged in the schmidtwmark#29 thread after merge. - Drop leading slash on lock/unlock door paths so the URL builder doesn't produce a double slash. - Stop using the PIN-derived control token on legacy v1 endpoints. Legacy endpoints reject control-token auth with "400 Authorization field missing" and expect the regular access token. Gate the control-token flow on ccs2 and use authorizedHeaders for the legacy branch. - Pass ccs2: ccs2 to commandPathAndBody. The call site relied on the default ccs2: true, so legacy vehicles got the CCS2 payload shape against a v1 URL. Live-validated against a CCS2 EV9 by hard-coding ccs2 = false locally: lock + unlock both return 200 / resCode 0000 and the doors physically lock and unlock — confirming the Bluelink backend routes legacy v1 and CCS2 endpoints to the same handler. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mirrors @Nachtlatscher's #32 for Hyundai Europe — the same three bugs exist in the Kia Europe client and were flagged on the #29 thread.
Fixes
Leading slash on door commands (
KiaEuropeAPIClient+Commands.swift).lock/unlockreturned"/control/door"while every other legacy case returned"control/...", so the URL builder produced a double slash (…/spa/vehicles/<id>//control/door).Control-token used on legacy endpoints (
KiaEuropeAPIClient.swift).sendCommandunconditionally fetched a PIN-derived control token and usedcommandHeaders(Authorization: Bearer <controlToken>). Legacy v1 endpoints reject this with400 "Authorization field missing"— they expect the regular access token. Gate the control-token flow onccs2; legacy usesauthorizedHeaders(authToken:ccs2:)directly.commandPathAndBodyalways took the CCS2 branch. The call site passed noccs2:argument, so the defaultccs2: truealways selected the CCS2 path/body shape — even for legacy vehicles whose URL was being built as v1. Passccs2: ccs2explicitly.Validation
Live-tested against my CCS2 Kia EV9 by hard-coding
ccs2 = falselocally to force the legacy branch:Normal CCS2 path on my EV9 unchanged (still works, 286/286 tests pass).
A true CCS1 vehicle owner would be the ideal validator, but the wire-level fix is confirmed by the symmetry with #32 and the Python reference (`ApiImplType1`).
🤖 Drafted with assistance from Claude Code (Anthropic).