@@ -261,6 +261,8 @@ void TransactionService::Evse::loop() {
261261
262262 MO_DBG_INFO (" Session mngt: timeout" );
263263 endTransaction (Ocpp201::Transaction::StoppedReason::Timeout, TransactionEventTriggerReason::EVConnectTimeout);
264+
265+ updateTxNotification (TxNotification_ConnectionTimeout);
264266 }
265267
266268 if (transaction->active &&
@@ -576,6 +578,14 @@ void TransactionService::Evse::loop() {
576578 txStore.commit (txEvent.get ());
577579 }
578580
581+ if (txEvent) {
582+ if (txEvent->eventType == TransactionEventData::Type::Started) {
583+ updateTxNotification (TxNotification_StartTx);
584+ } else if (txEvent->eventType == TransactionEventData::Type::Ended) {
585+ updateTxNotification (TxNotification_StartTx);
586+ }
587+ }
588+
579589 // try to pass ownership to front txEvent immediatley
580590 if (txEvent && !txEventFront &&
581591 transaction->txNr == txNrFront &&
@@ -604,6 +614,16 @@ void TransactionService::Evse::setEvseReadyInput(std::function<bool()> connector
604614 this ->evseReadyInput = connectorEnergized;
605615}
606616
617+ void TransactionService::Evse::setTxNotificationOutput (std::function<void (Ocpp201::Transaction*, TxNotification)> txNotificationOutput) {
618+ this ->txNotificationOutput = txNotificationOutput;
619+ }
620+
621+ void TransactionService::Evse::updateTxNotification (TxNotification event) {
622+ if (txNotificationOutput) {
623+ txNotificationOutput (transaction.get (), event);
624+ }
625+ }
626+
607627bool TransactionService::Evse::beginAuthorization (IdToken idToken, bool validateIdToken) {
608628 MO_DBG_DEBUG (" begin auth: %s" , idToken.get ());
609629
@@ -649,13 +669,17 @@ bool TransactionService::Evse::beginAuthorization(IdToken idToken, bool validate
649669 MO_DBG_DEBUG (" Authorize rejected (%s), abort tx process" , tx->idToken .get ());
650670 tx->isDeauthorized = true ;
651671 txStore.commit (tx);
672+
673+ updateTxNotification (TxNotification_AuthorizationRejected);
652674 return ;
653675 }
654676
655677 MO_DBG_DEBUG (" Authorized tx with validation (%s)" , tx->idToken .get ());
656678 tx->isAuthorized = true ;
657679 tx->notifyIdToken = true ;
658680 txStore.commit (tx);
681+
682+ updateTxNotification (TxNotification_Authorized);
659683 });
660684 authorize->setOnAbortListener ([this , txId] () {
661685 auto tx = getTransaction ();
@@ -667,13 +691,18 @@ bool TransactionService::Evse::beginAuthorization(IdToken idToken, bool validate
667691 MO_DBG_DEBUG (" Authorize timeout (%s)" , tx->idToken .get ());
668692 tx->isDeauthorized = true ;
669693 txStore.commit (tx);
694+
695+ updateTxNotification (TxNotification_AuthorizationTimeout);
670696 });
671697 authorize->setTimeout (20 * 1000 );
672698 context.initiateRequest (std::move (authorize));
673699 } else {
674700 MO_DBG_DEBUG (" Authorized tx directly (%s)" , transaction->idToken .get ());
675701 transaction->isAuthorized = true ;
676702 transaction->notifyIdToken = true ;
703+ txStore.commit (transaction.get ());
704+
705+ updateTxNotification (TxNotification_Authorized);
677706 }
678707
679708 return true ;
@@ -692,10 +721,16 @@ bool TransactionService::Evse::endAuthorization(IdToken idToken, bool validateId
692721 // use same idToken like tx start
693722 transaction->isAuthorizationActive = false ;
694723 transaction->notifyIdToken = true ;
724+ txStore.commit (transaction.get ());
725+
726+ updateTxNotification (TxNotification_Authorized);
695727 } else if (!validateIdToken) {
696728 transaction->stopIdToken = std::unique_ptr<IdToken>(new IdToken (idToken, getMemoryTag ()));
697729 transaction->isAuthorizationActive = false ;
698730 transaction->notifyStopIdToken = true ;
731+ txStore.commit (transaction.get ());
732+
733+ updateTxNotification (TxNotification_Authorized);
699734 } else {
700735 // use a different idToken for stopping the tx
701736
@@ -718,6 +753,8 @@ bool TransactionService::Evse::endAuthorization(IdToken idToken, bool validateId
718753
719754 if (strcmp (response[" idTokenInfo" ][" status" ] | " _Undefined" , " Accepted" )) {
720755 MO_DBG_DEBUG (" Authorize rejected (%s), don't stop tx" , idToken.get ());
756+
757+ updateTxNotification (TxNotification_AuthorizationRejected);
721758 return ;
722759 }
723760
@@ -735,6 +772,17 @@ bool TransactionService::Evse::endAuthorization(IdToken idToken, bool validateId
735772 tx->isAuthorizationActive = false ;
736773 tx->notifyStopIdToken = true ;
737774 txStore.commit (tx);
775+
776+ updateTxNotification (TxNotification_Authorized);
777+ });
778+ authorize->setOnTimeoutListener ([this , txId] () {
779+ auto tx = getTransaction ();
780+ if (!tx || strcmp (tx->transactionId , txId)) {
781+ MO_DBG_INFO (" dangling Authorize -- discard" );
782+ return ;
783+ }
784+
785+ updateTxNotification (TxNotification_AuthorizationTimeout);
738786 });
739787 authorize->setTimeout (20 * 1000 );
740788 context.initiateRequest (std::move (authorize));
0 commit comments