mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-06-28 09:10:57 +02:00
Compare commits
39 Commits
feat/corre
...
3.2.0
Author | SHA1 | Date | |
---|---|---|---|
54808ac076 | |||
063bb2a227 | |||
93f79173b2 | |||
615c2389e7 | |||
f972637cca | |||
4c7e72b8e7 | |||
d4b4f51c3c | |||
1c42ff083d | |||
17d2e62b15 | |||
38aebeb50a | |||
b0f5263829 | |||
3226c14b6d | |||
0e26aa1b5d | |||
bd9dbec663 | |||
29d701780a | |||
afd498074b | |||
e851d0781c | |||
2c27c6904c | |||
03f1b969c2 | |||
85ba13de12 | |||
6ec545b00e | |||
05dbe60db2 | |||
d2ee3a5d24 | |||
1839664137 | |||
154f3ecf8a | |||
b75e40b800 | |||
84a358291b | |||
0e41b2d630 | |||
3e48a562e7 | |||
f0c4df42b7 | |||
c8f0e6a0d2 | |||
1537d5d480 | |||
32c78f6018 | |||
c5c0dae4bb | |||
92e74feabd | |||
56809a412c | |||
6a83743e2a | |||
faaf051e39 | |||
280ea5e997 |
@ -154,11 +154,14 @@ If the monitor is set up on the AirGradient dashboard, it will also receive the
|
|||||||
| `ledBarTestRequested` | Can be set to trigger a test. | Boolean | `true` : LEDs will run test sequence | `{"ledBarTestRequested": true}` |
|
| `ledBarTestRequested` | Can be set to trigger a test. | Boolean | `true` : LEDs will run test sequence | `{"ledBarTestRequested": true}` |
|
||||||
| `noxLearningOffset` | Set NOx learning gain offset. | Number | 0-720 (default 12) | `{"noxLearningOffset": 12}` |
|
| `noxLearningOffset` | Set NOx learning gain offset. | Number | 0-720 (default 12) | `{"noxLearningOffset": 12}` |
|
||||||
| `tvocLearningOffset` | Set VOC learning gain offset. | Number | 0-720 (default 12) | `{"tvocLearningOffset": 12}` |
|
| `tvocLearningOffset` | Set VOC learning gain offset. | Number | 0-720 (default 12) | `{"tvocLearningOffset": 12}` |
|
||||||
| `offlineMode` | Set monitor to run without WiFi. | Boolean | `false`: Disabled (default) <br> `true`: Enabled | `{"offlineMode": true}` |
|
|
||||||
| `monitorDisplayCompensatedValues` | Set the display show the PM value with/without compensate value (only on [3.1.9]()) | Boolean | `false`: Without compensate (default) <br> `true`: with compensate | `{"monitorDisplayCompensatedValues": false }` |
|
| `monitorDisplayCompensatedValues` | Set the display show the PM value with/without compensate value (only on [3.1.9]()) | Boolean | `false`: Without compensate (default) <br> `true`: with compensate | `{"monitorDisplayCompensatedValues": false }` |
|
||||||
| `corrections` | Sets correction options to display and measurement values on local server response. (version >= [3.1.11]()) | Object | _see corrections section_ | _see corrections section_ |
|
| `corrections` | Sets correction options to display and measurement values on local server response. (version >= [3.1.11]()) | Object | _see corrections section_ | _see corrections section_ |
|
||||||
|
|
||||||
|
|
||||||
|
**Notes**
|
||||||
|
|
||||||
|
- `offlineMode` : the device will disable all network operation, and only show measurements on the display and ledbar; Read-Only; Change can be apply using reset button on boot.
|
||||||
|
- `disableCloudConnection` : disable every request to AirGradient server, means features like post data to AirGradient server, configuration from AirGradient server and automatic firmware updates are disabled. This configuration overrides `configurationControl` and `postDataToAirGradient`; Read-Only; Change can be apply from wifi setup webpage.
|
||||||
|
|
||||||
### Corrections
|
### Corrections
|
||||||
|
|
||||||
|
@ -150,9 +150,12 @@ void setup() {
|
|||||||
initMqtt();
|
initMqtt();
|
||||||
sendDataToAg();
|
sendDataToAg();
|
||||||
|
|
||||||
|
if (configuration.getConfigurationControl() !=
|
||||||
|
ConfigurationControl::ConfigurationControlLocal) {
|
||||||
apiClient.fetchServerConfiguration();
|
apiClient.fetchServerConfiguration();
|
||||||
|
}
|
||||||
configSchedule.update();
|
configSchedule.update();
|
||||||
if (apiClient.isFetchConfigureFailed()) {
|
if (apiClient.isFetchConfigurationFailed()) {
|
||||||
if (apiClient.isNotAvailableOnDashboard()) {
|
if (apiClient.isNotAvailableOnDashboard()) {
|
||||||
stateMachine.displaySetAddToDashBoard();
|
stateMachine.displaySetAddToDashBoard();
|
||||||
stateMachine.displayHandle(
|
stateMachine.displayHandle(
|
||||||
@ -416,6 +419,14 @@ static void failedHandler(String msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void configurationUpdateSchedule(void) {
|
static void configurationUpdateSchedule(void) {
|
||||||
|
if (configuration.isOfflineMode() ||
|
||||||
|
configuration.getConfigurationControl() == ConfigurationControl::ConfigurationControlLocal) {
|
||||||
|
Serial.println("Ignore fetch server configuration. Either mode is offline "
|
||||||
|
"or configurationControl set to local");
|
||||||
|
apiClient.resetFetchConfigurationStatus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (apiClient.fetchServerConfiguration()) {
|
if (apiClient.fetchServerConfiguration()) {
|
||||||
configUpdateHandle();
|
configUpdateHandle();
|
||||||
}
|
}
|
||||||
@ -473,7 +484,7 @@ static void appDispHandler(void) {
|
|||||||
if (configuration.isOfflineMode() == false) {
|
if (configuration.isOfflineMode() == false) {
|
||||||
if (wifiConnector.isConnected() == false) {
|
if (wifiConnector.isConnected() == false) {
|
||||||
state = AgStateMachineWiFiLost;
|
state = AgStateMachineWiFiLost;
|
||||||
} else if (apiClient.isFetchConfigureFailed()) {
|
} else if (apiClient.isFetchConfigurationFailed()) {
|
||||||
state = AgStateMachineSensorConfigFailed;
|
state = AgStateMachineSensorConfigFailed;
|
||||||
if (apiClient.isNotAvailableOnDashboard()) {
|
if (apiClient.isNotAvailableOnDashboard()) {
|
||||||
stateMachine.displaySetAddToDashBoard();
|
stateMachine.displaySetAddToDashBoard();
|
||||||
@ -522,17 +533,21 @@ static void sendDataToServer(void) {
|
|||||||
int bootCount = measurements.bootCount() + 1;
|
int bootCount = measurements.bootCount() + 1;
|
||||||
measurements.setBootCount(bootCount);
|
measurements.setBootCount(bootCount);
|
||||||
|
|
||||||
/** Ignore send data to server if postToAirGradient disabled */
|
if (configuration.isOfflineMode() || !configuration.isPostDataToAirGradient()) {
|
||||||
if (configuration.isPostDataToAirGradient() == false ||
|
Serial.println("Skipping transmission of data to AG server. Either mode is offline "
|
||||||
configuration.isOfflineMode()) {
|
"or post data to server disabled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wifiConnector.isConnected() == false) {
|
||||||
|
Serial.println("WiFi not connected, skipping data transmission to AG server");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String syncData = measurements.toString(false, fwMode, wifiConnector.RSSI());
|
String syncData = measurements.toString(false, fwMode, wifiConnector.RSSI());
|
||||||
if (apiClient.postToServer(syncData)) {
|
if (apiClient.postToServer(syncData)) {
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.println(
|
Serial.println("Online mode and isPostToAirGradient = true");
|
||||||
"Online mode and isPostToAirGradient = true: watchdog reset");
|
|
||||||
Serial.println();
|
Serial.println();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ String OpenMetrics::getPayload(void) {
|
|||||||
"1 if the AirGradient device was able to successfully fetch its "
|
"1 if the AirGradient device was able to successfully fetch its "
|
||||||
"configuration from the server",
|
"configuration from the server",
|
||||||
"gauge");
|
"gauge");
|
||||||
add_metric_point("", apiClient.isFetchConfigureFailed() ? "0" : "1");
|
add_metric_point("", apiClient.isFetchConfigurationFailed() ? "0" : "1");
|
||||||
|
|
||||||
add_metric(
|
add_metric(
|
||||||
"post_ok",
|
"post_ok",
|
||||||
|
@ -150,9 +150,12 @@ void setup() {
|
|||||||
initMqtt();
|
initMqtt();
|
||||||
sendDataToAg();
|
sendDataToAg();
|
||||||
|
|
||||||
|
if (configuration.getConfigurationControl() !=
|
||||||
|
ConfigurationControl::ConfigurationControlLocal) {
|
||||||
apiClient.fetchServerConfiguration();
|
apiClient.fetchServerConfiguration();
|
||||||
|
}
|
||||||
configSchedule.update();
|
configSchedule.update();
|
||||||
if (apiClient.isFetchConfigureFailed()) {
|
if (apiClient.isFetchConfigurationFailed()) {
|
||||||
if (apiClient.isNotAvailableOnDashboard()) {
|
if (apiClient.isNotAvailableOnDashboard()) {
|
||||||
stateMachine.displaySetAddToDashBoard();
|
stateMachine.displaySetAddToDashBoard();
|
||||||
stateMachine.displayHandle(
|
stateMachine.displayHandle(
|
||||||
@ -468,6 +471,14 @@ static void failedHandler(String msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void configurationUpdateSchedule(void) {
|
static void configurationUpdateSchedule(void) {
|
||||||
|
if (configuration.isOfflineMode() ||
|
||||||
|
configuration.getConfigurationControl() == ConfigurationControl::ConfigurationControlLocal) {
|
||||||
|
Serial.println("Ignore fetch server configuration. Either mode is offline "
|
||||||
|
"or configurationControl set to local");
|
||||||
|
apiClient.resetFetchConfigurationStatus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (apiClient.fetchServerConfiguration()) {
|
if (apiClient.fetchServerConfiguration()) {
|
||||||
configUpdateHandle();
|
configUpdateHandle();
|
||||||
}
|
}
|
||||||
@ -525,7 +536,7 @@ static void appDispHandler(void) {
|
|||||||
if (configuration.isOfflineMode() == false) {
|
if (configuration.isOfflineMode() == false) {
|
||||||
if (wifiConnector.isConnected() == false) {
|
if (wifiConnector.isConnected() == false) {
|
||||||
state = AgStateMachineWiFiLost;
|
state = AgStateMachineWiFiLost;
|
||||||
} else if (apiClient.isFetchConfigureFailed()) {
|
} else if (apiClient.isFetchConfigurationFailed()) {
|
||||||
state = AgStateMachineSensorConfigFailed;
|
state = AgStateMachineSensorConfigFailed;
|
||||||
if (apiClient.isNotAvailableOnDashboard()) {
|
if (apiClient.isNotAvailableOnDashboard()) {
|
||||||
stateMachine.displaySetAddToDashBoard();
|
stateMachine.displaySetAddToDashBoard();
|
||||||
@ -574,17 +585,21 @@ static void sendDataToServer(void) {
|
|||||||
int bootCount = measurements.bootCount() + 1;
|
int bootCount = measurements.bootCount() + 1;
|
||||||
measurements.setBootCount(bootCount);
|
measurements.setBootCount(bootCount);
|
||||||
|
|
||||||
/** Ignore send data to server if postToAirGradient disabled */
|
if (configuration.isOfflineMode() || !configuration.isPostDataToAirGradient()) {
|
||||||
if (configuration.isPostDataToAirGradient() == false ||
|
Serial.println("Skipping transmission of data to AG server. Either mode is offline "
|
||||||
configuration.isOfflineMode()) {
|
"or post data to server disabled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wifiConnector.isConnected() == false) {
|
||||||
|
Serial.println("WiFi not connected, skipping data transmission to AG server");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String syncData = measurements.toString(false, fwMode, wifiConnector.RSSI());
|
String syncData = measurements.toString(false, fwMode, wifiConnector.RSSI());
|
||||||
if (apiClient.postToServer(syncData)) {
|
if (apiClient.postToServer(syncData)) {
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.println(
|
Serial.println("Online mode and isPostToAirGradient = true");
|
||||||
"Online mode and isPostToAirGradient = true: watchdog reset");
|
|
||||||
Serial.println();
|
Serial.println();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ String OpenMetrics::getPayload(void) {
|
|||||||
"1 if the AirGradient device was able to successfully fetch its "
|
"1 if the AirGradient device was able to successfully fetch its "
|
||||||
"configuration from the server",
|
"configuration from the server",
|
||||||
"gauge");
|
"gauge");
|
||||||
add_metric_point("", apiClient.isFetchConfigureFailed() ? "0" : "1");
|
add_metric_point("", apiClient.isFetchConfigurationFailed() ? "0" : "1");
|
||||||
|
|
||||||
add_metric(
|
add_metric(
|
||||||
"post_ok",
|
"post_ok",
|
||||||
|
@ -177,9 +177,12 @@ void setup() {
|
|||||||
initMqtt();
|
initMqtt();
|
||||||
sendDataToAg();
|
sendDataToAg();
|
||||||
|
|
||||||
|
if (configuration.getConfigurationControl() !=
|
||||||
|
ConfigurationControl::ConfigurationControlLocal) {
|
||||||
apiClient.fetchServerConfiguration();
|
apiClient.fetchServerConfiguration();
|
||||||
|
}
|
||||||
configSchedule.update();
|
configSchedule.update();
|
||||||
if (apiClient.isFetchConfigureFailed()) {
|
if (apiClient.isFetchConfigurationFailed()) {
|
||||||
if (apiClient.isNotAvailableOnDashboard()) {
|
if (apiClient.isNotAvailableOnDashboard()) {
|
||||||
stateMachine.displaySetAddToDashBoard();
|
stateMachine.displaySetAddToDashBoard();
|
||||||
stateMachine.displayHandle(
|
stateMachine.displayHandle(
|
||||||
@ -508,6 +511,14 @@ static void failedHandler(String msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void configurationUpdateSchedule(void) {
|
static void configurationUpdateSchedule(void) {
|
||||||
|
if (configuration.isOfflineMode() ||
|
||||||
|
configuration.getConfigurationControl() == ConfigurationControl::ConfigurationControlLocal) {
|
||||||
|
Serial.println("Ignore fetch server configuration. Either mode is offline "
|
||||||
|
"or configurationControl set to local");
|
||||||
|
apiClient.resetFetchConfigurationStatus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (apiClient.fetchServerConfiguration()) {
|
if (apiClient.fetchServerConfiguration()) {
|
||||||
configUpdateHandle();
|
configUpdateHandle();
|
||||||
}
|
}
|
||||||
@ -565,7 +576,7 @@ static void appDispHandler(void) {
|
|||||||
if (configuration.isOfflineMode() == false) {
|
if (configuration.isOfflineMode() == false) {
|
||||||
if (wifiConnector.isConnected() == false) {
|
if (wifiConnector.isConnected() == false) {
|
||||||
state = AgStateMachineWiFiLost;
|
state = AgStateMachineWiFiLost;
|
||||||
} else if (apiClient.isFetchConfigureFailed()) {
|
} else if (apiClient.isFetchConfigurationFailed()) {
|
||||||
state = AgStateMachineSensorConfigFailed;
|
state = AgStateMachineSensorConfigFailed;
|
||||||
if (apiClient.isNotAvailableOnDashboard()) {
|
if (apiClient.isNotAvailableOnDashboard()) {
|
||||||
stateMachine.displaySetAddToDashBoard();
|
stateMachine.displaySetAddToDashBoard();
|
||||||
@ -615,17 +626,21 @@ static void sendDataToServer(void) {
|
|||||||
int bootCount = measurements.bootCount() + 1;
|
int bootCount = measurements.bootCount() + 1;
|
||||||
measurements.setBootCount(bootCount);
|
measurements.setBootCount(bootCount);
|
||||||
|
|
||||||
/** Ignore send data to server if postToAirGradient disabled */
|
if (configuration.isOfflineMode() || !configuration.isPostDataToAirGradient()) {
|
||||||
if (configuration.isPostDataToAirGradient() == false ||
|
Serial.println("Skipping transmission of data to AG server. Either mode is offline "
|
||||||
configuration.isOfflineMode()) {
|
"or post data to server disabled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wifiConnector.isConnected() == false) {
|
||||||
|
Serial.println("WiFi not connected, skipping data transmission to AG server");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String syncData = measurements.toString(false, fwMode, wifiConnector.RSSI());
|
String syncData = measurements.toString(false, fwMode, wifiConnector.RSSI());
|
||||||
if (apiClient.postToServer(syncData)) {
|
if (apiClient.postToServer(syncData)) {
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.println(
|
Serial.println("Online mode and isPostToAirGradient = true");
|
||||||
"Online mode and isPostToAirGradient = true: watchdog reset");
|
|
||||||
Serial.println();
|
Serial.println();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ String OpenMetrics::getPayload(void) {
|
|||||||
"1 if the AirGradient device was able to successfully fetch its "
|
"1 if the AirGradient device was able to successfully fetch its "
|
||||||
"configuration from the server",
|
"configuration from the server",
|
||||||
"gauge");
|
"gauge");
|
||||||
add_metric_point("", apiClient.isFetchConfigureFailed() ? "0" : "1");
|
add_metric_point("", apiClient.isFetchConfigurationFailed() ? "0" : "1");
|
||||||
|
|
||||||
add_metric(
|
add_metric(
|
||||||
"post_ok",
|
"post_ok",
|
||||||
|
@ -96,6 +96,7 @@ static bool ledBarButtonTest = false;
|
|||||||
static String fwNewVersion;
|
static String fwNewVersion;
|
||||||
|
|
||||||
static void boardInit(void);
|
static void boardInit(void);
|
||||||
|
static void initializeNetwork(void);
|
||||||
static void failedHandler(String msg);
|
static void failedHandler(String msg);
|
||||||
static void configurationUpdateSchedule(void);
|
static void configurationUpdateSchedule(void);
|
||||||
static void updateDisplayAndLedBar(void);
|
static void updateDisplayAndLedBar(void);
|
||||||
@ -111,7 +112,7 @@ static void factoryConfigReset(void);
|
|||||||
static void wdgFeedUpdate(void);
|
static void wdgFeedUpdate(void);
|
||||||
static void ledBarEnabledUpdate(void);
|
static void ledBarEnabledUpdate(void);
|
||||||
static bool sgp41Init(void);
|
static bool sgp41Init(void);
|
||||||
static void firmwareCheckForUpdate(void);
|
static void checkForFirmwareUpdate(void);
|
||||||
static void otaHandlerCallback(OtaHandler::OtaState state, String mesasge);
|
static void otaHandlerCallback(OtaHandler::OtaState state, String mesasge);
|
||||||
static void displayExecuteOta(OtaHandler::OtaState state, String msg, int processing);
|
static void displayExecuteOta(OtaHandler::OtaState state, String msg, int processing);
|
||||||
static int calculateMaxPeriod(int updateInterval);
|
static int calculateMaxPeriod(int updateInterval);
|
||||||
@ -126,7 +127,7 @@ AgSchedule pmsSchedule(SENSOR_PM_UPDATE_INTERVAL, updatePm);
|
|||||||
AgSchedule tempHumSchedule(SENSOR_TEMP_HUM_UPDATE_INTERVAL, tempHumUpdate);
|
AgSchedule tempHumSchedule(SENSOR_TEMP_HUM_UPDATE_INTERVAL, tempHumUpdate);
|
||||||
AgSchedule tvocSchedule(SENSOR_TVOC_UPDATE_INTERVAL, updateTvoc);
|
AgSchedule tvocSchedule(SENSOR_TVOC_UPDATE_INTERVAL, updateTvoc);
|
||||||
AgSchedule watchdogFeedSchedule(60000, wdgFeedUpdate);
|
AgSchedule watchdogFeedSchedule(60000, wdgFeedUpdate);
|
||||||
AgSchedule checkForUpdateSchedule(FIRMWARE_CHECK_FOR_UPDATE_MS, firmwareCheckForUpdate);
|
AgSchedule checkForUpdateSchedule(FIRMWARE_CHECK_FOR_UPDATE_MS, checkForFirmwareUpdate);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
/** Serial for print debug message */
|
/** Serial for print debug message */
|
||||||
@ -209,51 +210,11 @@ void setup() {
|
|||||||
connectToWifi = true;
|
connectToWifi = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize networking configuration
|
||||||
if (connectToWifi) {
|
if (connectToWifi) {
|
||||||
apiClient.begin();
|
initializeNetwork();
|
||||||
|
}
|
||||||
|
|
||||||
if (wifiConnector.connect()) {
|
|
||||||
if (wifiConnector.isConnected()) {
|
|
||||||
mdnsInit();
|
|
||||||
localServer.begin();
|
|
||||||
initMqtt();
|
|
||||||
sendDataToAg();
|
|
||||||
|
|
||||||
#ifdef ESP8266
|
|
||||||
// ota not supported
|
|
||||||
#else
|
|
||||||
firmwareCheckForUpdate();
|
|
||||||
checkForUpdateSchedule.update();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
apiClient.fetchServerConfiguration();
|
|
||||||
configSchedule.update();
|
|
||||||
if (apiClient.isFetchConfigureFailed()) {
|
|
||||||
if (ag->isOne()) {
|
|
||||||
if (apiClient.isNotAvailableOnDashboard()) {
|
|
||||||
stateMachine.displaySetAddToDashBoard();
|
|
||||||
stateMachine.displayHandle(
|
|
||||||
AgStateMachineWiFiOkServerOkSensorConfigFailed);
|
|
||||||
} else {
|
|
||||||
stateMachine.displayClearAddToDashBoard();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
stateMachine.handleLeds(
|
|
||||||
AgStateMachineWiFiOkServerOkSensorConfigFailed);
|
|
||||||
delay(DISPLAY_DELAY_SHOW_CONTENT_MS);
|
|
||||||
} else {
|
|
||||||
ledBarEnabledUpdate();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (wifiConnector.isConfigurePorttalTimeout()) {
|
|
||||||
oledDisplay.showRebooting();
|
|
||||||
delay(2500);
|
|
||||||
oledDisplay.setText("", "", "");
|
|
||||||
ESP.restart();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/** Set offline mode without saving, cause wifi is not configured */
|
/** Set offline mode without saving, cause wifi is not configured */
|
||||||
if (wifiConnector.hasConfigurated() == false) {
|
if (wifiConnector.hasConfigurated() == false) {
|
||||||
Serial.println("Set offline mode cause wifi is not configurated");
|
Serial.println("Set offline mode cause wifi is not configurated");
|
||||||
@ -269,15 +230,16 @@ void setup() {
|
|||||||
oledDisplay.setBrightness(configuration.getDisplayBrightness());
|
oledDisplay.setBrightness(configuration.getDisplayBrightness());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update display and led bar after finishing setup to show dashboard
|
// Reset post schedulers to make sure measurements value already available
|
||||||
updateDisplayAndLedBar();
|
agApiPostSchedule.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
/** Handle schedule */
|
/** Run schedulers */
|
||||||
dispLedSchedule.run();
|
dispLedSchedule.run();
|
||||||
configSchedule.run();
|
configSchedule.run();
|
||||||
agApiPostSchedule.run();
|
agApiPostSchedule.run();
|
||||||
|
watchdogFeedSchedule.run();
|
||||||
|
|
||||||
if (configuration.hasSensorS8) {
|
if (configuration.hasSensorS8) {
|
||||||
co2Schedule.run();
|
co2Schedule.run();
|
||||||
@ -311,15 +273,13 @@ void loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
watchdogFeedSchedule.run();
|
|
||||||
|
|
||||||
/** Check for handle WiFi reconnect */
|
/** Check for handle WiFi reconnect */
|
||||||
wifiConnector.handle();
|
wifiConnector.handle();
|
||||||
|
|
||||||
/** factory reset handle */
|
/** factory reset handle */
|
||||||
factoryConfigReset();
|
factoryConfigReset();
|
||||||
|
|
||||||
/** check that local configura changed then do some action */
|
/** check that local configuration changed then do some action */
|
||||||
configUpdateHandle();
|
configUpdateHandle();
|
||||||
|
|
||||||
/** Firmware check for update handle */
|
/** Firmware check for update handle */
|
||||||
@ -504,17 +464,23 @@ static bool sgp41Init(void) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void firmwareCheckForUpdate(void) {
|
static void checkForFirmwareUpdate(void) {
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.println("firmwareCheckForUpdate:");
|
Serial.print("checkForFirmwareUpdate: ");
|
||||||
|
|
||||||
if (wifiConnector.isConnected()) {
|
if (configuration.isOfflineMode() || configuration.isCloudConnectionDisabled()) {
|
||||||
Serial.println("firmwareCheckForUpdate: Perform");
|
Serial.println("mode is offline or cloud connection disabled, ignored");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!wifiConnector.isConnected()) {
|
||||||
|
Serial.println("wifi not connected, ignored");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Serial.println("perform");
|
||||||
otaHandler.setHandlerCallback(otaHandlerCallback);
|
otaHandler.setHandlerCallback(otaHandlerCallback);
|
||||||
otaHandler.updateFirmwareIfOutdated(ag->deviceId());
|
otaHandler.updateFirmwareIfOutdated(ag->deviceId());
|
||||||
} else {
|
|
||||||
Serial.println("firmwareCheckForUpdate: Ignored");
|
|
||||||
}
|
|
||||||
Serial.println();
|
Serial.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -647,7 +613,7 @@ static void sendDataToAg() {
|
|||||||
}
|
}
|
||||||
stateMachine.handleLeds(AgStateMachineWiFiOkServerConnectFailed);
|
stateMachine.handleLeds(AgStateMachineWiFiOkServerConnectFailed);
|
||||||
}
|
}
|
||||||
delay(DISPLAY_DELAY_SHOW_CONTENT_MS);
|
|
||||||
stateMachine.handleLeds(AgStateMachineNormal);
|
stateMachine.handleLeds(AgStateMachineNormal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -871,7 +837,82 @@ static void failedHandler(String msg) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void initializeNetwork() {
|
||||||
|
if (!wifiConnector.connect()) {
|
||||||
|
Serial.println("Cannot initiate wifi connection");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!wifiConnector.isConnected()) {
|
||||||
|
Serial.println("Failed connect to WiFi");
|
||||||
|
if (wifiConnector.isConfigurePorttalTimeout()) {
|
||||||
|
oledDisplay.showRebooting();
|
||||||
|
delay(2500);
|
||||||
|
oledDisplay.setText("", "", "");
|
||||||
|
ESP.restart();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Directly return because the rest of the function applied if wifi is connect only
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initiate local network configuration
|
||||||
|
mdnsInit();
|
||||||
|
localServer.begin();
|
||||||
|
// Apply mqtt connection if configured
|
||||||
|
initMqtt();
|
||||||
|
|
||||||
|
// Ignore the rest if cloud connection to AirGradient is disabled
|
||||||
|
if (configuration.isCloudConnectionDisabled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize api client
|
||||||
|
apiClient.begin();
|
||||||
|
|
||||||
|
// Send data for the first time to AG server at boot
|
||||||
|
sendDataToAg();
|
||||||
|
|
||||||
|
// OTA check
|
||||||
|
#ifdef ESP8266
|
||||||
|
// ota not supported
|
||||||
|
#else
|
||||||
|
checkForFirmwareUpdate();
|
||||||
|
checkForUpdateSchedule.update();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
apiClient.fetchServerConfiguration();
|
||||||
|
configSchedule.update();
|
||||||
|
if (apiClient.isFetchConfigurationFailed()) {
|
||||||
|
if (ag->isOne()) {
|
||||||
|
if (apiClient.isNotAvailableOnDashboard()) {
|
||||||
|
stateMachine.displaySetAddToDashBoard();
|
||||||
|
stateMachine.displayHandle(AgStateMachineWiFiOkServerOkSensorConfigFailed);
|
||||||
|
} else {
|
||||||
|
stateMachine.displayClearAddToDashBoard();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stateMachine.handleLeds(AgStateMachineWiFiOkServerOkSensorConfigFailed);
|
||||||
|
delay(DISPLAY_DELAY_SHOW_CONTENT_MS);
|
||||||
|
} else {
|
||||||
|
ledBarEnabledUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void configurationUpdateSchedule(void) {
|
static void configurationUpdateSchedule(void) {
|
||||||
|
if (configuration.isOfflineMode() || configuration.isCloudConnectionDisabled() ||
|
||||||
|
configuration.getConfigurationControl() == ConfigurationControl::ConfigurationControlLocal) {
|
||||||
|
Serial.println("Ignore fetch server configuration. Either mode is offline or cloud connection "
|
||||||
|
"disabled or configurationControl set to local");
|
||||||
|
apiClient.resetFetchConfigurationStatus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wifiConnector.isConnected() == false) {
|
||||||
|
Serial.println(" WiFi not connected, skipping fetch configuration from AG server");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (apiClient.fetchServerConfiguration()) {
|
if (apiClient.fetchServerConfiguration()) {
|
||||||
configUpdateHandle();
|
configUpdateHandle();
|
||||||
}
|
}
|
||||||
@ -969,10 +1010,21 @@ static void updateDisplayAndLedBar(void) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
AgStateMachineState state = AgStateMachineNormal;
|
|
||||||
if (wifiConnector.isConnected() == false) {
|
if (wifiConnector.isConnected() == false) {
|
||||||
state = AgStateMachineWiFiLost;
|
stateMachine.displayHandle(AgStateMachineWiFiLost);
|
||||||
} else if (apiClient.isFetchConfigureFailed()) {
|
stateMachine.handleLeds(AgStateMachineWiFiLost);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (configuration.isCloudConnectionDisabled()) {
|
||||||
|
// Ignore API related check since cloud is disabled
|
||||||
|
stateMachine.displayHandle(AgStateMachineNormal);
|
||||||
|
stateMachine.handleLeds(AgStateMachineNormal);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
AgStateMachineState state = AgStateMachineNormal;
|
||||||
|
if (apiClient.isFetchConfigurationFailed()) {
|
||||||
state = AgStateMachineSensorConfigFailed;
|
state = AgStateMachineSensorConfigFailed;
|
||||||
if (apiClient.isNotAvailableOnDashboard()) {
|
if (apiClient.isNotAvailableOnDashboard()) {
|
||||||
stateMachine.displaySetAddToDashBoard();
|
stateMachine.displaySetAddToDashBoard();
|
||||||
@ -1140,16 +1192,22 @@ static void sendDataToServer(void) {
|
|||||||
int bootCount = measurements.bootCount() + 1;
|
int bootCount = measurements.bootCount() + 1;
|
||||||
measurements.setBootCount(bootCount);
|
measurements.setBootCount(bootCount);
|
||||||
|
|
||||||
/** Ignore send data to server if postToAirGradient disabled */
|
if (configuration.isOfflineMode() || configuration.isCloudConnectionDisabled() ||
|
||||||
if (configuration.isPostDataToAirGradient() == false || configuration.isOfflineMode()) {
|
!configuration.isPostDataToAirGradient()) {
|
||||||
|
Serial.println("Skipping transmission of data to AG server. Either mode is offline or cloud connection is "
|
||||||
|
"disabled or post data to server disabled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (wifiConnector.isConnected() == false) {
|
||||||
|
Serial.println("WiFi not connected, skipping data transmission to AG server");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String syncData = measurements.toString(false, fwMode, wifiConnector.RSSI());
|
String syncData = measurements.toString(false, fwMode, wifiConnector.RSSI());
|
||||||
if (apiClient.postToServer(syncData)) {
|
if (apiClient.postToServer(syncData)) {
|
||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.println(
|
Serial.println("Online mode and isPostToAirGradient = true");
|
||||||
"Online mode and isPostToAirGradient = true: watchdog reset");
|
|
||||||
Serial.println();
|
Serial.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ String OpenMetrics::getPayload(void) {
|
|||||||
"1 if the AirGradient device was able to successfully fetch its "
|
"1 if the AirGradient device was able to successfully fetch its "
|
||||||
"configuration from the server",
|
"configuration from the server",
|
||||||
"gauge");
|
"gauge");
|
||||||
add_metric_point("", apiClient.isFetchConfigureFailed() ? "0" : "1");
|
add_metric_point("", apiClient.isFetchConfigurationFailed() ? "0" : "1");
|
||||||
|
|
||||||
add_metric(
|
add_metric(
|
||||||
"post_ok",
|
"post_ok",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name=AirGradient Air Quality Sensor
|
name=AirGradient Air Quality Sensor
|
||||||
version=3.1.21
|
version=3.2.0
|
||||||
author=AirGradient <support@airgradient.com>
|
author=AirGradient <support@airgradient.com>
|
||||||
maintainer=AirGradient <support@airgradient.com>
|
maintainer=AirGradient <support@airgradient.com>
|
||||||
sentence=ESP32-C3 / ESP8266 library for air quality monitor measuring PM, CO2, Temperature, TVOC and Humidity with OLED display.
|
sentence=ESP32-C3 / ESP8266 library for air quality monitor measuring PM, CO2, Temperature, TVOC and Humidity with OLED display.
|
||||||
|
@ -34,17 +34,6 @@ void AgApiClient::begin(void) {
|
|||||||
* @return false Failure
|
* @return false Failure
|
||||||
*/
|
*/
|
||||||
bool AgApiClient::fetchServerConfiguration(void) {
|
bool AgApiClient::fetchServerConfiguration(void) {
|
||||||
if (config.getConfigurationControl() ==
|
|
||||||
ConfigurationControl::ConfigurationControlLocal ||
|
|
||||||
config.isOfflineMode()) {
|
|
||||||
logWarning("Ignore fetch server configuration");
|
|
||||||
|
|
||||||
// Clear server configuration failed flag, cause it's ignore but not
|
|
||||||
// really failed
|
|
||||||
getConfigFailed = false;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String uri = apiRoot + "/sensors/airgradient:" +
|
String uri = apiRoot + "/sensors/airgradient:" +
|
||||||
ag->deviceId() + "/one/config";
|
ag->deviceId() + "/one/config";
|
||||||
|
|
||||||
@ -58,7 +47,8 @@ bool AgApiClient::fetchServerConfiguration(void) {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
HTTPClient client;
|
HTTPClient client;
|
||||||
client.setTimeout(timeoutMs);
|
client.setConnectTimeout(timeoutMs); // Set timeout when establishing connection to server
|
||||||
|
client.setTimeout(timeoutMs); // Timeout when waiting for response from AG server
|
||||||
if (apiRootChanged) {
|
if (apiRootChanged) {
|
||||||
// If apiRoot is changed, assume not using https
|
// If apiRoot is changed, assume not using https
|
||||||
if (client.begin(uri) == false) {
|
if (client.begin(uri) == false) {
|
||||||
@ -114,15 +104,6 @@ bool AgApiClient::fetchServerConfiguration(void) {
|
|||||||
* @return false Failure
|
* @return false Failure
|
||||||
*/
|
*/
|
||||||
bool AgApiClient::postToServer(String data) {
|
bool AgApiClient::postToServer(String data) {
|
||||||
if (config.isPostDataToAirGradient() == false) {
|
|
||||||
logWarning("Ignore post data to server");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (WiFi.isConnected() == false) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String uri = apiRoot + "/sensors/airgradient:" + ag->deviceId() + "/measures";
|
String uri = apiRoot + "/sensors/airgradient:" + ag->deviceId() + "/measures";
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
HTTPClient client;
|
HTTPClient client;
|
||||||
@ -133,7 +114,8 @@ bool AgApiClient::postToServer(String data) {
|
|||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
HTTPClient client;
|
HTTPClient client;
|
||||||
client.setTimeout(timeoutMs);
|
client.setConnectTimeout(timeoutMs); // Set timeout when establishing connection to server
|
||||||
|
client.setTimeout(timeoutMs); // Timeout when waiting for response from AG server
|
||||||
if (apiRootChanged) {
|
if (apiRootChanged) {
|
||||||
// If apiRoot is changed, assume not using https
|
// If apiRoot is changed, assume not using https
|
||||||
if (client.begin(uri) == false) {
|
if (client.begin(uri) == false) {
|
||||||
@ -173,7 +155,12 @@ bool AgApiClient::postToServer(String data) {
|
|||||||
* @return true Success
|
* @return true Success
|
||||||
* @return false Failure
|
* @return false Failure
|
||||||
*/
|
*/
|
||||||
bool AgApiClient::isFetchConfigureFailed(void) { return getConfigFailed; }
|
bool AgApiClient::isFetchConfigurationFailed(void) { return getConfigFailed; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Reset status of get configuration from AirGradient cloud
|
||||||
|
*/
|
||||||
|
void AgApiClient::resetFetchConfigurationStatus(void) { getConfigFailed = false; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get failed status when post data to AirGradient cloud
|
* @brief Get failed status when post data to AirGradient cloud
|
||||||
|
@ -31,7 +31,7 @@ private:
|
|||||||
bool getConfigFailed;
|
bool getConfigFailed;
|
||||||
bool postToServerFailed;
|
bool postToServerFailed;
|
||||||
bool notAvailableOnDashboard = false; // Device not setup on Airgradient cloud dashboard.
|
bool notAvailableOnDashboard = false; // Device not setup on Airgradient cloud dashboard.
|
||||||
uint16_t timeoutMs = 10000; // Default set to 10s
|
uint16_t timeoutMs = 15000; // Default set to 15s
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AgApiClient(Stream &stream, Configuration &config);
|
AgApiClient(Stream &stream, Configuration &config);
|
||||||
@ -40,7 +40,8 @@ public:
|
|||||||
void begin(void);
|
void begin(void);
|
||||||
bool fetchServerConfiguration(void);
|
bool fetchServerConfiguration(void);
|
||||||
bool postToServer(String data);
|
bool postToServer(String data);
|
||||||
bool isFetchConfigureFailed(void);
|
bool isFetchConfigurationFailed(void);
|
||||||
|
void resetFetchConfigurationStatus(void);
|
||||||
bool isPostToServerFailed(void);
|
bool isPostToServerFailed(void);
|
||||||
bool isNotAvailableOnDashboard(void);
|
bool isNotAvailableOnDashboard(void);
|
||||||
void setAirGradient(AirGradient *ag);
|
void setAirGradient(AirGradient *ag);
|
||||||
|
@ -22,15 +22,10 @@ const char *LED_BAR_MODE_NAMES[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const char *PM_CORRECTION_ALGORITHM_NAMES[] = {
|
const char *PM_CORRECTION_ALGORITHM_NAMES[] = {
|
||||||
[Unknown] = "-", // This is only to pass "non-trivial designated initializers" error
|
[COR_ALGO_PM_UNKNOWN] = "-", // This is only to pass "non-trivial designated initializers" error
|
||||||
[None] = "none",
|
[COR_ALGO_PM_NONE] = "none",
|
||||||
[EPA_2021] = "epa_2021",
|
[COR_ALGO_PM_EPA_2021] = "epa_2021",
|
||||||
[SLR_PMS5003_20220802] = "slr_PMS5003_20220802",
|
[COR_ALGO_PM_SLR_CUSTOM] = "custom",
|
||||||
[SLR_PMS5003_20220803] = "slr_PMS5003_20220803",
|
|
||||||
[SLR_PMS5003_20220824] = "slr_PMS5003_20220824",
|
|
||||||
[SLR_PMS5003_20231030] = "slr_PMS5003_20231030",
|
|
||||||
[SLR_PMS5003_20231218] = "slr_PMS5003_20231218",
|
|
||||||
[SLR_PMS5003_20240104] = "slr_PMS5003_20240104",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *TEMP_HUM_CORRECTION_ALGORITHM_NAMES[] = {
|
const char *TEMP_HUM_CORRECTION_ALGORITHM_NAMES[] = {
|
||||||
@ -54,6 +49,7 @@ JSON_PROP_DEF(mqttBrokerUrl);
|
|||||||
JSON_PROP_DEF(temperatureUnit);
|
JSON_PROP_DEF(temperatureUnit);
|
||||||
JSON_PROP_DEF(configurationControl);
|
JSON_PROP_DEF(configurationControl);
|
||||||
JSON_PROP_DEF(postDataToAirGradient);
|
JSON_PROP_DEF(postDataToAirGradient);
|
||||||
|
JSON_PROP_DEF(disableCloudConnection);
|
||||||
JSON_PROP_DEF(ledBarBrightness);
|
JSON_PROP_DEF(ledBarBrightness);
|
||||||
JSON_PROP_DEF(displayBrightness);
|
JSON_PROP_DEF(displayBrightness);
|
||||||
JSON_PROP_DEF(co2CalibrationRequested);
|
JSON_PROP_DEF(co2CalibrationRequested);
|
||||||
@ -75,6 +71,7 @@ JSON_PROP_DEF(rhum);
|
|||||||
#define jprop_temperatureUnit_default "c"
|
#define jprop_temperatureUnit_default "c"
|
||||||
#define jprop_configurationControl_default String(CONFIGURATION_CONTROL_NAME[ConfigurationControl::ConfigurationControlBoth])
|
#define jprop_configurationControl_default String(CONFIGURATION_CONTROL_NAME[ConfigurationControl::ConfigurationControlBoth])
|
||||||
#define jprop_postDataToAirGradient_default true
|
#define jprop_postDataToAirGradient_default true
|
||||||
|
#define jprop_disableCloudConnection_default false
|
||||||
#define jprop_ledBarBrightness_default 100
|
#define jprop_ledBarBrightness_default 100
|
||||||
#define jprop_displayBrightness_default 100
|
#define jprop_displayBrightness_default 100
|
||||||
#define jprop_offlineMode_default false
|
#define jprop_offlineMode_default false
|
||||||
@ -113,8 +110,8 @@ PMCorrectionAlgorithm Configuration::matchPmAlgorithm(String algorithm) {
|
|||||||
// If the input string matches an algorithm name, return the corresponding enum value
|
// If the input string matches an algorithm name, return the corresponding enum value
|
||||||
// Else return Unknown
|
// Else return Unknown
|
||||||
|
|
||||||
const size_t enumSize = SLR_PMS5003_20240104 + 1; // Get the actual size of the enum
|
const size_t enumSize = COR_ALGO_PM_SLR_CUSTOM + 1; // Get the actual size of the enum
|
||||||
PMCorrectionAlgorithm result = PMCorrectionAlgorithm::Unknown;
|
PMCorrectionAlgorithm result = COR_ALGO_PM_UNKNOWN;;
|
||||||
|
|
||||||
// Loop through enum values
|
// Loop through enum values
|
||||||
for (size_t enumVal = 0; enumVal < enumSize; enumVal++) {
|
for (size_t enumVal = 0; enumVal < enumSize; enumVal++) {
|
||||||
@ -123,6 +120,15 @@ PMCorrectionAlgorithm Configuration::matchPmAlgorithm(String algorithm) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If string not match from enum, check if correctionAlgorithm is one of the PM batch corrections
|
||||||
|
if (result == COR_ALGO_PM_UNKNOWN) {
|
||||||
|
// Check the substring "slr_PMS5003_xxxxxxxx"
|
||||||
|
if (algorithm.substring(0, 11) == "slr_PMS5003") {
|
||||||
|
// If it is, then its a custom correction
|
||||||
|
result = COR_ALGO_PM_SLR_CUSTOM;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,36 +149,34 @@ TempHumCorrectionAlgorithm Configuration::matchTempHumAlgorithm(String algorithm
|
|||||||
|
|
||||||
bool Configuration::updatePmCorrection(JSONVar &json) {
|
bool Configuration::updatePmCorrection(JSONVar &json) {
|
||||||
if (!json.hasOwnProperty("corrections")) {
|
if (!json.hasOwnProperty("corrections")) {
|
||||||
Serial.println("corrections not found");
|
logInfo("corrections not found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONVar corrections = json["corrections"];
|
JSONVar corrections = json["corrections"];
|
||||||
if (!corrections.hasOwnProperty("pm02")) {
|
if (!corrections.hasOwnProperty("pm02")) {
|
||||||
Serial.println("pm02 not found");
|
logWarning("pm02 not found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONVar pm02 = corrections["pm02"];
|
JSONVar pm02 = corrections["pm02"];
|
||||||
if (!pm02.hasOwnProperty("correctionAlgorithm")) {
|
if (!pm02.hasOwnProperty("correctionAlgorithm")) {
|
||||||
Serial.println("correctionAlgorithm not found");
|
logWarning("pm02 correctionAlgorithm not found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Need to have data type check, with error message response if invalid
|
|
||||||
|
|
||||||
// Check algorithm
|
// Check algorithm
|
||||||
String algorithm = pm02["correctionAlgorithm"];
|
String algorithm = pm02["correctionAlgorithm"];
|
||||||
PMCorrectionAlgorithm algo = matchPmAlgorithm(algorithm);
|
PMCorrectionAlgorithm algo = matchPmAlgorithm(algorithm);
|
||||||
if (algo == Unknown) {
|
if (algo == COR_ALGO_PM_UNKNOWN) {
|
||||||
logInfo("Unknown algorithm");
|
logWarning("Unknown algorithm");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
logInfo("Correction algorithm: " + algorithm);
|
logInfo("Correction algorithm: " + algorithm);
|
||||||
|
|
||||||
// If algo is None or EPA_2021, no need to check slr
|
// If algo is None or EPA_2021, no need to check slr
|
||||||
// But first check if pmCorrection different from algo
|
// But first check if pmCorrection different from algo
|
||||||
if (algo == None || algo == EPA_2021) {
|
if (algo == COR_ALGO_PM_NONE || algo == COR_ALGO_PM_EPA_2021) {
|
||||||
if (pmCorrection.algorithm != algo) {
|
if (pmCorrection.algorithm != algo) {
|
||||||
// Deep copy corrections from root to jconfig, so it will be saved later
|
// Deep copy corrections from root to jconfig, so it will be saved later
|
||||||
jconfig[jprop_corrections]["pm02"]["correctionAlgorithm"] = algorithm;
|
jconfig[jprop_corrections]["pm02"]["correctionAlgorithm"] = algorithm;
|
||||||
@ -189,7 +193,7 @@ bool Configuration::updatePmCorrection(JSONVar &json) {
|
|||||||
|
|
||||||
// Check if pm02 has slr object
|
// Check if pm02 has slr object
|
||||||
if (!pm02.hasOwnProperty("slr")) {
|
if (!pm02.hasOwnProperty("slr")) {
|
||||||
Serial.println("slr not found");
|
logWarning("slr not found");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +202,7 @@ bool Configuration::updatePmCorrection(JSONVar &json) {
|
|||||||
// Validate required slr properties exist
|
// Validate required slr properties exist
|
||||||
if (!slr.hasOwnProperty("intercept") || !slr.hasOwnProperty("scalingFactor") ||
|
if (!slr.hasOwnProperty("intercept") || !slr.hasOwnProperty("scalingFactor") ||
|
||||||
!slr.hasOwnProperty("useEpa2021")) {
|
!slr.hasOwnProperty("useEpa2021")) {
|
||||||
Serial.println("Missing required slr properties");
|
logWarning("Missing required slr properties");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +240,6 @@ bool Configuration::updateTempHumCorrection(JSONVar &json, TempHumCorrection &ta
|
|||||||
|
|
||||||
JSONVar corrections = json[jprop_corrections];
|
JSONVar corrections = json[jprop_corrections];
|
||||||
if (!corrections.hasOwnProperty(correctionName)) {
|
if (!corrections.hasOwnProperty(correctionName)) {
|
||||||
Serial.println("pm02 not found");
|
|
||||||
logWarning(String(correctionName) + " correction field not found on configuration");
|
logWarning(String(correctionName) + " correction field not found on configuration");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -377,6 +380,7 @@ void Configuration::defaultConfig(void) {
|
|||||||
jconfig[jprop_configurationControl] = jprop_configurationControl_default;
|
jconfig[jprop_configurationControl] = jprop_configurationControl_default;
|
||||||
jconfig[jprop_pmStandard] = jprop_pmStandard_default;
|
jconfig[jprop_pmStandard] = jprop_pmStandard_default;
|
||||||
jconfig[jprop_temperatureUnit] = jprop_temperatureUnit_default;
|
jconfig[jprop_temperatureUnit] = jprop_temperatureUnit_default;
|
||||||
|
jconfig[jprop_disableCloudConnection] = jprop_disableCloudConnection_default;
|
||||||
jconfig[jprop_postDataToAirGradient] = jprop_postDataToAirGradient_default;
|
jconfig[jprop_postDataToAirGradient] = jprop_postDataToAirGradient_default;
|
||||||
if (ag->isOne()) {
|
if (ag->isOne()) {
|
||||||
jconfig[jprop_ledBarBrightness] = jprop_ledBarBrightness_default;
|
jconfig[jprop_ledBarBrightness] = jprop_ledBarBrightness_default;
|
||||||
@ -394,8 +398,8 @@ void Configuration::defaultConfig(void) {
|
|||||||
jconfig[jprop_offlineMode] = jprop_offlineMode_default;
|
jconfig[jprop_offlineMode] = jprop_offlineMode_default;
|
||||||
jconfig[jprop_monitorDisplayCompensatedValues] = jprop_monitorDisplayCompensatedValues_default;
|
jconfig[jprop_monitorDisplayCompensatedValues] = jprop_monitorDisplayCompensatedValues_default;
|
||||||
|
|
||||||
// PM2.5 correction
|
// PM2.5 default correction
|
||||||
pmCorrection.algorithm = None;
|
pmCorrection.algorithm = COR_ALGO_PM_NONE;
|
||||||
pmCorrection.changed = false;
|
pmCorrection.changed = false;
|
||||||
pmCorrection.intercept = 0;
|
pmCorrection.intercept = 0;
|
||||||
pmCorrection.scalingFactor = 1;
|
pmCorrection.scalingFactor = 1;
|
||||||
@ -1151,20 +1155,20 @@ void Configuration::toConfig(const char *buf) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
bool isInvalid = false;
|
bool isConfigFieldInvalid = false;
|
||||||
|
|
||||||
/** Validate country */
|
/** Validate country */
|
||||||
if (JSON.typeof_(jconfig[jprop_country]) != "string") {
|
if (JSON.typeof_(jconfig[jprop_country]) != "string") {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
String country = jconfig[jprop_country];
|
String country = jconfig[jprop_country];
|
||||||
if (country.length() != 2) {
|
if (country.length() != 2) {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
isInvalid = false;
|
isConfigFieldInvalid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isInvalid) {
|
if (isConfigFieldInvalid) {
|
||||||
jconfig[jprop_country] = jprop_country_default;
|
jconfig[jprop_country] = jprop_country_default;
|
||||||
changed = true;
|
changed = true;
|
||||||
logInfo("toConfig: country changed");
|
logInfo("toConfig: country changed");
|
||||||
@ -1172,17 +1176,17 @@ void Configuration::toConfig(const char *buf) {
|
|||||||
|
|
||||||
/** validate: PM standard */
|
/** validate: PM standard */
|
||||||
if (JSON.typeof_(jconfig[jprop_pmStandard]) != "string") {
|
if (JSON.typeof_(jconfig[jprop_pmStandard]) != "string") {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
String standard = jconfig[jprop_pmStandard];
|
String standard = jconfig[jprop_pmStandard];
|
||||||
if (standard != getPMStandardString(true) &&
|
if (standard != getPMStandardString(true) &&
|
||||||
standard != getPMStandardString(false)) {
|
standard != getPMStandardString(false)) {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
isInvalid = false;
|
isConfigFieldInvalid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isInvalid) {
|
if (isConfigFieldInvalid) {
|
||||||
jconfig[jprop_pmStandard] = jprop_pmStandard_default;
|
jconfig[jprop_pmStandard] = jprop_pmStandard_default;
|
||||||
changed = true;
|
changed = true;
|
||||||
logInfo("toConfig: pmStandard changed");
|
logInfo("toConfig: pmStandard changed");
|
||||||
@ -1190,18 +1194,18 @@ void Configuration::toConfig(const char *buf) {
|
|||||||
|
|
||||||
/** validate led bar mode */
|
/** validate led bar mode */
|
||||||
if (JSON.typeof_(jconfig[jprop_ledBarMode]) != "string") {
|
if (JSON.typeof_(jconfig[jprop_ledBarMode]) != "string") {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
String mode = jconfig[jprop_ledBarMode];
|
String mode = jconfig[jprop_ledBarMode];
|
||||||
if (mode != getLedBarModeName(LedBarMode::LedBarModeCO2) &&
|
if (mode != getLedBarModeName(LedBarMode::LedBarModeCO2) &&
|
||||||
mode != getLedBarModeName(LedBarMode::LedBarModeOff) &&
|
mode != getLedBarModeName(LedBarMode::LedBarModeOff) &&
|
||||||
mode != getLedBarModeName(LedBarMode::LedBarModePm)) {
|
mode != getLedBarModeName(LedBarMode::LedBarModePm)) {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
isInvalid = false;
|
isConfigFieldInvalid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isInvalid) {
|
if (isConfigFieldInvalid) {
|
||||||
jconfig[jprop_ledBarMode] = jprop_ledBarMode_default;
|
jconfig[jprop_ledBarMode] = jprop_ledBarMode_default;
|
||||||
changed = true;
|
changed = true;
|
||||||
logInfo("toConfig: ledBarMode changed");
|
logInfo("toConfig: ledBarMode changed");
|
||||||
@ -1209,11 +1213,11 @@ void Configuration::toConfig(const char *buf) {
|
|||||||
|
|
||||||
/** validate abcday */
|
/** validate abcday */
|
||||||
if (JSON.typeof_(jconfig[jprop_abcDays]) != "number") {
|
if (JSON.typeof_(jconfig[jprop_abcDays]) != "number") {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
isInvalid = false;
|
isConfigFieldInvalid = false;
|
||||||
}
|
}
|
||||||
if (isInvalid) {
|
if (isConfigFieldInvalid) {
|
||||||
jconfig[jprop_abcDays] = jprop_abcDays_default;
|
jconfig[jprop_abcDays] = jprop_abcDays_default;
|
||||||
changed = true;
|
changed = true;
|
||||||
logInfo("toConfig: abcDays changed");
|
logInfo("toConfig: abcDays changed");
|
||||||
@ -1221,16 +1225,16 @@ void Configuration::toConfig(const char *buf) {
|
|||||||
|
|
||||||
/** validate tvoc learning offset */
|
/** validate tvoc learning offset */
|
||||||
if (JSON.typeof_(jconfig[jprop_tvocLearningOffset]) != "number") {
|
if (JSON.typeof_(jconfig[jprop_tvocLearningOffset]) != "number") {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
int value = jconfig[jprop_tvocLearningOffset];
|
int value = jconfig[jprop_tvocLearningOffset];
|
||||||
if (value < 0) {
|
if (value < 0) {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
isInvalid = false;
|
isConfigFieldInvalid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isInvalid) {
|
if (isConfigFieldInvalid) {
|
||||||
jconfig[jprop_tvocLearningOffset] = jprop_tvocLearningOffset_default;
|
jconfig[jprop_tvocLearningOffset] = jprop_tvocLearningOffset_default;
|
||||||
changed = true;
|
changed = true;
|
||||||
logInfo("toConfig: tvocLearningOffset changed");
|
logInfo("toConfig: tvocLearningOffset changed");
|
||||||
@ -1238,16 +1242,16 @@ void Configuration::toConfig(const char *buf) {
|
|||||||
|
|
||||||
/** validate nox learning offset */
|
/** validate nox learning offset */
|
||||||
if (JSON.typeof_(jconfig[jprop_noxLearningOffset]) != "number") {
|
if (JSON.typeof_(jconfig[jprop_noxLearningOffset]) != "number") {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
int value = jconfig[jprop_noxLearningOffset];
|
int value = jconfig[jprop_noxLearningOffset];
|
||||||
if (value < 0) {
|
if (value < 0) {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
isInvalid = false;
|
isConfigFieldInvalid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isInvalid) {
|
if (isConfigFieldInvalid) {
|
||||||
jconfig[jprop_noxLearningOffset] = jprop_noxLearningOffset_default;
|
jconfig[jprop_noxLearningOffset] = jprop_noxLearningOffset_default;
|
||||||
changed = true;
|
changed = true;
|
||||||
logInfo("toConfig: noxLearningOffset changed");
|
logInfo("toConfig: noxLearningOffset changed");
|
||||||
@ -1255,11 +1259,11 @@ void Configuration::toConfig(const char *buf) {
|
|||||||
|
|
||||||
/** validate mqtt broker */
|
/** validate mqtt broker */
|
||||||
if (JSON.typeof_(jconfig[jprop_mqttBrokerUrl]) != "string") {
|
if (JSON.typeof_(jconfig[jprop_mqttBrokerUrl]) != "string") {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
isInvalid = false;
|
isConfigFieldInvalid = false;
|
||||||
}
|
}
|
||||||
if (isInvalid) {
|
if (isConfigFieldInvalid) {
|
||||||
changed = true;
|
changed = true;
|
||||||
jconfig[jprop_mqttBrokerUrl] = jprop_mqttBrokerUrl_default;
|
jconfig[jprop_mqttBrokerUrl] = jprop_mqttBrokerUrl_default;
|
||||||
logInfo("toConfig: mqttBroker changed");
|
logInfo("toConfig: mqttBroker changed");
|
||||||
@ -1267,24 +1271,36 @@ void Configuration::toConfig(const char *buf) {
|
|||||||
|
|
||||||
/** Validate temperature unit */
|
/** Validate temperature unit */
|
||||||
if (JSON.typeof_(jconfig[jprop_temperatureUnit]) != "string") {
|
if (JSON.typeof_(jconfig[jprop_temperatureUnit]) != "string") {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
String unit = jconfig[jprop_temperatureUnit];
|
String unit = jconfig[jprop_temperatureUnit];
|
||||||
if (unit != "c" && unit != "f") {
|
if (unit != "c" && unit != "f") {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
isInvalid = false;
|
isConfigFieldInvalid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isInvalid) {
|
if (isConfigFieldInvalid) {
|
||||||
jconfig[jprop_temperatureUnit] = jprop_temperatureUnit_default;
|
jconfig[jprop_temperatureUnit] = jprop_temperatureUnit_default;
|
||||||
changed = true;
|
changed = true;
|
||||||
logInfo("toConfig: temperatureUnit changed");
|
logInfo("toConfig: temperatureUnit changed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** validate disableCloudConnection configuration */
|
||||||
|
if (JSON.typeof_(jconfig[jprop_disableCloudConnection]) != "boolean") {
|
||||||
|
isConfigFieldInvalid = true;
|
||||||
|
} else {
|
||||||
|
isConfigFieldInvalid = false;
|
||||||
|
}
|
||||||
|
if (isConfigFieldInvalid) {
|
||||||
|
jconfig[jprop_disableCloudConnection] = jprop_disableCloudConnection_default;
|
||||||
|
changed = true;
|
||||||
|
logInfo("toConfig: disableCloudConnection changed");
|
||||||
|
}
|
||||||
|
|
||||||
/** validate configuration control */
|
/** validate configuration control */
|
||||||
if (JSON.typeof_(jprop_configurationControl) != "string") {
|
if (JSON.typeof_(jprop_configurationControl) != "string") {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
String ctrl = jconfig[jprop_configurationControl];
|
String ctrl = jconfig[jprop_configurationControl];
|
||||||
if (ctrl != String(CONFIGURATION_CONTROL_NAME
|
if (ctrl != String(CONFIGURATION_CONTROL_NAME
|
||||||
@ -1293,12 +1309,12 @@ void Configuration::toConfig(const char *buf) {
|
|||||||
[ConfigurationControl::ConfigurationControlLocal]) &&
|
[ConfigurationControl::ConfigurationControlLocal]) &&
|
||||||
ctrl != String(CONFIGURATION_CONTROL_NAME
|
ctrl != String(CONFIGURATION_CONTROL_NAME
|
||||||
[ConfigurationControl::ConfigurationControlCloud])) {
|
[ConfigurationControl::ConfigurationControlCloud])) {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
isInvalid = false;
|
isConfigFieldInvalid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isInvalid) {
|
if (isConfigFieldInvalid) {
|
||||||
jconfig[jprop_configurationControl] =jprop_configurationControl_default;
|
jconfig[jprop_configurationControl] =jprop_configurationControl_default;
|
||||||
changed = true;
|
changed = true;
|
||||||
logInfo("toConfig: configurationControl changed");
|
logInfo("toConfig: configurationControl changed");
|
||||||
@ -1306,11 +1322,11 @@ void Configuration::toConfig(const char *buf) {
|
|||||||
|
|
||||||
/** Validate post to airgradient cloud */
|
/** Validate post to airgradient cloud */
|
||||||
if (JSON.typeof_(jconfig[jprop_postDataToAirGradient]) != "boolean") {
|
if (JSON.typeof_(jconfig[jprop_postDataToAirGradient]) != "boolean") {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
isInvalid = false;
|
isConfigFieldInvalid = false;
|
||||||
}
|
}
|
||||||
if (isInvalid) {
|
if (isConfigFieldInvalid) {
|
||||||
jconfig[jprop_postDataToAirGradient] = jprop_postDataToAirGradient_default;
|
jconfig[jprop_postDataToAirGradient] = jprop_postDataToAirGradient_default;
|
||||||
changed = true;
|
changed = true;
|
||||||
logInfo("toConfig: postToAirGradient changed");
|
logInfo("toConfig: postToAirGradient changed");
|
||||||
@ -1318,16 +1334,16 @@ void Configuration::toConfig(const char *buf) {
|
|||||||
|
|
||||||
/** validate led bar brightness */
|
/** validate led bar brightness */
|
||||||
if (JSON.typeof_(jconfig[jprop_ledBarBrightness]) != "number") {
|
if (JSON.typeof_(jconfig[jprop_ledBarBrightness]) != "number") {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
int value = jconfig[jprop_ledBarBrightness];
|
int value = jconfig[jprop_ledBarBrightness];
|
||||||
if (value < 0 || value > 100) {
|
if (value < 0 || value > 100) {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
isInvalid = false;
|
isConfigFieldInvalid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isInvalid) {
|
if (isConfigFieldInvalid) {
|
||||||
jconfig[jprop_ledBarBrightness] = jprop_ledBarBrightness_default;
|
jconfig[jprop_ledBarBrightness] = jprop_ledBarBrightness_default;
|
||||||
changed = true;
|
changed = true;
|
||||||
logInfo("toConfig: ledBarBrightness changed");
|
logInfo("toConfig: ledBarBrightness changed");
|
||||||
@ -1335,16 +1351,16 @@ void Configuration::toConfig(const char *buf) {
|
|||||||
|
|
||||||
/** Validate display brightness */
|
/** Validate display brightness */
|
||||||
if (JSON.typeof_(jconfig[jprop_displayBrightness]) != "number") {
|
if (JSON.typeof_(jconfig[jprop_displayBrightness]) != "number") {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
int value = jconfig[jprop_displayBrightness];
|
int value = jconfig[jprop_displayBrightness];
|
||||||
if (value < 0 || value > 100) {
|
if (value < 0 || value > 100) {
|
||||||
isInvalid = true;
|
isConfigFieldInvalid = true;
|
||||||
} else {
|
} else {
|
||||||
isInvalid = false;
|
isConfigFieldInvalid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isInvalid) {
|
if (isConfigFieldInvalid) {
|
||||||
jconfig[jprop_displayBrightness] = jprop_displayBrightness_default;
|
jconfig[jprop_displayBrightness] = jprop_displayBrightness_default;
|
||||||
changed = true;
|
changed = true;
|
||||||
logInfo("toConfig: displayBrightness changed");
|
logInfo("toConfig: displayBrightness changed");
|
||||||
@ -1365,7 +1381,7 @@ void Configuration::toConfig(const char *buf) {
|
|||||||
|
|
||||||
// PM2.5 correction
|
// PM2.5 correction
|
||||||
/// Set default first before parsing local config
|
/// Set default first before parsing local config
|
||||||
pmCorrection.algorithm = PMCorrectionAlgorithm::None;
|
pmCorrection.algorithm = COR_ALGO_PM_NONE;
|
||||||
pmCorrection.intercept = 0;
|
pmCorrection.intercept = 0;
|
||||||
pmCorrection.scalingFactor = 0;
|
pmCorrection.scalingFactor = 0;
|
||||||
pmCorrection.useEPA = false;
|
pmCorrection.useEPA = false;
|
||||||
@ -1465,6 +1481,17 @@ void Configuration::setOfflineModeWithoutSave(bool offline) {
|
|||||||
_offlineMode = offline;
|
_offlineMode = offline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Configuration::isCloudConnectionDisabled(void) {
|
||||||
|
bool disabled = jconfig[jprop_disableCloudConnection];
|
||||||
|
return disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Configuration::setDisableCloudConnection(bool disable) {
|
||||||
|
logInfo("Set DisableCloudConnection to " + String(disable ? "True" : "False"));
|
||||||
|
jconfig[jprop_disableCloudConnection] = disable;
|
||||||
|
saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
bool Configuration::isLedBarModeChanged(void) {
|
bool Configuration::isLedBarModeChanged(void) {
|
||||||
bool changed = _ledBarModeChanged;
|
bool changed = _ledBarModeChanged;
|
||||||
_ledBarModeChanged = false;
|
_ledBarModeChanged = false;
|
||||||
@ -1500,8 +1527,8 @@ bool Configuration::isPMCorrectionChanged(void) {
|
|||||||
*/
|
*/
|
||||||
bool Configuration::isPMCorrectionEnabled(void) {
|
bool Configuration::isPMCorrectionEnabled(void) {
|
||||||
PMCorrection pmCorrection = getPMCorrection();
|
PMCorrection pmCorrection = getPMCorrection();
|
||||||
if (pmCorrection.algorithm == PMCorrectionAlgorithm::None ||
|
if (pmCorrection.algorithm == COR_ALGO_PM_NONE ||
|
||||||
pmCorrection.algorithm == PMCorrectionAlgorithm::Unknown) {
|
pmCorrection.algorithm == COR_ALGO_PM_UNKNOWN) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +106,8 @@ public:
|
|||||||
bool isOfflineMode(void);
|
bool isOfflineMode(void);
|
||||||
void setOfflineMode(bool offline);
|
void setOfflineMode(bool offline);
|
||||||
void setOfflineModeWithoutSave(bool offline);
|
void setOfflineModeWithoutSave(bool offline);
|
||||||
|
bool isCloudConnectionDisabled(void);
|
||||||
|
void setDisableCloudConnection(bool disable);
|
||||||
bool isLedBarModeChanged(void);
|
bool isLedBarModeChanged(void);
|
||||||
bool isMonitorDisplayCompensatedValues(void);
|
bool isMonitorDisplayCompensatedValues(void);
|
||||||
bool isPMCorrectionChanged(void);
|
bool isPMCorrectionChanged(void);
|
||||||
|
147
src/AgValue.cpp
147
src/AgValue.cpp
@ -31,6 +31,45 @@ Measurements::Measurements(Configuration &config) : config(config) {
|
|||||||
#ifndef ESP8266
|
#ifndef ESP8266
|
||||||
_resetReason = (int)ESP_RST_UNKNOWN;
|
_resetReason = (int)ESP_RST_UNKNOWN;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Set invalid value for each measurements as default value when initialized*/
|
||||||
|
_temperature[0].update.avg = utils::getInvalidTemperature();
|
||||||
|
_temperature[1].update.avg = utils::getInvalidTemperature();
|
||||||
|
_humidity[0].update.avg = utils::getInvalidHumidity();
|
||||||
|
_humidity[1].update.avg = utils::getInvalidHumidity();
|
||||||
|
_co2.update.avg = utils::getInvalidCO2();
|
||||||
|
_tvoc.update.avg = utils::getInvalidVOC();
|
||||||
|
_tvoc_raw.update.avg = utils::getInvalidVOC();
|
||||||
|
_nox.update.avg = utils::getInvalidNOx();
|
||||||
|
_nox_raw.update.avg = utils::getInvalidNOx();
|
||||||
|
|
||||||
|
_pm_03_pc[0].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_03_pc[1].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_05_pc[0].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_05_pc[1].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_5_pc[0].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_5_pc[1].update.avg = utils::getInvalidPmValue();
|
||||||
|
|
||||||
|
_pm_01[0].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_01_sp[0].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_01_pc[0].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_01[1].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_01_sp[1].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_01_pc[1].update.avg = utils::getInvalidPmValue();
|
||||||
|
|
||||||
|
_pm_25[0].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_25_sp[0].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_25_pc[0].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_25[1].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_25_sp[1].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_25_pc[1].update.avg = utils::getInvalidPmValue();
|
||||||
|
|
||||||
|
_pm_10[0].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_10_sp[0].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_10_pc[0].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_10[1].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_10_sp[1].update.avg = utils::getInvalidPmValue();
|
||||||
|
_pm_10_pc[1].update.avg = utils::getInvalidPmValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Measurements::setAirGradient(AirGradient *ag) { this->ag = ag; }
|
void Measurements::setAirGradient(AirGradient *ag) { this->ag = ag; }
|
||||||
@ -600,7 +639,7 @@ float Measurements::getCorrectedTempHum(MeasurementType type, int ch, bool force
|
|||||||
return corrected;
|
return corrected;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Measurements::getCorrectedPM25(bool useAvg, int ch) {
|
float Measurements::getCorrectedPM25(bool useAvg, int ch, bool forceCorrection) {
|
||||||
float pm25;
|
float pm25;
|
||||||
float corrected;
|
float corrected;
|
||||||
float humidity;
|
float humidity;
|
||||||
@ -619,12 +658,18 @@ float Measurements::getCorrectedPM25(bool useAvg, int ch) {
|
|||||||
|
|
||||||
Configuration::PMCorrection pmCorrection = config.getPMCorrection();
|
Configuration::PMCorrection pmCorrection = config.getPMCorrection();
|
||||||
switch (pmCorrection.algorithm) {
|
switch (pmCorrection.algorithm) {
|
||||||
case PMCorrectionAlgorithm::Unknown:
|
case PMCorrectionAlgorithm::COR_ALGO_PM_UNKNOWN:
|
||||||
case PMCorrectionAlgorithm::None:
|
case PMCorrectionAlgorithm::COR_ALGO_PM_NONE: {
|
||||||
// If correction is Unknown, then default is None
|
// If correction is Unknown or None, then default is None
|
||||||
|
// Unless forceCorrection enabled
|
||||||
|
if (forceCorrection) {
|
||||||
|
corrected = ag->pms5003.compensate(pm25, humidity);
|
||||||
|
} else {
|
||||||
corrected = pm25;
|
corrected = pm25;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case PMCorrectionAlgorithm::EPA_2021:
|
}
|
||||||
|
case PMCorrectionAlgorithm::COR_ALGO_PM_EPA_2021:
|
||||||
corrected = ag->pms5003.compensate(pm25, humidity);
|
corrected = ag->pms5003.compensate(pm25, humidity);
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
@ -741,8 +786,8 @@ JSONVar Measurements::buildIndoor(bool localServer) {
|
|||||||
// buildPMS params:
|
// buildPMS params:
|
||||||
/// PMS channel 1 (indoor only have 1 PMS; hence allCh false)
|
/// PMS channel 1 (indoor only have 1 PMS; hence allCh false)
|
||||||
/// Not include temperature and humidity from PMS sensor
|
/// Not include temperature and humidity from PMS sensor
|
||||||
/// Not include compensated calculation
|
/// Include compensated calculation
|
||||||
indoor = buildPMS(1, false, false, false);
|
indoor = buildPMS(1, false, false, true);
|
||||||
if (!localServer) {
|
if (!localServer) {
|
||||||
// Indoor is using PMS5003
|
// Indoor is using PMS5003
|
||||||
indoor[json_prop_pmFirmware] = this->pms5003FirmwareVersion(ag->pms5003.getFirmwareVersion());
|
indoor[json_prop_pmFirmware] = this->pms5003FirmwareVersion(ag->pms5003.getFirmwareVersion());
|
||||||
@ -766,15 +811,6 @@ JSONVar Measurements::buildIndoor(bool localServer) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add pm25 compensated value only if PM2.5 and humidity value is valid
|
|
||||||
if (config.hasSensorPMS1 && utils::isValidPm(_pm_25[0].update.avg)) {
|
|
||||||
if (config.hasSensorSHT && utils::isValidHumidity(_humidity[0].update.avg)) {
|
|
||||||
// Correction using moving average value
|
|
||||||
float tmp = getCorrectedPM25(true);
|
|
||||||
indoor[json_prop_pm25Compensated] = ag->round2(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return indoor;
|
return indoor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -787,58 +823,58 @@ JSONVar Measurements::buildPMS(int ch, bool allCh, bool withTempHum, bool compen
|
|||||||
validateChannel(ch);
|
validateChannel(ch);
|
||||||
|
|
||||||
// Follow array indexing just for get address of the value type
|
// Follow array indexing just for get address of the value type
|
||||||
ch = ch - 1;
|
int chIndex = ch - 1;
|
||||||
|
|
||||||
if (utils::isValidPm(_pm_01[ch].update.avg)) {
|
if (utils::isValidPm(_pm_01[chIndex].update.avg)) {
|
||||||
pms[json_prop_pm01Ae] = ag->round2(_pm_01[ch].update.avg);
|
pms[json_prop_pm01Ae] = ag->round2(_pm_01[chIndex].update.avg);
|
||||||
}
|
}
|
||||||
if (utils::isValidPm(_pm_25[ch].update.avg)) {
|
if (utils::isValidPm(_pm_25[chIndex].update.avg)) {
|
||||||
pms[json_prop_pm25Ae] = ag->round2(_pm_25[ch].update.avg);
|
pms[json_prop_pm25Ae] = ag->round2(_pm_25[chIndex].update.avg);
|
||||||
}
|
}
|
||||||
if (utils::isValidPm(_pm_10[ch].update.avg)) {
|
if (utils::isValidPm(_pm_10[chIndex].update.avg)) {
|
||||||
pms[json_prop_pm10Ae] = ag->round2(_pm_10[ch].update.avg);
|
pms[json_prop_pm10Ae] = ag->round2(_pm_10[chIndex].update.avg);
|
||||||
}
|
}
|
||||||
if (utils::isValidPm(_pm_01_sp[ch].update.avg)) {
|
if (utils::isValidPm(_pm_01_sp[chIndex].update.avg)) {
|
||||||
pms[json_prop_pm01Sp] = ag->round2(_pm_01_sp[ch].update.avg);
|
pms[json_prop_pm01Sp] = ag->round2(_pm_01_sp[chIndex].update.avg);
|
||||||
}
|
}
|
||||||
if (utils::isValidPm(_pm_25_sp[ch].update.avg)) {
|
if (utils::isValidPm(_pm_25_sp[chIndex].update.avg)) {
|
||||||
pms[json_prop_pm25Sp] = ag->round2(_pm_25_sp[ch].update.avg);
|
pms[json_prop_pm25Sp] = ag->round2(_pm_25_sp[chIndex].update.avg);
|
||||||
}
|
}
|
||||||
if (utils::isValidPm(_pm_10_sp[ch].update.avg)) {
|
if (utils::isValidPm(_pm_10_sp[chIndex].update.avg)) {
|
||||||
pms[json_prop_pm10Sp] = ag->round2(_pm_10_sp[ch].update.avg);
|
pms[json_prop_pm10Sp] = ag->round2(_pm_10_sp[chIndex].update.avg);
|
||||||
}
|
}
|
||||||
if (utils::isValidPm03Count(_pm_03_pc[ch].update.avg)) {
|
if (utils::isValidPm03Count(_pm_03_pc[chIndex].update.avg)) {
|
||||||
pms[json_prop_pm03Count] = ag->round2(_pm_03_pc[ch].update.avg);
|
pms[json_prop_pm03Count] = ag->round2(_pm_03_pc[chIndex].update.avg);
|
||||||
}
|
}
|
||||||
if (utils::isValidPm03Count(_pm_05_pc[ch].update.avg)) {
|
if (utils::isValidPm03Count(_pm_05_pc[chIndex].update.avg)) {
|
||||||
pms[json_prop_pm05Count] = ag->round2(_pm_05_pc[ch].update.avg);
|
pms[json_prop_pm05Count] = ag->round2(_pm_05_pc[chIndex].update.avg);
|
||||||
}
|
}
|
||||||
if (utils::isValidPm03Count(_pm_01_pc[ch].update.avg)) {
|
if (utils::isValidPm03Count(_pm_01_pc[chIndex].update.avg)) {
|
||||||
pms[json_prop_pm1Count] = ag->round2(_pm_01_pc[ch].update.avg);
|
pms[json_prop_pm1Count] = ag->round2(_pm_01_pc[chIndex].update.avg);
|
||||||
}
|
}
|
||||||
if (utils::isValidPm03Count(_pm_25_pc[ch].update.avg)) {
|
if (utils::isValidPm03Count(_pm_25_pc[chIndex].update.avg)) {
|
||||||
pms[json_prop_pm25Count] = ag->round2(_pm_25_pc[ch].update.avg);
|
pms[json_prop_pm25Count] = ag->round2(_pm_25_pc[chIndex].update.avg);
|
||||||
}
|
}
|
||||||
if (_pm_5_pc[ch].listValues.empty() == false) {
|
if (_pm_5_pc[chIndex].listValues.empty() == false) {
|
||||||
// Only include pm5.0 count when values available on its list
|
// Only include pm5.0 count when values available on its list
|
||||||
// If not, means no pm5_pc available from the sensor
|
// If not, means no pm5_pc available from the sensor
|
||||||
if (utils::isValidPm03Count(_pm_5_pc[ch].update.avg)) {
|
if (utils::isValidPm03Count(_pm_5_pc[chIndex].update.avg)) {
|
||||||
pms[json_prop_pm5Count] = ag->round2(_pm_5_pc[ch].update.avg);
|
pms[json_prop_pm5Count] = ag->round2(_pm_5_pc[chIndex].update.avg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_pm_10_pc[ch].listValues.empty() == false) {
|
if (_pm_10_pc[chIndex].listValues.empty() == false) {
|
||||||
// Only include pm10 count when values available on its list
|
// Only include pm10 count when values available on its list
|
||||||
// If not, means no pm10_pc available from the sensor
|
// If not, means no pm10_pc available from the sensor
|
||||||
if (utils::isValidPm03Count(_pm_10_pc[ch].update.avg)) {
|
if (utils::isValidPm03Count(_pm_10_pc[chIndex].update.avg)) {
|
||||||
pms[json_prop_pm10Count] = ag->round2(_pm_10_pc[ch].update.avg);
|
pms[json_prop_pm10Count] = ag->round2(_pm_10_pc[chIndex].update.avg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (withTempHum) {
|
if (withTempHum) {
|
||||||
float _vc;
|
float _vc;
|
||||||
// Set temperature if valid
|
// Set temperature if valid
|
||||||
if (utils::isValidTemperature(_temperature[ch].update.avg)) {
|
if (utils::isValidTemperature(_temperature[chIndex].update.avg)) {
|
||||||
pms[json_prop_temp] = ag->round2(_temperature[ch].update.avg);
|
pms[json_prop_temp] = ag->round2(_temperature[chIndex].update.avg);
|
||||||
// Compensate temperature when flag is set
|
// Compensate temperature when flag is set
|
||||||
if (compensate) {
|
if (compensate) {
|
||||||
_vc = getCorrectedTempHum(Temperature, ch, true);
|
_vc = getCorrectedTempHum(Temperature, ch, true);
|
||||||
@ -848,8 +884,8 @@ JSONVar Measurements::buildPMS(int ch, bool allCh, bool withTempHum, bool compen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Set humidity if valid
|
// Set humidity if valid
|
||||||
if (utils::isValidHumidity(_humidity[ch].update.avg)) {
|
if (utils::isValidHumidity(_humidity[chIndex].update.avg)) {
|
||||||
pms[json_prop_rhum] = ag->round2(_humidity[ch].update.avg);
|
pms[json_prop_rhum] = ag->round2(_humidity[chIndex].update.avg);
|
||||||
// Compensate relative humidity when flag is set
|
// Compensate relative humidity when flag is set
|
||||||
if (compensate) {
|
if (compensate) {
|
||||||
_vc = getCorrectedTempHum(Humidity, ch, true);
|
_vc = getCorrectedTempHum(Humidity, ch, true);
|
||||||
@ -859,19 +895,16 @@ JSONVar Measurements::buildPMS(int ch, bool allCh, bool withTempHum, bool compen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Add pm25 compensated value only if PM2.5 and humidity value is valid
|
// Add pm25 compensated value only if PM2.5 and humidity value is valid
|
||||||
if (compensate) {
|
if (compensate) {
|
||||||
if (utils::isValidPm(_pm_25[ch].update.avg) &&
|
if (utils::isValidPm(_pm_25[chIndex].update.avg) &&
|
||||||
utils::isValidHumidity(_humidity[ch].update.avg)) {
|
utils::isValidHumidity(_humidity[chIndex].update.avg)) {
|
||||||
// Note: the pms5003t object is not matter either for channel 1 or 2, compensate points to
|
float pm25 = getCorrectedPM25(true, ch, true);
|
||||||
// the same base function
|
|
||||||
float pm25 = ag->pms5003t_1.compensate(_pm_25[ch].update.avg, _humidity[ch].update.avg);
|
|
||||||
if (utils::isValidPm(pm25)) {
|
|
||||||
pms[json_prop_pm25Compensated] = ag->round2(pm25);
|
pms[json_prop_pm25Compensated] = ag->round2(pm25);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Directly return the json object
|
// Directly return the json object
|
||||||
return pms;
|
return pms;
|
||||||
@ -1117,12 +1150,12 @@ JSONVar Measurements::buildPMS(int ch, bool allCh, bool withTempHum, bool compen
|
|||||||
float pm25_comp2 = utils::getInvalidPmValue();
|
float pm25_comp2 = utils::getInvalidPmValue();
|
||||||
if (utils::isValidPm(_pm_25[0].update.avg) &&
|
if (utils::isValidPm(_pm_25[0].update.avg) &&
|
||||||
utils::isValidHumidity(_humidity[0].update.avg)) {
|
utils::isValidHumidity(_humidity[0].update.avg)) {
|
||||||
pm25_comp1 = ag->pms5003t_1.compensate(_pm_25[0].update.avg, _humidity[0].update.avg);
|
pm25_comp1 = getCorrectedPM25(true, 1, true);
|
||||||
pms["channels"]["1"][json_prop_pm25Compensated] = ag->round2(pm25_comp1);
|
pms["channels"]["1"][json_prop_pm25Compensated] = ag->round2(pm25_comp1);
|
||||||
}
|
}
|
||||||
if (utils::isValidPm(_pm_25[1].update.avg) &&
|
if (utils::isValidPm(_pm_25[1].update.avg) &&
|
||||||
utils::isValidHumidity(_humidity[1].update.avg)) {
|
utils::isValidHumidity(_humidity[1].update.avg)) {
|
||||||
pm25_comp2 = ag->pms5003t_2.compensate(_pm_25[1].update.avg, _humidity[1].update.avg);
|
pm25_comp2 = getCorrectedPM25(true, 2, true);
|
||||||
pms["channels"]["2"][json_prop_pm25Compensated] = ag->round2(pm25_comp2);
|
pms["channels"]["2"][json_prop_pm25Compensated] = ag->round2(pm25_comp2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,9 +144,10 @@ public:
|
|||||||
*
|
*
|
||||||
* @param useAvg Use moving average value if true, otherwise use latest value
|
* @param useAvg Use moving average value if true, otherwise use latest value
|
||||||
* @param ch MeasurementType channel
|
* @param ch MeasurementType channel
|
||||||
|
* @param forceCorrection force using correction even though config correction is not applied, default to EPA
|
||||||
* @return float Corrected PM2.5 value
|
* @return float Corrected PM2.5 value
|
||||||
*/
|
*/
|
||||||
float getCorrectedPM25(bool useAvg = false, int ch = 1);
|
float getCorrectedPM25(bool useAvg = false, int ch = 1, bool forceCorrection = false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* build json payload for every measurements
|
* build json payload for every measurements
|
||||||
|
@ -81,16 +81,15 @@ bool WifiConnector::connect(void) {
|
|||||||
// ssid = "AG-" + String(ESP.getChipId(), HEX);
|
// ssid = "AG-" + String(ESP.getChipId(), HEX);
|
||||||
WIFI()->setConfigPortalTimeout(WIFI_CONNECT_COUNTDOWN_MAX);
|
WIFI()->setConfigPortalTimeout(WIFI_CONNECT_COUNTDOWN_MAX);
|
||||||
|
|
||||||
WiFiManagerParameter postToAg("chbPostToAg",
|
WiFiManagerParameter disableCloud("chbPostToAg", "Prevent Connection to AirGradient Server", "T",
|
||||||
"Prevent Connection to AirGradient Server", "T",
|
|
||||||
2, "type=\"checkbox\" ", WFM_LABEL_AFTER);
|
2, "type=\"checkbox\" ", WFM_LABEL_AFTER);
|
||||||
WIFI()->addParameter(&postToAg);
|
WIFI()->addParameter(&disableCloud);
|
||||||
WiFiManagerParameter postToAgInfo(
|
WiFiManagerParameter disableCloudInfo(
|
||||||
"<p>Prevent connection to the AirGradient Server. Important: Only enable "
|
"<p>Prevent connection to the AirGradient Server. Important: Only enable "
|
||||||
"it if you are sure you don't want to use any AirGradient cloud "
|
"it if you are sure you don't want to use any AirGradient cloud "
|
||||||
"features. As a result you will not receive automatic firmware updates "
|
"features. As a result you will not receive automatic firmware updates, "
|
||||||
"and your data will not reach the AirGradient dashboard.</p>");
|
"configuration settings from cloud and the measure data will not reach the AirGradient dashboard.</p>");
|
||||||
WIFI()->addParameter(&postToAgInfo);
|
WIFI()->addParameter(&disableCloudInfo);
|
||||||
|
|
||||||
WIFI()->autoConnect(ssid.c_str(), WIFI_HOTSPOT_PASSWORD_DEFAULT);
|
WIFI()->autoConnect(ssid.c_str(), WIFI_HOTSPOT_PASSWORD_DEFAULT);
|
||||||
|
|
||||||
@ -174,12 +173,11 @@ bool WifiConnector::connect(void) {
|
|||||||
logInfo("WiFi Connected: " + WiFi.SSID() + " IP: " + localIpStr());
|
logInfo("WiFi Connected: " + WiFi.SSID() + " IP: " + localIpStr());
|
||||||
|
|
||||||
if (hasPortalConfig) {
|
if (hasPortalConfig) {
|
||||||
String result = String(postToAg.getValue());
|
String result = String(disableCloud.getValue());
|
||||||
logInfo("Setting postToAirGradient set from " +
|
logInfo("Setting disableCloudConnection set from " +
|
||||||
String(config.isPostDataToAirGradient() ? "True" : "False") +
|
String(config.isCloudConnectionDisabled() ? "True" : "False") + String(" to ") +
|
||||||
String(" to ") + String(result != "T" ? "True" : "False") +
|
String(result == "T" ? "True" : "False") + String(" successful"));
|
||||||
String(" successful"));
|
config.setDisableCloudConnection(result == "T");
|
||||||
config.setPostToAirGradient(result != "T");
|
|
||||||
}
|
}
|
||||||
hasPortalConfig = false;
|
hasPortalConfig = false;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include "Main/utils.h"
|
#include "Main/utils.h"
|
||||||
|
|
||||||
#ifndef GIT_VERSION
|
#ifndef GIT_VERSION
|
||||||
#define GIT_VERSION "3.1.21-snap"
|
#define GIT_VERSION "3.2.0-snap"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef ESP8266
|
#ifndef ESP8266
|
||||||
|
@ -95,15 +95,10 @@ enum ConfigurationControl {
|
|||||||
};
|
};
|
||||||
|
|
||||||
enum PMCorrectionAlgorithm {
|
enum PMCorrectionAlgorithm {
|
||||||
Unknown, // Unknown algorithm
|
COR_ALGO_PM_UNKNOWN, // Unknown algorithm
|
||||||
None, // No PM correction
|
COR_ALGO_PM_NONE, // No PM correction
|
||||||
EPA_2021,
|
COR_ALGO_PM_EPA_2021,
|
||||||
SLR_PMS5003_20220802,
|
COR_ALGO_PM_SLR_CUSTOM,
|
||||||
SLR_PMS5003_20220803,
|
|
||||||
SLR_PMS5003_20220824,
|
|
||||||
SLR_PMS5003_20231030,
|
|
||||||
SLR_PMS5003_20231218,
|
|
||||||
SLR_PMS5003_20240104,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Don't change the order of the enum
|
// Don't change the order of the enum
|
||||||
|
Reference in New Issue
Block a user