Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SessionID length in SessionSetupReq for ISO15118-20 #378

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions iso15118/evcc/states/sap_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -168,18 +168,19 @@ 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
if evcc_settings.RESUME_SESSION_ID:
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