LightHub 4.6.0
Open-source smart home controller firmware
Loading...
Searching...
No Matches
abstractCh Class Referenceabstract

Base class of all abstract channels (input and output drivers). More...

#include <abstractch.h>

Inheritance diagram for abstractCh:

Public Member Functions

 abstractCh ()
virtual ~abstractCh ()
virtual int Poll (short cause)
virtual int Setup ()=0
virtual int Stop ()
virtual int Status ()
virtual void setStatus (uint8_t status)

Protected Member Functions

int publishTopic (const char *topic, long value, const char *subtopic=NULL)
int publishTopic (const char *topic, float value, const char *subtopic=NULL)
int publishTopic (const char *topic, const char *value, const char *subtopic=NULL, const char *suffix=NULL)

Detailed Description

Base class of all abstract channels (input and output drivers).

abstractCh defines the lifecycle contract of a driver module: Setup() initializes the hardware and reserves resources, Poll() is called periodically with a cause (POLLING_SLOW/POLLING_FAST/...), Status()/setStatus() track the initialization state (CST_*) and Stop() releases the resources. The class also provides protected publishTopic() helpers that publish a value to a fixed MQTT topic as a retained message.

Constructor & Destructor Documentation

◆ abstractCh()

abstractCh::abstractCh ( )
inline

◆ ~abstractCh()

virtual abstractCh::~abstractCh ( )
inlinevirtual

Member Function Documentation

◆ Poll()

virtual int abstractCh::Poll ( short cause)
inlinevirtual

Periodic poll hook.

Parameters
cause- POLLING_SLOW/POLLING_FAST/POLLING_INT/POLLING_1S

Reimplemented in in_ccs811, in_hdc1080, out_AC, out_counter, out_Modbus, out_Motor, out_Multivent, out_pid, and out_relay.

◆ publishTopic() [1/3]

int abstractCh::publishTopic ( const char * topic,
const char * value,
const char * subtopic = NULL,
const char * suffix = NULL )
protected

Publish a string value to a topic as a retained MQTT message.

◆ publishTopic() [2/3]

int abstractCh::publishTopic ( const char * topic,
float value,
const char * subtopic = NULL )
protected

Publish a float value to a topic as a retained MQTT message.

◆ publishTopic() [3/3]

int abstractCh::publishTopic ( const char * topic,
long value,
const char * subtopic = NULL )
protected

Publish an integer value to a topic as a retained MQTT message.

Parameters
topic- full topic or a name to be prefixed with the T_OUT topic
subtopic- optional subtopic/suffix appended to the topic

◆ setStatus()

virtual void abstractCh::setStatus ( uint8_t status)
inlinevirtual

Set the CST_* status of the channel.

Reimplemented in abstractOut.

◆ Setup()

virtual int abstractCh::Setup ( )
pure virtual

Initialize hardware and reserve resources.

Returns
0 on success.

Implemented in abstractOut, in_ccs811, in_hdc1080, out_AC, out_counter, out_dmx, out_Modbus, out_Motor, out_Multivent, out_pid, out_pwm, out_relay, and out_SPILed.

◆ Status()

virtual int abstractCh::Status ( )
inlinevirtual
Returns
current CST_* status of the channel.

Reimplemented in abstractOut.

◆ Stop()

virtual int abstractCh::Stop ( )
inlinevirtual

Free resources allocated in Setup().

Reimplemented in out_AC, out_counter, out_dmx, out_Modbus, out_Motor, out_Multivent, out_pid, out_pwm, out_relay, and out_SPILed.


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