Merge branch 'develop' into feat/disable-cloud

This commit is contained in:
samuelbles07
2025-02-05 10:06:39 +07:00
4 changed files with 49 additions and 9 deletions

View File

@ -229,15 +229,16 @@ void setup() {
oledDisplay.setBrightness(configuration.getDisplayBrightness());
}
// Update display and led bar after finishing setup to show dashboard
updateDisplayAndLedBar();
// Reset post schedulers to make sure measurements value already available
agApiPostSchedule.update();
}
void loop() {
/** Handle schedule */
/** Run schedulers */
dispLedSchedule.run();
configSchedule.run();
agApiPostSchedule.run();
watchdogFeedSchedule.run();
if (configuration.hasSensorS8) {
co2Schedule.run();
@ -271,15 +272,13 @@ void loop() {
}
}
watchdogFeedSchedule.run();
/** Check for handle WiFi reconnect */
wifiConnector.handle();
/** factory reset handle */
factoryConfigReset();
/** check that local configura changed then do some action */
/** check that local configuration changed then do some action */
configUpdateHandle();
/** Firmware check for update handle */

View File

@ -47,7 +47,8 @@ bool AgApiClient::fetchServerConfiguration(void) {
}
#else
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 apiRoot is changed, assume not using https
if (client.begin(uri) == false) {
@ -113,7 +114,8 @@ bool AgApiClient::postToServer(String data) {
}
#else
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 apiRoot is changed, assume not using https
if (client.begin(uri) == false) {

View File

@ -31,7 +31,7 @@ private:
bool getConfigFailed;
bool postToServerFailed;
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:
AgApiClient(Stream &stream, Configuration &config);

View File

@ -31,6 +31,45 @@ Measurements::Measurements() {
#ifndef ESP8266
_resetReason = (int)ESP_RST_UNKNOWN;
#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::maxPeriod(MeasurementType type, int max) {