@@ -103,35 +103,14 @@ void loop() {
103103 if (/* RFID chip detected? */ false ) {
104104 String idTag = " 0123456789ABCD" ; // e.g. idTag = RFID.readIdTag();
105105
106- if (!getTransaction ()) {
107- // no transaction running or preparing. Begin a new transaction
108- Serial.printf (" [main] Begin Transaction with idTag %s\n " , idTag.c_str ());
109-
110- /*
111- * Begin Transaction. The OCPP lib will prepare transaction by checking the Authorization
112- * and listen to the ConnectorPlugged Input. When the Authorization succeeds and an EV
113- * is plugged, the OCPP lib will send the StartTransaction
114- */
115- auto ret = beginTransaction (idTag.c_str ());
116-
117- if (ret) {
118- Serial.println (F (" [main] Transaction initiated. OCPP lib will send a StartTransaction when" \
119- " ConnectorPlugged Input becomes true and if the Authorization succeeds" ));
120- } else {
121- Serial.println (F (" [main] No transaction initiated" ));
122- }
123-
124- } else {
125- // Transaction already initiated. Check if to stop current Tx by RFID card
126- if (idTag.equals (getTransactionIdTag ())) {
127- // card matches -> user can stop Tx
128- Serial.println (F (" [main] End transaction by RFID card" ));
129-
130- endTransaction (idTag.c_str ());
131- } else {
132- Serial.println (F (" [main] Cannot end transaction by RFID card (different card?)" ));
133- }
134- }
106+ /*
107+ * Begin Transaction. The OCPP lib will prepare transaction by checking the Authorization
108+ * and listen to the ConnectorPlugged Input. When the Authorization succeeds and an EV
109+ * is plugged, the OCPP lib will send the StartTransaction
110+ *
111+ * If transaction already exists, stop by RFID card (if idTag or parentIdTag match)
112+ */
113+ authorize (idTag.c_str ());
135114 }
136115
137116 // ... see MicroOcpp.h for more possibilities
0 commit comments