From 129b8905a7418329d84f73e89f1e4ebf390aba8b Mon Sep 17 00:00:00 2001 From: Ivan Rogach Date: Thu, 18 Apr 2024 13:16:14 +0200 Subject: [PATCH 1/2] Send idToken at finish transaction only if it is deauthorized using a token Signed-off-by: Ivan Rogach --- lib/ocpp/v201/charge_point.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/ocpp/v201/charge_point.cpp b/lib/ocpp/v201/charge_point.cpp index ba626092d..99b715732 100644 --- a/lib/ocpp/v201/charge_point.cpp +++ b/lib/ocpp/v201/charge_point.cpp @@ -374,9 +374,13 @@ void ChargePoint::on_transaction_finished(const int32_t evse_id, const DateTime& const auto trigger_reason = utils::stop_reason_to_trigger_reason_enum(reason); + // Requirement E07.FR.02 + const std::optional transaction_id_token = + trigger_reason == ocpp::v201::TriggerReasonEnum::StopAuthorized ? id_token : std::nullopt; + this->transaction_event_req(TransactionEventEnum::Ended, timestamp, transaction, trigger_reason, seq_no, - std::nullopt, this->evses.at(static_cast(evse_id))->get_evse_info(), id_token, - meter_values, std::nullopt, this->is_offline(), std::nullopt); + std::nullopt, this->evses.at(static_cast(evse_id))->get_evse_info(), + transaction_id_token, meter_values, std::nullopt, this->is_offline(), std::nullopt); this->database_handler->transaction_metervalues_clear(transaction_id); From 6c4bcf5f2130c7339f88c5df014e2b22d73818c7 Mon Sep 17 00:00:00 2001 From: Ivan Rogach Date: Thu, 18 Apr 2024 16:45:46 +0200 Subject: [PATCH 2/2] Update the comment with reference to documentation Signed-off-by: Ivan Rogach --- lib/ocpp/v201/charge_point.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ocpp/v201/charge_point.cpp b/lib/ocpp/v201/charge_point.cpp index 99b715732..b0b3f6529 100644 --- a/lib/ocpp/v201/charge_point.cpp +++ b/lib/ocpp/v201/charge_point.cpp @@ -374,7 +374,7 @@ void ChargePoint::on_transaction_finished(const int32_t evse_id, const DateTime& const auto trigger_reason = utils::stop_reason_to_trigger_reason_enum(reason); - // Requirement E07.FR.02 + // E07.FR.02 The field idToken is provided when the authorization of the transaction has been ended const std::optional transaction_id_token = trigger_reason == ocpp::v201::TriggerReasonEnum::StopAuthorized ? id_token : std::nullopt;