mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 08:19:52 +03:00
hostname renamed to set wifi hostname to fix console issue
This commit is contained in:
104
src/system.cpp
104
src/system.cpp
@@ -29,7 +29,7 @@ MAKE_PSTR_WORD(wifi)
|
|||||||
MAKE_PSTR_WORD(ssid)
|
MAKE_PSTR_WORD(ssid)
|
||||||
|
|
||||||
MAKE_PSTR(host_fmt, "Host = %s")
|
MAKE_PSTR(host_fmt, "Host = %s")
|
||||||
MAKE_PSTR(hostname_fmt, "System Hostname = %s")
|
MAKE_PSTR(hostname_fmt, "Hostname = %s")
|
||||||
MAKE_PSTR(mark_interval_fmt, "Mark interval = %lus");
|
MAKE_PSTR(mark_interval_fmt, "Mark interval = %lus");
|
||||||
MAKE_PSTR(wifi_ssid_fmt, "WiFi SSID = %s");
|
MAKE_PSTR(wifi_ssid_fmt, "WiFi SSID = %s");
|
||||||
MAKE_PSTR(wifi_password_fmt, "WiFi Password = %S")
|
MAKE_PSTR(wifi_password_fmt, "WiFi Password = %S")
|
||||||
@@ -327,12 +327,25 @@ void System::show_system(uuid::console::Shell & shell) {
|
|||||||
void System::console_commands(Shell & shell, unsigned int context) {
|
void System::console_commands(Shell & shell, unsigned int context) {
|
||||||
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
||||||
CommandFlags::ADMIN,
|
CommandFlags::ADMIN,
|
||||||
flash_string_vector{F_(set), F_(hostname)},
|
flash_string_vector{F_(restart)},
|
||||||
flash_string_vector{F_(name_mandatory)},
|
[](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments __attribute__((unused))) {
|
||||||
[](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments) {
|
restart();
|
||||||
|
});
|
||||||
|
|
||||||
|
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
||||||
|
CommandFlags::ADMIN,
|
||||||
|
flash_string_vector{F_(format)},
|
||||||
|
[](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) {
|
||||||
|
shell.enter_password(F_(password_prompt), [=](Shell & shell, bool completed, const std::string & password) {
|
||||||
|
if (completed) {
|
||||||
Settings settings;
|
Settings settings;
|
||||||
settings.hostname(arguments.front());
|
if ((settings.admin_password().empty()) || (!password.empty() && password == settings.admin_password())) {
|
||||||
settings.commit();
|
settings.format(shell);
|
||||||
|
} else {
|
||||||
|
shell.println(F("incorrect password"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
||||||
@@ -358,6 +371,34 @@ void System::console_commands(Shell & shell, unsigned int context) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
||||||
|
CommandFlags::ADMIN,
|
||||||
|
flash_string_vector{F_(wifi), F_(disconnect)},
|
||||||
|
[](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments __attribute__((unused))) {
|
||||||
|
Network::disconnect();
|
||||||
|
});
|
||||||
|
|
||||||
|
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
||||||
|
CommandFlags::ADMIN,
|
||||||
|
flash_string_vector{F_(wifi), F_(reconnect)},
|
||||||
|
[](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments __attribute__((unused))) {
|
||||||
|
Network::reconnect();
|
||||||
|
});
|
||||||
|
|
||||||
|
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
||||||
|
CommandFlags::ADMIN,
|
||||||
|
flash_string_vector{F_(wifi), F_(scan)},
|
||||||
|
[](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) { Network::scan(shell); });
|
||||||
|
|
||||||
|
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
||||||
|
CommandFlags::USER,
|
||||||
|
flash_string_vector{F_(show)},
|
||||||
|
[=](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) {
|
||||||
|
Network::show_network(shell);
|
||||||
|
show_system(shell);
|
||||||
|
shell.println();
|
||||||
|
});
|
||||||
|
|
||||||
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
||||||
CommandFlags::ADMIN,
|
CommandFlags::ADMIN,
|
||||||
flash_string_vector{F_(set), F_(syslog), F_(host)},
|
flash_string_vector{F_(set), F_(syslog), F_(host)},
|
||||||
@@ -414,25 +455,12 @@ void System::console_commands(Shell & shell, unsigned int context) {
|
|||||||
|
|
||||||
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
||||||
CommandFlags::ADMIN,
|
CommandFlags::ADMIN,
|
||||||
flash_string_vector{F_(restart)},
|
flash_string_vector{F_(set), F_(wifi), F_(hostname)},
|
||||||
[](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments __attribute__((unused))) {
|
flash_string_vector{F_(name_mandatory)},
|
||||||
restart();
|
[](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments) {
|
||||||
});
|
|
||||||
|
|
||||||
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
|
||||||
CommandFlags::ADMIN,
|
|
||||||
flash_string_vector{F_(format)},
|
|
||||||
[](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) {
|
|
||||||
shell.enter_password(F_(password_prompt), [=](Shell & shell, bool completed, const std::string & password) {
|
|
||||||
if (completed) {
|
|
||||||
Settings settings;
|
Settings settings;
|
||||||
if ((settings.admin_password().empty()) || (!password.empty() && password == settings.admin_password())) {
|
settings.hostname(arguments.front());
|
||||||
settings.format(shell);
|
settings.commit();
|
||||||
} else {
|
|
||||||
shell.println(F("incorrect password"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
EMSESPShell::commands->add_command(
|
EMSESPShell::commands->add_command(
|
||||||
@@ -453,25 +481,6 @@ void System::console_commands(Shell & shell, unsigned int context) {
|
|||||||
return std::vector<std::string>{settings.wifi_ssid()};
|
return std::vector<std::string>{settings.wifi_ssid()};
|
||||||
});
|
});
|
||||||
|
|
||||||
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
|
||||||
CommandFlags::ADMIN,
|
|
||||||
flash_string_vector{F_(wifi), F_(disconnect)},
|
|
||||||
[](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments __attribute__((unused))) {
|
|
||||||
Network::disconnect();
|
|
||||||
});
|
|
||||||
|
|
||||||
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
|
||||||
CommandFlags::ADMIN,
|
|
||||||
flash_string_vector{F_(wifi), F_(reconnect)},
|
|
||||||
[](Shell & shell __attribute__((unused)), const std::vector<std::string> & arguments __attribute__((unused))) {
|
|
||||||
Network::reconnect();
|
|
||||||
});
|
|
||||||
|
|
||||||
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
|
||||||
CommandFlags::ADMIN,
|
|
||||||
flash_string_vector{F_(wifi), F_(scan)},
|
|
||||||
[](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) { Network::scan(shell); });
|
|
||||||
|
|
||||||
|
|
||||||
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
||||||
CommandFlags::ADMIN,
|
CommandFlags::ADMIN,
|
||||||
@@ -497,15 +506,6 @@ void System::console_commands(Shell & shell, unsigned int context) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
|
||||||
CommandFlags::USER,
|
|
||||||
flash_string_vector{F_(show)},
|
|
||||||
[=](Shell & shell, const std::vector<std::string> & arguments __attribute__((unused))) {
|
|
||||||
Network::show_network(shell);
|
|
||||||
show_system(shell);
|
|
||||||
shell.println();
|
|
||||||
});
|
|
||||||
|
|
||||||
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
EMSESPShell::commands->add_command(ShellContext::SYSTEM,
|
||||||
CommandFlags::USER,
|
CommandFlags::USER,
|
||||||
flash_string_vector{F_(set)},
|
flash_string_vector{F_(set)},
|
||||||
|
|||||||
Reference in New Issue
Block a user