Skip to content

Commit

Permalink
OCPP201: Set Auth connection timeout base on EVConnectionTimeOut
Browse files Browse the repository at this point in the history
Signed-off-by: Kai-Uwe Hermann <[email protected]>
  • Loading branch information
hikinggrass committed Jan 17, 2024
1 parent 13b2e9c commit 14d8469
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
3 changes: 3 additions & 0 deletions config/config-sil-ocpp201.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions modules/OCPP201/OCPP201.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -851,6 +864,14 @@ void OCPP201::ready() {
this->config.CoreDatabasePath, sql_init_path.string(), this->config.MessageLogPath,
std::make_shared<EvseSecurity>(*this->r_security), callbacks);

const auto ev_connection_timeout_request_value_response = this->charge_point->request_value<int32_t>(
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,
Expand Down
6 changes: 5 additions & 1 deletion modules/OCPP201/OCPP201.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <generated/interfaces/ocpp_data_transfer/Implementation.hpp>

// headers for required interface implementations
#include <generated/interfaces/auth/Interface.hpp>
#include <generated/interfaces/evse_manager/Interface.hpp>
#include <generated/interfaces/evse_security/Interface.hpp>
#include <generated/interfaces/kvs/Interface.hpp>
Expand Down Expand Up @@ -58,7 +59,8 @@ class OCPP201 : public Everest::ModuleBase {
std::unique_ptr<ocpp_data_transferImplBase> p_data_transfer,
std::vector<std::unique_ptr<evse_managerIntf>> r_evse_manager, std::unique_ptr<systemIntf> r_system,
std::unique_ptr<evse_securityIntf> r_security, std::unique_ptr<kvsIntf> r_kvs,
std::vector<std::unique_ptr<ocpp_data_transferIntf>> r_data_transfer, Conf& config) :
std::vector<std::unique_ptr<ocpp_data_transferIntf>> r_data_transfer, std::unique_ptr<authIntf> r_auth,
Conf& config) :
ModuleBase(info),
mqtt(mqtt_provider),
p_main(std::move(p_main)),
Expand All @@ -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;
Expand All @@ -82,6 +85,7 @@ class OCPP201 : public Everest::ModuleBase {
const std::unique_ptr<evse_securityIntf> r_security;
const std::unique_ptr<kvsIntf> r_kvs;
const std::vector<std::unique_ptr<ocpp_data_transferIntf>> r_data_transfer;
const std::unique_ptr<authIntf> r_auth;
const Conf& config;

// ev@1fce4c5e-0ab8-41bb-90f7-14277703d2ac:v1
Expand Down
4 changes: 4 additions & 0 deletions modules/OCPP201/manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 14d8469

Please sign in to comment.