matth-x / MicroOcpp

OCPP 1.6 client for microcontrollers
MIT License
300 stars 131 forks source link

Offline Behavior: Session Data Persistence #298

Closed jonlarra11 closed 15 hours ago

jonlarra11 commented 1 month ago

Hi Matth, First of all, congratulations on all the work done so far. I'm implementing and testing a charging point that handles local lists, and I have an issue: I have included the IdTag 12345678 in the local list. If I don't have a connection with the backend (offline), it eventually authorizes with the local list and starts charging correctly with 12345678. Charging stops correctly. Then, if the equipment is restarted and I still don't have a connection with the backend: [OCPP] debug (FilesystemUtils.cpp:73): Loaded JSON file: tx-1-0.jsn [OCPP] debug (TransactionDeserialize.cpp:237): DUMP TX [OCPP] debug (TransactionDeserialize.cpp:238): Session | idTag 12345678, active: 0, authorized: 1, deauthorized: 0 [OCPP] debug (TransactionDeserialize.cpp:239): Start RPC | req: 1, conf: 0 [OCPP] debug (TransactionDeserialize.cpp:240): Stop RPC | req: 1, conf: 0 And at this point, ocpp_getTransactionIdTag_m returns 12345678. Therefore, when trying to start a new charge: [OCPP] warning (Connector.cpp:730): tx process still running. Please call endTransaction(...) before When are the Session data reset? When the BootNotification has been accepted? Is there any way to make it work without a connection to the backend? Thanks in advance!

matth-x commented 1 month ago

Hi @jonlarra11,

There has been an unfortunate regression bug with offline transactions which lead to stuck transactions. v1.0.3 is still affected, but the issue has been fixed on main and I will release the fix with v1.1.0 very soon. Do you use v1.0.3?

Btw. if you need to reset the transaction cache for a reason like this, then you can always send a ClearCache command to the charger, followed by a Reset.

jonlarra11 commented 1 month ago

Hi Matth,

With the release v1.1.0, is it possible to be in offline mode from the moment the EVSE starts? Or does the offline behavior assume that we are online and, for some reason, the connection is lost? Thanks for your response!

matth-x commented 1 month ago

Yes that's possible, see this comment, bullet point 2: https://github.com/matth-x/MicroOcpp/issues/307#issuecomment-2133530011

Offline behavior begins when the Authorize message is not responded to for 20 seconds (timeout) or when the WebSocket client reports that the connection is not open.

jonlarra11 commented 1 month ago

Hello Matth, I have tested the offline mode with Cst_FreeVendActive and everything works correctly. On the other hand, I tested the offline mode with RFID and something is not working. I don't know if I'm missing a parameter to configure. I have set: Cst_FreeVendActive = false Cst_PreBootTransaction = true Cst_SilentOfflineTransactions = true RFID 12345678 in the local list Case 1: (works correctly) The EVSE is online and goes offline -> I start a charging session, authorize->setTimeout(1); and it finally enters authorize->setOnTimeoutListener(...) with "Offline transaction process (12345678), locally authorized." Case 2: The EVSE starts offline -> I start a charging session, authorize->setTimeout(1); but it never enters authorize->setOnTimeoutListener(...). Any ideas? Thanks

matth-x commented 2 weeks ago

Hi @jonlarra11, this could be related to a recent regression bug which should be fixed in version 1.1.0. Can you check if upgrading does the trick?

jonlarra11 commented 15 hours ago

Ok thanks!