Browse Source

sml_data_received() only returned false with empty rtc data area.

Thomas Buck 3 months ago
parent
commit
476f8db02f
1 changed files with 4 additions and 1 deletions
  1. 4
    1
      src/smart_meter.cpp

+ 4
- 1
src/smart_meter.cpp View File

29
 
29
 
30
 static EspSoftwareSerial::UART port;
30
 static EspSoftwareSerial::UART port;
31
 RTC_DATA_ATTR static unsigned long counter = 0;
31
 RTC_DATA_ATTR static unsigned long counter = 0;
32
+bool got_data = false;
32
 
33
 
33
 static double SumWh = NAN, T1Wh = NAN, T2Wh = NAN;
34
 static double SumWh = NAN, T1Wh = NAN, T2Wh = NAN;
34
 static double SumW = NAN, L1W = NAN, L2W = NAN, L3W = NAN;
35
 static double SumW = NAN, L1W = NAN, L2W = NAN, L3W = NAN;
35
 
36
 
36
 bool sml_data_received(void) {
37
 bool sml_data_received(void) {
37
-    return counter > 0;
38
+    return got_data;
38
 }
39
 }
39
 
40
 
40
 static void EnergySum(void) {
41
 static void EnergySum(void) {
164
 
165
 
165
         debug.println();
166
         debug.println();
166
 
167
 
168
+        got_data = true;
169
+
167
 #ifdef FEATURE_LORA
170
 #ifdef FEATURE_LORA
168
         // the power readings (Watt) are just sent as is, if available.
171
         // the power readings (Watt) are just sent as is, if available.
169
         // the energy readings are consolidated if possible, to avoid
172
         // the energy readings are consolidated if possible, to avoid

Loading…
Cancel
Save