Skip to content

Commit d33051b

Browse files
committed
Potential epoch fix
1 parent 757af97 commit d33051b

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
test.py
2+
test*.py
23
register.py
34
*.pyc
45
__pycache__

tesla_fleet_api/vehiclesigned.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from cryptography.hazmat.primitives.asymmetric import ec
1010
from cryptography.hazmat.primitives.serialization import PublicFormat, Encoding
1111

12-
from .exceptions import MESSAGE_FAULTS
12+
from .exceptions import MESSAGE_FAULTS, TeslaFleetMessageFaultIncorrectEpoch
1313

1414
from .const import (
1515
LOGGER,
@@ -23,6 +23,7 @@
2323

2424
from .pb2.universal_message_pb2 import (
2525
# OPERATIONSTATUS_OK,
26+
MESSAGEFAULT_ERROR_INCORRECT_EPOCH,
2627
OPERATIONSTATUS_WAIT,
2728
OPERATIONSTATUS_ERROR,
2829
DOMAIN_VEHICLE_SECURITY,
@@ -273,7 +274,13 @@ async def _send(self, domain: int, command: bytes) -> dict[str, Any]:
273274

274275
msg.signature_data.CopyFrom(signature)
275276

276-
resp = await self._signed_message(msg)
277+
try:
278+
resp = await self._signed_message(msg)
279+
except TeslaFleetMessageFaultIncorrectEpoch:
280+
LOGGER.info(f"Session expired, starting new handshake with {Domain.Name(domain)}")
281+
await self._handshake(domain)
282+
LOGGER.info(f"Handshake complete, retrying message to {Domain.Name(domain)}")
283+
return await self._send(domain, command)
277284

278285
if resp.signedMessageStatus.operation_status == OPERATIONSTATUS_WAIT:
279286
return {"response": {"result": False}}

0 commit comments

Comments
 (0)