Skip to content

TransactionEvent can be FormatViolation without triggerReason #405

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

Open
KSR-Yasuda opened this issue Mar 10, 2025 · 1 comment
Open

TransactionEvent can be FormatViolation without triggerReason #405

KSR-Yasuda opened this issue Mar 10, 2025 · 1 comment

Comments

@KSR-Yasuda
Copy link

In some cases, TransactionEvent do not have the required property triggerReason.

In TransactionService::Evse::loop(),
here it sets event triggerReason, but it may be the initial value UNDEFINED.

Then, the triggerReason property is skipped in message serialization.

Shouldn't you set something to follow the OCPP spec?

@KSR-Yasuda
Copy link
Author

Perhaps here is where to set txEvent->transaction->stopTrigger.

If the started transaction comes to be active = false,
it would fall into the case of TransactionEventData::Type::Ended above.

--- a/src/MicroOcpp/Operations/TransactionEvent.cpp
+++ b/src/MicroOcpp/Operations/TransactionEvent.cpp
@@ -131,14 +131,23 @@ std::unique_ptr<JsonDoc> TransactionEvent::createReq() {
 void TransactionEvent::processConf(JsonObject payload) {
 
     if (payload.containsKey("idTokenInfo")) {
         if (strcmp(payload["idTokenInfo"]["status"], "Accepted")) {
             MO_DBG_INFO("transaction deAuthorized");
             txEvent->transaction->active = false;
             txEvent->transaction->isDeauthorized = true;
+            if (txEvent->transaction->started && !txEvent->transaction->stopped) {
+                if (txEvent->transaction->stopTrigger == TransactionEventTriggerReason::UNDEFINED) {
+                    txEvent->transaction->stopTrigger = TransactionEventTriggerReason::Deauthorized;
+                }
+
+                if (txEvent->transaction->stoppedReason == Ocpp201::Transaction::StoppedReason::UNDEFINED) {
+                    txEvent->transaction->stoppedReason = Ocpp201::Transaction::StoppedReason::DeAuthorized;
+                }
+            }
         }
     }
 }
 
 void TransactionEvent::processReq(JsonObject payload) {
     /**
      * Ignore Contents of this Req-message, because this is for debug purposes only

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant