This repository was archived by the owner on Feb 26, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Add AuthorizationSetup to EV side state machine, including a feedback mechanism to report EVSE parameters to the EV. #165
Merged
SebaLukas
merged 6 commits into
EVerest:feat/adding-ev-d20
from
rogerbedell:feat/adding-ev-d20-AuthorizationSetup2
Feb 17, 2026
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d7ef096
Add AuthorizationSetup to EV side state machine
cienporcien 2f6e468
Fixed some minor issues in the pull request comment.
cienporcien 51c0f27
Added a check for non standard response codes and fixed a small bug i…
cienporcien 3d7acf3
Fixed a lint issue.
cienporcien 4659eba
Fixed an issue with the test with ResponseCode is FAILED.
cienporcien 97d588f
Fixed lint issue
cienporcien File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // Copyright 2025 Pionix GmbH and Contributors to EVerest | ||
| #pragma once | ||
|
|
||
| #include <iso15118/message/common_types.hpp> | ||
|
|
||
| namespace iso15118::ev::d20 { | ||
|
|
||
| // Holds information reported by the EVSE that could be different between sessions | ||
| struct EVSESessionInfo { | ||
| std::vector<message_20::datatypes::Authorization> auth_services{}; | ||
| bool certificate_installation_service{false}; | ||
| std::optional<std::vector<message_20::datatypes::Name>> supported_providers{std::nullopt}; | ||
| message_20::datatypes::GenChallenge gen_challenge{std::array<uint8_t, 16>{}}; // 16 bytes | ||
| }; | ||
|
|
||
| } // namespace iso15118::ev::d20 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // Copyright 2025 Pionix GmbH and Contributors to EVerest | ||
| #pragma once | ||
|
|
||
| #include "../states.hpp" | ||
|
|
||
| namespace iso15118::ev::d20::state { | ||
|
|
||
| struct Authorization : public StateBase { | ||
| public: | ||
| Authorization(Context& ctx) : StateBase(ctx, StateID::Authorization) { | ||
| } | ||
|
|
||
| void enter() final; | ||
|
|
||
| Result feed(Event) final; | ||
| }; | ||
|
|
||
| } // namespace iso15118::ev::d20::state | ||
|
cienporcien marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // Copyright 2023 Pionix GmbH and Contributors to EVerest | ||
| #pragma once | ||
|
|
||
| #include <cmath> | ||
| #include <functional> | ||
| #include <optional> | ||
| #include <string> | ||
| #include <variant> | ||
|
|
||
| #include <iso15118/ev/d20/evse_session_info.hpp> | ||
| #include <iso15118/ev/d20/session.hpp> | ||
| #include <iso15118/message/dc_charge_loop.hpp> | ||
| #include <iso15118/message/dc_charge_parameter_discovery.hpp> | ||
| #include <iso15118/message/schedule_exchange.hpp> | ||
| #include <iso15118/message/service_detail.hpp> | ||
| #include <iso15118/message/service_selection.hpp> | ||
| #include <iso15118/message/type.hpp> | ||
|
cienporcien marked this conversation as resolved.
|
||
|
|
||
| namespace iso15118::ev::d20::session { | ||
|
|
||
| namespace dt = message_20::datatypes; | ||
|
|
||
| namespace feedback { | ||
|
|
||
| struct Callbacks { | ||
| std::function<void(const EVSESessionInfo&)> evse_session_info; | ||
| }; | ||
|
|
||
| } // namespace feedback | ||
|
|
||
| class Feedback { | ||
| public: | ||
| Feedback(feedback::Callbacks); | ||
|
|
||
| void evse_session_info(const EVSESessionInfo&) const; | ||
|
|
||
| private: | ||
| feedback::Callbacks callbacks; | ||
| }; | ||
|
|
||
| } // namespace iso15118::ev::d20::session | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // Copyright 2025 Pionix GmbH and Contributors to EVerest | ||
| #include <iso15118/detail/helper.hpp> | ||
| #include <iso15118/ev/d20/state/authorization.hpp> | ||
| #include <iso15118/ev/detail/d20/context_helper.hpp> | ||
| #include <iso15118/message/authorization.hpp> | ||
|
|
||
| namespace iso15118::ev::d20::state { | ||
|
|
||
| message_20::AuthorizationRequest handle_request() { | ||
| // TODO(SL): Implement | ||
| return message_20::AuthorizationRequest(); | ||
| } | ||
|
|
||
| void Authorization::enter() { | ||
| // TODO(SL): Adding logging | ||
| } | ||
|
|
||
| Result Authorization::feed(Event ev) { | ||
| if (ev != Event::V2GTP_MESSAGE) { | ||
| return {}; | ||
| } else { | ||
| return {}; | ||
| } | ||
| } | ||
|
|
||
| } // namespace iso15118::ev::d20::state | ||
|
cienporcien marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,103 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // Copyright 2025 Pionix GmbH and Contributors to EVerest | ||
| // Copyright 2025 Pionix GmbH, Roger Bedell and Contributors to EVerest | ||
| #include <iso15118/detail/helper.hpp> | ||
| #include <iso15118/ev/d20/context.hpp> | ||
| #include <iso15118/ev/d20/state/authorization.hpp> | ||
| #include <iso15118/ev/d20/state/authorization_setup.hpp> | ||
| #include <iso15118/ev/detail/d20/context_helper.hpp> | ||
| #include <iso15118/ev/session/feedback.hpp> | ||
| #include <iso15118/message/authorization.hpp> | ||
| #include <iso15118/message/authorization_setup.hpp> | ||
|
|
||
| namespace iso15118::ev::d20::state { | ||
|
|
||
| namespace { | ||
| using ResponseCode = message_20::datatypes::ResponseCode; | ||
| bool check_response_code(ResponseCode response_code) { | ||
| switch (response_code) { | ||
| case ResponseCode::OK: | ||
| return true; | ||
| [[fallthrough]]; | ||
| default: | ||
| return false; | ||
| } | ||
|
cienporcien marked this conversation as resolved.
|
||
| } | ||
| } // namespace | ||
|
|
||
| void AuthorizationSetup::enter() { | ||
| // TODO(SL): Adding logging | ||
| } | ||
|
|
||
| Result AuthorizationSetup::feed([[maybe_unused]] Event ev) { | ||
| return {}; | ||
| } | ||
| if (ev != Event::V2GTP_MESSAGE) { | ||
| return {}; | ||
| } | ||
|
|
||
| const auto variant = m_ctx.pull_response(); | ||
|
|
||
| if (const auto res = variant->get_if<message_20::AuthorizationSetupResponse>()) { | ||
|
|
||
| if (not check_response_code(res->response_code)) { | ||
| m_ctx.stop_session(true); // Tell stack to close the tcp/tls connection | ||
| return {}; | ||
| } | ||
|
|
||
| if (res->certificate_installation_service) { | ||
| // TODO(RB): Implement certificate installation service | ||
| logf_warning("EVSE supports certificate installation service, but this is not implemented in the EV yet."); | ||
| // Remember it in the context for later use | ||
| m_ctx.evse_session_info.certificate_installation_service = true; | ||
| } | ||
|
|
||
| // Save the offered authorization services in the session context so we can use it later and also report it to | ||
| // the EV. | ||
| m_ctx.evse_session_info.auth_services = res->authorization_services; | ||
|
|
||
| if (res->authorization_mode.index() == 1) { // PnC | ||
|
cienporcien marked this conversation as resolved.
Outdated
|
||
| const auto& pnc_auth_mode = | ||
| std::get<message_20::datatypes::PnC_ASResAuthorizationMode>(res->authorization_mode); | ||
| if (pnc_auth_mode.supported_providers.has_value()) { | ||
| m_ctx.evse_session_info.supported_providers = pnc_auth_mode.supported_providers.value(); | ||
| } | ||
|
cienporcien marked this conversation as resolved.
Outdated
|
||
| m_ctx.evse_session_info.gen_challenge = pnc_auth_mode.gen_challenge; | ||
| } else { | ||
| // EIM selected, nothing to do here for now since authorization_mode is empty for EIM | ||
| } | ||
| // Inform the ev about the evse session information | ||
| m_ctx.feedback.evse_session_info(m_ctx.evse_session_info); | ||
|
|
||
| // Send request and transition to next state | ||
| message_20::AuthorizationRequest req; | ||
| setup_header(req.header, m_ctx.get_session()); | ||
| // TODO(RB): Choose the authorization service based on user preference and what the evse supports | ||
| // For now, we just pick the first one offered by the evse | ||
| if (m_ctx.evse_session_info.auth_services.empty()) { | ||
| logf_error("No authorization services offered by the EVSE. Abort the session."); | ||
| m_ctx.stop_session(true); // Tell stack to close the tcp/tls connection | ||
| return {}; | ||
| } | ||
| req.selected_authorization_service = m_ctx.evse_session_info.auth_services.front(); | ||
| if (req.selected_authorization_service == message_20::datatypes::Authorization::EIM) { | ||
| req.authorization_mode = message_20::datatypes::EIM_ASReqAuthorizationMode{}; | ||
| } else if (req.selected_authorization_service == message_20::datatypes::Authorization::PnC) { | ||
| // TODO(RB): Fill in the PnC authorization mode data | ||
| // For now, we just fill in dummy data | ||
| message_20::datatypes::PnC_ASReqAuthorizationMode pnc_mode; | ||
| pnc_mode.id = "dummy_id"; // TODO(RB): Replace with actual ID | ||
| pnc_mode.gen_challenge = m_ctx.evse_session_info.gen_challenge; // Use the challenge from the evse | ||
| // TODO(RB): Fill in the contract certificate chain | ||
| req.authorization_mode = pnc_mode; | ||
|
SebaLukas marked this conversation as resolved.
Outdated
|
||
| } else { | ||
| logf_error("Unknown authorization service selected. Abort the session."); | ||
| m_ctx.stop_session(true); // Tell stack to close the tcp/tls connection | ||
| return {}; | ||
| } | ||
| m_ctx.respond(req); | ||
| return m_ctx.create_state<Authorization>(); | ||
| } else { | ||
| logf_error("expected AuthorizationSetupResponse! But code type id: %d", variant->get_type()); | ||
| m_ctx.stop_session(true); // Tell stack to close the tcp/tls connection | ||
| return {}; | ||
| } | ||
| } | ||
| } // namespace iso15118::ev::d20::state | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // Copyright 2023 Pionix GmbH and Contributors to EVerest | ||
| #include <iso15118/ev/session/feedback.hpp> | ||
|
|
||
| #include <iso15118/detail/helper.hpp> | ||
| #include <iso15118/ev/d20/evse_session_info.hpp> | ||
| namespace iso15118::ev::d20::session { | ||
|
|
||
| Feedback::Feedback(feedback::Callbacks callbacks_) : callbacks(std::move(callbacks_)) { | ||
| } | ||
|
|
||
| void Feedback::evse_session_info(const d20::EVSESessionInfo& info) const { | ||
| call_if_available(callbacks.evse_session_info, info); | ||
| } | ||
|
|
||
| } // namespace iso15118::ev::d20::session |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.