Skip to content

Commit

Permalink
Review comment: change parameters of reserve now callback.
Browse files Browse the repository at this point in the history
Signed-off-by: Maaike Zijderveld, iolar <[email protected]>
  • Loading branch information
maaikez committed Nov 8, 2024
1 parent 27bcebb commit 045bdaf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion include/ocpp/v201/charge_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ class ChargePoint : public ChargePointInterface, private ocpp::ChargingStationBa
// Function Block H: Reservations
void handle_reserve_now_request(Call<ReserveNowRequest> call);
void handle_cancel_reservation_callback(Call<CancelReservationRequest> call);
void send_reserve_now_rejected_response(const MessageId& unique_id, const std::string status_info);
void send_reserve_now_rejected_response(const MessageId& unique_id, const std::string& status_info);

// Functional Block I: TariffAndCost
void handle_costupdated_req(const Call<CostUpdatedRequest> call);
Expand Down
7 changes: 2 additions & 5 deletions include/ocpp/v201/charge_point_callbacks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <ocpp/v201/messages/GetDisplayMessages.hpp>
#include <ocpp/v201/messages/GetLog.hpp>
#include <ocpp/v201/messages/RequestStartTransaction.hpp>
#include <ocpp/v201/messages/ReserveNow.hpp>
#include <ocpp/v201/messages/SetDisplayMessage.hpp>
#include <ocpp/v201/messages/TransactionEvent.hpp>
#include <ocpp/v201/messages/UnlockConnector.hpp>
Expand Down Expand Up @@ -153,11 +154,7 @@ struct Callbacks {
set_running_cost_callback;

/// \brief Callback function is called when a reservation request is received from the CSMS
std::optional<std::function<ReserveNowStatusEnum(
const int32_t id, const ocpp::DateTime& expiry_date_time, const IdToken& id_token,
const std::optional<ConnectorEnum> connector_type, const std::optional<uint32_t> evse_id,
const std::optional<IdToken>& group_id_token)>>
reserve_now_callback;
std::optional<std::function<ReserveNowStatusEnum(const ReserveNowRequest& request)>> reserve_now_callback;
/// \brief Callback function is called when a cancel reservation request is received from the CSMS
std::optional<std::function<bool(const int32_t reservationId)>> cancel_reservation_callback;
};
Expand Down
8 changes: 3 additions & 5 deletions lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3416,10 +3416,8 @@ void ChargePoint::handle_reserve_now_request(Call<ReserveNowRequest> call) {
// should be overwritten.

// Call reserve now callback and wait for the response.
ReserveNowRequest reservation_request = call.msg;
response.status = this->callbacks.reserve_now_callback.value()(
reservation_request.id, reservation_request.expiryDateTime, reservation_request.idToken,
reservation_request.connectorType, reservation_request.evseId, reservation_request.groupIdToken);
const ReserveNowRequest reservation_request = call.msg;
response.status = this->callbacks.reserve_now_callback.value()(reservation_request);

// Reply with the response from the callback.
const ocpp::CallResult<ReserveNowResponse> call_result(response, call.uniqueId);
Expand Down Expand Up @@ -3456,7 +3454,7 @@ void ChargePoint::handle_cancel_reservation_callback(Call<CancelReservationReque
this->send<CancelReservationResponse>(call_result);
}

void ChargePoint::send_reserve_now_rejected_response(const MessageId& unique_id, const std::string status_info) {
void ChargePoint::send_reserve_now_rejected_response(const MessageId& unique_id, const std::string& status_info) {
ReserveNowResponse response;
response.status = ReserveNowStatusEnum::Rejected;
response.statusInfo = StatusInfo();
Expand Down

0 comments on commit 045bdaf

Please sign in to comment.