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 demo issues enable two payment modes #57

Merged
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
14 changes: 11 additions & 3 deletions demo-iso15118-2-ac-plus-ocpp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ cd "${DEMO_DIR}" || exit 1

echo "Cloning EVerest from ${DEMO_REPO} into ${DEMO_DIR}/everest-demo"
git clone --branch "${DEMO_BRANCH}" "${DEMO_REPO}" everest-demo
# cp -r "${DEMO_REPO}" everest-demo

if [[ "$DEMO_VERSION" != v1.6j ]]; then
echo "Cloning ${CSMS} CSMS from ${CSMS_REPO} into ${DEMO_DIR}/${CSMS}-csms and starting it"
Expand Down Expand Up @@ -120,9 +121,6 @@ if [[ "$DEMO_VERSION" != v1.6j ]]; then
fi
else
cp ../everest-demo/manager/cached_certs_correct_name_emaid.tar.gz .

echo "Patching the CSMS to disable load balancer"
patch -p1 -i ../everest-demo/maeve/maeve-csms-no-lb.patch
fi

# Set up certificates for SP2 and SP3
Expand Down Expand Up @@ -347,7 +345,17 @@ fi

pushd everest-demo || exit 1
docker compose --project-name everest-ac-demo --file "${DEMO_COMPOSE_FILE_NAME}" up -d --wait

# Configure and restart nodered
docker cp nodered/config/config-sil-iso15118-ac-flow.json everest-ac-demo-nodered-1:/config/config-sil-two-evse-flow.json
docker restart everest-ac-demo-nodered-1

# Configure and restart EVerest
docker cp config-sil-ocpp201-pnc.yaml everest-ac-demo-manager-1:/ext/source/config/config-sil-ocpp201-pnc.yaml
docker cp manager/enable_payment_method.patch everest-ac-demo-manager-1:/tmp/
docker cp manager/enable_evcc_logging.cfg everest-ac-demo-manager-1:/ext/source/build/dist/etc/everest/default_logging.cfg
docker exec everest-ac-demo-manager-1 /bin/bash -c "apk add patch && cd /ext && patch -p0 -i /tmp/enable_payment_method.patch"

if [[ "$DEMO_VERSION" =~ sp2 || "$DEMO_VERSION" =~ sp3 ]]; then
docker cp manager/cached_certs_correct_name_emaid.tar.gz everest-ac-demo-manager-1:/ext/source/build
docker exec everest-ac-demo-manager-1 /bin/bash -c "pushd /ext/source/build && tar xf cached_certs_correct_name_emaid.tar.gz"
Expand Down
12 changes: 6 additions & 6 deletions maeve/maeve-csms-ignore-ocsp.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@ diff --git a/manager/handlers/ocpp201/authorize.go b/manager/handlers/ocpp201/au
index 5df2305..0db9f79 100644
--- a/manager/handlers/ocpp201/authorize.go
+++ b/manager/handlers/ocpp201/authorize.go
@@ -49,7 +49,12 @@ func (a AuthorizeHandler) HandleCall(ctx context.Context, chargeStationId string
@@ -38,7 +38,12 @@ func (a AuthorizeHandler) HandleCall(ctx context.Context, chargeStationId string
if req.Certificate != nil {
_, err = a.CertificateValidationService.ValidatePEMCertificateChain(ctx, []byte(*req.Certificate), req.IdToken.IdToken)
status, certificateStatus = handleCertificateValidationError(err)
idTokenInfo.Status, certificateStatus = handleCertificateValidationError(err)
- if err != nil {
+ if err.Error() == "failed to perform ocsp check after 1 attempts" {
+ var tempStatus = types.AuthorizeCertificateStatusEnumTypeAccepted
+ certificateStatus = &tempStatus
+ status = types.AuthorizationStatusEnumTypeAccepted
+ idTokenInfo.Status = types.AuthorizationStatusEnumTypeAccepted
+ span.SetAttributes(attribute.String("authorize.cert_warn", "No OCSP, but ignoring for testing purpose."))
+ } else if err != nil {
span.SetAttributes(attribute.String("authorize.cert_error", err.Error()))
}
}
@@ -57,7 +62,12 @@ func (a AuthorizeHandler) HandleCall(ctx context.Context, chargeStationId string
@@ -46,7 +46,12 @@ func (a AuthorizeHandler) HandleCall(ctx context.Context, chargeStationId string
if req.Iso15118CertificateHashData != nil {
_, err := a.CertificateValidationService.ValidateHashedCertificateChain(ctx, *req.Iso15118CertificateHashData)
status, certificateStatus = handleCertificateValidationError(err)
idTokenInfo.Status, certificateStatus = handleCertificateValidationError(err)
- if err != nil {
+ if err.Error() == "failed to perform ocsp check after 1 attempts" {
+ var tempStatus = types.AuthorizeCertificateStatusEnumTypeAccepted
+ certificateStatus = &tempStatus
+ status = types.AuthorizationStatusEnumTypeAccepted
+ idTokenInfo.Status = types.AuthorizationStatusEnumTypeAccepted
+ span.SetAttributes(attribute.String("authorize.cert_warn", "No OCSP, but ignoring for testing purpose."))
+ } else if err != nil {
span.SetAttributes(attribute.String("authorize.cert_error", err.Error()))
Expand Down
24 changes: 24 additions & 0 deletions manager/enable_evcc_logging.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# for documentation on this file format see:
# https://www.boost.org/doc/libs/1_54_0/libs/log/doc/html/log/detailed/utilities.html#log.detailed.utilities.setup.filter_formatter

[Core]
DisableLogging=false

# To get debug logs of only one module, add the "%Process% contains" filter, e.g.:
#
# "(%Process% contains OCPP201 and %Severity% >= DEBG)"
#
# whereas "OCPP201" is the value of the field `active_modules.NAME.module` in the respective /config/config-*.yaml.
Filter="%Severity% >= INFO or (%Process% contains iso15118_car and %Severity% >= DEBG)"

[Sinks.Console]
Destination=Console
# Filter="%Target% contains \"MySink1\""
Format="%TimeStamp% [%Severity%] \033[1;32m%Process%\033[0m \033[1;36m%function%\033[0m \033[1;30m%file%:\033[0m\033[1;32m%line%\033[0m: %Message%"
Asynchronous=false
AutoFlush=true
SeverityStringColorDebug="\033[1;30m"
SeverityStringColorInfo="\033[1;37m"
SeverityStringColorWarning="\033[1;33m"
SeverityStringColorError="\033[1;31m"
SeverityStringColorCritical="\033[1;35m"
114 changes: 114 additions & 0 deletions manager/enable_payment_method.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
--- ext-switchev-iso15118/iso15118/evcc/controller/interface.py
+++ source/build/dist/libexec/everest/3rd_party/josev/iso15118/evcc/controller/interface.py
@@ -109,6 +109,15 @@
raise NotImplementedError

@abstractmethod
+ async def get_selected_auth_option(
+ self, protocol: Protocol
+ ) -> AuthEnum:
+ """
+ Gets the auth transfer mode requested for the current charging session.
+ """
+ raise NotImplementedError
+
+ @abstractmethod
async def get_energy_transfer_mode(
self, protocol: Protocol
) -> EnergyTransferModeEnum:
--- ext-switchev-iso15118/iso15118/evcc/controller/simulator.py
+++ source/build/dist/libexec/everest/3rd_party/josev/iso15118/evcc/controller/simulator.py
@@ -53,6 +53,7 @@
SAScheduleTupleEntry as SAScheduleTupleEntryDINSPEC,
)
from iso15118.shared.messages.enums import (
+ AuthEnum,
ControlMode,
DCEVErrorCode,
EnergyTransferModeEnum,
@@ -233,11 +234,18 @@
logger.error(f"Invalid protocol '{protocol}', can't determine EVCCID")
raise InvalidProtocolError

+ async def get_selected_auth_option(
+ self, protocol: Protocol
+ ) -> AuthEnum:
+ """Overrides EVControllerInterface.get_selected_auth_option()."""
+ return AuthEnum(EVEREST_EV_STATE.PaymentOption)
+
async def get_energy_transfer_mode(
self, protocol: Protocol
) -> EnergyTransferModeEnum:
"""Overrides EVControllerInterface.get_energy_transfer_mode()."""
return EnergyTransferModeEnum(EVEREST_EV_STATE.EnergyTransferMode)
+

async def get_supported_energy_services(self) -> List[ServiceV20]:
"""Overrides EVControllerInterface.get_energy_transfer_service()."""
--- ext-switchev-iso15118/iso15118/evcc/states/iso15118_2_states.py
+++ source/build/dist/libexec/everest/3rd_party/josev/iso15118/evcc/states/iso15118_2_states.py
@@ -193,8 +193,9 @@
self.stop_state_machine("ChargeService not offered")
return

- self.select_auth_mode(service_discovery_res.auth_option_list.auth_options)
+ logger.warn("received auth options list %s" % service_discovery_res.auth_option_list.auth_options)
await self.select_services(service_discovery_res)
+ await self.select_auth_mode(service_discovery_res.auth_option_list.auth_options)
await self.select_energy_transfer_mode()

charge_service: ChargeService = service_discovery_res.charge_service
@@ -262,12 +263,13 @@
self.comm_session.selected_energy_mode.value.startswith("AC")
)

- def select_auth_mode(self, auth_option_list: List[AuthEnum]):
+ async def select_auth_mode(self, auth_option_list: List[AuthEnum]):
"""
Check if an authorization mode (aka payment option in ISO 15118-2) was
saved from a previously paused communication session and reuse for
resumed session, otherwise request from EV controller.
"""
+ logger.warn("V2G_PAYMENT: in function received auth options list %s" % auth_option_list)
if evcc_settings.ev_session_context.selected_auth_option:
logger.debug(
"Reusing authorization option "
@@ -279,15 +281,30 @@
)
evcc_settings.ev_session_context.selected_auth_option = None
else:
- # Choose Plug & Charge (pnc) or External Identification Means (eim)
- # as the selected authorization option. The car manufacturer might
- # have a mechanism to determine a user-defined or default
- # authorization option. This implementation favors pnc, but
- # feel free to change if need be.
- if AuthEnum.PNC_V2 in auth_option_list and self.comm_session.is_tls:
- self.comm_session.selected_auth_option = AuthEnum.PNC_V2
+ logger.warn("V2G_PAYMENT: about to read value from state")
+ self.comm_session.selected_auth_option = (
+ await self.comm_session.ev_controller.get_selected_auth_option(
+ Protocol.ISO_15118_2
+ )
+ )
+ logger.warn("V2G_PAYMENT: in function read value from state %s" % self.comm_session.selected_auth_option)
+ if self.comm_session.selected_auth_option is not None:
+ logger.debug(
+ "V2G_PAYMENT: Found Payment Option %s passed in from the PyJoseV module, using it" % self.comm_session.selected_auth_option
+ )
else:
- self.comm_session.selected_auth_option = AuthEnum.EIM_V2
+ logger.debug(
+ "V2G_PAYMENT: No previous paused session, no PaymentOption set, using TLS flag %s to decide auth method" % self.comm_session.is_tls
+ )
+ # Choose Plug & Charge (pnc) or External Identification Means (eim)
+ # as the selected authorization option. The car manufacturer might
+ # have a mechanism to determine a user-defined or default
+ # authorization option. This implementation favors pnc, but
+ # feel free to change if need be.
+ if AuthEnum.PNC_V2 in auth_option_list and self.comm_session.is_tls:
+ self.comm_session.selected_auth_option = AuthEnum.PNC_V2
+ else:
+ self.comm_session.selected_auth_option = AuthEnum.EIM_V2

async def select_services(self, service_discovery_res: ServiceDiscoveryRes):
"""
Loading