Skip to content

Re: Implementation of ClearCache and AuthorizationCache functionalities #428

Open

Description

@rushikesh-shirke

Currently I am using the MicroOcpp v1.1.0.

I didn't find any function that implements the "Clear Cache" OCPP feature, also on enabling the "AuthorizationCacheEnabled" key nothing happens as such, so do we have to create an Authorization Cache or is there any other way we can achieve this particular functionality.

Also "AuthorizeRemoteTxRequests", "LocalAuthorizeOffline", "LocalPreAuthorize" configuration key implementation.

@matth-x can you please guide me as to how can I implement these above features?

Also anyone else knows the solution please share your thoughts.

Activity

  1. matth-x commented on Nov 11, 2025

    @matth-x
    Owner

    AuthorizationCache is currently not supported, only LocalAuthLists.

    To implement it, you need to implement NFC based authorization in firmware. Then you can build a list of known idTags. After NFC swipe, check if the idTag exists in the list and still valid, and if not, send an Authorize request like here:

    auto authorize = makeRequest(new Ocpp16::Authorize(context.getModel(), idTag));
    authorize->setTimeout(authorizationTimeoutInt && authorizationTimeoutInt->getInt() > 0 ? authorizationTimeoutInt->getInt() * 1000UL : 20UL * 1000UL);
    if (!context.getConnection().isConnected()) {
    //WebSockt unconnected. Enter offline mode immediately
    authorize->setTimeout(1);
    }
    auto tx = transaction;
    authorize->setOnReceiveConfListener([this, tx] (JsonObject response) {
    JsonObject idTagInfo = response["idTagInfo"];
    if (strcmp("Accepted", idTagInfo["status"] | "UNDEFINED")) {

    The Authorization confirmation handler needs to contain the logic to update the local cache and to initiate the transaction if all looks good using beginTransaction_authorized(...)

    The ClearCache command needs to be overridden in the firmware. There are plenty of examples in the unit tests, in general it looks like this:

    getOcppContext()->getOperationRegistry().registerOperation("TransactionEvent", [] () {
    return new Ocpp16::CustomOperation("TransactionEvent",
    [] (JsonObject) {}, //ignore req
    [] () {
    //create conf
    auto doc = makeJsonDoc("UnitTests", 2 * JSON_OBJECT_SIZE(1));
    auto payload = doc->to<JsonObject>();
    payload["idTokenInfo"]["status"] = "Accepted";
    return doc;
    });});

    To check for the OCPP Configurations, use the Configuation API for existing Configurations:

    Configuration *getConfigurationPublic(const char *key);

    Or if you need to add new Configurations:

    std::shared_ptr<Configuration> declareConfiguration(const char *key, T factoryDefault, const char *filename = CONFIGURATION_FN, bool readonly = false, bool rebootRequired = false, bool accessible = true);

    There are a few examples in the MicroOCPP source code about Configurations. I would recommend searching for similar functionality in the source, and then copy and paste the necessary to the outer firmware integration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions