mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-28 16:07:16 +02:00
Redundant check if cellular client not ready for 2 hours
Check calls happen in both task
This commit is contained in:
@ -120,6 +120,9 @@ static bool ledBarButtonTest = false;
|
|||||||
static String fwNewVersion;
|
static String fwNewVersion;
|
||||||
static int lastCellSignalQuality = 99; // CSQ
|
static int lastCellSignalQuality = 99; // CSQ
|
||||||
|
|
||||||
|
// Default value is 0, indicate its not started yet
|
||||||
|
uint32_t startTimeClientNotReady = 0;
|
||||||
|
|
||||||
SemaphoreHandle_t mutexMeasurementCycleQueue;
|
SemaphoreHandle_t mutexMeasurementCycleQueue;
|
||||||
static std::vector<Measurements::Measures> measurementCycleQueue;
|
static std::vector<Measurements::Measures> measurementCycleQueue;
|
||||||
|
|
||||||
@ -147,6 +150,7 @@ static void displayExecuteOta(AirgradientOTA::OtaResult result, String msg, int
|
|||||||
static int calculateMaxPeriod(int updateInterval);
|
static int calculateMaxPeriod(int updateInterval);
|
||||||
static void setMeasurementMaxPeriod();
|
static void setMeasurementMaxPeriod();
|
||||||
static void newMeasurementCycle();
|
static void newMeasurementCycle();
|
||||||
|
static void checkCellularClientNotReady();
|
||||||
static void networkSignalCheck();
|
static void networkSignalCheck();
|
||||||
static void networkingTask(void *args);
|
static void networkingTask(void *args);
|
||||||
|
|
||||||
@ -299,6 +303,12 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
if (networkOption == UseCellular) {
|
||||||
|
// Check if cellular client not ready until certain time
|
||||||
|
// Redundant check in both task to make sure its executed
|
||||||
|
checkCellularClientNotReady();
|
||||||
|
}
|
||||||
|
|
||||||
// Schedule to feed external watchdog
|
// Schedule to feed external watchdog
|
||||||
watchdogFeedSchedule.run();
|
watchdogFeedSchedule.run();
|
||||||
|
|
||||||
@ -1494,6 +1504,30 @@ void networkSignalCheck() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If in 2 hours still not ready, then restart esp
|
||||||
|
*/
|
||||||
|
void checkCellularClientNotReady() {
|
||||||
|
if (startTimeClientNotReady > 0 &&
|
||||||
|
(millis() - startTimeClientNotReady) > (2 * 60 * 60000)) {
|
||||||
|
// Give up wait
|
||||||
|
Serial.println("CLIENT NOT READY TAKING TOO LONG! Rebooting ...");
|
||||||
|
int i = 3;
|
||||||
|
while (i != 0) {
|
||||||
|
if (ag->isOne()) {
|
||||||
|
String tmp = "Reboot in " + String(i);
|
||||||
|
oledDisplay.setText("CE error", "too long", tmp.c_str());
|
||||||
|
} else {
|
||||||
|
Serial.println("Rebooting... " + String(i));
|
||||||
|
}
|
||||||
|
i = i - 1;
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
oledDisplay.setBrightness(0);
|
||||||
|
esp_restart();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void networkingTask(void *args) {
|
void networkingTask(void *args) {
|
||||||
// OTA check on boot
|
// OTA check on boot
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
@ -1515,9 +1549,6 @@ void networkingTask(void *args) {
|
|||||||
measurementSchedule.update();
|
measurementSchedule.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default value is 0, indicate its not started yet
|
|
||||||
uint32_t startTimeClientNotReady = 0;
|
|
||||||
|
|
||||||
// Reset scheduler
|
// Reset scheduler
|
||||||
configSchedule.update();
|
configSchedule.update();
|
||||||
transmissionSchedule.update();
|
transmissionSchedule.update();
|
||||||
@ -1543,23 +1574,9 @@ void networkingTask(void *args) {
|
|||||||
// Enable at command debug
|
// Enable at command debug
|
||||||
agSerial->setDebug(true);
|
agSerial->setDebug(true);
|
||||||
|
|
||||||
// If in 2 hours still not ready, then restart esp
|
// Check if cellular client not ready until certain time
|
||||||
if ((millis() - startTimeClientNotReady) > (2 * 60 * 60000)) {
|
// Redundant check in both task to make sure its executed
|
||||||
Serial.println("CLIENT NOT READY TAKING TOO LONG! Rebooting ...");
|
checkCellularClientNotReady();
|
||||||
int i = 3;
|
|
||||||
while (i != 0) {
|
|
||||||
if (ag->isOne()) {
|
|
||||||
String tmp = "Reboot in " + String(i);
|
|
||||||
oledDisplay.setText("CE error", "too long", tmp.c_str());
|
|
||||||
} else {
|
|
||||||
Serial.println("Rebooting... " + String(i));
|
|
||||||
}
|
|
||||||
i = i - 1;
|
|
||||||
delay(1000);
|
|
||||||
}
|
|
||||||
oledDisplay.setBrightness(0);
|
|
||||||
esp_restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Starting from 1 hour since its not ready, power cycling the module
|
// Starting from 1 hour since its not ready, power cycling the module
|
||||||
bool resetModule = true;
|
bool resetModule = true;
|
||||||
|
Reference in New Issue
Block a user