mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-29 16:37:17 +02:00
Standardize result of /measures/current for OpenAir
This commit is contained in:
@ -244,15 +244,7 @@ public:
|
||||
uint8_t ledBarMode = UseLedBarOff;
|
||||
if (JSON.typeof_(root["ledBarMode"]) == "string") {
|
||||
String mode = root["ledBarMode"];
|
||||
if (mode == "co2") {
|
||||
ledBarMode = UseLedBarCO2;
|
||||
} else if (mode == "pm") {
|
||||
ledBarMode = UseLedBarPM;
|
||||
} else if (mode == "off") {
|
||||
ledBarMode = UseLedBarOff;
|
||||
} else {
|
||||
ledBarMode = UseLedBarOff;
|
||||
}
|
||||
ledBarMode = parseLedBarMode(mode);
|
||||
}
|
||||
|
||||
/** Get model */
|
||||
@ -447,6 +439,24 @@ public:
|
||||
*/
|
||||
UseLedBar getLedBarMode(void) { return (UseLedBar)config.useRGBLedBar; }
|
||||
|
||||
/**
|
||||
* @brief Return the name of the led bare mode.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String getLedBarModeName(void) {
|
||||
UseLedBar ledBarMode = getLedBarMode();
|
||||
if (ledBarMode == UseLedBarOff) {
|
||||
return String("off");
|
||||
} else if (ledBarMode == UseLedBarPM) {
|
||||
return String("pm");
|
||||
} else if (ledBarMode == UseLedBarCO2) {
|
||||
return String("co2");
|
||||
} else {
|
||||
return String("off");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get the Country
|
||||
*
|
||||
@ -516,6 +526,20 @@ private:
|
||||
EEPROM.commit();
|
||||
Serial.println("Save config");
|
||||
}
|
||||
|
||||
UseLedBar parseLedBarMode(String mode) {
|
||||
UseLedBar ledBarMode = UseLedBarOff;
|
||||
if (mode == "co2") {
|
||||
ledBarMode = UseLedBarCO2;
|
||||
} else if (mode == "pm") {
|
||||
ledBarMode = UseLedBarPM;
|
||||
} else if (mode == "off") {
|
||||
ledBarMode = UseLedBarOff;
|
||||
} else {
|
||||
ledBarMode = UseLedBarOff;
|
||||
}
|
||||
return ledBarMode;
|
||||
}
|
||||
};
|
||||
AgServer agServer;
|
||||
|
||||
@ -1664,7 +1688,11 @@ static String getServerSyncData(bool localServer) {
|
||||
root["pm10"] = pm10_1;
|
||||
}
|
||||
if (pm03PCount_1 >= 0) {
|
||||
root["pm003_count"] = pm03PCount_1;
|
||||
if (localServer) {
|
||||
root["pm003Count"] = pm03PCount_1;
|
||||
} else {
|
||||
root["pm003_count"] = pm03PCount_1;
|
||||
}
|
||||
}
|
||||
if (temp_1 > -1001) {
|
||||
root["atmp"] = ag.round2(temp_1);
|
||||
@ -1683,7 +1711,11 @@ static String getServerSyncData(bool localServer) {
|
||||
root["pm10"] = pm10_2;
|
||||
}
|
||||
if (pm03PCount_2 >= 0) {
|
||||
root["pm003_count"] = pm03PCount_2;
|
||||
if (localServer) {
|
||||
root["pm003Count"] = pm03PCount_2;
|
||||
} else {
|
||||
root["pm003_count"] = pm03PCount_2;
|
||||
}
|
||||
}
|
||||
if (temp_2 > -1001) {
|
||||
root["atmp"] = ag.round2(temp_2);
|
||||
@ -1697,13 +1729,21 @@ static String getServerSyncData(bool localServer) {
|
||||
if ((fw_mode == FW_MODE_PPT) || (fw_mode == FW_MODE_PST)) {
|
||||
if (hasSensorSGP) {
|
||||
if (tvocIndex >= 0) {
|
||||
root["tvoc_index"] = tvocIndex;
|
||||
if (localServer) {
|
||||
root["tvocIndex"] = tvocIndex;
|
||||
} else {
|
||||
root["tvoc_index"] = tvocIndex;
|
||||
}
|
||||
}
|
||||
if (tvocRawIndex >= 0) {
|
||||
root["tvoc_raw"] = tvocRawIndex;
|
||||
}
|
||||
if (noxIndex >= 0) {
|
||||
root["nox_index"] = noxIndex;
|
||||
if (localServer) {
|
||||
root["noxIndex"] = noxIndex;
|
||||
} else {
|
||||
root["nox_index"] = noxIndex;
|
||||
}
|
||||
}
|
||||
if (noxRawIndex >= 0) {
|
||||
root["nox_raw"] = noxRawIndex;
|
||||
@ -1716,7 +1756,11 @@ static String getServerSyncData(bool localServer) {
|
||||
root["pm01"] = ag.round2((pm01_1 + pm01_2) / 2.0);
|
||||
root["pm02"] = ag.round2((pm25_1 + pm25_2) / 2.0);
|
||||
root["pm10"] = ag.round2((pm10_1 + pm10_2) / 2.0);
|
||||
root["pm003_count"] = ag.round2((pm03PCount_1 + pm03PCount_2) / 2.0);
|
||||
if (localServer) {
|
||||
root["pm003Count"] = ag.round2((pm03PCount_1 + pm03PCount_2) / 2.0);
|
||||
} else {
|
||||
root["pm003_count"] = ag.round2((pm03PCount_1 + pm03PCount_2) / 2.0);
|
||||
}
|
||||
root["atmp"] = ag.round2((temp_1 + temp_2) / 2.0);
|
||||
root["rhum"] = ag.round2((hum_1 + hum_2) / 2.0);
|
||||
}
|
||||
@ -1724,7 +1768,11 @@ static String getServerSyncData(bool localServer) {
|
||||
root["channels"]["1"]["pm01"] = pm01_1;
|
||||
root["channels"]["1"]["pm02"] = pm25_1;
|
||||
root["channels"]["1"]["pm10"] = pm10_1;
|
||||
root["channels"]["1"]["pm003_count"] = pm03PCount_1;
|
||||
if (localServer) {
|
||||
root["channels"]["1"]["pm003Count"] = pm03PCount_1;
|
||||
} else {
|
||||
root["channels"]["1"]["pm003_count"] = pm03PCount_1;
|
||||
}
|
||||
root["channels"]["1"]["atmp"] = ag.round2(temp_1);
|
||||
root["channels"]["1"]["rhum"] = hum_1;
|
||||
}
|
||||
@ -1732,12 +1780,21 @@ static String getServerSyncData(bool localServer) {
|
||||
root["channels"]["2"]["pm01"] = pm01_2;
|
||||
root["channels"]["2"]["pm02"] = pm25_2;
|
||||
root["channels"]["2"]["pm10"] = pm10_2;
|
||||
root["channels"]["2"]["pm003_count"] = pm03PCount_2;
|
||||
if (localServer) {
|
||||
root["channels"]["2"]["pm003Count"] = pm03PCount_2;
|
||||
} else {
|
||||
root["channels"]["2"]["pm003_count"] = pm03PCount_2;
|
||||
}
|
||||
root["channels"]["2"]["atmp"] = ag.round2(temp_2);
|
||||
root["channels"]["2"]["rhum"] = hum_2;
|
||||
}
|
||||
}
|
||||
|
||||
if (localServer) {
|
||||
root["ledMode"] = agServer.getLedBarModeName();
|
||||
root["firmwareVersion"] = ag.getVersion();
|
||||
}
|
||||
|
||||
return JSON.stringify(root);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user