mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-29 16:37:17 +02:00
Handle reconnection when network option is cellular
This commit is contained in:
@ -1383,21 +1383,31 @@ int calculateMaxPeriod(int updateInterval) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void networkingTask(void *args) {
|
void networkingTask(void *args) {
|
||||||
|
// TODO: Need to better define delay value
|
||||||
|
|
||||||
|
// Reset scheduler
|
||||||
|
configSchedule.update();
|
||||||
|
transmissionSchedule.update();
|
||||||
while (1) {
|
while (1) {
|
||||||
// Handle reconnection based on mode
|
// Handle reconnection based on mode
|
||||||
if (networkOption == UseWifi) {
|
if (networkOption == UseWifi) {
|
||||||
wifiConnector.handle();
|
wifiConnector.handle();
|
||||||
if (wifiConnector.isConnected() == false) {
|
if (wifiConnector.isConnected() == false) {
|
||||||
// NOTE: If not connect while mode is not offline, skip the rest of code
|
|
||||||
delay(1000);
|
delay(1000);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (networkOption == UseCellular) {
|
else if (networkOption == UseCellular) {
|
||||||
/// Handle reconnection cellular here
|
// Check if last fetch config and post measures failed
|
||||||
/// If failed fetch config or transmission it is an indication that the module might have a problem
|
// It can be an indication that module has a problem
|
||||||
/// cellular-client or the cell module it self need an inteface for last operation success or not
|
if (agClient->isLastFetchConfigSucceed() == false ||
|
||||||
/// For example, httpGet() failed, then there's a state like isLastOperationSuccess
|
agClient->isLastPostMeasureSucceed() == false) {
|
||||||
|
if (agClient->ensureClientConnection() == false) {
|
||||||
|
Serial.println("Cellular client connection not ready, retry in 5s...");
|
||||||
|
delay(5000);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If connection to AirGradient server disable don't run config and transmission schedule
|
// If connection to AirGradient server disable don't run config and transmission schedule
|
||||||
@ -1418,7 +1428,6 @@ void networkingTask(void *args) {
|
|||||||
|
|
||||||
void newMeasurementCycle() {
|
void newMeasurementCycle() {
|
||||||
// TODO: Need to check max queue
|
// TODO: Need to check max queue
|
||||||
// NOTE: Maybe define acquire mutex timeout
|
|
||||||
if (xSemaphoreTake(mutexMeasurementCycleQueue, portMAX_DELAY) == pdTRUE) {
|
if (xSemaphoreTake(mutexMeasurementCycleQueue, portMAX_DELAY) == pdTRUE) {
|
||||||
Measurements::MeasurementCycle mc = measurements.getMeasurementCycle();
|
Measurements::MeasurementCycle mc = measurements.getMeasurementCycle();
|
||||||
mc.wifi = wifiConnector.RSSI();
|
mc.wifi = wifiConnector.RSSI();
|
||||||
|
Submodule src/Libraries/airgradient-client updated: c6465b5ef0...24ec7c9e67
Reference in New Issue
Block a user