Doxygen with github
Loading...
Searching...
No Matches
ksf::comps::ksConfigProvider Class Referenceabstract

A component responsible for providing a set of parameters to ksWifiConfigurator and managing its storage. More...

#include <ksConfigProvider.h>

+ Inheritance diagram for ksf::comps::ksConfigProvider:

Public Member Functions

virtual const std::size_t getInstanceType () const
 Retrieves type ID of the object.
 
virtual bool isA (const std::size_t id) const
 Checks whether object is of given type.
 
std::list< ksConfigParameter > & getParameters ()
 Provides const reference to the list of managed parameters.
 
virtual void readParams ()=0
 Populates the parameter list by processing the configuration file.
 
virtual void saveParams ()=0
 Outputs the parameter list to the configuration file.
 
- Public Member Functions inherited from ksf::ksComponent
virtual bool init (ksApplication *app)
 Initializes component.
 
virtual bool loop (ksApplication *app)
 Handles component loop logic, called from application loop.
 
virtual bool postInit (ksApplication *app)
 Method called after component initialization, used to setup references to other components.
 
- Public Member Functions inherited from ksf::ksRtti
virtual ~ksRtti ()=default
 Destructor.
 
template<typename TType >
TType * as ()
 Tries to cast object to the type provided as a template parameter.
 
template<typename TType >
const TType * as () const
 Tries to cast object to the type provided as a template parameter (const version).
 

Static Public Member Functions

static const std::size_t getClassType ()
 
- Static Public Member Functions inherited from ksf::ksComponent
static const std::size_t getClassType ()
 

Protected Member Functions

void addNewParam (std::string id, std::string label, std::string defaultValue, int maxLength=50, EConfigParamType::Type type={})
 Defines new configutation parameter.
 
void addNewParamWithConfigDefault (misc::ksConfig &config, std::string id, std::string label={}, int maxLength=50, EConfigParamType::Type type={})
 Defines new configuation parameter (with default value).
 

Protected Attributes

std::list< ksConfigParameterparams
 List of configuration parameters.
 
- Protected Attributes inherited from ksf::ksComponent
ksComponentState::TYPE componentState { ksComponentState::NotInitialized }
 Holds current state of the component.
 

Detailed Description

A component responsible for providing a set of parameters to ksWifiConfigurator and managing its storage.

In the configurator application, this component should be instantiated like any other, with ksWifiConfigurator included in the component stack. In this setup, it ensures the proper flow of data reading and saving.

In a standard application, however, it is typically created temporarily—often within the application's init method—to read the necessary data and return the required value. For an example, refer to the EnergySensor init method. The component is destroyed once the function returns.

Additionally, be aware that the setupRotations method may return false if there is an issue retrieving the value (e.g., if no configuration is present). This could cause the application to fail, triggering the app rotator to switch to the next defined application, which is usually an AP-based configurator.

Member Function Documentation

◆ addNewParam()

void ksf::comps::ksConfigProvider::addNewParam ( std::string id,
std::string label,
std::string defaultValue,
int maxLength = 50,
EConfigParamType::Type type = {} )
protected

Defines new configutation parameter.

Parameters
idUnique identificator that will be also used as property label by Device Portal.
labelParameter label.
defaultValueDefault parameter value.
maxLengthMaximum length of the value.
typeType of parameter, which tells the Device Portal which field type should be used.

References params.

Referenced by addNewParamWithConfigDefault().

◆ addNewParamWithConfigDefault()

void ksf::comps::ksConfigProvider::addNewParamWithConfigDefault ( misc::ksConfig & config,
std::string id,
std::string label = {},
int maxLength = 50,
EConfigParamType::Type type = {} )
protected

Defines new configuation parameter (with default value).

Parameters
configksConfig reference.
idUnique identificator that will be also used as property label by Device Portal.
labelParameter label.
maxLengthMaximum length of the value.
typeType of parameter, which tells the Device Portal which field type should be used.

References addNewParam(), and ksf::misc::ksConfig::getParam().

Referenced by ksf::comps::ksMqttConfigProvider::readParams().

◆ getInstanceType()

virtual const std::size_t ksf::comps::ksConfigProvider::getInstanceType ( ) const
inlinevirtual

Retrieves type ID of the object.

Returns
Object type ID.

Reimplemented from ksf::ksComponent.

Reimplemented in ksf::comps::ksMqttConfigProvider.

◆ isA()

virtual bool ksf::comps::ksConfigProvider::isA ( const std::size_t id) const
inlinevirtual

Checks whether object is of given type.

Parameters
idType ID to check against.
Returns
True if object is of given type, otherwise false.

Reimplemented from ksf::ksComponent.

Reimplemented in ksf::comps::ksMqttConfigProvider.

◆ readParams()

virtual void ksf::comps::ksConfigProvider::readParams ( )
pure virtual

Populates the parameter list by processing the configuration file.

Implemented in ksf::comps::ksMqttConfigProvider.

◆ saveParams()

virtual void ksf::comps::ksConfigProvider::saveParams ( )
pure virtual

Outputs the parameter list to the configuration file.

Implemented in ksf::comps::ksMqttConfigProvider.


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