This commit is contained in:
lumapu 2022-11-18 12:03:09 +01:00
parent 0305c114cf
commit c1eed6eef2
2 changed files with 10 additions and 4 deletions

View file

@ -42,6 +42,7 @@ void app::setup(uint32_t timeout) {
mMqtt.setup(&mConfig->mqtt, mConfig->sys.deviceName, mVersion, mSys, &mUtcTimestamp, &mSunrise, &mSunset);
mPayload.addListener(std::bind(&PubMqttType::payloadEventListener, &mMqtt, std::placeholders::_1));
addListener(EVERY_SEC, std::bind(&PubMqttType::tickerSecond, &mMqtt));
addListener(EVERY_MIN, std::bind(&PubMqttType::tickerMinute, &mMqtt));
}
#endif
setupLed();

View file

@ -67,6 +67,14 @@ class PubMqtt {
sendIvData();
}
void tickerMinute() {
if(mAddressSet) {
char val[40];
snprintf(val, 40, "%ld", millis() / 1000);
sendMsg("uptime", val);
}
}
void setCallback(MQTT_CALLBACK_SIGNATURE) {
mClient->setCallback(callback);
}
@ -218,13 +226,10 @@ class PubMqtt {
return;
isConnected(true); // really needed? See comment from HorstG-57 #176
char topic[32 + MAX_NAME_LENGTH], val[32];
char topic[32 + MAX_NAME_LENGTH], val[40];
float total[4];
bool sendTotal = false;
bool totalIncomplete = false;
snprintf(val, 40, "%ld", millis() / 1000);
sendMsg("uptime", val);
sendMsg("wifi_rssi", String(WiFi.RSSI()).c_str());