From 24aaacee72c099427f8469a1c19908cc1fc3fc82 Mon Sep 17 00:00:00 2001 From: pietfried Date: Thu, 5 Sep 2024 16:14:35 +0200 Subject: [PATCH 1/2] Fix issue that connectivity_manager was only initialized in a single constructor Signed-off-by: pietfried --- lib/ocpp/v201/charge_point.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ocpp/v201/charge_point.cpp b/lib/ocpp/v201/charge_point.cpp index d7e2962b4..9bc6405d9 100644 --- a/lib/ocpp/v201/charge_point.cpp +++ b/lib/ocpp/v201/charge_point.cpp @@ -158,10 +158,6 @@ ChargePoint::ChargePoint(const std::map& evse_connector_struct initialize(evse_connector_structure, message_log_path); - this->connectivity_manager = - std::make_unique(*this->device_model, this->evse_security, this->logging, - std::bind(&ChargePoint::message_callback, this, std::placeholders::_1)); - this->connectivity_manager->set_websocket_connected_callback( std::bind(&ChargePoint::websocket_connected_callback, this, std::placeholders::_1)); this->connectivity_manager->set_websocket_disconnected_callback( @@ -1015,6 +1011,10 @@ void ChargePoint::initialize(const std::map& evse_connector_st this->monitoring_updater.start_monitoring(); this->auth_cache_cleanup_thread = std::thread(&ChargePoint::cache_cleanup_handler, this); + + this->connectivity_manager = + std::make_unique(*this->device_model, this->evse_security, this->logging, + std::bind(&ChargePoint::message_callback, this, std::placeholders::_1)); } void ChargePoint::init_certificate_expiration_check_timers() { From 40420dcf4641dacab4b53ff8004b2cb06b21aeba Mon Sep 17 00:00:00 2001 From: pietfried Date: Thu, 5 Sep 2024 16:24:04 +0200 Subject: [PATCH 2/2] moved even more initialization of connectivity manager Signed-off-by: pietfried --- lib/ocpp/v201/charge_point.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/ocpp/v201/charge_point.cpp b/lib/ocpp/v201/charge_point.cpp index 9bc6405d9..aed79595e 100644 --- a/lib/ocpp/v201/charge_point.cpp +++ b/lib/ocpp/v201/charge_point.cpp @@ -158,18 +158,6 @@ ChargePoint::ChargePoint(const std::map& evse_connector_struct initialize(evse_connector_structure, message_log_path); - this->connectivity_manager->set_websocket_connected_callback( - std::bind(&ChargePoint::websocket_connected_callback, this, std::placeholders::_1)); - this->connectivity_manager->set_websocket_disconnected_callback( - std::bind(&ChargePoint::websocket_disconnected_callback, this)); - this->connectivity_manager->set_websocket_connection_failed_callback( - std::bind(&ChargePoint::websocket_connection_failed, this, std::placeholders::_1)); - - if (this->callbacks.configure_network_connection_profile_callback.has_value()) { - this->connectivity_manager->set_configure_network_connection_profile_callback( - this->callbacks.configure_network_connection_profile_callback.value()); - } - this->message_queue = std::make_unique>( [this](json message) -> bool { return this->connectivity_manager->send_to_websocket(message.dump()); }, MessageQueueConfig{ @@ -1015,6 +1003,18 @@ void ChargePoint::initialize(const std::map& evse_connector_st this->connectivity_manager = std::make_unique(*this->device_model, this->evse_security, this->logging, std::bind(&ChargePoint::message_callback, this, std::placeholders::_1)); + + this->connectivity_manager->set_websocket_connected_callback( + std::bind(&ChargePoint::websocket_connected_callback, this, std::placeholders::_1)); + this->connectivity_manager->set_websocket_disconnected_callback( + std::bind(&ChargePoint::websocket_disconnected_callback, this)); + this->connectivity_manager->set_websocket_connection_failed_callback( + std::bind(&ChargePoint::websocket_connection_failed, this, std::placeholders::_1)); + + if (this->callbacks.configure_network_connection_profile_callback.has_value()) { + this->connectivity_manager->set_configure_network_connection_profile_callback( + this->callbacks.configure_network_connection_profile_callback.value()); + } } void ChargePoint::init_certificate_expiration_check_timers() {