|
@@ -115,27 +115,19 @@ void sml_run(void) {
|
115
|
115
|
|
116
|
116
|
if (!isnan(SumWh)) {
|
117
|
117
|
debug.printf("Sum: %14.3lf Wh\n", SumWh);
|
118
|
|
-#ifdef FEATURE_LORA
|
119
|
|
- lora_sml_send(LORA_SML_SUM_WH, SumWh, counter);
|
120
|
|
-#endif // FEATURE_LORA
|
121
|
118
|
}
|
122
|
119
|
|
123
|
120
|
if (!isnan(T1Wh)) {
|
124
|
121
|
debug.printf(" T1: %14.3lf Wh\n", T1Wh);
|
125
|
|
-#ifdef FEATURE_LORA
|
126
|
|
- lora_sml_send(LORA_SML_T1_WH, T1Wh, counter);
|
127
|
|
-#endif // FEATURE_LORA
|
128
|
122
|
}
|
129
|
123
|
|
130
|
124
|
if (!isnan(T2Wh)) {
|
131
|
125
|
debug.printf(" T2: %14.3lf Wh\n", T2Wh);
|
132
|
|
-#ifdef FEATURE_LORA
|
133
|
|
- lora_sml_send(LORA_SML_T2_WH, T2Wh, counter);
|
134
|
|
-#endif // FEATURE_LORA
|
135
|
126
|
}
|
136
|
127
|
|
137
|
128
|
if (!isnan(SumW)) {
|
138
|
129
|
debug.printf("Sum: %14.3lf W\n", SumW);
|
|
130
|
+
|
139
|
131
|
#ifdef FEATURE_LORA
|
140
|
132
|
lora_sml_send(LORA_SML_SUM_W, SumW, counter);
|
141
|
133
|
#endif // FEATURE_LORA
|
|
@@ -150,6 +142,7 @@ void sml_run(void) {
|
150
|
142
|
|
151
|
143
|
if (!isnan(L2W)) {
|
152
|
144
|
debug.printf(" L2: %14.3lf W\n", L2W);
|
|
145
|
+
|
153
|
146
|
#ifdef FEATURE_LORA
|
154
|
147
|
lora_sml_send(LORA_SML_L2_W, L2W, counter);
|
155
|
148
|
#endif // FEATURE_LORA
|
|
@@ -157,16 +150,46 @@ void sml_run(void) {
|
157
|
150
|
|
158
|
151
|
if (!isnan(L3W)) {
|
159
|
152
|
debug.printf(" L3: %14.3lf W\n", L3W);
|
|
153
|
+
|
160
|
154
|
#ifdef FEATURE_LORA
|
161
|
155
|
lora_sml_send(LORA_SML_L3_W, L3W, counter);
|
162
|
156
|
#endif // FEATURE_LORA
|
163
|
157
|
}
|
164
|
158
|
|
|
159
|
+ debug.println();
|
|
160
|
+
|
165
|
161
|
#ifdef FEATURE_LORA
|
|
162
|
+ // the power readings (Watt) are just sent as is, if available.
|
|
163
|
+ // the energy readings are consolidated if possible, to avoid
|
|
164
|
+ // unneccessary data transmission
|
|
165
|
+ if ((!isnan(SumWh)) && (!isnan(T1Wh))
|
|
166
|
+ && (fabs(SumWh - T1Wh) < 0.1)
|
|
167
|
+ && ((isnan(T2Wh)) || (fabs(T2Wh) < 0.1))) {
|
|
168
|
+ // (SumWh == T1Wh) && ((T2Wh == 0) || (T2Wh == NAN))
|
|
169
|
+ // just send T1Wh
|
|
170
|
+ lora_sml_send(LORA_SML_T1_WH, T1Wh, counter);
|
|
171
|
+ } else if ((!isnan(SumWh)) && (!isnan(T2Wh))
|
|
172
|
+ && (fabs(SumWh - T2Wh) < 0.1)
|
|
173
|
+ && ((isnan(T1Wh)) || (fabs(T1Wh) < 0.1))) {
|
|
174
|
+ // (SumWh == T2Wh) && ((T1Wh == 0) || (T1Wh == NAN))
|
|
175
|
+ // just send T2Wh
|
|
176
|
+ lora_sml_send(LORA_SML_T2_WH, T2Wh, counter);
|
|
177
|
+ } else {
|
|
178
|
+ // just do normal sending if available
|
|
179
|
+ if (!isnan(SumWh)) {
|
|
180
|
+ lora_sml_send(LORA_SML_SUM_WH, SumWh, counter);
|
|
181
|
+ }
|
|
182
|
+ if (!isnan(T1Wh)) {
|
|
183
|
+ lora_sml_send(LORA_SML_T1_WH, T1Wh, counter);
|
|
184
|
+ }
|
|
185
|
+ if (!isnan(T2Wh)) {
|
|
186
|
+ lora_sml_send(LORA_SML_T2_WH, T2Wh, counter);
|
|
187
|
+ }
|
|
188
|
+ }
|
|
189
|
+
|
|
190
|
+ // update own battery state with each sml readout
|
166
|
191
|
lora_sml_send(LORA_SML_BAT_V, lora_get_mangled_bat(), counter);
|
167
|
192
|
#endif // FEATURE_LORA
|
168
|
|
-
|
169
|
|
- debug.println();
|
170
|
193
|
}
|
171
|
194
|
}
|
172
|
195
|
|