matth-x / MicroOcpp

OCPP 1.6 client for microcontrollers
MIT License
333 stars 145 forks source link

BeginTransaction process with 2 connectors #273

Closed martamartz closed 3 months ago

martamartz commented 6 months ago

Hello Matth,

I'm working with a charger with two connectors (connectorId = 1 and connectorId = 2). When a card is detected and both connectors are available, I would like to start charging on the connectorId where the car is plugged in (taking into account ocpp_setConnectorPluggedInput_m and ConnectionTimeOut).

To achieve this, I have tried: ocpp_beginTransaction_m(1, idTag); and ocpp_beginTransaction_m(2, idTag); but this sends two Authorize messages when only one is needed.

I have also tried: ocpp_beginTransaction_m(0, idTag); and then plug into connectorId 2. It only sends one Authorize, but the charging does not start on 2.

Is there any way to do this? Or is the only way for the library to default to assigning it to connectorId 1?

Thankss!!

imanolmc commented 5 months ago

Dear Matth,

I am having more or less the same issue as the previous message. I am using an RFID card without selecting any connector in the charger. The process starts but it is always assigned to the connectorID 1, is there any possibility to start the transaction without a connector and including the connectorID after detecting that the car is plugged to one of the connectors.

Regards,

jonlarra11 commented 5 months ago

Hey Matth,

I'm having trouble starting a charge after detecting an RFID. Upon accepting the card, without having a specific connector assigned, it always chooses one of the two, regardless of whether there is a connected EV in the other connector.

I was wondering if there was a way for me to choose which connector is plugged in.

Thx in advance!

matth-x commented 5 months ago

There is no real suggestion in the OCPP specs how to decide whether the RFID card should authorize connector 1 or 2. It's user-defined behavior with MicroOcpp too.

Generally, beginTransaction(const char *idTag, unsigned int connectorId) assigns the transaction to a fixed connectorId. After that point, no decision is possible anymore. If you don't know the connector for sure at the point where the user swipes their card, I would suggest to either wait until the user plugs the car to a specific connector and take that Id, or to send an authorize(...) request manually (doesn't need the connectorId) and interpret the authorization status in the response. That's especially useful for informational purposes, when you want to indicate via LED if the card works at all. In this case, beginTransaction will send another, somewhat redundant Authorize message, but this will be improved in a future release with the introduction of the authorization cache.

@martamartz I like the idea of beginTransaction with connectorId=0 being a generic version of beginTransaction. I will revisit it when implementing the authorization cache.

martamartz commented 4 months ago

Having a generic begin_transaction for connector 0 would be great, Matth! Do you have any estimate of when this could be done?

Thank you very much

matth-x commented 4 months ago

It will take me a couple of months to work on it, there are quite a few things stapling up on my bucket list. Probably it's best to solve this on your end by manually sending an Authorize messag and finally calling beginTransaction.