Skip to content

Commit

Permalink
OCPP1.6: Pending transactions at startup (EVerest#610)
Browse files Browse the repository at this point in the history
* stopping pending transactions in start function
* allowing to queue transaction related messages before BootNotification.conf(Accepted) has been received
---------

Signed-off-by: pietfried <[email protected]>
Signed-off-by: Daniel Moore <[email protected]>
  • Loading branch information
Pietfried authored and drmrd committed Jun 4, 2024
1 parent f37a941 commit 5ef8400
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
15 changes: 15 additions & 0 deletions include/ocpp/v16/utils.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2020 - 2024 Pionix GmbH and Contributors to EVerest

#include <ocpp/v16/types.hpp>

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
14 changes: 6 additions & 8 deletions lib/ocpp/v16/charge_point_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <ocpp/v16/charge_point.hpp>
#include <ocpp/v16/charge_point_configuration.hpp>
#include <ocpp/v16/charge_point_impl.hpp>
#include <ocpp/v16/utils.hpp>
#include <ocpp/v201/utils.hpp>

#include <optional>
Expand Down Expand Up @@ -821,6 +822,9 @@ bool ChargePointImpl::start(const std::map<int, ChargePointStatus>& 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();

Expand Down Expand Up @@ -1249,10 +1253,6 @@ void ChargePointImpl::handleBootNotificationResponse(ocpp::CallResult<BootNotifi
ocpp::DateTime());
}

// push transaction messages including SecurityEventNotification.req onto the message queue
this->message_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);
Expand All @@ -1267,8 +1267,6 @@ void ChargePointImpl::handleBootNotificationResponse(ocpp::CallResult<BootNotifi
this->ocsp_request_timer->timeout(INITIAL_CERTIFICATE_REQUESTS_DELAY);
}

this->stop_pending_transactions();

break;
}
case RegistrationStatus::Pending:
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5ef8400

Please sign in to comment.