Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
ConfigUpdateListener Class Referenceabstract

Abstract class for components that need to receive configuration from EEPROM. More...

#include <ConfigUpdateListener.hxx>

Inheritance diagram for ConfigUpdateListener:
QMember DefaultConfigUpdateListener openlcb::ConfiguredConsumer openlcb::ConfiguredProducer openlcb::ConfiguredPulseConsumer openlcb::MultiConfiguredConsumer openlcb::MultiConfiguredPC openlcb::ServoConsumer openmrn_arduino::Esp32WiFiManager

Public Types

enum  UpdateAction { UPDATED = 0 , REINIT_NEEDED , REBOOT_NEEDED }
 Specifies what additional steps are needed to apply the new configuration. More...
 

Public Member Functions

virtual UpdateAction apply_configuration (int fd, bool initial_load, BarrierNotifiable *done)=0
 Notifies the component that there is new configuration available for loading.
 
virtual void factory_reset (int fd)=0
 Clears configuration file and resets the configuration settings to factory value.
 
- Public Member Functions inherited from QMember
void init ()
 Initiailize a QMember, in place of a public placement construction.
 

Additional Inherited Members

- Protected Member Functions inherited from QMember
 QMember ()
 Constructor.
 
 ~QMember ()
 Destructor.
 
- Protected Attributes inherited from QMember
QMembernext
 pointer to the next member in the queue
 

Detailed Description

Abstract class for components that need to receive configuration from EEPROM.

Configuration update comes in two flavors: initial load and refresh (upon potential change). Each configuration update call supplies the file desriptor of the EEPROM file, which is already opened for reading.

Config listeners provide feedback to the system in two forms: they notify the system in case the configuration change can be applied only with a reboot of the hardware node, or whether an application-level reinitialization sequence is needed.

Definition at line 51 of file ConfigUpdateListener.hxx.

Member Enumeration Documentation

◆ UpdateAction

Specifies what additional steps are needed to apply the new configuration.

Enumerator
UPDATED 

No additional step is necessary.

REINIT_NEEDED 

Need to perform application-level reinitialization.

(In case of OpenLCB this means an identify all events procedure is needed.)

REBOOT_NEEDED 

Need to reboot the hardware.

Definition at line 56 of file ConfigUpdateListener.hxx.

Member Function Documentation

◆ apply_configuration()

virtual UpdateAction ConfigUpdateListener::apply_configuration ( int  fd,
bool  initial_load,
BarrierNotifiable done 
)
pure virtual

Notifies the component that there is new configuration available for loading.

The call is made on the main executor, so the call must not block. Reading the given EEPROM device should be fine. Asynchronous operations may be implemented by using a special return status RETRY: the runner will call the same method on the same component once more after the done callback is invoked. This allows implementing state machines.

Parameters
fdis the file descriptor for the EEPROM file. The current offset in this file is unspecified, callees must do lseek.
initial_loadis true if this is the first load upon starting the binary.
donemust be notified when the call and its dependent actions are complete. No other configuration component will be called until the done callback is invoked.
Returns
any necessary action. If returns UPDATED, then assumes that the configuration change was applied. If returns RETRY, then the same call will be made again after the notifiable is called. If return REINIT_NEEDED or REBOOT_NEEDED then at the end of the configuration update process the node will be reinitialized or rebooted accordingly.

Implemented in openmrn_arduino::Esp32WiFiManager, openlcb::ConfiguredConsumer, openlcb::ConfiguredPulseConsumer, openlcb::ConfiguredProducer, and openlcb::ServoConsumer.

◆ factory_reset()

virtual void ConfigUpdateListener::factory_reset ( int  fd)
pure virtual

Clears configuration file and resets the configuration settings to factory value.

Parameters
fdis the file descriptor for the EEPROM file. The current offset in this file is unspecified, callees must do lseek.

Implemented in openmrn_arduino::Esp32WiFiManager, openlcb::ConfiguredConsumer, openlcb::ConfiguredPulseConsumer, openlcb::ConfiguredProducer, and openlcb::ServoConsumer.


The documentation for this class was generated from the following file: