Skip to content

Commit

Permalink
Properly stop OCPP 2.0.1 transaction if reason is ImmediateReset (#736)
Browse files Browse the repository at this point in the history
Signed-off-by: Kai-Uwe Hermann <[email protected]>
  • Loading branch information
hikinggrass authored Jun 25, 2024
1 parent 65b8e2c commit b59cfed
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions modules/OCPP201/OCPP201.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ TxEvent get_tx_event(const ocpp::v201::ReasonEnum reason) {
return TxEvent::DEAUTHORIZED;
case ocpp::v201::ReasonEnum::EVDisconnected:
return TxEvent::EV_DISCONNECTED;
case ocpp::v201::ReasonEnum::ImmediateReset:
return TxEvent::IMMEDIATE_RESET;
default:
return TxEvent::NONE;
}
Expand Down Expand Up @@ -796,6 +798,9 @@ void OCPP201::process_transaction_finished(const int32_t evse_id, const int32_t
auto charging_state = transaction_data->charging_state;
if (reason == ocpp::v201::ReasonEnum::EVDisconnected) {
charging_state = ocpp::v201::ChargingStateEnum::Idle;
} else if (reason == ocpp::v201::ReasonEnum::ImmediateReset &&
charging_state != ocpp::v201::ChargingStateEnum::Idle) {
charging_state = ocpp::v201::ChargingStateEnum::EVConnected;
} else if (tx_event == TxEvent::DEAUTHORIZED) {
charging_state = ocpp::v201::ChargingStateEnum::EVConnected;
}
Expand Down
10 changes: 9 additions & 1 deletion modules/OCPP201/transaction_handler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ enum class TxEvent {
PARKING_BAY_UNOCCUPIED,
ENERGY_TRANSFER_STARTED,
ENERGY_TRANSFER_STOPPED,
SIGNED_START_DATA_RECEIVED
SIGNED_START_DATA_RECEIVED,
IMMEDIATE_RESET
};

/// \brief Effect to an TxEvent. An effect can either trigger the start of a Transaction, the stop of a transaction or
Expand All @@ -53,6 +54,7 @@ struct TxStartStopConditions {
bool is_parking_bay_occupied = false;
bool is_energy_transfered = false;
bool is_signed_data_received = false;
bool is_immediate_reset = false;

void submit_event(const TxEvent tx_event) {

Expand Down Expand Up @@ -85,6 +87,9 @@ struct TxStartStopConditions {
case TxEvent::SIGNED_START_DATA_RECEIVED:
is_signed_data_received = true;
break;
case TxEvent::IMMEDIATE_RESET:
is_immediate_reset = true;
break;
}
};

Expand All @@ -108,6 +113,9 @@ struct TxStartStopConditions {
};

bool is_stop_condition_fullfilled(const TxStartStopPoint tx_stop_point) {
if (is_immediate_reset) {
return true;
}
switch (tx_stop_point) {
case TxStartStopPoint::ParkingBayOccupancy:
return !is_parking_bay_occupied;
Expand Down

0 comments on commit b59cfed

Please sign in to comment.