Doxygen with github
|
A component that periodocally reports device state to the broker. More...
#include <ksDevStatMqttReporter.h>
Public Member Functions | |
virtual const size_t | getInstanceType () const |
Retrieves type ID of the object. | |
virtual bool | isA (const size_t id) const |
Checks whether object is of given type. | |
ksDevStatMqttReporter (uint8_t intervalInSeconds=60) | |
Constructs device statistics reporter component. | |
bool | postInit (ksApplication *app) override |
Handles component post-initialization. | |
bool | loop (ksApplication *app) override |
Handles MQTT debug connector component loop logic. | |
Public Member Functions inherited from ksf::ksComponent | |
virtual bool | init (ksApplication *app) |
Initializes component. | |
Public Member Functions inherited from ksf::ksRtti | |
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 size_t | getClassType () |
Static Public Member Functions inherited from ksf::ksComponent | |
static const size_t | getClassType () |
Public Attributes | |
std::shared_ptr< ksf::evt::ksEvent< std::shared_ptr< ksMqttConnector > & > > | onReportCustomStats {std::make_shared<ksf::evt::ksEvent<std::shared_ptr<ksMqttConnector>&>>()} |
Called when Dev Stat Reporter timer is triggered. Users can bind to this event to add their own stats. | |
Protected Member Functions | |
void | onConnected () |
Calback executed on MQTT connection. | |
void | reportDevStats () const |
Reports device statistics to the MQTT broker. | |
Protected Attributes | |
std::weak_ptr< ksMqttConnector > | mqttConnWp |
Weak pointer to MQTT connector. | |
std::unique_ptr< evt::ksEventHandle > | connEventHandle |
Event handle for connection delegate. | |
ksSimpleTimer | reporterTimer |
Timer to report device stats. | |
Protected Attributes inherited from ksf::ksComponent | |
ksComponentState::TYPE | componentState { ksComponentState::NotInitialized } |
A component that periodocally reports device state to the broker.
Upon instantiated, the component will look for ksMqttConnector component. The interval between each update is defined by the construction parameter.
Each update contain values like RSSI, device uptime, connection time and IP address. The subtopic used is "dstat", so for example RSSI will be sent to the topic named "deviceprefix/dstat/rssi".
ksf::comps::ksDevStatMqttReporter::ksDevStatMqttReporter | ( | uint8_t | intervalInSeconds = 60 | ) |
Constructs device statistics reporter component.
intervalInSeconds | Interval in seconds between each report. |
|
inlinevirtual |
|
inlinevirtual |
Checks whether object is of given type.
id | Type ID to check against. |
Reimplemented from ksf::ksComponent.
|
overridevirtual |
Handles MQTT debug connector component loop logic.
app | Pointer to the parent ksApplication. |
Reimplemented from ksf::ksComponent.
References reportDevStats(), reporterTimer, and ksf::ksSimpleTimer::triggered().
|
protected |
Calback executed on MQTT connection.
This callback is used to restart reporter timer to match the intervals between individual reports. The timer will be processed even if the MQTT is not connected, but reportDevStats will quickly return.
References reporterTimer, and ksf::ksSimpleTimer::restart().
Referenced by postInit().
|
overridevirtual |
Handles component post-initialization.
This method is responsible for reference gathering (component lookup) as well as binding to the events.
app | Pointer to the paren ksApplication. |
Reimplemented from ksf::ksComponent.
References connEventHandle, ksf::ksApplication::findComponent(), mqttConnWp, onConnected(), ksf::comps::ksMqttConnector::onConnected, and ksf::evt::ksEvent< Params >::registerEvent().
std::shared_ptr<ksf::evt::ksEvent<std::shared_ptr<ksMqttConnector>&> > ksf::comps::ksDevStatMqttReporter::onReportCustomStats {std::make_shared<ksf::evt::ksEvent<std::shared_ptr<ksMqttConnector>&>>()} |
Called when Dev Stat Reporter timer is triggered. Users can bind to this event to add their own stats.
param_1 | Shared pointer to the MQTT connector. |
Referenced by reportDevStats().