diff --git a/WifiControlSensor/Teleinfo.h b/WifiControlSensor/Teleinfo.h index ce4aa7e..14134a0 100644 --- a/WifiControlSensor/Teleinfo.h +++ b/WifiControlSensor/Teleinfo.h @@ -4,9 +4,8 @@ #ifdef CONFIG_ENABLE_TELEINFO #include int TeleinfoSetup(); -int TeleinfoProcess(std::vector &batchInfo); -int TeleinfoProcess(float &iinst, float &papp, float &base); -int TeleinfoProcess(float &iinst, float &papp, float &base, +int TeleinfoRetrieve(float &iinst, float &papp, float &base); +int TeleinfoRetrieve(float &iinst, float &papp, float &base, std::vector &batchInfo); #else int TeleinfoSetup() { @@ -14,8 +13,11 @@ int TeleinfoSetup() { return -1; }; -int TeleinfoProcess(float &, float &, float &, - std::vector &){ - return 0; +int TeleinfoRetrieve(float &, float &, float &){ + return 0; +} +int TeleinfoRetrieve(float &, float &, float &, std::vector &) +{ + return 0; } #endif diff --git a/WifiControlSensor/Teleinfo.ino b/WifiControlSensor/Teleinfo.ino index 6566cb4..7f5cb00 100644 --- a/WifiControlSensor/Teleinfo.ino +++ b/WifiControlSensor/Teleinfo.ino @@ -13,8 +13,8 @@ int TeleinfoSetup() return 0; } -int TeleinfoProcess(std::vector &batchInfo) -{ + +int TeleinfoRetrieve(float &iinst, float &papp, float &base){ int c; while ((c = TELESerial.read()) >= 0) { @@ -25,16 +25,16 @@ int TeleinfoProcess(std::vector &batchInfo) me = me->next; while (me) { if (strcmp(me->name, "IINST") == 0) { - float val = atof(me->value); - batchInfo.push_back({val, TELEINFO_IINST_FEED_FORMAT, 0, 0}); + iinst = atof(me->value); } if (strcmp(me->name, "PAPP") == 0) { - float val = atof(me->value); - batchInfo.push_back({val, TELEINFO_PAPP_FEED_FORMAT, 0, 0}); + papp = atof(me->value); } if (strcmp(me->name, "BASE") == 0) { - float val = atof(me->value); - batchInfo.push_back({val, TELEINFO_BASE_FEED_FORMAT, 0, 0}); + float tmp = atof(me->value); + if(tmp != 0){ + base = tmp; + } } me = me->next; } @@ -42,7 +42,7 @@ int TeleinfoProcess(std::vector &batchInfo) return 0; } -int TeleinfoProcess(float &iinst, float &papp, float &base, +int TeleinfoRetrieve(float &iinst, float &papp, float &base, std::vector &batchInfo) { int c; @@ -63,8 +63,11 @@ int TeleinfoProcess(float &iinst, float &papp, float &base, batchInfo.push_back({papp, TELEINFO_PAPP_FEED_FORMAT, 0, 0}); } if (strcmp(me->name, "BASE") == 0) { - base = atof(me->value); - batchInfo.push_back({base, TELEINFO_BASE_FEED_FORMAT, 0, 0}); + float tmp = atof(me->value); + if(tmp != 0){ + base = tmp; + batchInfo.push_back({base, TELEINFO_BASE_FEED_FORMAT, 0, 0}); + } } me = me->next; }