Skip to content

Commit 9aa9b44

Browse files
committed
add definition for getTransactionV201()
1 parent e1c93a9 commit 9aa9b44

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/MicroOcpp.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,30 @@ std::shared_ptr<Transaction>& getTransaction(unsigned int connectorId) {
712712
return connector->getTransaction();
713713
}
714714

715+
#if MO_ENABLE_V201
716+
Ocpp201::Transaction *getTransactionV201(unsigned int evseId) {
717+
if (!context) {
718+
MO_DBG_ERR("OCPP uninitialized"); //need to call mocpp_initialize before
719+
return nullptr;
720+
}
721+
722+
if (context->getVersion().major != 2) {
723+
MO_DBG_ERR("only supported in v201"); //need to call mocpp_initialize before
724+
return nullptr;
725+
}
726+
727+
TransactionService::Evse *evse = nullptr;
728+
if (auto txService = context->getModel().getTransactionService()) {
729+
evse = txService->getEvse(evseId);
730+
}
731+
if (!evse) {
732+
MO_DBG_ERR("could not find EVSE");
733+
return nullptr;
734+
}
735+
return evse->getTransaction();
736+
}
737+
#endif //MO_ENABLE_V201
738+
715739
bool ocppPermitsCharge(unsigned int connectorId) {
716740
if (!context) {
717741
MO_DBG_WARN("OCPP uninitialized");

0 commit comments

Comments
 (0)