Apply stop main task for wifi too

Improve flow OTA success display
This commit is contained in:
samuelbles07
2025-03-27 17:46:08 +07:00
parent 86cd90b94a
commit fff982f35f

View File

@ -209,7 +209,6 @@ void setup() {
// Comment below line to disable debug measurement readings // Comment below line to disable debug measurement readings
measurements.setDebug(true); measurements.setDebug(true);
// bool connectToWifi = false;
bool connectToNetwork = true; bool connectToNetwork = true;
if (ag->isOne()) { // Offline mode only available for indoor monitor if (ag->isOne()) { // Offline mode only available for indoor monitor
/** Show message confirm offline mode, should me perform if LED bar button /** Show message confirm offline mode, should me perform if LED bar button
@ -541,14 +540,12 @@ void checkForFirmwareUpdate(void) {
} }
// Indicate main task that ota is performing // Indicate main task that ota is performing
// Only for cellular because it can disturb i2c line Serial.println("Check for firmware update, disabling main task");
Serial.println("Check for firmware update"); otaInProgress = true;
if (networkOption == UseCellular) { if (configuration.hasSensorSGP && networkOption == UseCellular) {
Serial.println("Disabling scheduler to read sensors for cellular OTA"); // Only for cellular because it can disturb i2c line
otaInProgress = true; Serial.println("Disable SGP41 task for cellular OTA");
if (configuration.hasSensorSGP) { ag->sgp41.end();
ag->sgp41.end();
}
} }
agOta->setHandlerCallback(otaHandlerCallback); agOta->setHandlerCallback(otaHandlerCallback);
@ -556,12 +553,12 @@ void checkForFirmwareUpdate(void) {
// Only goes to this line if OTA is not success // Only goes to this line if OTA is not success
// Handled by otaHandlerCallback // Handled by otaHandlerCallback
if (networkOption == UseCellular) {
otaInProgress = false; otaInProgress = false;
if (configuration.hasSensorSGP) { if (configuration.hasSensorSGP && networkOption == UseCellular) {
if (!sgp41Init()) { // Re-start SGP41 task
Serial.println("Failed re-start SGP41 task"); if (!sgp41Init()) {
} Serial.println("Failed re-start SGP41 task");
} }
} }
@ -634,23 +631,18 @@ static void displayExecuteOta(AirgradientOTA::OtaResult result, String msg, int
} }
break; break;
case AirgradientOTA::Success: { case AirgradientOTA::Success: {
int i = 6; Serial.println("OTA update performed, restarting ...");
int i = 3;
while (i != 0) { while (i != 0) {
i = i - 1; i = i - 1;
Serial.println("OTA update performed, restarting ..."); if (ag->isOne()) {
int i = 6; oledDisplay.showFirmwareUpdateSuccess(i);
while (i != 0) { } else {
i = i - 1; Serial.println("Rebooting... " + String(i));
if (ag->isOne()) {
oledDisplay.showFirmwareUpdateSuccess(i);
} else {
Serial.println("Rebooting... " + String(i));
}
delay(1000);
} }
oledDisplay.setBrightness(0); delay(1000);
} }
oledDisplay.setAirGradient(0);
break; break;
} }
default: default: