mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-30 00:47:17 +02:00
Rename cellularModule object name to cellularCard
Rename checkCellularClientNotReady to restartIfCeClientIssueOverTwoHours
This commit is contained in:
@ -108,7 +108,7 @@ static OpenMetrics openMetrics(measurements, configuration, wifiConnector);
|
|||||||
static LocalServer localServer(Serial, openMetrics, measurements, configuration,
|
static LocalServer localServer(Serial, openMetrics, measurements, configuration,
|
||||||
wifiConnector);
|
wifiConnector);
|
||||||
static AgSerial *agSerial;
|
static AgSerial *agSerial;
|
||||||
static CellularModule *cellularModule;
|
static CellularModule *cellularCard;
|
||||||
static AirgradientClient *agClient;
|
static AirgradientClient *agClient;
|
||||||
|
|
||||||
enum NetworkOption {
|
enum NetworkOption {
|
||||||
@ -156,7 +156,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 restartIfCeClientIssueOverTwoHours();
|
||||||
static void networkSignalCheck();
|
static void networkSignalCheck();
|
||||||
static void networkingTask(void *args);
|
static void networkingTask(void *args);
|
||||||
|
|
||||||
@ -312,7 +312,7 @@ void loop() {
|
|||||||
if (networkOption == UseCellular) {
|
if (networkOption == UseCellular) {
|
||||||
// Check if cellular client not ready until certain time
|
// Check if cellular client not ready until certain time
|
||||||
// Redundant check in both task to make sure its executed
|
// Redundant check in both task to make sure its executed
|
||||||
checkCellularClientNotReady();
|
restartIfCeClientIssueOverTwoHours();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Schedule to feed external watchdog
|
// Schedule to feed external watchdog
|
||||||
@ -559,7 +559,7 @@ void checkForFirmwareUpdate(void) {
|
|||||||
if (networkOption == UseWifi) {
|
if (networkOption == UseWifi) {
|
||||||
agOta = new AirgradientOTAWifi;
|
agOta = new AirgradientOTAWifi;
|
||||||
} else {
|
} else {
|
||||||
agOta = new AirgradientOTACellular(cellularModule);
|
agOta = new AirgradientOTACellular(cellularCard);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Indicate main task that ota is performing
|
// Indicate main task that ota is performing
|
||||||
@ -943,8 +943,8 @@ void initializeNetwork() {
|
|||||||
if (agSerial->open()) {
|
if (agSerial->open()) {
|
||||||
Serial.println("Cellular module found");
|
Serial.println("Cellular module found");
|
||||||
// Initialize cellular module and use cellular as agClient
|
// Initialize cellular module and use cellular as agClient
|
||||||
cellularModule = new CellularModuleA7672XX(agSerial, GPIO_POWER_MODULE_PIN);
|
cellularCard = new CellularModuleA7672XX(agSerial, GPIO_POWER_MODULE_PIN);
|
||||||
agClient = new AirgradientCellularClient(cellularModule);
|
agClient = new AirgradientCellularClient(cellularCard);
|
||||||
networkOption = UseCellular;
|
networkOption = UseCellular;
|
||||||
} else {
|
} else {
|
||||||
Serial.println("Cellular module not available, using wifi");
|
Serial.println("Cellular module not available, using wifi");
|
||||||
@ -1501,7 +1501,7 @@ void networkSignalCheck() {
|
|||||||
if (networkOption == UseWifi) {
|
if (networkOption == UseWifi) {
|
||||||
Serial.printf("WiFi RSSI %d\n", wifiConnector.RSSI());
|
Serial.printf("WiFi RSSI %d\n", wifiConnector.RSSI());
|
||||||
} else if (networkOption == UseCellular) {
|
} else if (networkOption == UseCellular) {
|
||||||
auto result = cellularModule->retrieveSignal();
|
auto result = cellularCard->retrieveSignal();
|
||||||
if (result.status != CellReturnStatus::Ok) {
|
if (result.status != CellReturnStatus::Ok) {
|
||||||
agClient->setClientReady(false);
|
agClient->setClientReady(false);
|
||||||
lastCellSignalQuality = 99;
|
lastCellSignalQuality = 99;
|
||||||
@ -1522,9 +1522,9 @@ void networkSignalCheck() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If in 2 hours still not ready, then restart esp
|
* If in 2 hours cellular client still not ready, then restart system
|
||||||
*/
|
*/
|
||||||
void checkCellularClientNotReady() {
|
void restartIfCeClientIssueOverTwoHours() {
|
||||||
if (agCeClientProblemDetectedTime > 0 &&
|
if (agCeClientProblemDetectedTime > 0 &&
|
||||||
(MICROS_TO_MINUTES() - agCeClientProblemDetectedTime) >
|
(MICROS_TO_MINUTES() - agCeClientProblemDetectedTime) >
|
||||||
TIMEOUT_WAIT_FOR_CELLULAR_MODULE_READY) {
|
TIMEOUT_WAIT_FOR_CELLULAR_MODULE_READY) {
|
||||||
@ -1534,7 +1534,7 @@ void checkCellularClientNotReady() {
|
|||||||
while (i != 0) {
|
while (i != 0) {
|
||||||
if (ag->isOne()) {
|
if (ag->isOne()) {
|
||||||
String tmp = "Rebooting in " + String(i);
|
String tmp = "Rebooting in " + String(i);
|
||||||
oledDisplay.setText("CE error", "since 1h", tmp.c_str());
|
oledDisplay.setText("CE error", "since 2h", tmp.c_str());
|
||||||
} else {
|
} else {
|
||||||
Serial.println("Rebooting... " + String(i));
|
Serial.println("Rebooting... " + String(i));
|
||||||
}
|
}
|
||||||
@ -1592,7 +1592,7 @@ void networkingTask(void *args) {
|
|||||||
|
|
||||||
// Check if cellular client not ready until certain time
|
// Check if cellular client not ready until certain time
|
||||||
// Redundant check in both task to make sure its executed
|
// Redundant check in both task to make sure its executed
|
||||||
checkCellularClientNotReady();
|
restartIfCeClientIssueOverTwoHours();
|
||||||
|
|
||||||
// Power cycling cellular module due to network issues for more than 1 hour
|
// Power cycling cellular module due to network issues for more than 1 hour
|
||||||
bool resetModule = true;
|
bool resetModule = true;
|
||||||
@ -1600,9 +1600,9 @@ void networkingTask(void *args) {
|
|||||||
TIME_TO_START_POWER_CYCLE_CELLULAR_MODULE) {
|
TIME_TO_START_POWER_CYCLE_CELLULAR_MODULE) {
|
||||||
Serial.println("The CE client hasn't recovered in more than 1 hour, "
|
Serial.println("The CE client hasn't recovered in more than 1 hour, "
|
||||||
"performing a power cycle");
|
"performing a power cycle");
|
||||||
cellularModule->powerOff();
|
cellularCard->powerOff();
|
||||||
delay(2000);
|
delay(2000);
|
||||||
cellularModule->powerOn();
|
cellularCard->powerOn();
|
||||||
delay(10000);
|
delay(10000);
|
||||||
// no need to reset module when calling ensureClientConnection()
|
// no need to reset module when calling ensureClientConnection()
|
||||||
resetModule = false;
|
resetModule = false;
|
||||||
@ -1650,7 +1650,7 @@ void newMeasurementCycle() {
|
|||||||
|
|
||||||
// Get current measures
|
// Get current measures
|
||||||
auto mc = measurements.getMeasures();
|
auto mc = measurements.getMeasures();
|
||||||
mc.signal = cellularModule->csqToDbm(lastCellSignalQuality); // convert to RSSI
|
mc.signal = cellularCard->csqToDbm(lastCellSignalQuality); // convert to RSSI
|
||||||
|
|
||||||
measurementCycleQueue.push_back(mc);
|
measurementCycleQueue.push_back(mc);
|
||||||
Serial.println("New measurement cycle added to queue");
|
Serial.println("New measurement cycle added to queue");
|
||||||
|
Reference in New Issue
Block a user