Handling cellular client not ready better

This commit is contained in:
samuelbles07
2025-03-27 16:10:56 +07:00
parent 656509c74d
commit 86cd90b94a
3 changed files with 10 additions and 8 deletions

View File

@ -1455,7 +1455,12 @@ void networkSignalCheck() {
} else if (networkOption == UseCellular) { } else if (networkOption == UseCellular) {
auto result = cell->retrieveSignal(); auto result = cell->retrieveSignal();
if (result.status != CellReturnStatus::Ok) { if (result.status != CellReturnStatus::Ok) {
// TODO: Need to do something when get signal failed agClient->setClientReady(false);
return;
}
if (result.data == 99) {
// 99 indicate cellular not attached to network
agClient->setClientReady(false);
return; return;
} }
Serial.printf("Cellular signal strength %d\n", result.data); Serial.printf("Cellular signal strength %d\n", result.data);
@ -1496,11 +1501,8 @@ void networkingTask(void *args) {
} }
} }
else if (networkOption == UseCellular) { else if (networkOption == UseCellular) {
// Check if last fetch config and post measures failed if (agClient->isClientReady() == false) {
// It can be an indication that module has a problem Serial.println("Cellular client not ready, ensuring connection...");
if (agClient->isLastFetchConfigSucceed() == false ||
agClient->isLastPostMeasureSucceed() == false) {
Serial.println("Last server communication might failed, checking...");
if (agClient->ensureClientConnection() == false) { if (agClient->ensureClientConnection() == false) {
Serial.println("Cellular client connection not ready, retry in 5s..."); Serial.println("Cellular client connection not ready, retry in 5s...");
delay(5000); delay(5000);

View File

@ -10,7 +10,7 @@
} }
#else #else
#include <esp32-hal-log.h> #include <esp32-hal-log.h>
#define AgLog(c, ...) log_d(c, ##__VA_ARGS__) #define AgLog(c, ...) log_i(c, ##__VA_ARGS__)
#endif #endif
/** /**