From 350430f137986a98354021cc04eef17c9e858f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piet=20G=C3=B6mpel?= <37657534+Pietfried@users.noreply.github.com> Date: Tue, 19 Nov 2024 09:04:32 +0100 Subject: [PATCH] Moved functionality to create message id from message_queue to call_types and made it a free function. Removed unused imports and usage of boost/uuid headers (#869) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Piet Gömpel --- include/ocpp/common/call_types.hpp | 12 ++++- include/ocpp/common/charging_station_base.hpp | 6 --- include/ocpp/common/message_queue.hpp | 20 ++------ include/ocpp/v16/transaction.hpp | 4 -- include/ocpp/v201/charge_point.hpp | 3 +- lib/ocpp/common/call_types.cpp | 12 +++++ lib/ocpp/common/charging_station_base.cpp | 9 +--- lib/ocpp/v16/charge_point_impl.cpp | 36 +++++++------- lib/ocpp/v201/charge_point.cpp | 49 +++++++++---------- tests/lib/ocpp/v16/test_message_queue.cpp | 34 ++++++------- tests/lib/ocpp/v201/test_charge_point.cpp | 2 +- tests/lib/ocpp/v201/test_message_queue.cpp | 12 ++--- 12 files changed, 93 insertions(+), 106 deletions(-) diff --git a/include/ocpp/common/call_types.hpp b/include/ocpp/common/call_types.hpp index 4d547e341..18b93fd7f 100644 --- a/include/ocpp/common/call_types.hpp +++ b/include/ocpp/common/call_types.hpp @@ -52,6 +52,10 @@ enum class MessageTypeId { UNKNOWN, }; +/// \brief Creates a unique message ID +/// \returns the unique message ID +MessageId create_message_id(); + /// \brief Contains a OCPP Call message template struct Call { T msg; @@ -61,7 +65,13 @@ template struct Call { Call() { } - /// \brief Creates a new Call message object with the given OCPP message \p msg and \p uniqueID + /// \brief Creates a new Call message object with the given OCPP message \p msg + explicit Call(T msg) { + this->msg = msg; + this->uniqueId = create_message_id(); + } + + /// \brief Creates a new Call message object with the given OCPP message \p msg and \p uniqueId Call(T msg, MessageId uniqueId) { this->msg = msg; this->uniqueId = uniqueId; diff --git a/include/ocpp/common/charging_station_base.hpp b/include/ocpp/common/charging_station_base.hpp index c52d99645..adeba297f 100644 --- a/include/ocpp/common/charging_station_base.hpp +++ b/include/ocpp/common/charging_station_base.hpp @@ -23,12 +23,6 @@ class ChargingStationBase { boost::asio::io_service io_service; std::thread io_service_thread; - boost::uuids::random_generator uuid_generator; - - /// \brief Generates a uuid - /// \return uuid - std::string uuid(); - public: /// \brief Constructor for ChargingStationBase /// \param evse_security Pointer to evse_security that manages security related operations; if nullptr diff --git a/include/ocpp/common/message_queue.hpp b/include/ocpp/common/message_queue.hpp index 63dc0e59c..d5726976d 100644 --- a/include/ocpp/common/message_queue.hpp +++ b/include/ocpp/common/message_queue.hpp @@ -12,10 +12,6 @@ #include #include -#include -#include -#include - #include #include @@ -186,7 +182,6 @@ template class MessageQueue { bool running; bool new_message; bool is_registration_status_accepted; - boost::uuids::random_generator uuid_generator; std::recursive_mutex next_message_mutex; std::optional next_message_to_send; @@ -405,7 +400,6 @@ template class MessageQueue { running(true), new_message(false), is_registration_status_accepted(false), - uuid_generator(boost::uuids::random_generator()), start_transaction_message_retry_callback(start_transaction_message_retry_callback) { this->send_callback = send_callback; @@ -641,7 +635,7 @@ template class MessageQueue { // MeterValues have to be delivered in chronological order // intentionally break this message for testing... - // message->message[CALL_PAYLOAD]["broken"] = this->createMessageId(); + // message->message[CALL_PAYLOAD]["broken"] = ocpp::create_message_id(); this->add_to_transaction_message_queue(control_message); } else { // all other messages are allowed to "jump the queue" to improve user experience @@ -833,7 +827,7 @@ template class MessageQueue { EVLOG_warning << "Message shall be persisted and will therefore be sent again"; // Generate a new message ID for the retry const auto old_message_id = this->in_flight->message[MESSAGE_ID]; - this->in_flight->message[MESSAGE_ID] = this->createMessageId(); + this->in_flight->message[MESSAGE_ID] = ocpp::create_message_id(); if (this->config.transaction_message_retry_interval > 0) { // exponential backoff this->in_flight->timestamp = @@ -890,7 +884,7 @@ template class MessageQueue { } else if (is_boot_notification_message(this->in_flight->messageType)) { EVLOG_warning << "Message is BootNotification.req and will therefore be sent again"; // Generate a new message ID for the retry - this->in_flight->message[MESSAGE_ID] = this->createMessageId(); + this->in_flight->message[MESSAGE_ID] = ocpp::create_message_id(); // Spec does not define how to handle retries for BootNotification.req: We use the // the boot_notification_retry_interval_seconds this->in_flight->timestamp = @@ -1013,14 +1007,6 @@ template class MessageQueue { this->config.message_timeout_seconds = timeout; } - /// \brief Creates a unique message ID - /// \returns the unique message ID - MessageId createMessageId() { - std::stringstream s; - s << this->uuid_generator(); - return MessageId(s.str()); - } - /// \brief Adds the given \p transaction_id to the message_id_transaction_id_map using the key \p /// stop_transaction_message_id void add_stopped_transaction_id(std::string stop_transaction_message_id, int32_t transaction_id) { diff --git a/include/ocpp/v16/transaction.hpp b/include/ocpp/v16/transaction.hpp index 0333a54d0..7fa935e07 100644 --- a/include/ocpp/v16/transaction.hpp +++ b/include/ocpp/v16/transaction.hpp @@ -10,10 +10,6 @@ #include #include -#include -#include -#include - namespace ocpp { namespace v16 { diff --git a/include/ocpp/v201/charge_point.hpp b/include/ocpp/v201/charge_point.hpp index bbdded89c..7e4980573 100644 --- a/include/ocpp/v201/charge_point.hpp +++ b/include/ocpp/v201/charge_point.hpp @@ -766,9 +766,8 @@ class ChargePoint : public ChargePointInterface, private ocpp::ChargingStationBa template std::function send_callback(MessageType expected_response_message_type) { return [this, expected_response_message_type](auto request) { - MessageId message_id = MessageId(to_string(this->uuid_generator())); const auto enhanced_response = - this->message_dispatcher->dispatch_call_async(ocpp::Call(request, message_id)).get(); + this->message_dispatcher->dispatch_call_async(ocpp::Call(request)).get(); if (enhanced_response.messageType != expected_response_message_type) { throw UnexpectedMessageTypeFromCSMS( std::string("Got unexpected message type from CSMS, expected: ") + diff --git a/lib/ocpp/common/call_types.cpp b/lib/ocpp/common/call_types.cpp index 5877fdaaa..20b7eaf4b 100644 --- a/lib/ocpp/common/call_types.cpp +++ b/lib/ocpp/common/call_types.cpp @@ -3,8 +3,20 @@ #include +#include +#include +#include + namespace ocpp { +MessageId create_message_id() { + static boost::uuids::random_generator uuid_generator; + boost::uuids::uuid uuid = uuid_generator(); + std::stringstream s; + s << uuid; + return MessageId(s.str()); +} + bool operator<(const MessageId& lhs, const MessageId& rhs) { return lhs.get() < rhs.get(); } diff --git a/lib/ocpp/common/charging_station_base.cpp b/lib/ocpp/common/charging_station_base.cpp index 8da84cfcf..8fa1289d4 100644 --- a/lib/ocpp/common/charging_station_base.cpp +++ b/lib/ocpp/common/charging_station_base.cpp @@ -6,8 +6,7 @@ namespace ocpp { ChargingStationBase::ChargingStationBase(const std::shared_ptr evse_security, - const std::optional security_configuration) : - uuid_generator(boost::uuids::random_generator()) { + const std::optional security_configuration) { if (evse_security != nullptr) { this->evse_security = evse_security; @@ -28,10 +27,4 @@ ChargingStationBase::~ChargingStationBase() { io_service_thread.join(); } -std::string ChargingStationBase::uuid() { - std::stringstream s; - s << this->uuid_generator(); - return s.str(); -} - } // namespace ocpp diff --git a/lib/ocpp/v16/charge_point_impl.cpp b/lib/ocpp/v16/charge_point_impl.cpp index 0c9501f69..b7f06c545 100644 --- a/lib/ocpp/v16/charge_point_impl.cpp +++ b/lib/ocpp/v16/charge_point_impl.cpp @@ -418,7 +418,7 @@ void ChargePointImpl::heartbeat(bool initiated_by_trigger_message) { EVLOG_debug << "Sending heartbeat"; HeartbeatRequest req; - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call, initiated_by_trigger_message); } @@ -435,7 +435,7 @@ void ChargePointImpl::boot_notification(bool initiated_by_trigger_message) { req.meterSerialNumber = this->configuration->getMeterSerialNumber(); req.meterType = this->configuration->getMeterType(); - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call, initiated_by_trigger_message); } @@ -953,7 +953,7 @@ void ChargePointImpl::send_meter_value(int32_t connector, MeterValue meter_value } MeterValuesRequest req; - const auto message_id = this->message_queue->createMessageId(); + const auto message_id = ocpp::create_message_id(); // connector = 0 designates the main measurement // connector > 0 designates a connector of the charge point req.connectorId = connector; @@ -2618,7 +2618,7 @@ void ChargePointImpl::sign_certificate(const ocpp::CertificateSigningUseEnum& ce req.csr = response.csr.value(); - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call, initiated_by_trigger_message); } @@ -2817,7 +2817,7 @@ void ChargePointImpl::securityEventNotification(const CiString<50>& event_type, } if (critical_security_event and !this->configuration->getDisableSecurityEventNotifications()) { - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call); } @@ -2838,7 +2838,7 @@ void ChargePointImpl::log_status_notification(UploadLogStatusEnumType status, in this->log_status = status; this->log_status_request_id = requestId; - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call, initiated_by_trigger_message); } @@ -2865,7 +2865,7 @@ void ChargePointImpl::signed_firmware_update_status_notification(FirmwareStatusE this->signed_firmware_status = status; this->signed_firmware_status_request_id = requestId; - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call, initiated_by_trigger_message); if (status == FirmwareStatusEnumType::InvalidSignature) { @@ -3234,7 +3234,7 @@ void ChargePointImpl::status_notification(const int32_t connector, const ChargeP request.info = info; request.vendorId = vendor_id; request.vendorErrorCode = vendor_error_code; - ocpp::Call call(request, this->message_queue->createMessageId()); + ocpp::Call call(request); this->message_dispatcher->dispatch_call(call, initiated_by_trigger_message); } @@ -3280,7 +3280,7 @@ IdTagInfo ChargePointImpl::authorize_id_token(CiString<20> idTag, const bool aut AuthorizeRequest req; req.idTag = idTag; - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); auto authorize_future = this->message_dispatcher->dispatch_call_async(call); @@ -3494,7 +3494,7 @@ ocpp::v201::AuthorizeResponse ChargePointImpl::data_transfer_pnc_authorize( req.data.emplace(json(authorize_req).dump()); // Send the DataTransfer(Authorize) to the CSMS - Call call(req, this->message_queue->createMessageId()); + Call call(req); auto authorize_future = this->message_dispatcher->dispatch_call_async(call); if (authorize_future.wait_for(DEFAULT_WAIT_FOR_FUTURE_TIMEOUT) == std::future_status::timeout) { @@ -3576,7 +3576,7 @@ void ChargePointImpl::data_transfer_pnc_sign_certificate() { csr_req.certificateType = ocpp::v201::CertificateSigningUseEnum::V2GCertificate; req.data.emplace(json(csr_req).dump()); - Call call(req, this->message_queue->createMessageId()); + Call call(req); this->message_dispatcher->dispatch_call(call); } @@ -3602,7 +3602,7 @@ void ChargePointImpl::data_transfer_pnc_get_15118_ev_certificate( req.data.emplace(json(cert_req).dump()); - Call call(req, this->message_queue->createMessageId()); + Call call(req); auto future = this->message_dispatcher->dispatch_call_async(call); if (future.wait_for(DEFAULT_WAIT_FOR_FUTURE_TIMEOUT) == std::future_status::timeout) { @@ -3652,7 +3652,7 @@ void ChargePointImpl::data_transfer_pnc_get_certificate_status(const ocpp::v201: req.data.emplace(json(cert_status_req).dump()); - Call call(req, this->message_queue->createMessageId()); + Call call(req); auto future = this->message_dispatcher->dispatch_call_async(call); if (future.wait_for(DEFAULT_WAIT_FOR_FUTURE_TIMEOUT) == std::future_status::timeout) { @@ -3907,7 +3907,7 @@ std::optional ChargePointImpl::data_transfer(const CiStrin DataTransferResponse response; response.status = DataTransferStatus::Rejected; - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); auto data_transfer_future = this->message_dispatcher->dispatch_call_async(call); if (this->websocket == nullptr or !this->websocket->is_connected()) { @@ -3987,7 +3987,7 @@ void ChargePointImpl::start_transaction(std::shared_ptr transaction req.idTag = transaction->get_id_tag(); req.meterStart = std::round(transaction->get_start_energy_wh()->energy_Wh); req.timestamp = transaction->get_start_energy_wh()->timestamp; - const auto message_id = this->message_queue->createMessageId(); + const auto message_id = ocpp::create_message_id(); try { this->database_handler->insert_transaction( @@ -4164,7 +4164,7 @@ void ChargePointImpl::stop_transaction(int32_t connector, Reason reason, std::op req.transactionData.emplace(transaction_data); } - auto message_id = this->message_queue->createMessageId(); + auto message_id = ocpp::create_message_id(); ocpp::Call call(req, message_id); const auto max_message_size = this->configuration->getMaxMessageSize(); @@ -4322,7 +4322,7 @@ void ChargePointImpl::diagnostic_status_notification(DiagnosticsStatus status, b req.status = status; this->diagnostics_status = status; - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call_async(call, true); } @@ -4344,7 +4344,7 @@ void ChargePointImpl::firmware_status_notification(FirmwareStatus status, bool i this->firmware_status = status; - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call_async(call, initiated_by_trigger_message); if (this->firmware_update_is_pending) { diff --git a/lib/ocpp/v201/charge_point.cpp b/lib/ocpp/v201/charge_point.cpp index 7c439b703..39ed7f358 100644 --- a/lib/ocpp/v201/charge_point.cpp +++ b/lib/ocpp/v201/charge_point.cpp @@ -203,7 +203,7 @@ void ChargePoint::on_firmware_update_status_notification(int32_t request_id, this->firmware_status_id = request_id; } - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call_async(call); if (req.status == FirmwareStatusEnum::Installed) { @@ -232,7 +232,7 @@ void ChargePoint::on_firmware_update_status_notification(int32_t request_id, if (transaction_active) { this->firmware_status = FirmwareStatusEnum::InstallScheduled; req.status = firmware_status; - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call_async(call); } this->change_all_connectors_to_unavailable_for_firmware_update(); @@ -258,8 +258,7 @@ ChargePoint::on_get_15118_ev_certificate_request(const Get15118EVCertificateRequ } EVLOG_debug << "Received Get15118EVCertificateRequest " << request; - auto future_res = this->message_dispatcher->dispatch_call_async( - ocpp::Call(request, this->message_queue->createMessageId())); + auto future_res = this->message_dispatcher->dispatch_call_async(ocpp::Call(request)); if (future_res.wait_for(DEFAULT_WAIT_FOR_FUTURE_TIMEOUT) == std::future_status::timeout) { EVLOG_warning << "Waiting for Get15118EVCertificateRequest.conf future timed out!"; @@ -1039,7 +1038,7 @@ void ChargePoint::on_log_status_notification(UploadLogStatusEnum status, int32_t this->upload_log_status = status; this->upload_log_status_id = requestId; - ocpp::Call call(request, this->message_queue->createMessageId()); + ocpp::Call call(request); this->message_dispatcher->dispatch_call(call); } @@ -2016,7 +2015,7 @@ void ChargePoint::security_event_notification_req(const CiString<50>& event_type req.techInfo = tech_info; this->logging->security(json(req).dump()); if (critical) { - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call); } if (triggered_internally and this->callbacks.security_event_callback != nullptr) { @@ -2091,7 +2090,7 @@ void ChargePoint::sign_certificate_req(const ocpp::CertificateSigningUseEnum& ce this->awaited_certificate_signing_use_enum = certificate_signing_use; - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call, initiated_by_trigger_message); } @@ -2111,7 +2110,7 @@ void ChargePoint::boot_notification_req(const BootReasonEnum& reason, const bool req.reason = reason; req.chargingStation = charging_station; - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call, initiated_by_trigger_message); } @@ -2125,14 +2124,14 @@ void ChargePoint::notify_report_req(const int request_id, const std::vector call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call); } else { NotifyReportRequestsSplitter splitter{ req, this->device_model->get_optional_value(ControllerComponentVariables::MaxMessageSize) .value_or(DEFAULT_MAX_MESSAGE_SIZE), - [this]() { return this->message_queue->createMessageId(); }}; + [this]() { return ocpp::create_message_id(); }}; for (const auto& msg : splitter.create_call_payloads()) { this->message_queue->push_call(msg); } @@ -2153,7 +2152,7 @@ AuthorizeResponse ChargePoint::authorize_req(const IdToken id_token, const std:: return response; } - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); auto future = this->message_dispatcher->dispatch_call_async(call); if (future.wait_for(DEFAULT_WAIT_FOR_FUTURE_TIMEOUT) == std::future_status::timeout) { @@ -2186,7 +2185,7 @@ void ChargePoint::status_notification_req(const int32_t evse_id, const int32_t c req.timestamp = DateTime(); req.connectorStatus = status; - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call, initiated_by_trigger_message); } @@ -2194,7 +2193,7 @@ void ChargePoint::heartbeat_req(const bool initiated_by_trigger_message) { HeartbeatRequest req; heartbeat_request_time = std::chrono::steady_clock::now(); - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call, initiated_by_trigger_message); } @@ -2222,7 +2221,7 @@ void ChargePoint::transaction_event_req(const TransactionEventEnum& event_type, req.offline = offline; req.reservationId = reservation_id; - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); // Check if id token is in the remote start map, because when a remote // start request is done, the first transaction event request should @@ -2264,7 +2263,7 @@ void ChargePoint::meter_values_req(const int32_t evse_id, const std::vector call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call, initiated_by_trigger_message); } @@ -2278,12 +2277,12 @@ void ChargePoint::report_charging_profile_req(const int32_t request_id, const in req.chargingProfile = profiles; req.tbc = tbc; - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call); } void ChargePoint::report_charging_profile_req(const ReportChargingProfilesRequest& req) { - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call); } @@ -2293,7 +2292,7 @@ void ChargePoint::notify_event_req(const std::vector& events) { req.generatedAt = DateTime(); req.seqNo = 0; - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call); } @@ -2311,7 +2310,7 @@ void ChargePoint::notify_customer_information_req(const std::string& data, const return req; }(); - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call); pos += 512; @@ -3086,7 +3085,7 @@ void ChargePoint::handle_trigger_message(Call call) { request.status = UploadLogStatusEnum::Idle; } - ocpp::Call call(request, this->message_queue->createMessageId()); + ocpp::Call call(request); this->message_dispatcher->dispatch_call(call, true); } break; @@ -3105,7 +3104,7 @@ void ChargePoint::handle_trigger_message(Call call) { break; } - ocpp::Call call(request, this->message_queue->createMessageId()); + ocpp::Call call(request); this->message_dispatcher->dispatch_call(call, true); } break; @@ -3820,7 +3819,7 @@ void ChargePoint::notify_monitoring_report_req(const int request_id, req.monitor.emplace(montoring_data); req.tbc = false; - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call); } else { // Split for larger message sizes @@ -3846,7 +3845,7 @@ void ChargePoint::notify_monitoring_report_req(const int request_id, req.monitor = sub_data; - ocpp::Call call(req, this->message_queue->createMessageId()); + ocpp::Call call(req); this->message_dispatcher->dispatch_call(call); sequence_num++; @@ -3948,7 +3947,7 @@ void ChargePoint::handle_get_display_message(const Call request(messages_request, this->message_queue->createMessageId()); + ocpp::Call request(messages_request); this->message_dispatcher->dispatch_call(request); } @@ -4075,7 +4074,7 @@ std::optional ChargePoint::data_transfer_req(const DataTra DataTransferResponse response; response.status = DataTransferStatusEnum::Rejected; - ocpp::Call call(request, this->message_queue->createMessageId()); + ocpp::Call call(request); auto data_transfer_future = this->message_dispatcher->dispatch_call_async(call); if (this->connectivity_manager == nullptr or !this->connectivity_manager->is_websocket_connected()) { diff --git a/tests/lib/ocpp/v16/test_message_queue.cpp b/tests/lib/ocpp/v16/test_message_queue.cpp index a1bba3291..3de6c5281 100644 --- a/tests/lib/ocpp/v16/test_message_queue.cpp +++ b/tests/lib/ocpp/v16/test_message_queue.cpp @@ -26,36 +26,34 @@ class ControlMessageV16Test : public ::testing::Test { TEST_F(ControlMessageV16Test, test_is_transactional) { - EXPECT_TRUE(is_transaction_message( - (ControlMessage{Call{v16::StartTransactionRequest{}, "0"}} - .messageType))); - EXPECT_TRUE(is_transaction_message( - (ControlMessage{Call{v16::StopTransactionRequest{}, "0"}} - .messageType))); + EXPECT_TRUE(is_transaction_message((ControlMessage{ + Call{ + v16::StartTransactionRequest{}}}.messageType))); + EXPECT_TRUE(is_transaction_message((ControlMessage{ + Call{ + v16::StopTransactionRequest{}}}.messageType))); EXPECT_TRUE(is_transaction_message(ControlMessage{ - Call{v16::SecurityEventNotificationRequest{}, "0"}} + Call{v16::SecurityEventNotificationRequest{}}} .messageType)); EXPECT_TRUE(is_transaction_message( - ControlMessage{Call{v16::MeterValuesRequest{}, "0"}}.messageType)); + ControlMessage{Call{v16::MeterValuesRequest{}}}.messageType)); EXPECT_TRUE(!is_transaction_message( - ControlMessage{Call{v16::AuthorizeRequest{}, "0"}}.messageType)); + ControlMessage{Call{v16::AuthorizeRequest{}}}.messageType)); } TEST_F(ControlMessageV16Test, test_is_transactional_update) { - EXPECT_TRUE( - !(ControlMessage{Call{v16::StartTransactionRequest{}, "0"}}) - .is_transaction_update_message()); - EXPECT_TRUE( - !(ControlMessage{Call{v16::StopTransactionRequest{}, "0"}}) - .is_transaction_update_message()); + EXPECT_TRUE(!(ControlMessage{Call{v16::StartTransactionRequest{}}}) + .is_transaction_update_message()); + EXPECT_TRUE(!(ControlMessage{Call{v16::StopTransactionRequest{}}}) + .is_transaction_update_message()); EXPECT_TRUE(!(ControlMessage{ - Call{v16::SecurityEventNotificationRequest{}, "0"}}) + Call{v16::SecurityEventNotificationRequest{}}}) .is_transaction_update_message()); - EXPECT_TRUE((ControlMessage{Call{v16::MeterValuesRequest{}, "0"}}) + EXPECT_TRUE((ControlMessage{Call{v16::MeterValuesRequest{}}}) .is_transaction_update_message()); - EXPECT_TRUE(!(ControlMessage{Call{v16::AuthorizeRequest{}, "0"}}) + EXPECT_TRUE(!(ControlMessage{Call{v16::AuthorizeRequest{}}}) .is_transaction_update_message()); } diff --git a/tests/lib/ocpp/v201/test_charge_point.cpp b/tests/lib/ocpp/v201/test_charge_point.cpp index f42331e6a..c41ea3657 100644 --- a/tests/lib/ocpp/v201/test_charge_point.cpp +++ b/tests/lib/ocpp/v201/test_charge_point.cpp @@ -625,7 +625,7 @@ class ChargePointFunctionalityTestFixtureV201 : public ChargePointCommonTestFixt template EnhancedMessage request_to_enhanced_message(const T& req) { auto message_id = uuid(); - ocpp::Call call(req, message_id); + ocpp::Call call(req); EnhancedMessage enhanced_message; enhanced_message.uniqueId = message_id; enhanced_message.messageType = M; diff --git a/tests/lib/ocpp/v201/test_message_queue.cpp b/tests/lib/ocpp/v201/test_message_queue.cpp index 0ee38826a..58759a65b 100644 --- a/tests/lib/ocpp/v201/test_message_queue.cpp +++ b/tests/lib/ocpp/v201/test_message_queue.cpp @@ -18,11 +18,11 @@ class ControlMessageV201Test : public ::testing::Test { TEST_F(ControlMessageV201Test, test_is_transactional) { EXPECT_TRUE(is_transaction_message( - (ControlMessage{Call{v201::TransactionEventRequest{}, "0"}} + (ControlMessage{Call{v201::TransactionEventRequest{}}} .messageType))); EXPECT_TRUE(!is_transaction_message( - ControlMessage{Call{v201::AuthorizeRequest{}, "0"}}.messageType)); + ControlMessage{Call{v201::AuthorizeRequest{}}}.messageType)); } TEST_F(ControlMessageV201Test, test_is_transactional_update) { @@ -30,18 +30,18 @@ TEST_F(ControlMessageV201Test, test_is_transactional_update) { v201::TransactionEventRequest transaction_event_request{}; transaction_event_request.eventType = v201::TransactionEventEnum::Updated; - EXPECT_TRUE((ControlMessage{Call{transaction_event_request, "0"}} + EXPECT_TRUE((ControlMessage{Call{transaction_event_request}} .is_transaction_update_message())); transaction_event_request.eventType = v201::TransactionEventEnum::Started; - EXPECT_TRUE(!(ControlMessage{Call{transaction_event_request, "0"}} + EXPECT_TRUE(!(ControlMessage{Call{transaction_event_request}} .is_transaction_update_message())); transaction_event_request.eventType = v201::TransactionEventEnum::Ended; - EXPECT_TRUE(!(ControlMessage{Call{transaction_event_request, "0"}} + EXPECT_TRUE(!(ControlMessage{Call{transaction_event_request}} .is_transaction_update_message())); - EXPECT_TRUE(!(ControlMessage{Call{v201::AuthorizeRequest{}, "0"}} + EXPECT_TRUE(!(ControlMessage{Call{v201::AuthorizeRequest{}}} .is_transaction_update_message())); }