mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
do not reset wifi when value changed (in progress) - #435
This commit is contained in:
@@ -558,15 +558,11 @@ void System::console_commands(Shell & shell, unsigned int context) {
|
|||||||
flash_string_vector{F_(set), F_(wifi), F_(ssid)},
|
flash_string_vector{F_(set), F_(wifi), F_(ssid)},
|
||||||
flash_string_vector{F_(name_mandatory)},
|
flash_string_vector{F_(name_mandatory)},
|
||||||
[](Shell & shell, const std::vector<std::string> & arguments) {
|
[](Shell & shell, const std::vector<std::string> & arguments) {
|
||||||
shell.println("The wifi connection will be reset...");
|
EMSESP::esp8266React.getWiFiSettingsService()->updateWithoutPropagation([&](WiFiSettings & wifiSettings) {
|
||||||
Shell::loop_all();
|
|
||||||
delay(1000); // wait a second
|
|
||||||
EMSESP::esp8266React.getWiFiSettingsService()->update(
|
|
||||||
[&](WiFiSettings & wifiSettings) {
|
|
||||||
wifiSettings.ssid = arguments.front().c_str();
|
wifiSettings.ssid = arguments.front().c_str();
|
||||||
return StateUpdateResult::CHANGED;
|
return StateUpdateResult::CHANGED;
|
||||||
},
|
});
|
||||||
"local");
|
shell.println("You will need to restart to apply the new WiFi changes");
|
||||||
});
|
});
|
||||||
|
|
||||||
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
||||||
@@ -579,13 +575,12 @@ void System::console_commands(Shell & shell, unsigned int context) {
|
|||||||
[password1](Shell & shell, bool completed, const std::string & password2) {
|
[password1](Shell & shell, bool completed, const std::string & password2) {
|
||||||
if (completed) {
|
if (completed) {
|
||||||
if (password1 == password2) {
|
if (password1 == password2) {
|
||||||
EMSESP::esp8266React.getWiFiSettingsService()->update(
|
EMSESP::esp8266React.getWiFiSettingsService()->updateWithoutPropagation(
|
||||||
[&](WiFiSettings & wifiSettings) {
|
[&](WiFiSettings & wifiSettings) {
|
||||||
wifiSettings.password = password2.c_str();
|
wifiSettings.password = password2.c_str();
|
||||||
return StateUpdateResult::CHANGED;
|
return StateUpdateResult::CHANGED;
|
||||||
},
|
});
|
||||||
"local");
|
shell.println("You will need to restart to apply the new WiFi changes");
|
||||||
shell.println(F("WiFi password updated"));
|
|
||||||
} else {
|
} else {
|
||||||
shell.println(F("Passwords do not match"));
|
shell.println(F("Passwords do not match"));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user