3 Commits

Author SHA1 Message Date
7d9e4dfda1 another fix 2020-07-29 15:19:10 +02:00
9ffea49d71 adjust release info 2020-07-29 15:13:24 +02:00
c295d2c169 fix heartbeat 2020-07-29 15:11:49 +02:00
2 changed files with 6 additions and 6 deletions

View File

@ -1,8 +1,8 @@
{
"releaseTag": "v1.0.1",
"releaseTag": "v1.0.3",
"createReleaseTag": "true",
"releaseName": "heartbeat",
"description": "heartbeat message added"
"releaseName": "heartbeat fix 2",
"description": "heartbeat message fixed, raincnt has to be static"
}

View File

@ -69,12 +69,11 @@ void loopApplication() {
static uint32_t totalCnt = 0;
static uint32_t lastValuesMillis = 0;
static uint32_t lastHeartbeatMillis = 0;
char buf[VALUES_BUF_SIZE];
static uint32_t rainCnt = 0;
if (currentMillis > (lastValuesMillis + (configBlock.valuesPeriod * 1000))) {
lastValuesMillis = currentMillis;
// rain sensor
uint32_t rainCnt = 0;
noInterrupts();
rainCnt = cnt;
cnt = 0;
@ -86,6 +85,7 @@ void loopApplication() {
totalCnt += rainCnt;
// MQTT publishing
char buf[VALUES_BUF_SIZE];
memset(buf, 0, VALUES_BUF_SIZE);
snprintf(buf, VALUES_BUF_SIZE-1, "{\"raincnt\":%ld, \"totalCnt\":%ld, \"uptime\":%ld}", rainCnt, totalCnt, uptime);
mqttClient.publish(configBlock.mqttValuesTopic, buf);
@ -101,7 +101,7 @@ void loopApplication() {
// MQTT publishing
char heartbeatBuf[HEARTBEAT_BUF_SIZE];
memset(heartbeatBuf, 0, HEARTBEAT_BUF_SIZE);
snprintf(heartbeatBuf, HEARTBEAT_BUF_SIZE-1, "{\"lastMessage\":%s, \"uptime\":%ld}", buf, uptime);
snprintf(heartbeatBuf, HEARTBEAT_BUF_SIZE-1, "{\"lastValues\":{\"raincnt\":%ld, \"totalCnt\":%ld}, \"uptime\":%ld}", rainCnt, totalCnt, uptime);
mqttClient.publish(configBlock.mqttHeartbeatTopic, heartbeatBuf);
}