From e2084f0738ed5b039ced137eaa186bb3132729ce Mon Sep 17 00:00:00 2001 From: samuelbles07 Date: Mon, 5 May 2025 17:36:14 +0700 Subject: [PATCH 1/2] Fix OTA request on boot when cloud Connection disabled --- examples/OneOpenAir/OneOpenAir.ino | 39 ++++++++++++++++++------------ 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/examples/OneOpenAir/OneOpenAir.ino b/examples/OneOpenAir/OneOpenAir.ino index 1ba41df..a07418d 100644 --- a/examples/OneOpenAir/OneOpenAir.ino +++ b/examples/OneOpenAir/OneOpenAir.ino @@ -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; @@ -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) { From 6b557193997187b6dfdcc3472fb1e0e19840c91c Mon Sep 17 00:00:00 2001 From: samuelbles07 Date: Mon, 5 May 2025 17:37:28 +0700 Subject: [PATCH 2/2] Fix cloud connection mode Use continue instead of return to ignore the rest of transmission code --- examples/OneOpenAir/OneOpenAir.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/OneOpenAir/OneOpenAir.ino b/examples/OneOpenAir/OneOpenAir.ino index a07418d..d418a1d 100644 --- a/examples/OneOpenAir/OneOpenAir.ino +++ b/examples/OneOpenAir/OneOpenAir.ino @@ -1644,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