Skip to content

Commit

Permalink
checking if error has changed before executing status_notification_ca…
Browse files Browse the repository at this point in the history
…llback

Signed-off-by: pietfried <[email protected]>
  • Loading branch information
Pietfried committed Nov 9, 2023
1 parent 092d88f commit d767505
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/ocpp/v16/charge_point_state_machine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,19 @@ bool ChargePointFSM::handle_event(FSMEvent event) {
state = dest_state_it->second;

if (!faulted) {
status_notification_callback(state, ChargePointErrorCode::NoError);
status_notification_callback(state, this->error_code);
}

return true;
}

bool ChargePointFSM::handle_fault(const ChargePointErrorCode& error_code) {
this->error_code = error_code;
if (error_code == this->error_code) {
// has already been handled and reported
return false;
}

this->error_code = error_code;
if (this->error_code == ChargePointErrorCode::NoError) {
faulted = false;
status_notification_callback(state, this->error_code);
Expand All @@ -150,6 +154,11 @@ bool ChargePointFSM::handle_fault(const ChargePointErrorCode& error_code) {
}

bool ChargePointFSM::handle_error(const ChargePointErrorCode& error_code) {
if (error_code == this->error_code) {
// has already been handled and reported
return false;
}

this->error_code = error_code;
if (!faulted) {
status_notification_callback(this->state, error_code);
Expand Down

0 comments on commit d767505

Please sign in to comment.