Skip to content

Commit

Permalink
fix postDataToAirGradient set false after device power up and con…
Browse files Browse the repository at this point in the history
…nected to WiFi
  • Loading branch information
pnt325 committed Apr 22, 2024
1 parent 7561017 commit 2d96fc2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/AgWiFiConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ bool WifiConnector::connect(void) {
}

WIFI()->setConfigPortalBlocking(false);
WIFI()->setConnectTimeout(15);
WIFI()->setTimeout(WIFI_CONNECT_COUNTDOWN_MAX);

#ifdef ESP32
Expand Down Expand Up @@ -148,9 +149,15 @@ bool WifiConnector::connect(void) {
hasConfig = true;
logInfo("WiFi Connected: " + WiFi.SSID() + " IP: " + localIpStr());

String result = String(postToAg.getValue());
logInfo("Post to AirGradient Configure: " + result);
config.setPostToAirGradient(result != "T");
if (hasPortalConfig) {
String result = String(postToAg.getValue());
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();
Expand Down Expand Up @@ -226,6 +233,7 @@ void WifiConnector::_wifiSaveParamCallback(void) {
sm.ledAnimationInit();
sm.handleLeds(AgStateMachineWiFiManagerStaConnecting);
sm.setDisplayState(AgStateMachineWiFiManagerStaConnecting);
hasPortalConfig = true;
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/AgWiFiConnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class WifiConnector : public PrintLog {
void *wifi = NULL;
bool hasConfig;
uint32_t lastRetry;
bool hasPortalConfig = false;

bool wifiClientConnected(void);

Expand Down

0 comments on commit 2d96fc2

Please sign in to comment.