Skip to content

Commit ee91265

Browse files
committed
Moved SecurityEventNotification up so that it is logged in case a message cant be handled
Signed-off-by: Piet Gömpel <pietgoempel@gmail.com>
1 parent a37e8e6 commit ee91265

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/ocpp/v16/charge_point_impl.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1356,24 +1356,24 @@ void ChargePointImpl::message_callback(const std::string& message) {
13561356
}
13571357
} catch (json::exception& e) {
13581358
EVLOG_error << "JSON exception during handling of message: " << e.what();
1359+
this->securityEventNotification(ocpp::security_events::INVALIDMESSAGES, std::optional<CiString<255>>(message),
1360+
true);
13591361
if (enhanced_message.messageTypeId != MessageTypeId::CALL) {
13601362
return; // CALLERROR shall only follow on a CALL message
13611363
}
13621364
if (json_message.is_array() && json_message.size() > MESSAGE_ID) {
13631365
auto call_error = CallError(enhanced_message.uniqueId, "FormationViolation", e.what(), json({}, true));
13641366
this->message_dispatcher->dispatch_call_error(call_error);
1365-
this->securityEventNotification(ocpp::security_events::INVALIDMESSAGES,
1366-
std::optional<CiString<255>>(message), true);
13671367
}
13681368
} catch (const EnumConversionException& e) {
13691369
EVLOG_error << "EnumConversionException during handling of message: " << e.what();
1370+
this->securityEventNotification(ocpp::security_events::INVALIDMESSAGES, std::optional<CiString<255>>(message),
1371+
true);
13701372
if (enhanced_message.messageTypeId != MessageTypeId::CALL) {
13711373
return; // CALLERROR shall only follow on a CALL message
13721374
}
13731375
auto call_error = CallError(enhanced_message.uniqueId, "FormationViolation", e.what(), json({}, true));
13741376
this->message_dispatcher->dispatch_call_error(call_error);
1375-
this->securityEventNotification(ocpp::security_events::INVALIDMESSAGES, std::optional<CiString<255>>(message),
1376-
true);
13771377
}
13781378
}
13791379

0 commit comments

Comments
 (0)