Fix wifi connection error when using cellular

This commit is contained in:
samuelbles07
2025-03-18 01:02:10 +07:00
parent e93009f31c
commit 7c2aa35e4f

View File

@ -938,8 +938,12 @@ void initializeNetwork() {
} }
if (!agClient->begin()) { if (!agClient->begin()) {
// TODO: Is assert here properly added? oledDisplay.setText("Client", "initialization", "failed");
assert("Failed start Airgradient Client"); delay(5000);
oledDisplay.showRebooting();
delay(2500);
oledDisplay.setText("", "", "");
ESP.restart();
} }
if (networkOption == UseWifi) { if (networkOption == UseWifi) {
@ -972,10 +976,6 @@ void initializeNetwork() {
return; return;
} }
} }
else if (networkOption == UseCellular) {
// TODO: check if cellular ready
// Display something on display if error, and ignore the rest of the function just like wifi
}
// Send data for the first time to AG server at boot // Send data for the first time to AG server at boot
sendDataToAg(); sendDataToAg();
@ -1108,12 +1108,12 @@ static void updateDisplayAndLedBar(void) {
return; return;
} }
if (wifiConnector.isConnected() == false) { if (wifiConnector.isConnected() == false && networkOption == UseWifi) {
stateMachine.displayHandle(AgStateMachineWiFiLost); stateMachine.displayHandle(AgStateMachineWiFiLost);
stateMachine.handleLeds(AgStateMachineWiFiLost); stateMachine.handleLeds(AgStateMachineWiFiLost);
return; return;
} }
// TODO: Also show for cellular connection // TODO: Also show for cellular connection problem
if (configuration.isCloudConnectionDisabled()) { if (configuration.isCloudConnectionDisabled()) {
// Ignore API related check since cloud is disabled // Ignore API related check since cloud is disabled