From f6da50e5eaa4ad98ead9de02ff2d7aed5f00b0e6 Mon Sep 17 00:00:00 2001 From: Andreas Doebber Date: Fri, 2 Feb 2024 13:56:33 +0100 Subject: [PATCH] Fix SessionID length in SessionSetupReq for ISO15118-20 according to {urn:iso:std:iso:15118:-20:CommonTypes}SessionID the length must be 8 --- iso15118/evcc/states/sap_states.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/iso15118/evcc/states/sap_states.py b/iso15118/evcc/states/sap_states.py index 4fd12c1e..9c40641a 100644 --- a/iso15118/evcc/states/sap_states.py +++ b/iso15118/evcc/states/sap_states.py @@ -128,7 +128,7 @@ async def process_message( protocol.protocol_ns ) header = MessageHeaderV20( - session_id=self.get_session_id(), timestamp=time.time() + session_id=self.get_session_id(length=8), timestamp=time.time() ) next_msg = SessionSetupReqV20( header=header, @@ -168,11 +168,12 @@ async def process_message( f"ID '{sap_res.schema_id}'" ) - def get_session_id(self) -> str: + def get_session_id(self, length=1) -> str: """ Check if there's a saved session ID from a previously paused charging session and applies that for the now resumed charging session. - If there's no stored session ID, we'll set the session ID equal to zero. + If there's no stored session ID, we'll set the session ID equal to zero + with the specified length in bytes. The session ID is also stored as a comm session variable. """ # TODO: get the session id from Redis @@ -180,6 +181,6 @@ def get_session_id(self) -> str: self.comm_session.session_id = evcc_settings.RESUME_SESSION_ID evcc_settings.RESUME_SESSION_ID = None else: - self.comm_session.session_id = bytes(1).hex().upper() + self.comm_session.session_id = bytes(length).hex().upper() return self.comm_session.session_id