Skip to content

fix: one session request per wake; resend session and command requests unchanged - #95

Merged
yoziru merged 1 commit into
yoziru:mainfrom
darek-margas:upstream-pr/wake-session-resend
Oct 10, 2026
Merged

yoziru merged 1 commit into
yoziru:mainfrom
darek-margas:upstream-pr/wake-session-resend

Conversation

@darek-margas

Copy link
Copy Markdown
Contributor

Summary

Three related fixes in how requests are sent around a wake, all matching Tesla's vehicle-command:

  • One infotainment session request per wake. A waking car sends a burst of VCSEC status updates. Once the session info request was out, each further "awake" status restarted the auth and sent another request (5 in 0.6 s seen on a car), queued behind each other: the first command after a wake took about 8 s instead of 0.5 s. Now only a command still waiting for the wake reacts.
  • Unanswered session info request resent unchanged every second. A single request sent the moment VCSEC reports the car awake is often ignored by the still-waking infotainment, and the command then waited the full 25 s auth timeout. It is now resent every TRANSPORT_RETRY_INTERVAL (1 s), at most MAX_AUTH_RESENDS (10) times. Same bytes and request UUID, so whichever copy the car answers is accepted.
  • Command resend is the identical message. When no reply arrives in time, the command is resent as the same encoded bytes instead of being rebuilt with a new counter. If the first copy arrived and only the reply was lost, the car sees a duplicate, so toggles (trunk, media play/pause) are not executed twice. After a new session the request is built again.

Tests in tests/test_vehicle.cpp. Running on two cars (ESP32) since early October: the first command after a wake now completes in about 0.5–7 s instead of failing after 25 s.

Independent of #94; touches vehicle.cpp in different places from #90 and #91.

…s unchanged

A waking car sends a burst of VCSEC status updates. Once the infotainment
session info request was out, each further "awake" status restarted the
auth and sent another request (5 in 0.6 s seen on a car), queued behind
each other, so the first command after a wake took about 8 s instead of
0.5 s. Now only a command still waiting for the wake reacts to it.

A single request sent the moment VCSEC reports the car awake is often
ignored by its still-waking infotainment, and the command then waited the
full 25 s auth timeout. An unanswered session info request is now resent
unchanged every TRANSPORT_RETRY_INTERVAL (1 s), at most MAX_AUTH_RESENDS
(10) times, as vehicle-command does. Same bytes and request UUID, so
whichever copy the car answers is accepted.

When a command gets no reply in time, it is resent as the identical
encoded bytes instead of being rebuilt with a new counter, as
vehicle-command does. If the first copy arrived and only the reply was
lost, the car sees a duplicate instead of a new command, so toggles
(trunk, media play/pause, volume step) are not executed twice. After a
new session the request is built again.

Tests in tests/test_vehicle.cpp.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@yoziru
yoziru force-pushed the upstream-pr/wake-session-resend branch from 26e5230 to 137fa62 Compare October 10, 2026 11:38
@yoziru

yoziru commented Oct 10, 2026

Copy link
Copy Markdown
Owner

Rebased onto current main and pushed to your branch (force-push; all commits preserved, 26e5230 → 137fa62). Resolutions:

238/238 tests pass locally; CI runs on the updated head. This is a great fix — the wake-burst session-request leak and the duplicate-command hazard are exactly the kind of thing that is invisible without a car.

@yoziru
yoziru merged commit 34cf522 into yoziru:main Oct 10, 2026
4 checks passed
darek-margas added a commit to darek-margas/tesla-ble that referenced this pull request Oct 10, 2026
With yoziru#96 the retry delay is applied before a resend; upstream adjusted
this test the same way when it merged yoziru#95 on top of yoziru#96.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants