Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
7d9e4dfda1
|
|||
|
9ffea49d71
|
|||
|
c295d2c169
|
@@ -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"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user