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

Fix keep WiFi connection after closing WebUi if it was established beforehand #682

Merged
merged 2 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions src/core/serialcmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,10 +617,6 @@ bool processSerialCommand(String cmd_str) {

if(cmd_str == "webui" ) {
// start the webui
if(!wifiConnected) {
Serial.println("wifiConnect");
wifiConnectMenu(WIFI_AP); // TODO: read mode from config file
}
Serial.println("startWebUi");
startWebUi(true); // MEMO: will quit when check(EscPress)
return true;
Expand Down
28 changes: 5 additions & 23 deletions src/modules/others/webInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,13 @@ WebServer* server=nullptr; // initialise webserver
const char* host = "bruce";
String uploadFolder="";



/**********************************************************************
** Function: webUIMyNet
** Display options to launch the WebUI
**********************************************************************/
void webUIMyNet() {
if (WiFi.status() != WL_CONNECTED) {
if(wifiConnectMenu()) startWebUi(false);
else {
displayError("Wifi Offline");
}
} else {
//If it is already connected, just start the network
startWebUi(false);
}
// On fail installing will run the following line
}


/**********************************************************************
** Function: loopOptionsWebUi
** Display options to launch the WebUI
**********************************************************************/
void loopOptionsWebUi() {
// Definição da matriz "Options"
options = {
{"my Network", [=]() { webUIMyNet(); }},
{"my Network", [=]() { startWebUi(false); }},
{"AP mode", [=]() { startWebUi(true); }},
};

Expand Down Expand Up @@ -493,11 +472,14 @@ server->on("/script.js", HTTP_GET, []() {
void startWebUi(bool mode_ap) {
setupSdCard();

bool keepWifiConnected = false;
if (WiFi.status() != WL_CONNECTED) {
if( mode_ap )
wifiConnectMenu(WIFI_AP);
else
wifiConnectMenu(WIFI_STA);
} else {
keepWifiConnected = true;
}

// configure web server
Expand Down Expand Up @@ -526,7 +508,7 @@ void startWebUi(bool mode_ap) {
MDNS.end();

delay(100);
wifiDisconnect();
if(!keepWifiConnected) wifiDisconnect();
enableCore0WDT();
enableCore1WDT();
enableLoopWDT();
Expand Down
Loading