Skip to content

Commit

Permalink
Moved SecurityEventNotification up so that it is logged in case a mes…
Browse files Browse the repository at this point in the history
…sage cant be handled

Signed-off-by: Piet Gömpel <[email protected]>
  • Loading branch information
Pietfried committed Feb 25, 2025
1 parent a37e8e6 commit ee91265
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/ocpp/v16/charge_point_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1356,24 +1356,24 @@ void ChargePointImpl::message_callback(const std::string& message) {
}
} catch (json::exception& e) {
EVLOG_error << "JSON exception during handling of message: " << e.what();
this->securityEventNotification(ocpp::security_events::INVALIDMESSAGES, std::optional<CiString<255>>(message),
true);
if (enhanced_message.messageTypeId != MessageTypeId::CALL) {
return; // CALLERROR shall only follow on a CALL message
}
if (json_message.is_array() && json_message.size() > MESSAGE_ID) {
auto call_error = CallError(enhanced_message.uniqueId, "FormationViolation", e.what(), json({}, true));
this->message_dispatcher->dispatch_call_error(call_error);
this->securityEventNotification(ocpp::security_events::INVALIDMESSAGES,
std::optional<CiString<255>>(message), true);
}
} catch (const EnumConversionException& e) {
EVLOG_error << "EnumConversionException during handling of message: " << e.what();
this->securityEventNotification(ocpp::security_events::INVALIDMESSAGES, std::optional<CiString<255>>(message),
true);
if (enhanced_message.messageTypeId != MessageTypeId::CALL) {
return; // CALLERROR shall only follow on a CALL message
}
auto call_error = CallError(enhanced_message.uniqueId, "FormationViolation", e.what(), json({}, true));
this->message_dispatcher->dispatch_call_error(call_error);
this->securityEventNotification(ocpp::security_events::INVALIDMESSAGES, std::optional<CiString<255>>(message),
true);
}
}

Expand Down

0 comments on commit ee91265

Please sign in to comment.