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

Reintroduce getter function for transaction id #992

Merged
merged 4 commits into from
Feb 24, 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
15 changes: 7 additions & 8 deletions include/ocpp/v201/charge_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ class ChargePointInterface {
on_charging_state_changed(const uint32_t evse_id, const ChargingStateEnum charging_state,
const TriggerReasonEnum trigger_reason = TriggerReasonEnum::ChargingStateChanged) = 0;

/// \brief Gets the transaction id for a certain \p evse_id if there is an active transaction
/// \param evse_id The evse to get the transaction for
/// \return The transaction id if a transaction is active, otherwise nullopt
virtual std::optional<std::string> get_evse_transaction_id(int32_t evse_id) = 0;

/// \brief Event handler that can be called to trigger a NotifyEvent.req with the given \p events
/// \param events
virtual void on_event(const std::vector<EventData>& events) = 0;
Expand Down Expand Up @@ -399,14 +404,6 @@ class ChargePoint : public ChargePointInterface, private ocpp::ChargingStationBa

void message_callback(const std::string& message);

///
/// \brief Check if the connector exists on the given evse id.
/// \param evse_id The evse id to check for.
/// \param connector_type The connector type.
/// \return False if evse id does not exist or evse does not have the given connector type.
///
bool does_connector_exist(const uint32_t evse_id, std::optional<ConnectorEnum> connector_type);

/// \brief Get the value optional offline flag
/// \return true if the charge point is offline. std::nullopt if it is online;
bool is_offline();
Expand Down Expand Up @@ -558,6 +555,8 @@ class ChargePoint : public ChargePointInterface, private ocpp::ChargingStationBa
const uint32_t evse_id, const ChargingStateEnum charging_state,
const TriggerReasonEnum trigger_reason = TriggerReasonEnum::ChargingStateChanged) override;

std::optional<std::string> get_evse_transaction_id(int32_t evse_id) override;

AuthorizeResponse validate_token(const IdToken id_token, const std::optional<CiString<5500>>& certificate,
const std::optional<std::vector<OCSPRequestData>>& ocsp_request_data) override;

Expand Down
10 changes: 10 additions & 0 deletions lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,16 @@ bool ChargePoint::on_charging_state_changed(const uint32_t evse_id, const Chargi
return true;
}

std::optional<std::string> ChargePoint::get_evse_transaction_id(int32_t evse_id) {
const auto& tx = this->evse_manager->get_evse(evse_id).get_transaction();

if (tx != nullptr) {
return tx->transactionId.get();
}

return std::nullopt;
}

AuthorizeResponse ChargePoint::validate_token(const IdToken id_token, const std::optional<CiString<5500>>& certificate,
const std::optional<std::vector<OCSPRequestData>>& ocsp_request_data) {
return this->authorization->validate_token(id_token, certificate, ocsp_request_data);
Expand Down