From b28019639596caf9135b27a71cb36c04c298c46d Mon Sep 17 00:00:00 2001 From: hsaturn Date: Sat, 10 Apr 2021 16:50:14 +0200 Subject: [PATCH] Added mqDns to tinytest --- examples/tinymqtt-test/tinymqtt-test.ino | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/examples/tinymqtt-test/tinymqtt-test.ino b/examples/tinymqtt-test/tinymqtt-test.ino index 5b825c2..f0b8785 100644 --- a/examples/tinymqtt-test/tinymqtt-test.ino +++ b/examples/tinymqtt-test/tinymqtt-test.ino @@ -1,10 +1,11 @@ -#define TINY_MQTT_DEBUG #include // https://github.com/hsaturn/TinyMqtt #include +#include + #include #include -/** +/** * Console allowing to make any kind of test. * * pros - Reduces internal latency (when publish is received by the same ESP) @@ -40,7 +41,7 @@ std::map brokers; void setup() { - WiFi.persistent(false); // https://github.com/esp8266/Arduino/issues/1054 + WiFi.persistent(false); // https://github.com/esp8266/Arduino/issues/1054 Serial.begin(115200); delay(500); Serial << endl << endl << endl @@ -55,6 +56,14 @@ void setup() Serial << "Connected to " << ssid << "IP address: " << WiFi.localIP() << endl; Serial << "Type help for more..." << endl; + const char* name="tinytest"; + Serial << "Starting MDNS, name= " << name; + if (!MDNS.begin(name)) + Serial << " error, not available." << endl; + else + Serial << " ok." << endl; + + MqttBroker* broker = new MqttBroker(1883); broker->begin(); brokers["broker"] = broker; @@ -344,6 +353,8 @@ void loop() } static long count; + MDNS.update(); + if (MqttClient::counter != count) { Serial << "# " << MqttClient::counter << endl; @@ -383,7 +394,7 @@ void loop() // client.function notation // ("a.fun " becomes "fun a ") - if (cmd.find('.') != std::string::npos && + if (cmd.find('.') != std::string::npos && cmd.find('.') < cmd.find(' ')) { s=getword(cmd, nullptr, '.');