diff --git a/include/ocpp/v201/charge_point.hpp b/include/ocpp/v201/charge_point.hpp index 07f0f7d316..23746eafc7 100644 --- a/include/ocpp/v201/charge_point.hpp +++ b/include/ocpp/v201/charge_point.hpp @@ -97,13 +97,8 @@ struct Callbacks { configure_network_connection_profile_callback; std::optional> time_sync_callback; - - enum class OcppMessageDirection { - CSMSToChargingStation, - ChargingStationToCSMS - }; /// @brief callback to be called to congigure ocpp message logging - std::optional> ocpp_messages_callback; + std::optional> ocpp_messages_callback; }; /// \brief Class implements OCPP2.0.1 Charging Station @@ -178,7 +173,6 @@ class ChargePoint : ocpp::ChargingStationBase { template bool send(CallResult call_result); bool send(CallError call_error); bool send(json message); - std::function ocpp_message_callback; // internal helper functions void init_websocket(); diff --git a/include/ocpp/v201/types.hpp b/include/ocpp/v201/types.hpp index 1012a7ea02..8987c99a18 100644 --- a/include/ocpp/v201/types.hpp +++ b/include/ocpp/v201/types.hpp @@ -177,6 +177,11 @@ WebsocketConnectionStatusEnum string_to_websocket_connection_status(const std::s /// \returns an output stream with the WebsocketConnectionStatusEnum written to std::ostream& operator<<(std::ostream& os, const WebsocketConnectionStatusEnum& websocket_connection_status); +enum class MessageDirection { + CSMSToChargingStation, + ChargingStationToCSMS +}; + } // namespace v201 } // namespace ocpp diff --git a/lib/ocpp/common/websocket/websocket.cpp b/lib/ocpp/common/websocket/websocket.cpp index a1c382885b..8ddcb81691 100644 --- a/lib/ocpp/common/websocket/websocket.cpp +++ b/lib/ocpp/common/websocket/websocket.cpp @@ -73,11 +73,6 @@ void Websocket::register_message_callback(const std::functionwebsocket->register_message_callback([this](const std::string& message) { this->message_callback(message); }); } -void Websocket::register_ocpp_message_callback(const std::function& callback){ - this->ocpp_message_callback = callback; - // this->websocket->register_ocpp_message_callback([this](const std::string& message) { this->ocpp_message_callback(message); }); -} - bool Websocket::send(const std::string& message) { this->logging->charge_point("Unknown", message); return this->websocket->send(message); diff --git a/lib/ocpp/v201/charge_point.cpp b/lib/ocpp/v201/charge_point.cpp index e98fb9f909..71dae73caa 100644 --- a/lib/ocpp/v201/charge_point.cpp +++ b/lib/ocpp/v201/charge_point.cpp @@ -449,18 +449,17 @@ template std::future> ChargePoint:: } template bool ChargePoint::send(ocpp::CallResult call_result) { - return send(json(call_result)); + return this->send(json(call_result)); } bool ChargePoint::send(CallError call_error) { - return send(json(call_error)); + return this->send(json(call_error)); } bool ChargePoint::send(json message) { const auto stringified = json(message).dump(); if (this->callbacks.ocpp_messages_callback.has_value()) { - this->callbacks.ocpp_messages_callback.value()(stringified, - Callbacks::OcppMessageDirection::ChargingStationToCSMS); + this->callbacks.ocpp_messages_callback.value()(stringified, MessageDirection::ChargingStationToCSMS); } return this->websocket->send(stringified); } @@ -709,7 +708,7 @@ void ChargePoint::message_callback(const std::string& message) { auto json_message = enhanced_message.message; this->logging->central_system(conversions::messagetype_to_string(enhanced_message.messageType), message); if (this->callbacks.ocpp_messages_callback.has_value()) { - this->callbacks.ocpp_messages_callback.value()(message, Callbacks::OcppMessageDirection::CSMSToChargingStation); + this->callbacks.ocpp_messages_callback.value()(message, MessageDirection::CSMSToChargingStation); } try {