From 1cfb5cfab156722ad3e3dfb9a695595139dffb60 Mon Sep 17 00:00:00 2001 From: hsaturn Date: Sun, 11 Apr 2021 19:19:06 +0200 Subject: [PATCH] Allow multiple command per line separated by ; --- examples/tinymqtt-test/tinymqtt-test.ino | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/examples/tinymqtt-test/tinymqtt-test.ino b/examples/tinymqtt-test/tinymqtt-test.ino index c310fad..d8d28e7 100644 --- a/examples/tinymqtt-test/tinymqtt-test.ino +++ b/examples/tinymqtt-test/tinymqtt-test.ino @@ -384,8 +384,15 @@ void loop() last_cmd=cmd; if (cmd.substr(0,3)!="set") replaceVars(cmd); + while(cmd.length()) { + std::string cmd_end; + if (cmd.find(';') != std::string::npos) + { + cmd_end = cmd; + cmd = getword(cmd_end,"",';'); + } MqttError retval = MqttOk; std::string s; @@ -619,7 +626,7 @@ void loop() Serial << "IP: " << WiFi.localIP() << endl; else if (compare(s,"help")) { - Serial << "syntax:" << endl; + Serial << "syntax: instr; instr; ..." << endl; Serial << " MqttBroker:" << endl; Serial << " broker {name} {port} : create a new broker" << endl; Serial << endl; @@ -654,6 +661,11 @@ void loop() { Serial << "## ERROR " << retval << endl; } + if (cmd_end.length()) + { + cmd = cmd_end; + cmd_end = ""; + } } } else