Compare commits

..

No commits in common. "f9985cc2c1524b1be1fe1694ba127e7432d8b2d3" and "0847e899607855531d357de8443fd065837ea6a6" have entirely different histories.

3 changed files with 19 additions and 27 deletions

View File

@ -4,8 +4,9 @@
#ifdef CONFIG_ENABLE_TELEINFO #ifdef CONFIG_ENABLE_TELEINFO
#include <LibTeleinfo.h> #include <LibTeleinfo.h>
int TeleinfoSetup(); int TeleinfoSetup();
int TeleinfoRetrieve(float &iinst, float &papp, float &base); int TeleinfoProcess(std::vector<struct mqttInfo> &batchInfo);
int TeleinfoRetrieve(float &iinst, float &papp, float &base, int TeleinfoProcess(float &iinst, float &papp, float &base);
int TeleinfoProcess(float &iinst, float &papp, float &base,
std::vector<struct mqttInfo> &batchInfo); std::vector<struct mqttInfo> &batchInfo);
#else #else
int TeleinfoSetup() { int TeleinfoSetup() {
@ -13,11 +14,8 @@ int TeleinfoSetup() {
return -1; return -1;
}; };
int TeleinfoRetrieve(float &, float &, float &){ int TeleinfoProcess(float &, float &, float &,
return 0; std::vector<struct mqttInfo> &){
}
int TeleinfoRetrieve(float &, float &, float &, std::vector<struct mqttInfo> &)
{
return 0; return 0;
} }
#endif #endif

View File

@ -13,8 +13,8 @@ int TeleinfoSetup()
return 0; return 0;
} }
int TeleinfoProcess(std::vector<struct mqttInfo> &batchInfo)
int TeleinfoRetrieve(float &iinst, float &papp, float &base){ {
int c; int c;
while ((c = TELESerial.read()) >= 0) { while ((c = TELESerial.read()) >= 0) {
@ -25,16 +25,16 @@ int TeleinfoRetrieve(float &iinst, float &papp, float &base){
me = me->next; me = me->next;
while (me) { while (me) {
if (strcmp(me->name, "IINST") == 0) { if (strcmp(me->name, "IINST") == 0) {
iinst = atof(me->value); float val = atof(me->value);
batchInfo.push_back({val, TELEINFO_IINST_FEED_FORMAT, 0, 0});
} }
if (strcmp(me->name, "PAPP") == 0) { if (strcmp(me->name, "PAPP") == 0) {
papp = atof(me->value); float val = atof(me->value);
batchInfo.push_back({val, TELEINFO_PAPP_FEED_FORMAT, 0, 0});
} }
if (strcmp(me->name, "BASE") == 0) { if (strcmp(me->name, "BASE") == 0) {
float tmp = atof(me->value); float val = atof(me->value);
if(tmp != 0){ batchInfo.push_back({val, TELEINFO_BASE_FEED_FORMAT, 0, 0});
base = tmp;
}
} }
me = me->next; me = me->next;
} }
@ -42,7 +42,7 @@ int TeleinfoRetrieve(float &iinst, float &papp, float &base){
return 0; return 0;
} }
int TeleinfoRetrieve(float &iinst, float &papp, float &base, int TeleinfoProcess(float &iinst, float &papp, float &base,
std::vector<struct mqttInfo> &batchInfo) std::vector<struct mqttInfo> &batchInfo)
{ {
int c; int c;
@ -63,12 +63,9 @@ int TeleinfoRetrieve(float &iinst, float &papp, float &base,
batchInfo.push_back({papp, TELEINFO_PAPP_FEED_FORMAT, 0, 0}); batchInfo.push_back({papp, TELEINFO_PAPP_FEED_FORMAT, 0, 0});
} }
if (strcmp(me->name, "BASE") == 0) { if (strcmp(me->name, "BASE") == 0) {
float tmp = atof(me->value); base = atof(me->value);
if(tmp != 0){
base = tmp;
batchInfo.push_back({base, TELEINFO_BASE_FEED_FORMAT, 0, 0}); batchInfo.push_back({base, TELEINFO_BASE_FEED_FORMAT, 0, 0});
} }
}
me = me->next; me = me->next;
} }

View File

@ -311,7 +311,6 @@ void loop() {
} }
delay(CONFIG_WEB_DELAY_MS); delay(CONFIG_WEB_DELAY_MS);
TeleinfoRetrieve(teleIinst, telePapp, teleBase);
nbCycle++; nbCycle++;
if (nbCycle > samplingPeriod / CONFIG_WEB_DELAY_MS) { if (nbCycle > samplingPeriod / CONFIG_WEB_DELAY_MS) {
std::vector<struct mqttInfo> batchInfo; std::vector<struct mqttInfo> batchInfo;
@ -366,12 +365,10 @@ void loop() {
batchInfo.push_back({bme680BSECIaqAcc, BME680_IAQ_ACC_FEED_FORMAT, 0, 0}); batchInfo.push_back({bme680BSECIaqAcc, BME680_IAQ_ACC_FEED_FORMAT, 0, 0});
} }
TeleinfoRetrieve(teleIinst, telePapp, teleBase, batchInfo); TeleinfoProcess(teleIinst, telePapp, teleBase, batchInfo);
if (mode == BOOTMODE_NORMAL) if (mode == BOOTMODE_NORMAL)
if (MqttBatchPublish(batchInfo, conf.mqttUser, conf.host)) MqttBatchPublish(batchInfo, conf.mqttUser, conf.host);
WifiSetup(conf);
nbCycle = 0; nbCycle = 0;
} }
} }