fix postDataToAirGradient set false after device power up and connected to WiFi

This commit is contained in:
Phat Nguyen
2024-04-22 14:24:01 +07:00
parent 7561017b3d
commit 2d96fc28c5
2 changed files with 12 additions and 3 deletions

View File

@ -46,6 +46,7 @@ bool WifiConnector::connect(void) {
}
WIFI()->setConfigPortalBlocking(false);
WIFI()->setConnectTimeout(15);
WIFI()->setTimeout(WIFI_CONNECT_COUNTDOWN_MAX);
#ifdef ESP32
@ -148,10 +149,16 @@ bool WifiConnector::connect(void) {
hasConfig = true;
logInfo("WiFi Connected: " + WiFi.SSID() + " IP: " + localIpStr());
if (hasPortalConfig) {
String result = String(postToAg.getValue());
logInfo("Post to AirGradient Configure: " + result);
logInfo("Setting postToAirGradient set from " +
String(config.isPostDataToAirGradient() ? "True" : "False") +
String(" to ") + String(result != "T" ? "True" : "False") +
String(" successful"));
config.setPostToAirGradient(result != "T");
}
hasPortalConfig = false;
}
#else
_wifiProcess();
#endif
@ -226,6 +233,7 @@ void WifiConnector::_wifiSaveParamCallback(void) {
sm.ledAnimationInit();
sm.handleLeds(AgStateMachineWiFiManagerStaConnecting);
sm.setDisplayState(AgStateMachineWiFiManagerStaConnecting);
hasPortalConfig = true;
}
/**

View File

@ -23,6 +23,7 @@ private:
void *wifi = NULL;
bool hasConfig;
uint32_t lastRetry;
bool hasPortalConfig = false;
bool wifiClientConnected(void);