diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cd09552..f3c4668 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,6 +1,6 @@ name: "CI" on: - + jobs: ci: runs-on: ubuntu-20.04 diff --git a/examples/advanced/mqtt_class_binder/mqtt_class_binder.ino b/examples/advanced/mqtt_class_binder/mqtt_class_binder.ino index 423b993..46eb6ca 100644 --- a/examples/advanced/mqtt_class_binder/mqtt_class_binder.ino +++ b/examples/advanced/mqtt_class_binder/mqtt_class_binder.ino @@ -1,12 +1,12 @@ #include // https://github.com/hsaturn/TinyMqtt #include -/** +/** * Example on how to bind a class:onPublish function * * Local broker that accept connections and two local clients * - * + * * +-----------------------------+ * | ESP | * | +--------+ | 1883 <--- External client/s @@ -15,14 +15,14 @@ * | | ^ | * | | | | * | | | | ----- - * | v v | --- - * | +----------+ +----------+ | - + * | v v | --- + * | +----------+ +----------+ | - * | | internal | | internal | +-------* Wifi - * | | client | | client | | - * | +----------+ +----------+ | + * | | client | | client | | + * | +----------+ +----------+ | * | | * +-----------------------------+ - * + * * pros - Reduces internal latency (when publish is received by the same ESP) * - Reduces wifi traffic * - No need to have an external broker @@ -50,7 +50,7 @@ MqttClient mqtt_sender(&broker); class MqttReceiver: public MqttClassBinder { public: - + void onPublish(const MqttClient* source, const Topic& topic, const char* payload, size_t /* length */) { Serial diff --git a/examples/client-with-wifi/client-with-wifi.ino b/examples/client-with-wifi/client-with-wifi.ino index 74a6266..716c4d1 100644 --- a/examples/client-with-wifi/client-with-wifi.ino +++ b/examples/client-with-wifi/client-with-wifi.ino @@ -1,9 +1,9 @@ #include // https://github.com/hsaturn/TinyMqtt -/** +/** * Local broker that accept connections and two local clients * - * + * * +-----------------------------+ * | ESP | * | +--------+ | 1883 <--- External client/s @@ -12,14 +12,14 @@ * | | ^ | * | | | | * | | | | ----- - * | v v | --- - * | +----------+ +----------+ | - + * | v v | --- + * | +----------+ +----------+ | - * | | internal | | internal | +-------* Wifi - * | | client | | client | | - * | +----------+ +----------+ | + * | | client | | client | | + * | +----------+ +----------+ | * | | * +-----------------------------+ - * + * * pros - Reduces internal latency (when publish is received by the same ESP) * - Reduces wifi traffic * - No need to have an external broker diff --git a/examples/client-without-wifi/client-without-wifi.ino b/examples/client-without-wifi/client-without-wifi.ino index 9fc8cb7..5cf0d55 100644 --- a/examples/client-without-wifi/client-without-wifi.ino +++ b/examples/client-without-wifi/client-without-wifi.ino @@ -1,7 +1,7 @@ #include // https://github.com/hsaturn/TinyMqtt /** TinyMQTT allows a disconnected mode: - * + * * +-----------------------------+ * | ESP | * | +--------+ | @@ -12,8 +12,8 @@ * | v v | * | +----------+ +----------+ | * | | internal | | internal | | - * | | client | | client | | - * | +----------+ +----------+ | + * | | client | | client | | + * | +----------+ +----------+ | * | | * +-----------------------------+ * diff --git a/examples/simple-client/simple-client.ino b/examples/simple-client/simple-client.ino index fe9ff3a..0ba8179 100644 --- a/examples/simple-client/simple-client.ino +++ b/examples/simple-client/simple-client.ino @@ -3,20 +3,20 @@ /** Simple Client (The simplest configuration) * - * - * +--------+ + * + * +--------+ * +------>| broker |<--- < Other client - * | +--------+ - * | + * | +--------+ + * | * +-----------------+ - * | ESP | | - * | +----------+ | - * | | internal | | - * | | client | | - * | +----------+ | + * | ESP | | + * | +----------+ | + * | | internal | | + * | | client | | + * | +----------+ | * | | * +-----------------+ - * + * * 1 - change the ssid/password * 2 - change BROKER values (or keep emqx.io test broker) * 3 - you can use mqtt-spy to connect to the same broker and @@ -39,7 +39,7 @@ const char* password = ""; static float temp=19; static MqttClient client; -void setup() +void setup() { Serial.begin(115200); delay(500); @@ -50,11 +50,11 @@ void setup() WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); - + while (WiFi.status() != WL_CONNECTED) { delay(500); Serial << '.'; } - Serial << "Connected to " << ssid << "IP address: " << WiFi.localIP() << endl; + Serial << "Connected to " << ssid << "IP address: " << WiFi.localIP() << endl; client.connect(BROKER, BROKER_PORT); } diff --git a/src/MqttClassBinder.h b/src/MqttClassBinder.h index 57bdf6c..86a96f7 100644 --- a/src/MqttClassBinder.h +++ b/src/MqttClassBinder.h @@ -8,7 +8,7 @@ class MqttClassBinder unregister(this); } ~MqttClassBinder() { unregister(this); } - + static void onUnpublished(MqttClient::CallBack handler) { unrouted_handler = handler; diff --git a/src/TinyMqtt.cpp b/src/TinyMqtt.cpp index 07d80d0..51b654c 100644 --- a/src/TinyMqtt.cpp +++ b/src/TinyMqtt.cpp @@ -538,7 +538,7 @@ void MqttClient::processMessage(MqttMessage* mesg) { if (!mqtt_connected) break; payload = header+2; - + debug("un/subscribe loop"); std::string qoss; while(payload < mesg->end()) @@ -862,7 +862,7 @@ void MqttMessage::encodeLength() buffer[2] = (length >> 7); vheader = 3; } - + // We could check that buffer[2] < 128 (end of length encoding) state = Complete; } diff --git a/tests/classbind-tests/classbind-tests.ino b/tests/classbind-tests/classbind-tests.ino index a96de70..14c7b4f 100644 --- a/tests/classbind-tests/classbind-tests.ino +++ b/tests/classbind-tests/classbind-tests.ino @@ -154,7 +154,7 @@ test(classbind_one_client_receives_the_message) client.loop(); broker.loop(); } - + assertEqual(TestReceiver::messages["receiver"], 1); assertEqual(unrouted, 0); } @@ -190,7 +190,7 @@ test(classbind_routes_should_be_empty_when_receiver_goes_out_of_scope) client.loop(); broker.loop(); } - + assertEqual(TestReceiver::messages["receiver"], 0); assertEqual(MqttClassBinder::size(), (size_t)0); } @@ -224,7 +224,7 @@ test(classbind_publish_should_be_dispatched_to_many_receivers) client.loop(); broker.loop(); } - + assertEqual(TestReceiver::messages["receiver_1"], 1); assertEqual(TestReceiver::messages["receiver_2"], 1); } @@ -274,7 +274,7 @@ test(classbind_register_to_many_clients) // Ensure publishes are processed for (int i =0; i<5; i++) loop(); - + assertEqual(TestReceiver::messages["receiver"], 4); } diff --git a/tests/network-tests/network-tests.ino b/tests/network-tests/network-tests.ino index fe80113..b758eda 100644 --- a/tests/network-tests/network-tests.ino +++ b/tests/network-tests/network-tests.ino @@ -99,7 +99,7 @@ void onPublish(const MqttClient* srce, const Topic& topic, const char* payload, { if (srce) published[srce->id()][topic]++; - + if (lastPayload) free(lastPayload); lastPayload = strdup(payload); lastLength = length; @@ -221,7 +221,7 @@ test(network_one_client_one_broker_publish_and_subscribe_through_network) client.loop(); broker.loop(); } - + assertEqual(published.size(), (size_t)1); assertEqual((int)lastLength, (int)2); // sizeof(ab) } @@ -321,7 +321,7 @@ test(network_publish_should_be_dispatched_to_clients) MqttClient publisher(&broker); publisher.publish("a/b"); // A and B should receive this - publisher.publish("a/c"); // A should receive this + publisher.publish("a/c"); // A should receive this assertEqual(published.size(), (size_t)2); // 2 clients have received something assertEqual(published["A"]["a/b"], 1); diff --git a/tests/nowifi-tests/nowifi-tests.ino b/tests/nowifi-tests/nowifi-tests.ino index 68bf24e..7bb06e9 100644 --- a/tests/nowifi-tests/nowifi-tests.ino +++ b/tests/nowifi-tests/nowifi-tests.ino @@ -24,7 +24,7 @@ void onPublish(const MqttClient* srce, const Topic& topic, const char* payload, { if (srce) published[srce->id()][topic]++; - + if (lastPayload) free(lastPayload); lastPayload = strdup(payload); lastLength = length; @@ -85,7 +85,7 @@ test(nowifi_publish_should_be_dispatched_to_clients) MqttClient publisher(&broker); publisher.publish("a/b"); // A and B should receive this - publisher.publish("a/c"); // A should receive this + publisher.publish("a/c"); // A should receive this assertEqual(published.size(), (size_t)2); // 2 clients have received something assertEqual(published["A"]["a/b"], 1);