mirror of
https://github.com/lumapu/ahoy.git
synced 2025-06-10 22:51:36 +02:00
potential fix #393 corrupted MQTT total values
This commit is contained in:
parent
921419de72
commit
1620b633d8
2 changed files with 23 additions and 23 deletions
|
@ -579,7 +579,6 @@ void app::sendMqtt(void) {
|
||||||
char topic[32 + MAX_NAME_LENGTH], val[32];
|
char topic[32 + MAX_NAME_LENGTH], val[32];
|
||||||
float total[4];
|
float total[4];
|
||||||
bool sendTotal = false;
|
bool sendTotal = false;
|
||||||
memset(total, 0, sizeof(float) * 4);
|
|
||||||
snprintf(val, 32, "%ld", millis() / 1000);
|
snprintf(val, 32, "%ld", millis() / 1000);
|
||||||
|
|
||||||
mMqtt.sendMsg("uptime", val);
|
mMqtt.sendMsg("uptime", val);
|
||||||
|
@ -588,6 +587,7 @@ void app::sendMqtt(void) {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while(!mMqttSendList.empty()) {
|
while(!mMqttSendList.empty()) {
|
||||||
|
memset(total, 0, sizeof(float) * 4);
|
||||||
for (uint8_t id = 0; id < mSys->getNumInverters(); id++) {
|
for (uint8_t id = 0; id < mSys->getNumInverters(); id++) {
|
||||||
Inverter<> *iv = mSys->getInverterByPos(id);
|
Inverter<> *iv = mSys->getInverterByPos(id);
|
||||||
if (NULL == iv)
|
if (NULL == iv)
|
||||||
|
@ -653,29 +653,29 @@ void app::sendMqtt(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
mMqttSendList.pop(); // remove from list once all inverters were processed
|
mMqttSendList.pop(); // remove from list once all inverters were processed
|
||||||
}
|
|
||||||
|
|
||||||
if (true == sendTotal) {
|
if (true == sendTotal) {
|
||||||
uint8_t fieldId;
|
uint8_t fieldId;
|
||||||
for (uint8_t i = 0; i < 4; i++) {
|
for (uint8_t i = 0; i < 4; i++) {
|
||||||
switch (i) {
|
switch (i) {
|
||||||
default:
|
default:
|
||||||
case 0:
|
case 0:
|
||||||
fieldId = FLD_PAC;
|
fieldId = FLD_PAC;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
fieldId = FLD_YT;
|
fieldId = FLD_YT;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
fieldId = FLD_YD;
|
fieldId = FLD_YD;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
fieldId = FLD_PDC;
|
fieldId = FLD_PDC;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
snprintf(topic, 32 + MAX_NAME_LENGTH, "total/%s", fields[fieldId]);
|
||||||
|
snprintf(val, 10, "%.3f", total[i]);
|
||||||
|
mMqtt.sendMsg(topic, val);
|
||||||
}
|
}
|
||||||
snprintf(topic, 32 + MAX_NAME_LENGTH, "total/%s", fields[fieldId]);
|
|
||||||
snprintf(val, 10, "%.3f", total[i]);
|
|
||||||
mMqtt.sendMsg(topic, val);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
#define VERSION_MAJOR 0
|
#define VERSION_MAJOR 0
|
||||||
#define VERSION_MINOR 5
|
#define VERSION_MINOR 5
|
||||||
#define VERSION_PATCH 31
|
#define VERSION_PATCH 32
|
||||||
|
|
||||||
//-------------------------------------
|
//-------------------------------------
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue