Closed shardul10 closed 1 year ago
I guess I can use setTxNotificationOutput() to get the status? So if I get MicroOcpp::TxNotification::Authorized, I can instruct the charger to offer energy and as soon as connector is plugged (setConnectorPluggedInput()), library will send StartTransaction. Is that correct understanding?
The following functions return the current transaction state:
In addition to that, beginTransaction(...)
and getTransaction(...);
return a pointer to the current transaction process (if existent). The Transaction class contains all data related to the transaction.
ocppPermitsCharge(...)
returns if charging is permitted by OCPP at the moment. This is not always the same as isTransactionRunning()
, because for example, a transaction can be DeAuthorized and continue running while charging is not allowed anymore. Here is the API description:
The functions above return the current status at any time. The library also emits transaction-related events defined in the TxNotification enum (it's called "notification" to avoid confusion with the transaction events which will be introduced for OCPP 2.0.1). The OpenEVSE integration shows how the TxNotification Output can be used to show messages on the display:
But these TxNotifications shouldn't be the basis of controlling the high power electronics (use ocppPermitsCharge(...)
instead). In case of a blackout the library won't emit the latest TxNotification again and the API doesn't guarantee that a TxNotification is always sent in case of a Start-/StopTransaction. TxNotifications are more relevant when the reason of an authorization failure is of interest.
Thanks for detailed response. The problem is where to check the status of transaction and for how long (in case of timeout)? Here's the scenario:
In the loop() I get RFID and issue beginTransaction(). Now I have to know the status of authorisation first
Do I start checking the status immediately (using the APIs you have suggested) until I get some status update? How long? That would block the loop().
I looked at the Open-evse example where the beginTransaciton() is issued similar to my code in onIdTagInput(). Where does it check the success/failure to start offering energy?
Would you consider adding a callback(s) to beginTransaction() for authorisation and starttransaction responses? Alternatively adding a setOnReceiveConf() similar to setOnSendConf()?
I think it will greatly simplify usage of beginTransaction().
Would this work for you?
//tracking variable for detecting status changes
bool trackOcppPermitsCharge = false;
void loop() {
//...
if (trackOcppPermitsCharge != ocppPermitsCharge()) {
//status change, enable / disable the PWM communication (and relay locks) here
}
trackOcppPermitsCharge = ocppPermitsCharge();
}
The OpenEVSE integration ultimately follows the same approach (here it polls ocppPermitsCharge()
): https://github.com/OpenEVSE/openevse_esp32_firmware/blob/8c9a482c912005f4c5f0e2d82d2f596e665dd6eb/src/ocpp.cpp#L420-L424
I will certainly try this approach. If the authorisation/reservation check fails inside beginTransaction(), ocppPermitsCharge() will never return true, right?
It would be good to inform the user that authentication failed. Should I continue to do that through TxNotification?
Will this function also return true in RemoteStartTransaction() scenario (once StartTransaction is sent)?
Thanks Shardul
On 04-Oct-2023, at 4:52 PM, Matthias Akstaller @.***> wrote:
Would this work for you?
//tracking variable for detecting status changes bool trackOcppPermitsCharge = false;
void loop() { //... if (trackOcppPermitsCharge != ocppPermitsCharge()) { //status change, enable / disable the PWM communication (and relay locks) here } trackOcppPermitsCharge = ocppPermitsCharge(); } The OpenEVSE integration ultimately follows the same approach (here it polls ocppPermitsCharge()): https://github.com/OpenEVSE/openevse_esp32_firmware/blob/8c9a482c912005f4c5f0e2d82d2f596e665dd6eb/src/ocpp.cpp#L420-L424
— Reply to this email directly, view it on GitHub https://github.com/matth-x/MicroOcpp/issues/205#issuecomment-1746673943, or unsubscribe https://github.com/notifications/unsubscribe-auth/AES3MDSTPXLC7LP6KQW3S3LX5VBH3AVCNFSM6AAAAAA5QSAZUCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBWGY3TGOJUGM. You are receiving this because you authored the thread.
Yes, yes and yes :)
One more clarification please.
Will the ocppPermitsCharge() return true only after setConnectorPluggedInput() returns true?
On 04-Oct-2023, at 5:49 PM, Matthias Akstaller @.***> wrote:
Yes, yes and yes :)
— Reply to this email directly, view it on GitHub https://github.com/matth-x/MicroOcpp/issues/205#issuecomment-1746763010, or unsubscribe https://github.com/notifications/unsubscribe-auth/AES3MDVNUYUSURSN3WH4YGDX5VH6LAVCNFSM6AAAAAA5QSAZUCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONBWG43DGMBRGA. You are receiving this because you authored the thread.
Closing this now. Using ocppPermitsCharge() to start energy offer.
I am following one of the examples to use beginTransaction() to Authorise and issue StarTransaction. The API returns immediately if it is able to initiate the transaction.
How to check:
I didn't see any callbacks to register to get this information. These triggers are required to inform the charger to start/stop charing.