Skip to content

Commit 0037840

Browse files
committed
only send SecurityEventNotification.req if the DisableSecurityEventNotifications configuration key is false (which is the default)
Signed-off-by: pietfried <pietgoempel@gmail.com>
1 parent e147f27 commit 0037840

File tree

3 files changed

+21
-11
lines changed

3 files changed

+21
-11
lines changed

include/ocpp/common/message_queue.hpp

+14-7
Original file line numberDiff line numberDiff line change
@@ -430,18 +430,25 @@ template <typename M> class MessageQueue {
430430
MessageQueue(send_callback, config, {}, databaseHandler) {
431431
}
432432

433-
void get_transaction_messages_from_db() {
433+
void get_transaction_messages_from_db(bool ignore_security_event_notifications = false) {
434434
std::vector<ocpp::common::DBTransactionMessage> transaction_messages =
435435
database_handler->get_transaction_messages();
436436

437437
if (!transaction_messages.empty()) {
438438
for (auto& transaction_message : transaction_messages) {
439-
std::shared_ptr<ControlMessage<M>> message =
440-
std::make_shared<ControlMessage<M>>(transaction_message.json_message);
441-
message->messageType = string_to_messagetype(transaction_message.message_type);
442-
message->timestamp = transaction_message.timestamp;
443-
message->message_attempts = transaction_message.message_attempts;
444-
transaction_message_queue.push_back(message);
439+
440+
if (ignore_security_event_notifications &&
441+
transaction_message.message_type == "SecurityEventNotification") {
442+
// remove from database in case SecurityEventNotification.req should not be sent
443+
this->database_handler->remove_transaction_message(transaction_message.unique_id);
444+
} else {
445+
std::shared_ptr<ControlMessage<M>> message =
446+
std::make_shared<ControlMessage<M>>(transaction_message.json_message);
447+
message->messageType = string_to_messagetype(transaction_message.message_type);
448+
message->timestamp = transaction_message.timestamp;
449+
message->message_attempts = transaction_message.message_attempts;
450+
transaction_message_queue.push_back(message);
451+
}
445452
}
446453

447454
this->new_message = true;

include/ocpp/v16/charge_point_configuration.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ class ChargePointConfiguration {
335335
void setDisableSecurityEventNotifications(bool disable_security_event_notifications);
336336
KeyValue getDisableSecurityEventNotificationsKeyValue();
337337

338-
339338
// Local Auth List Management Profile
340339
bool getLocalAuthListEnabled();
341340
void setLocalAuthListEnabled(bool local_auth_list_enabled);

lib/ocpp/v16/charge_point_impl.cpp

+7-3
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,9 @@ void ChargePointImpl::handleBootNotificationResponse(ocpp::CallResult<BootNotifi
11851185
ocpp::DateTime());
11861186
}
11871187

1188-
this->message_queue->get_transaction_messages_from_db();
1188+
// push transaction messages including SecurityEventNotification.req onto the message queue
1189+
this->message_queue->get_transaction_messages_from_db(
1190+
this->configuration->getDisableSecurityEventNotifications());
11891191

11901192
if (this->is_pnc_enabled()) {
11911193
this->ocsp_request_timer->timeout(INITIAL_CERTIFICATE_REQUESTS_DELAY);
@@ -2377,8 +2379,10 @@ void ChargePointImpl::securityEventNotification(const std::string& type, const s
23772379

23782380
this->logging->security(json(req).dump());
23792381

2380-
ocpp::Call<SecurityEventNotificationRequest> call(req, this->message_queue->createMessageId());
2381-
this->send<SecurityEventNotificationRequest>(call);
2382+
if (!this->configuration->getDisableSecurityEventNotifications()) {
2383+
ocpp::Call<SecurityEventNotificationRequest> call(req, this->message_queue->createMessageId());
2384+
this->send<SecurityEventNotificationRequest>(call);
2385+
}
23822386

23832387
if (triggered_internally and this->security_event_callback != nullptr) {
23842388
this->security_event_callback(type, tech_info);

0 commit comments

Comments
 (0)