#include <Mqtt.h>
Public Member Functions | |
MyMqtt (Client &client, MyOptions &options, MyData &data) | |
bool | begin () |
void | handleClient () |
bool | waitingForMqtt () |
Static Public Member Functions | |
static void | mqttCallback (char *topic, byte *payload, unsigned int len) |
Protected Member Functions | |
bool | mySubscribe (String subTopic) |
bool | myPublish (String subTopic, String value) |
Protected Attributes | |
MyOptions & | myOptions |
Reference to the options. | |
MyData & | myData |
Reference to the data. | |
bool | publishInProgress |
Are we publishing right now. | |
Static Protected Attributes | |
static MyOptions * | g_myOptions = NULL |
Static option pointer for the callback function. | |
Constructor/Destructor
Definition at line 84 of file Mqtt.h.
References g_myOptions.
bool MyMqtt::begin | ( | ) |
Sets the MQTT server settings
Definition at line 152 of file Mqtt.h.
References mqttCallback(), MyOptions::mqttPort, MyOptions::mqttServer, MyDbg(), and myOptions.
Referenced by setup().
void MyMqtt::handleClient | ( | ) |
Connect To the MQTT server and send the data when the time is right.
Definition at line 161 of file Mqtt.h.
References MyData::batteryLevel, MyData::batteryVolt, formatInterval(), MyData::getActiveTimeSec(), MyGps::getAsGpsJson(), MyData::getLowPowerPowerConsumption(), MyData::getPowerConsumption(), MyData::humidity, MyData::isGsmActive, MyData::isMoving, MyData::RtcData::lastGps, MyData::RtcData::lastMqttPublishSec, MyData::movingDistance, MyData::RtcData::mqttLastSentTime, MyOptions::mqttName, MyOptions::mqttPassword, MyData::RtcData::mqttSendCount, MyOptions::mqttSendOnMoveEverySec, MyOptions::mqttSendOnNonMoveEverySec, MyOptions::mqttUser, myData, MyDbg(), MyDelay(), myOptions, myPublish(), MyData::pressure, publishInProgress, MyData::rtcData, secondsElapsed(), secondsSincePowerOn(), MyData::signalQuality, MyData::temperature, MyGps::time, topic_alive, topic_batt_level, topic_batt_volt, topic_gps, topic_gps_distance, topic_humidity, topic_mAh, topic_mAhLowPower, topic_pressure, topic_rssi, topic_signal_quality, topic_temperature, topic_voltage, MyData::voltage, and WifiGetRssiAsQuality().
Referenced by loop().
|
static |
Static function for MQTT callback on registered topics.
Definition at line 235 of file Mqtt.h.
References g_myOptions, MyOptions::isDeepSleepEnabled, MyOptions::isGpsEnabled, MyOptions::mqttName, MyOptions::mqttSendOnMoveEverySec, MyOptions::mqttSendOnNonMoveEverySec, MyDbg(), MyOptions::powerOn, topic_deep_sleep, topic_gps_enabled, topic_power_on, topic_send_every, topic_send_on_move_every, and topic_send_on_non_move_every.
Referenced by begin().
|
protected |
Helper function to publish on mqtt It put the mqttName from optione before the topic.
Definition at line 116 of file Mqtt.h.
References MyData::isGsmActive, MyOptions::mqttId, MyOptions::mqttName, myData, MyDbg(), and myOptions.
Referenced by handleClient().
|
protected |
Helper function to subscrbe on mqtt It put the mqttName and id from options before the topic.
Definition at line 100 of file Mqtt.h.
References MyData::isGsmActive, MyOptions::mqttId, MyOptions::mqttName, myData, MyDbg(), and myOptions.
bool MyMqtt::waitingForMqtt | ( | ) |
Check if we have to wait for sending mqtt data.
Definition at line 135 of file Mqtt.h.
References MyData::isGsmActive, MyData::isMoving, MyData::RtcData::lastMqttPublishSec, MyOptions::mqttSendOnMoveEverySec, MyOptions::mqttSendOnNonMoveEverySec, myData, myOptions, publishInProgress, MyData::rtcData, and secondsElapsed().
Referenced by loop().