Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WiFi] Only start AP if wifi is not configured, or we received extern… #250

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions networkStuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,16 @@ void startWiFi(const char* hostname, int timeOut)
//--- if it does not connect it starts an access point with the specified name
//--- here "<HOSTNAME>-<MAC>"
//--- and goes into a blocking loop awaiting configuration
OTGWSerial.printf("AutoConnect to: %s\r\n", thisAP.c_str());
if (!manageWiFi.autoConnect(thisAP.c_str()))
{
//-- fail to connect? Have you tried turning it off and on again?
DebugTln(F("failed to connect and hit timeout"));
delay(2000); // Enough time for messages to be sent.
ESP.restart();
delay(5000); // Enough time to ensure we don't return.
if ( ! manageWiFi.getWiFiIsSaved() || ESP.getResetReason() == "External System"){
OTGWSerial.printf("AutoConnect to: %s\r\n", thisAP.c_str());
if (!manageWiFi.startConfigPortal(thisAP.c_str()))
{
//-- fail to connect? Have you tried turning it off and on again?
DebugTln(F("failed to connect and hit timeout"));
delay(2000); // Enough time for messages to be sent.
ESP.restart();
delay(5000); // Enough time to ensure we don't return.
}
}

// WiFi.mode(WIFI_STA); // explicitly set mode, esp defaults to STA+AP
Expand Down