Skip to content
Open
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
18 changes: 18 additions & 0 deletions src/MicroOcpp/Model/Transactions/TransactionService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,24 @@ void TransactionService::Evse::loop() {
return;
}

// triggerReason is required by the 2.0.1 schema. Some stop paths
// reach here with it UNDEFINED - notably a CSMS deAuthorization
// (TransactionEvent::processConf clears `active` directly, without
// going through endTransaction, so no stopTrigger is recorded). An
// Ended with no triggerReason is rejected by the CSMS
// (FormatViolation) and retried forever, stalling the tx queue.
// Fill a valid reason before the event is built and committed.
if (triggerReason == TransactionEventTriggerReason::UNDEFINED) {
triggerReason = transaction->isDeauthorized
? TransactionEventTriggerReason::Deauthorized
: TransactionEventTriggerReason::AbnormalCondition;
}
if (stoppedReason == Ocpp201::Transaction::StoppedReason::UNDEFINED) {
stoppedReason = transaction->isDeauthorized
? Ocpp201::Transaction::StoppedReason::DeAuthorized
: Ocpp201::Transaction::StoppedReason::Other;
}

transaction->stopTrigger = triggerReason;
transaction->stoppedReason = stoppedReason;

Expand Down
2 changes: 1 addition & 1 deletion src/MicroOcpp/Model/Transactions/TransactionStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ bool TransactionStoreEvse::deserializeTransactionEvent(TransactionEventData& txE
}

TransactionEventTriggerReason triggerReason;
if (!deserializeTransactionEventTriggerReason(txEventJson["triggerReason"] | "_Undefined", triggerReason)) {
if (!deserializeTransactionEventTriggerReason(txEventJson["triggerReason"] | (const char*)nullptr, triggerReason)) {
return false;
}
txEvent.triggerReason = triggerReason;
Expand Down