MicroOcpp icon indicating copy to clipboard operation
MicroOcpp copied to clipboard

How to implement/Use Authorization Cache

Open demirschmid61 opened this issue 1 year ago • 1 comments

@matth-x

Thank you very much for the wonderful library, I can use charging transactions remotely and locally when CP is online.

Can you please throw some light on the authorization cache or how I can proceed to implement it?

Do I need to add any configuration parameter for it, so that I can use it when the charger is not connected to the server, to improve the experience for users?

demirschmid61 avatar Mar 08 '24 04:03 demirschmid61

@demirschmid61

Sorry for the late response. At the moment, MicroOcpp does not come with AuthorizationCache support. Would LocalAuthorizationLists work instead?

If you want to implement it, you can use the TxNotificationOutput to capture successful authorizations and keep the idTags in a whitelist. Then, when the user swipes a card and the idTag exists in the whitelist, you can start charging with beginTransaction_authorized(...). If the card doesn't exist, then just beginTransaction(...).

The TxNotificationOutput can be set here:

https://github.com/matth-x/MicroOcpp/blob/80da31d92f39e666193c14ffbe11d1a01b84d8bd/src/MicroOcpp.h#L303C6-L303C29

The event types to check for defined here, especially:

https://github.com/matth-x/MicroOcpp/blob/80da31d92f39e666193c14ffbe11d1a01b84d8bd/src/MicroOcpp/Model/ConnectorBase/Notification.h#L13-L14

You can fetch the idTag from the transaction object which is passed with the event type to the callback function.

matth-x avatar Apr 23 '24 20:04 matth-x