Skip to content

Fix bootloop when cloud connection is disabled #313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions examples/OneOpenAir/OneOpenAir.ino
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,11 @@ static bool sgp41Init(void) {
}

void checkForFirmwareUpdate(void) {
if (configuration.isCloudConnectionDisabled()) {
Serial.println("Cloud connection is disabled, skip firmware update");
return;
}

AirgradientOTA *agOta;
if (networkOption == UseWifi) {
agOta = new AirgradientOTAWifi;
Expand Down Expand Up @@ -1562,27 +1567,29 @@ void restartIfCeClientIssueOverTwoHours() {
}

void networkingTask(void *args) {
// OTA check on boot
// If cloud connection enabled, run first transmission to server at boot
if (configuration.isCloudConnectionDisabled() == false) {
// OTA check on boot
#ifndef ESP8266
checkForFirmwareUpdate();
checkForUpdateSchedule.update();
checkForFirmwareUpdate();
checkForUpdateSchedule.update();
#endif

// Because cellular interval is longer, needs to send first measures cycle on
// boot to indicate that its online
if (networkOption == UseCellular) {
Serial.println("Prepare first measures cycle to send on boot for 20s");
delay(20000);
networkSignalCheck();
newMeasurementCycle();
postUsingCellular(true);
measurementSchedule.update();
// Because cellular interval is longer, needs to send first measures cycle on
// boot to indicate that its online
if (networkOption == UseCellular) {
Serial.println("Prepare first measures cycle to send on boot for 20s");
delay(20000);
networkSignalCheck();
newMeasurementCycle();
postUsingCellular(true);
measurementSchedule.update();
}
// Reset scheduler
configSchedule.update();
transmissionSchedule.update();
}

// Reset scheduler
configSchedule.update();
transmissionSchedule.update();

while (1) {
// Handle reconnection based on mode
if (networkOption == UseWifi) {
Expand Down Expand Up @@ -1637,7 +1644,7 @@ void networkingTask(void *args) {
// If connection to AirGradient server disable don't run config and transmission schedule
if (configuration.isCloudConnectionDisabled()) {
delay(1000);
return;
continue;
}

// Run scheduler
Expand Down