From 6d8baab6691279de2af498000e7391072fa95c47 Mon Sep 17 00:00:00 2001 From: proddy Date: Sat, 6 Jun 2020 21:42:37 +0200 Subject: [PATCH] hostname renamed to set wifi hostname to fix console issue --- src/system.cpp | 108 ++++++++++++++++++++++++------------------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/src/system.cpp b/src/system.cpp index eff52647d..897d48506 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -29,7 +29,7 @@ MAKE_PSTR_WORD(wifi) MAKE_PSTR_WORD(ssid) 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(wifi_ssid_fmt, "WiFi SSID = %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) { EMSESPShell::commands->add_command(ShellContext::SYSTEM, CommandFlags::ADMIN, - flash_string_vector{F_(set), F_(hostname)}, - flash_string_vector{F_(name_mandatory)}, - [](Shell & shell __attribute__((unused)), const std::vector & arguments) { - Settings settings; - settings.hostname(arguments.front()); - settings.commit(); + flash_string_vector{F_(restart)}, + [](Shell & shell __attribute__((unused)), const std::vector & arguments __attribute__((unused))) { + restart(); + }); + + EMSESPShell::commands->add_command(ShellContext::SYSTEM, + CommandFlags::ADMIN, + flash_string_vector{F_(format)}, + [](Shell & shell, const std::vector & arguments __attribute__((unused))) { + shell.enter_password(F_(password_prompt), [=](Shell & shell, bool completed, const std::string & password) { + if (completed) { + Settings settings; + if ((settings.admin_password().empty()) || (!password.empty() && password == settings.admin_password())) { + settings.format(shell); + } else { + shell.println(F("incorrect password")); + } + } + }); }); 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 & 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 & 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 & arguments __attribute__((unused))) { Network::scan(shell); }); + + EMSESPShell::commands->add_command(ShellContext::SYSTEM, + CommandFlags::USER, + flash_string_vector{F_(show)}, + [=](Shell & shell, const std::vector & arguments __attribute__((unused))) { + Network::show_network(shell); + show_system(shell); + shell.println(); + }); + EMSESPShell::commands->add_command(ShellContext::SYSTEM, CommandFlags::ADMIN, 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, CommandFlags::ADMIN, - flash_string_vector{F_(restart)}, - [](Shell & shell __attribute__((unused)), const std::vector & arguments __attribute__((unused))) { - restart(); - }); - - EMSESPShell::commands->add_command(ShellContext::SYSTEM, - CommandFlags::ADMIN, - flash_string_vector{F_(format)}, - [](Shell & shell, const std::vector & arguments __attribute__((unused))) { - shell.enter_password(F_(password_prompt), [=](Shell & shell, bool completed, const std::string & password) { - if (completed) { - Settings settings; - if ((settings.admin_password().empty()) || (!password.empty() && password == settings.admin_password())) { - settings.format(shell); - } else { - shell.println(F("incorrect password")); - } - } - }); + flash_string_vector{F_(set), F_(wifi), F_(hostname)}, + flash_string_vector{F_(name_mandatory)}, + [](Shell & shell __attribute__((unused)), const std::vector & arguments) { + Settings settings; + settings.hostname(arguments.front()); + settings.commit(); }); EMSESPShell::commands->add_command( @@ -453,25 +481,6 @@ void System::console_commands(Shell & shell, unsigned int context) { return std::vector{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 & 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 & 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 & arguments __attribute__((unused))) { Network::scan(shell); }); - EMSESPShell::commands->add_command(ShellContext::SYSTEM, 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 & arguments __attribute__((unused))) { - Network::show_network(shell); - show_system(shell); - shell.println(); - }); - EMSESPShell::commands->add_command(ShellContext::SYSTEM, CommandFlags::USER, flash_string_vector{F_(set)},