mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
no wifi disconnect until reboot on ssid cleared
This commit is contained in:
@@ -112,11 +112,10 @@ class HttpPostEndpoint {
|
||||
AsyncJsonResponse * response = new AsyncJsonResponse(false, _bufferSize);
|
||||
jsonObject = response->getRoot().to<JsonObject>();
|
||||
_statefulService->read(jsonObject, _stateReader);
|
||||
response->setLength();
|
||||
|
||||
if (outcome == StateUpdateResult::CHANGED_RESTART) {
|
||||
response->setCode(205); // reboot required
|
||||
}
|
||||
response->setLength();
|
||||
request->send(response);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,10 +28,16 @@ void NetworkSettingsService::begin() {
|
||||
WiFi.onEvent(std::bind(&NetworkSettingsService::WiFiEvent, this, _1));
|
||||
|
||||
_fsPersistence.readFromFS();
|
||||
reconfigureWiFiConnection();
|
||||
// reconfigureWiFiConnection();
|
||||
_lastConnectionAttempt = 0;
|
||||
_stopping = false;
|
||||
}
|
||||
|
||||
void NetworkSettingsService::reconfigureWiFiConnection() {
|
||||
// do not disconnect for switching to eth, restart is needed
|
||||
if (WiFi.isConnected() && _state.ssid.length() == 0) {
|
||||
return;
|
||||
}
|
||||
// disconnect and de-configure wifi
|
||||
if (WiFi.disconnect(true)) {
|
||||
_stopping = true;
|
||||
|
||||
@@ -76,6 +76,7 @@ class NetworkSettings {
|
||||
static StateUpdateResult update(JsonObject & root, NetworkSettings & settings) {
|
||||
auto enableCORS = settings.enableCORS;
|
||||
auto CORSOrigin = settings.CORSOrigin;
|
||||
auto ssid = settings.ssid;
|
||||
settings.ssid = root["ssid"] | FACTORY_WIFI_SSID;
|
||||
settings.bssid = root["bssid"] | "";
|
||||
settings.password = root["password"] | FACTORY_WIFI_PASSWORD;
|
||||
@@ -108,7 +109,7 @@ class NetworkSettings {
|
||||
if (settings.staticIPConfig && (IPUtils::isNotSet(settings.localIP) || IPUtils::isNotSet(settings.gatewayIP) || IPUtils::isNotSet(settings.subnetMask))) {
|
||||
settings.staticIPConfig = false;
|
||||
}
|
||||
if (enableCORS != settings.enableCORS || CORSOrigin != settings.CORSOrigin) {
|
||||
if (enableCORS != settings.enableCORS || CORSOrigin != settings.CORSOrigin || (ssid != settings.ssid && settings.ssid == "")) {
|
||||
return StateUpdateResult::CHANGED_RESTART; // tell WebUI that a restart is needed
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user