Skip to content

Commit

Permalink
Setting transaction pointer of connector to null in case a transactio…
Browse files Browse the repository at this point in the history
…n is stopped. This addresses the issue that charging profiles with purpose TxProfile were accepted even in case no transaction was active (#821)

Signed-off-by: Piet Gömpel <pietgoempel@gmail.com>
  • Loading branch information
Pietfried authored Oct 7, 2024
1 parent feb302d commit 7d46674
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/ocpp/v16/charge_point_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4120,6 +4120,10 @@ void ChargePointImpl::on_transaction_stopped(const int32_t connector, const std:
<< ", with session_id: " << session_id;
return;
}
if (connector <= 0 or connector > this->connectors.size()) {
EVLOG_error << "Attempting to stop transaction for invalid connector id: " << connector;
}

if (signed_meter_value) {
const auto meter_value =
this->get_signed_meter_value(signed_meter_value.value(), ReadingContext::Transaction_End, timestamp);
Expand All @@ -4131,6 +4135,7 @@ void ChargePointImpl::on_transaction_stopped(const int32_t connector, const std:
this->status->submit_event(connector, FSMEvent::TransactionStoppedAndUserActionRequired, ocpp::DateTime());
this->stop_transaction(connector, reason, id_tag_end);
this->transaction_handler->remove_active_transaction(connector);
this->connectors.at(connector)->transaction = nullptr;

const auto profile_cleared = this->smart_charging_handler->clear_all_profiles_with_filter(
std::nullopt, connector, std::nullopt, ChargingProfilePurposeType::TxProfile, false);
Expand Down

0 comments on commit 7d46674

Please sign in to comment.