Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send CALLERROR only as response to CALL message #995

Merged
merged 2 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/ocpp/v16/charge_point_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1356,18 +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
Copy link
Contributor

@maaikez maaikez Feb 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also no security event notification?

}
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();
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);
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);
}
}

Expand Down
15 changes: 15 additions & 0 deletions lib/ocpp/v2/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,22 +781,37 @@ void ChargePoint::message_callback(const std::string& message) {
}
} catch (const EvseOutOfRangeException& e) {
EVLOG_error << "Exception during handling of message: " << e.what();
if (enhanced_message.messageTypeId != MessageTypeId::CALL) {
return; // CALLERROR shall only follow on a CALL message
}
auto call_error = CallError(enhanced_message.uniqueId, "OccurrenceConstraintViolation", e.what(), json({}));
this->message_dispatcher->dispatch_call_error(call_error);
} catch (const ConnectorOutOfRangeException& e) {
EVLOG_error << "Exception during handling of message: " << e.what();
if (enhanced_message.messageTypeId != MessageTypeId::CALL) {
return; // CALLERROR shall only follow on a CALL message
}
auto call_error = CallError(enhanced_message.uniqueId, "OccurrenceConstraintViolation", e.what(), json({}));
this->message_dispatcher->dispatch_call_error(call_error);
} catch (const EnumConversionException& e) {
EVLOG_error << "EnumConversionException during handling of message: " << e.what();
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({}));
this->message_dispatcher->dispatch_call_error(call_error);
} catch (const TimePointParseException& e) {
EVLOG_error << "Exception during handling of message: " << e.what();
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({}));
this->message_dispatcher->dispatch_call_error(call_error);
} catch (json::exception& e) {
EVLOG_error << "JSON exception during handling of message: " << e.what();
if (enhanced_message.messageTypeId != MessageTypeId::CALL) {
return; // CALLERROR shall only follow on a CALL message
}
if (json_message.is_array() and json_message.size() > MESSAGE_ID) {
auto call_error = CallError(enhanced_message.uniqueId, "FormationViolation", e.what(), json({}));
this->message_dispatcher->dispatch_call_error(call_error);
Expand Down