Vytvoření funkce getMetricsVar

funkce pro sestavení výstupu metrik
master
David Zálešák 1 year ago
parent c0177b3b3e
commit d98b289b28

@ -193,13 +193,21 @@ void readSensor() {
avgTemperature = avgTemperature / savedTemperatures; avgTemperature = avgTemperature / savedTemperatures;
for (int i = 0; i < ds18Count; i++) { metrics = getMetricsVar(temperature, tempC);
}
String getMetricsVar(float temperature[], float tempC[]) {
metrics = "temp{device=\"";
for (int i = 0; i < sizeof(temperature) - 1 ; i++) {
if (i != 0) {
metrics += "\ntemp{device=\""; metrics += "\ntemp{device=\"";
}
metrics += i; metrics += i;
metrics += "\"} "; metrics += "\"} ";
metrics += temperature[i]; metrics += temperature[i];
} }
for (int i = 0; i < ds18Count; i++) { for (int i = 0; i < sizeof(tempC) - 1; i++) {
metrics += "\nraw_temp{device=\""; metrics += "\nraw_temp{device=\"";
metrics += i; metrics += i;
metrics += "\"} "; metrics += "\"} ";
@ -214,6 +222,7 @@ void readSensor() {
metrics += offset; metrics += offset;
} }
return metrics;
} }
void startConversion() { void startConversion() {