added 'set mqtt on|off' for easier debugging

This commit is contained in:
proddy
2023-01-09 21:49:59 +01:00
parent ab6267e122
commit e89260b8b0

View File

@@ -264,6 +264,32 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
#endif
*/
#ifdef EMSESP_DEBUG
// only for debug
commands->add_command(
ShellContext::MAIN,
CommandFlags::ADMIN,
string_vector{F_(set), "mqtt"},
string_vector{"[on|off]"},
[](Shell & shell, const std::vector<std::string> & arguments) {
auto b = arguments.front();
if ((b == "on") || (b == "off")) {
to_app(shell).esp8266React.getMqttSettingsService()->updateWithoutPropagation([&](MqttSettings & settings) {
settings.enabled = (b == "on");
shell.printfln("MQTT %s", settings.enabled ? "enabled" : "disabled");
return StateUpdateResult::CHANGED;
});
emsesp::EMSESP::mqtt_.reset_mqtt();
} else {
shell.println("Must be on or off");
}
},
[](Shell & shell, const std::vector<std::string> & current_arguments, const std::string & next_argument) -> std::vector<std::string> {
return std::vector<std::string>{"on", "off"};
});
#endif
commands->add_command(ShellContext::MAIN,
CommandFlags::ADMIN,
string_vector{F_(set), F_(wifi), F_(password)},