diff --git a/include/ocpp/v16/utils.hpp b/include/ocpp/v16/utils.hpp new file mode 100644 index 000000000..5b85ba62e --- /dev/null +++ b/include/ocpp/v16/utils.hpp @@ -0,0 +1,15 @@ +// SPDX-License-Identifier: Apache-2.0 +// Copyright 2020 - 2024 Pionix GmbH and Contributors to EVerest + +#include + +namespace ocpp { +namespace v16 { +namespace utils { +bool is_transaction_message_type(const MessageType& message_type) { + return message_type == MessageType::StartTransaction or message_type == MessageType::StopTransaction or + message_type == MessageType::MeterValues or message_type == MessageType::SecurityEventNotification; +} +} // namespace utils +} // namespace v16 +} // namespace ocpp diff --git a/lib/ocpp/v16/charge_point_impl.cpp b/lib/ocpp/v16/charge_point_impl.cpp index beae01243..1b2d5542c 100644 --- a/lib/ocpp/v16/charge_point_impl.cpp +++ b/lib/ocpp/v16/charge_point_impl.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -821,6 +822,9 @@ bool ChargePointImpl::start(const std::map& connector_st this->init_websocket(); this->websocket->connect(); this->boot_notification(); + // push transaction messages including SecurityEventNotification.req onto the message queue + this->message_queue->get_transaction_messages_from_db(this->configuration->getDisableSecurityEventNotifications()); + this->stop_pending_transactions(); this->load_charging_profiles(); this->call_set_connection_timeout(); @@ -1249,10 +1253,6 @@ void ChargePointImpl::handleBootNotificationResponse(ocpp::CallResultmessage_queue->get_transaction_messages_from_db( - this->configuration->getDisableSecurityEventNotifications()); - if (this->is_pnc_enabled()) { this->ocsp_request_timer->timeout(INITIAL_CERTIFICATE_REQUESTS_DELAY); this->v2g_certificate_timer->timeout(INITIAL_CERTIFICATE_REQUESTS_DELAY); @@ -1267,8 +1267,6 @@ void ChargePointImpl::handleBootNotificationResponse(ocpp::CallResultocsp_request_timer->timeout(INITIAL_CERTIFICATE_REQUESTS_DELAY); } - this->stop_pending_transactions(); - break; } case RegistrationStatus::Pending: @@ -2601,8 +2599,8 @@ bool ChargePointImpl::allowed_to_send_message(json::array_t message, bool initia } if (!this->initialized) { - // BootNotification and StopTransaction messages can be queued before receiving a BootNotification.conf - if (message_type == MessageType::BootNotification || message_type == MessageType::StopTransaction) { + // BootNotification and transaction related messages can be queued before receiving a BootNotification.conf + if (message_type == MessageType::BootNotification or utils::is_transaction_message_type(message_type)) { return true; } return false;