diff --git a/lib/everest/ocpp/include/ocpp/common/message_queue.hpp b/lib/everest/ocpp/include/ocpp/common/message_queue.hpp index 046ca2a8c3..fccbbca455 100644 --- a/lib/everest/ocpp/include/ocpp/common/message_queue.hpp +++ b/lib/everest/ocpp/include/ocpp/common/message_queue.hpp @@ -525,7 +525,6 @@ template class MessageQueue { } if (!this->send_callback(this->in_flight->message)) { - this->paused = true; EVLOG_error << "Could not send message, this is most likely because the charge point is offline."; if (this->in_flight && is_transaction_message(*this->in_flight)) { EVLOG_info << "The message in flight is transaction related and will be sent again once the " diff --git a/lib/everest/ocpp/include/ocpp/common/websocket/websocket_base.hpp b/lib/everest/ocpp/include/ocpp/common/websocket/websocket_base.hpp index 309e91305e..10bece16a2 100644 --- a/lib/everest/ocpp/include/ocpp/common/websocket/websocket_base.hpp +++ b/lib/everest/ocpp/include/ocpp/common/websocket/websocket_base.hpp @@ -20,6 +20,7 @@ struct WebsocketConnectionOptions { Uri csms_uri; // the URI of the CSMS int security_profile; // FIXME: change type to `SecurityProfile` std::optional authorization_key; + std::chrono::milliseconds message_timeout; int retry_backoff_random_range_s; int retry_backoff_repeat_times; int retry_backoff_wait_minimum_s; diff --git a/lib/everest/ocpp/lib/ocpp/common/websocket/websocket_libwebsockets.cpp b/lib/everest/ocpp/lib/ocpp/common/websocket/websocket_libwebsockets.cpp index c7face2d9d..8cad76278b 100644 --- a/lib/everest/ocpp/lib/ocpp/common/websocket/websocket_libwebsockets.cpp +++ b/lib/everest/ocpp/lib/ocpp/common/websocket/websocket_libwebsockets.cpp @@ -73,9 +73,6 @@ enum class EConnectionState { /// \brief Message to return in the callback to close the socket connection static constexpr int LWS_CLOSE_SOCKET_RESPONSE_MESSAGE = -1; -/// \brief How much we wait for a message to be sent in seconds -static constexpr int MESSAGE_SEND_TIMEOUT_S = 1; - /// \brief Current connection data, sets the internal state of the struct ConnectionData { explicit ConnectionData(WebsocketLibwebsockets* owner) : @@ -1153,7 +1150,7 @@ void WebsocketLibwebsockets::poll_message(const std::shared_ptrmessage_sent); }, - std::chrono::seconds(MESSAGE_SEND_TIMEOUT_S)); + this->connection_options.message_timeout); if (msg->message_sent) { EVLOG_debug << "Successfully sent last message!"; diff --git a/lib/everest/ocpp/lib/ocpp/v16/charge_point_impl.cpp b/lib/everest/ocpp/lib/ocpp/v16/charge_point_impl.cpp index 4eee46dcb6..67c1989f64 100644 --- a/lib/everest/ocpp/lib/ocpp/v16/charge_point_impl.cpp +++ b/lib/everest/ocpp/lib/ocpp/v16/charge_point_impl.cpp @@ -404,6 +404,7 @@ WebsocketConnectionOptions ChargePointImpl::get_ws_connection_options() { uri, security_profile, this->configuration->getAuthorizationKey(), + std::chrono::seconds(10), this->configuration->getRetryBackoffRandomRange(), this->configuration->getRetryBackoffRepeatTimes(), this->configuration->getRetryBackoffWaitMinimum(), diff --git a/lib/everest/ocpp/lib/ocpp/v2/charge_point.cpp b/lib/everest/ocpp/lib/ocpp/v2/charge_point.cpp index f83e69308b..d11ac430d1 100644 --- a/lib/everest/ocpp/lib/ocpp/v2/charge_point.cpp +++ b/lib/everest/ocpp/lib/ocpp/v2/charge_point.cpp @@ -1082,6 +1082,7 @@ std::optional ChargePoint::data_transfer_req(const DataTra void ChargePoint::websocket_connected_callback(const int configuration_slot, const NetworkConnectionProfile& network_connection_profile, const OcppProtocolVersion ocpp_version) { + this->message_queue->update_message_timeout(network_connection_profile.messageTimeout); this->message_queue->resume(this->message_queue_resume_delay); this->ocpp_version = ocpp_version; if (this->registration_status == RegistrationStatusEnum::Accepted) { diff --git a/lib/everest/ocpp/lib/ocpp/v2/connectivity_manager.cpp b/lib/everest/ocpp/lib/ocpp/v2/connectivity_manager.cpp index 573539fec8..ef74c7cf0f 100644 --- a/lib/everest/ocpp/lib/ocpp/v2/connectivity_manager.cpp +++ b/lib/everest/ocpp/lib/ocpp/v2/connectivity_manager.cpp @@ -342,10 +342,10 @@ ConnectivityManager::get_ws_connection_options(const std::int32_t configuration_ this->device_model.get_value(ControllerComponentVariables::SupportedOcppVersions)); WebsocketConnectionOptions connection_options{ - ocpp_versions, - uri, - network_connection_profile.securityProfile, + ocpp_versions, uri, network_connection_profile.securityProfile, this->device_model.get_optional_value(ControllerComponentVariables::BasicAuthPassword), + // Always use a minimum of 1 second otherwise each message would timeout immediately + std::chrono::seconds(std::max(network_connection_profile.messageTimeout, 1)), this->device_model.get_value(ControllerComponentVariables::RetryBackOffRandomRange), this->device_model.get_value(ControllerComponentVariables::RetryBackOffRepeatTimes), this->device_model.get_value(ControllerComponentVariables::RetryBackOffWaitMinimum), diff --git a/lib/everest/ocpp/lib/ocpp/v2/functional_blocks/provisioning.cpp b/lib/everest/ocpp/lib/ocpp/v2/functional_blocks/provisioning.cpp index c6f005d94f..1ed5b4237c 100644 --- a/lib/everest/ocpp/lib/ocpp/v2/functional_blocks/provisioning.cpp +++ b/lib/everest/ocpp/lib/ocpp/v2/functional_blocks/provisioning.cpp @@ -585,13 +585,6 @@ void Provisioning::handle_variable_changed(const SetVariableData& set_variable_d } } - if (component_variable == ControllerComponentVariables::MessageTimeout) { - if (component_variable.variable.has_value()) { - this->message_queue.update_message_timeout( - this->context.device_model.get_value(ControllerComponentVariables::MessageTimeout)); - } - } - // TODO(piet): other special handling of changed variables can be added here... }