EVerest / everest-framework

Apache License 2.0
19 stars 18 forks source link

Add support for subscriptions to all instances of an interface for subscribing to variables #217

Open james-ctc opened 2 hours ago

james-ctc commented 2 hours ago

Currently you subscribe to a specific module instance for a particular interface. e.g.

evse_manager->subscribe_session_event([](types::evse_manager::SessionEvent event) {...});

There can be more than one EVSE manager (up to 128) and each one would require:

The improvement is to allow a "wildcard" subscription so that a single subscribe would provide all session events regardless of which EVSE manager raised it.

e.g. a subscribe which provides the session event (variable) along with the EVSE manager ID that published it.

mqtt->subscribe_all_session_events([](const std::string &evse_manager_id, types::evse_manager::SessionEvent event) {...});

It might be possible to further generalise the approach so that other interface variables can be subscribed to without having to bind to a specific instance.

james-ctc commented 2 hours ago

idea came from PR #215