mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-03 11:26:29 +02:00
Prevent reboot in offline mode
This commit is contained in:
@ -705,6 +705,7 @@ static void webServerInit(void);
|
||||
static String getServerSyncData(bool localServer);
|
||||
static void createMqttTask(void);
|
||||
static void factoryConfigReset(void);
|
||||
static void wdgFeedUpdate(void);
|
||||
|
||||
/** Init schedule */
|
||||
bool hasSensorS8 = true;
|
||||
@ -717,6 +718,8 @@ String mdnsModelName = "I-9PSL";
|
||||
int getCO2FailCount = 0;
|
||||
uint32_t addToDashboardTime;
|
||||
bool isAddToDashboard = true;
|
||||
bool offlineMode = false;
|
||||
|
||||
AgSchedule dispLedSchedule(DISP_UPDATE_INTERVAL, displayAndLedBarUpdate);
|
||||
AgSchedule configSchedule(SERVER_CONFIG_UPDATE_INTERVAL,
|
||||
updateServerConfiguration);
|
||||
@ -725,6 +728,7 @@ AgSchedule co2Schedule(SENSOR_CO2_UPDATE_INTERVAL, co2Update);
|
||||
AgSchedule pmsSchedule(SENSOR_PM_UPDATE_INTERVAL, pmUpdate);
|
||||
AgSchedule tempHumSchedule(SENSOR_TEMP_HUM_UPDATE_INTERVAL, tempHumUpdate);
|
||||
AgSchedule tvocSchedule(SENSOR_TVOC_UPDATE_INTERVAL, tvocUpdate);
|
||||
AgSchedule wdgFeedSchedule(60000, wdgFeedUpdate);
|
||||
|
||||
void setup() {
|
||||
EEPROM.begin(512);
|
||||
@ -807,6 +811,8 @@ void setup() {
|
||||
} else {
|
||||
ag.ledBar.setEnable(agServer.getLedBarMode() != UseLedBarOff);
|
||||
}
|
||||
} else {
|
||||
offlineMode = true;
|
||||
}
|
||||
|
||||
/** Show display Warning up */
|
||||
@ -840,6 +846,10 @@ void loop() {
|
||||
tvocSchedule.run();
|
||||
}
|
||||
|
||||
if (offlineMode) {
|
||||
wdgFeedSchedule.run();
|
||||
}
|
||||
|
||||
/** Check for handle WiFi reconnect */
|
||||
updateWiFiConnect();
|
||||
|
||||
@ -1253,6 +1263,13 @@ static void factoryConfigReset(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static void wdgFeedUpdate(void) {
|
||||
ag.watchdog.reset();
|
||||
Serial.println();
|
||||
Serial.println("External watchdog feed");
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
static void sendPing() {
|
||||
JSONVar root;
|
||||
root["wifi"] = WiFi.RSSI();
|
||||
|
@ -723,6 +723,7 @@ static void webServerInit(void);
|
||||
static String getServerSyncData(bool localServer);
|
||||
static void createMqttTask(void);
|
||||
static void factoryConfigReset(void);
|
||||
static void wdgFeedUpdate(void);
|
||||
|
||||
bool hasSensorS8 = true;
|
||||
bool hasSensorPMS1 = true;
|
||||
@ -731,12 +732,15 @@ bool hasSensorSGP = true;
|
||||
uint32_t factoryBtnPressTime = 0;
|
||||
String mdnsModelName = "";
|
||||
int getCO2FailCount = 0;
|
||||
bool offlineMode = false;
|
||||
|
||||
AgSchedule configSchedule(SERVER_CONFIG_UPDATE_INTERVAL,
|
||||
updateServerConfiguration);
|
||||
AgSchedule serverSchedule(SERVER_SYNC_INTERVAL, sendDataToServer);
|
||||
AgSchedule co2Schedule(SENSOR_CO2_UPDATE_INTERVAL, co2Update);
|
||||
AgSchedule pmsSchedule(SENSOR_PM_UPDATE_INTERVAL, pmUpdate);
|
||||
AgSchedule tvocSchedule(SENSOR_TVOC_UPDATE_INTERVAL, tvocUpdate);
|
||||
AgSchedule wdgFeedSchedule(60000, wdgFeedUpdate);
|
||||
|
||||
void setup() {
|
||||
EEPROM.begin(512);
|
||||
@ -775,6 +779,8 @@ void setup() {
|
||||
ledSmHandler(APP_SM_WIFI_OK_SERVER_OK_SENSOR_CONFIG_FAILED);
|
||||
delay(DISPLAY_DELAY_SHOW_CONTENT_MS);
|
||||
}
|
||||
} else {
|
||||
offlineMode = true;
|
||||
}
|
||||
|
||||
ledSmHandler(APP_SM_NORMAL);
|
||||
@ -809,6 +815,10 @@ void loop() {
|
||||
if (hasSensorPMS2) {
|
||||
ag.pms5003t_2.handle();
|
||||
}
|
||||
|
||||
if (offlineMode) {
|
||||
wdgFeedSchedule.run();
|
||||
}
|
||||
}
|
||||
|
||||
void sendPing() {
|
||||
@ -1819,6 +1829,13 @@ static void factoryConfigReset(void) {
|
||||
}
|
||||
}
|
||||
|
||||
static void wdgFeedUpdate(void) {
|
||||
ag.watchdog.reset();
|
||||
Serial.println();
|
||||
Serial.println("External watchdog feed");
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
static void mqtt_event_handler(void *handler_args, esp_event_base_t base,
|
||||
int32_t event_id, void *event_data) {
|
||||
esp_mqtt_event_handle_t event = (esp_mqtt_event_handle_t)event_data;
|
||||
|
Reference in New Issue
Block a user