From fcb9e38705a7205790e4b193901508df4c5b9eec Mon Sep 17 00:00:00 2001 From: Matthias Suess Date: Tue, 24 Oct 2023 06:33:46 +0200 Subject: [PATCH] Fixes on clang format Signed-off-by: Matthias Suess --- lib/ocpp/common/websocket/websocket.cpp | 9 ++-- lib/ocpp/v16/charge_point_impl.cpp | 37 ++++++------- lib/ocpp/v201/charge_point.cpp | 70 ++++++++++++------------- 3 files changed, 59 insertions(+), 57 deletions(-) diff --git a/lib/ocpp/common/websocket/websocket.cpp b/lib/ocpp/common/websocket/websocket.cpp index 599460a8f..1d6be0b7d 100644 --- a/lib/ocpp/common/websocket/websocket.cpp +++ b/lib/ocpp/common/websocket/websocket.cpp @@ -61,10 +61,11 @@ void Websocket::register_connected_callback(const std::function& callback) { this->closed_callback = callback; - this->websocket->register_closed_callback([this](const websocketpp::close::status::value reason, const bool doFull) { - this->logging->sys("Disconnected"); - this->closed_callback(reason, doFull); - }); + this->websocket->register_closed_callback( + [this](const websocketpp::close::status::value reason, const bool doFull) { + this->logging->sys("Disconnected"); + this->closed_callback(reason, doFull); + }); } void Websocket::register_message_callback(const std::function& callback) { diff --git a/lib/ocpp/v16/charge_point_impl.cpp b/lib/ocpp/v16/charge_point_impl.cpp index 26c7a8bff..b4b2fbf89 100644 --- a/lib/ocpp/v16/charge_point_impl.cpp +++ b/lib/ocpp/v16/charge_point_impl.cpp @@ -153,26 +153,27 @@ void ChargePointImpl::init_websocket() { this->message_queue->resume(); // this->connected_callback(); // }); - this->websocket->register_closed_callback([this](const websocketpp::close::status::value reason, const bool doFull) { - if (this->connection_state_changed_callback != nullptr) { - this->connection_state_changed_callback(false); - } - if (doFull) { - this->message_queue->pause(); // - if (this->ocsp_request_timer != nullptr) { - this->ocsp_request_timer->stop(); - } - if (this->switch_security_profile_callback != nullptr) { - this->switch_security_profile_callback(); + this->websocket->register_closed_callback( + [this](const websocketpp::close::status::value reason, const bool doFull) { + if (this->connection_state_changed_callback != nullptr) { + this->connection_state_changed_callback(false); } - if (this->client_certificate_timer != nullptr) { - this->client_certificate_timer->stop(); - } - if (this->v2g_certificate_timer != nullptr) { - this->v2g_certificate_timer->stop(); + if (doFull) { + this->message_queue->pause(); // + if (this->ocsp_request_timer != nullptr) { + this->ocsp_request_timer->stop(); + } + if (this->switch_security_profile_callback != nullptr) { + this->switch_security_profile_callback(); + } + if (this->client_certificate_timer != nullptr) { + this->client_certificate_timer->stop(); + } + if (this->v2g_certificate_timer != nullptr) { + this->v2g_certificate_timer->stop(); + } } - } - }); + }); this->websocket->register_message_callback([this](const std::string& message) { this->message_callback(message); }); } diff --git a/lib/ocpp/v201/charge_point.cpp b/lib/ocpp/v201/charge_point.cpp index 2c4e49009..5c4c54366 100644 --- a/lib/ocpp/v201/charge_point.cpp +++ b/lib/ocpp/v201/charge_point.cpp @@ -576,44 +576,44 @@ void ChargePoint::init_websocket() { this->time_disconnected = std::chrono::time_point(); }); - this->websocket->register_closed_callback( - [this, connection_options, configuration_slot](const websocketpp::close::status::value reason, const bool doFull) { - EVLOG_warning << "Failed to connect to NetworkConfigurationPriority: " - << this->network_configuration_priority + 1 - << " which is configurationSlot: " << configuration_slot; - this->websocket_connection_status = WebsocketConnectionStatusEnum::Disconnected; - this->message_queue->pause(); - - // check if offline threshold has been defined - if (this->device_model->get_value(ControllerComponentVariables::OfflineThreshold) != 0) { - // get the status of all the connectors - for (auto const& [evse_id, evse] : this->evses) { - int number_of_connectors = evse->get_number_of_connectors(); - EvseConnectorPair conn_states_struct_key; - EVLOG_debug << "evseId: " << evse_id << " numConn: " << number_of_connectors; - for (int connector_id = 1; connector_id <= number_of_connectors; connector_id++) { - conn_states_struct_key.evse_id = evse_id; - conn_states_struct_key.connector_id = connector_id; - conn_state_per_evse[conn_states_struct_key] = evse->get_state(connector_id); - EVLOG_debug << "conn_id: " << conn_states_struct_key.connector_id - << " State: " << conn_state_per_evse[conn_states_struct_key]; - } + this->websocket->register_closed_callback([this, connection_options, configuration_slot]( + const websocketpp::close::status::value reason, const bool doFull) { + EVLOG_warning << "Failed to connect to NetworkConfigurationPriority: " + << this->network_configuration_priority + 1 + << " which is configurationSlot: " << configuration_slot; + this->websocket_connection_status = WebsocketConnectionStatusEnum::Disconnected; + this->message_queue->pause(); + + // check if offline threshold has been defined + if (this->device_model->get_value(ControllerComponentVariables::OfflineThreshold) != 0) { + // get the status of all the connectors + for (auto const& [evse_id, evse] : this->evses) { + int number_of_connectors = evse->get_number_of_connectors(); + EvseConnectorPair conn_states_struct_key; + EVLOG_debug << "evseId: " << evse_id << " numConn: " << number_of_connectors; + for (int connector_id = 1; connector_id <= number_of_connectors; connector_id++) { + conn_states_struct_key.evse_id = evse_id; + conn_states_struct_key.connector_id = connector_id; + conn_state_per_evse[conn_states_struct_key] = evse->get_state(connector_id); + EVLOG_debug << "conn_id: " << conn_states_struct_key.connector_id + << " State: " << conn_state_per_evse[conn_states_struct_key]; } - // Get the current time point using steady_clock - this->time_disconnected = std::chrono::steady_clock::now(); } + // Get the current time point using steady_clock + this->time_disconnected = std::chrono::steady_clock::now(); + } - if (!this->disable_automatic_websocket_reconnects) { - this->websocket_timer.timeout( - [this, reason]() { - if (reason != websocketpp::close::status::service_restart) { - this->next_network_configuration_priority(); - } - this->start_websocket(); - }, - WEBSOCKET_INIT_DELAY); - } - }); + if (!this->disable_automatic_websocket_reconnects) { + this->websocket_timer.timeout( + [this, reason]() { + if (reason != websocketpp::close::status::service_restart) { + this->next_network_configuration_priority(); + } + this->start_websocket(); + }, + WEBSOCKET_INIT_DELAY); + } + }); this->websocket->register_message_callback([this](const std::string& message) { this->message_callback(message); }); }