From 14d8469648d1df4a20f9a589e6cf2ada8ffc61b7 Mon Sep 17 00:00:00 2001 From: Kai-Uwe Hermann Date: Wed, 17 Jan 2024 20:53:29 +0100 Subject: [PATCH] OCPP201: Set Auth connection timeout base on EVConnectionTimeOut Signed-off-by: Kai-Uwe Hermann --- config/config-sil-ocpp201.yaml | 3 +++ dependencies.yaml | 2 +- modules/OCPP201/OCPP201.cpp | 21 +++++++++++++++++++++ modules/OCPP201/OCPP201.hpp | 6 +++++- modules/OCPP201/manifest.yaml | 4 ++++ 5 files changed, 34 insertions(+), 2 deletions(-) diff --git a/config/config-sil-ocpp201.yaml b/config/config-sil-ocpp201.yaml index 91c080d1a..a59b74ef1 100644 --- a/config/config-sil-ocpp201.yaml +++ b/config/config-sil-ocpp201.yaml @@ -120,6 +120,9 @@ active_modules: implementation_id: evse - module_id: evse_manager_2 implementation_id: evse + auth: + - module_id: auth + implementation_id: main system: - module_id: system implementation_id: main diff --git a/dependencies.yaml b/dependencies.yaml index 005a0301c..a0a2e16ab 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -41,7 +41,7 @@ libcurl: # OCPP libocpp: git: https://github.com/EVerest/libocpp.git - git_tag: 9afe405 + git_tag: "0c5d1d7" # Josev Josev: git: https://github.com/EVerest/ext-switchev-iso15118.git diff --git a/modules/OCPP201/OCPP201.cpp b/modules/OCPP201/OCPP201.cpp index 39911dde4..9ba5af1d7 100644 --- a/modules/OCPP201/OCPP201.cpp +++ b/modules/OCPP201/OCPP201.cpp @@ -799,6 +799,19 @@ void OCPP201::ready() { return get_update_firmware_response(response); }; + callbacks.variable_changed_callback = [this](const ocpp::v201::SetVariableData& set_variable_data) { + if (set_variable_data.component.name == "TxCtrlr" and + set_variable_data.variable.name == "EVConnectionTimeOut") { + try { + auto ev_connection_timeout = std::stoi(set_variable_data.attributeValue.get()); + this->r_auth->call_set_connection_timeout(ev_connection_timeout); + } catch (const std::exception& e) { + EVLOG_error << "Could not parse EVConnectionTimeOut and did not set it in Auth module, error: " << e.what(); + return; + } + } + }; + callbacks.validate_network_profile_callback = [this](const int32_t configuration_slot, const ocpp::v201::NetworkConnectionProfile& network_connection_profile) { @@ -851,6 +864,14 @@ void OCPP201::ready() { this->config.CoreDatabasePath, sql_init_path.string(), this->config.MessageLogPath, std::make_shared(*this->r_security), callbacks); + const auto ev_connection_timeout_request_value_response = this->charge_point->request_value( + ocpp::v201::Component{"TxCtrlr"}, ocpp::v201::Variable{"EVConnectionTimeOut"}, + ocpp::v201::AttributeEnum::Actual); + if (ev_connection_timeout_request_value_response.status == ocpp::v201::GetVariableStatusEnum::Accepted and + ev_connection_timeout_request_value_response.value.has_value()) { + this->r_auth->call_set_connection_timeout(ev_connection_timeout_request_value_response.value.value()); + } + if (this->config.EnableExternalWebsocketControl) { const std::string connect_topic = "everest_api/ocpp/cmd/connect"; this->mqtt.subscribe(connect_topic, diff --git a/modules/OCPP201/OCPP201.hpp b/modules/OCPP201/OCPP201.hpp index 1aec647d9..75d68b63f 100644 --- a/modules/OCPP201/OCPP201.hpp +++ b/modules/OCPP201/OCPP201.hpp @@ -17,6 +17,7 @@ #include // headers for required interface implementations +#include #include #include #include @@ -58,7 +59,8 @@ class OCPP201 : public Everest::ModuleBase { std::unique_ptr p_data_transfer, std::vector> r_evse_manager, std::unique_ptr r_system, std::unique_ptr r_security, std::unique_ptr r_kvs, - std::vector> r_data_transfer, Conf& config) : + std::vector> r_data_transfer, std::unique_ptr r_auth, + Conf& config) : ModuleBase(info), mqtt(mqtt_provider), p_main(std::move(p_main)), @@ -70,6 +72,7 @@ class OCPP201 : public Everest::ModuleBase { r_security(std::move(r_security)), r_kvs(std::move(r_kvs)), r_data_transfer(std::move(r_data_transfer)), + r_auth(std::move(r_auth)), config(config){}; Everest::MqttProvider& mqtt; @@ -82,6 +85,7 @@ class OCPP201 : public Everest::ModuleBase { const std::unique_ptr r_security; const std::unique_ptr r_kvs; const std::vector> r_data_transfer; + const std::unique_ptr r_auth; const Conf& config; // ev@1fce4c5e-0ab8-41bb-90f7-14277703d2ac:v1 diff --git a/modules/OCPP201/manifest.yaml b/modules/OCPP201/manifest.yaml index 29cca370e..8673884fb 100644 --- a/modules/OCPP201/manifest.yaml +++ b/modules/OCPP201/manifest.yaml @@ -62,6 +62,10 @@ requires: interface: ocpp_data_transfer min_connections: 0 max_connections: 1 + auth: + interface: auth + min_connections: 1 + max_connections: 1 enable_external_mqtt: true metadata: license: https://opensource.org/licenses/Apache-2.0