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 min_length of EVSE ID for DIN protocol #257

Merged
merged 2 commits into from
Jun 22, 2023
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion iso15118/shared/messages/din_spec/body.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ class SessionSetupRes(Response):
The SECC and the EVCC shall use the format for EVSEID as defined
in DIN SPEC 91286.

See section 9.4.1.2.3 Table 30 in DIN SPEC 70121
"If an SECC cannot provide such ID data, the value of the EVSEID
is set to zero (00hex)."
=> min_length = 2

For EVSE ID format see section 5.3.2:
"Each <EVSEID> has a variable length with at least five characters (one
digit <Country Code>, three digits <Spot Operator ID>, one digit <Power Outlet ID>)
Expand All @@ -119,7 +124,7 @@ class SessionSetupRes(Response):
as “0x49 0xA8 0x9A 0x63 0x60”.
"""

evse_id: str = Field(..., min_length=7, max_length=32, alias="EVSEID")
evse_id: str = Field(..., min_length=2, max_length=32, alias="EVSEID")
datetime_now: int = Field(None, alias="DateTimeNow")


Expand Down
12 changes: 12 additions & 0 deletions tests/dinspec/evcc/evcc_mock_messages.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from typing import List, Optional

from iso15118.shared.messages.datatypes import (
Expand All @@ -22,6 +23,7 @@
PowerDeliveryRes,
ServiceDiscoveryRes,
ServicePaymentSelectionRes,
SessionSetupRes,
WeldingDetectionRes,
)
from iso15118.shared.messages.din_spec.datatypes import (
Expand Down Expand Up @@ -343,3 +345,13 @@ def get_welding_detection_on_going_message():
header=MessageHeader(session_id=MOCK_SESSION_ID),
body=Body(welding_detection_res=welding_detection),
)


def get_session_setup_evseid_zero():
session_setup: SessionSetupRes = SessionSetupRes(
response_code=ResponseCode.OK, evse_id="00", datetime_now=time.time()
)
return V2GMessage(
header=MessageHeader(session_id=MOCK_SESSION_ID),
body=Body(session_setup_res=session_setup),
)
7 changes: 7 additions & 0 deletions tests/dinspec/evcc/test_dinspec_evcc_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
PowerDelivery,
ServiceDiscovery,
ServicePaymentSelection,
SessionSetup,
WeldingDetection,
)
from iso15118.shared.messages.enums import AuthEnum, EnergyTransferModeEnum, Protocol
Expand All @@ -32,6 +33,7 @@
get_service_discovery_message_payment_service_not_offered,
get_service_payment_selection_fail_message,
get_service_payment_selection_message,
get_session_setup_evseid_zero,
get_v2g_message_current_demand_current_limit_not_achieved,
get_welding_detection_on_going_message,
)
Expand Down Expand Up @@ -165,6 +167,11 @@ async def test_charge_parameter_discovery_timeout(self):
)
assert charge_parameter_discovery.next_state is Terminate

async def test_session_setup_to_service_discovery(self):
session_setup = SessionSetup(self.comm_session_mock)
await session_setup.process_message(message=get_session_setup_evseid_zero())
assert session_setup.next_state is ServiceDiscovery

async def cable_check_req_to_pre_charge(self):
pass

Expand Down