Remove spaces to end of lines

This commit is contained in:
Francois BIOT
2022-12-28 21:22:19 +01:00
parent 42fc054c94
commit 2b92833ea5
10 changed files with 44 additions and 44 deletions

View File

@@ -1,6 +1,6 @@
name: "CI" name: "CI"
on: on:
jobs: jobs:
ci: ci:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04

View File

@@ -1,12 +1,12 @@
#include <TinyMqtt.h> // https://github.com/hsaturn/TinyMqtt #include <TinyMqtt.h> // https://github.com/hsaturn/TinyMqtt
#include <MqttClassBinder.h> #include <MqttClassBinder.h>
/** /**
* Example on how to bind a class:onPublish function * Example on how to bind a class:onPublish function
* *
* Local broker that accept connections and two local clients * Local broker that accept connections and two local clients
* *
* *
* +-----------------------------+ * +-----------------------------+
* | ESP | * | ESP |
* | +--------+ | 1883 <--- External client/s * | +--------+ | 1883 <--- External client/s
@@ -15,14 +15,14 @@
* | | ^ | * | | ^ |
* | | | | * | | | |
* | | | | ----- * | | | | -----
* | v v | --- * | v v | ---
* | +----------+ +----------+ | - * | +----------+ +----------+ | -
* | | internal | | internal | +-------* Wifi * | | internal | | internal | +-------* Wifi
* | | client | | client | | * | | client | | client | |
* | +----------+ +----------+ | * | +----------+ +----------+ |
* | | * | |
* +-----------------------------+ * +-----------------------------+
* *
* pros - Reduces internal latency (when publish is received by the same ESP) * pros - Reduces internal latency (when publish is received by the same ESP)
* - Reduces wifi traffic * - Reduces wifi traffic
* - No need to have an external broker * - No need to have an external broker
@@ -50,7 +50,7 @@ MqttClient mqtt_sender(&broker);
class MqttReceiver: public MqttClassBinder<MqttReceiver> class MqttReceiver: public MqttClassBinder<MqttReceiver>
{ {
public: public:
void onPublish(const MqttClient* source, const Topic& topic, const char* payload, size_t /* length */) void onPublish(const MqttClient* source, const Topic& topic, const char* payload, size_t /* length */)
{ {
Serial Serial

View File

@@ -1,9 +1,9 @@
#include <TinyMqtt.h> // https://github.com/hsaturn/TinyMqtt #include <TinyMqtt.h> // https://github.com/hsaturn/TinyMqtt
/** /**
* Local broker that accept connections and two local clients * Local broker that accept connections and two local clients
* *
* *
* +-----------------------------+ * +-----------------------------+
* | ESP | * | ESP |
* | +--------+ | 1883 <--- External client/s * | +--------+ | 1883 <--- External client/s
@@ -12,14 +12,14 @@
* | | ^ | * | | ^ |
* | | | | * | | | |
* | | | | ----- * | | | | -----
* | v v | --- * | v v | ---
* | +----------+ +----------+ | - * | +----------+ +----------+ | -
* | | internal | | internal | +-------* Wifi * | | internal | | internal | +-------* Wifi
* | | client | | client | | * | | client | | client | |
* | +----------+ +----------+ | * | +----------+ +----------+ |
* | | * | |
* +-----------------------------+ * +-----------------------------+
* *
* pros - Reduces internal latency (when publish is received by the same ESP) * pros - Reduces internal latency (when publish is received by the same ESP)
* - Reduces wifi traffic * - Reduces wifi traffic
* - No need to have an external broker * - No need to have an external broker

View File

@@ -1,7 +1,7 @@
#include <TinyMqtt.h> // https://github.com/hsaturn/TinyMqtt #include <TinyMqtt.h> // https://github.com/hsaturn/TinyMqtt
/** TinyMQTT allows a disconnected mode: /** TinyMQTT allows a disconnected mode:
* *
* +-----------------------------+ * +-----------------------------+
* | ESP | * | ESP |
* | +--------+ | * | +--------+ |
@@ -12,8 +12,8 @@
* | v v | * | v v |
* | +----------+ +----------+ | * | +----------+ +----------+ |
* | | internal | | internal | | * | | internal | | internal | |
* | | client | | client | | * | | client | | client | |
* | +----------+ +----------+ | * | +----------+ +----------+ |
* | | * | |
* +-----------------------------+ * +-----------------------------+
* *

View File

@@ -3,20 +3,20 @@
/** Simple Client (The simplest configuration) /** Simple Client (The simplest configuration)
* *
* *
* +--------+ * +--------+
* +------>| broker |<--- < Other client * +------>| broker |<--- < Other client
* | +--------+ * | +--------+
* | * |
* +-----------------+ * +-----------------+
* | ESP | | * | ESP | |
* | +----------+ | * | +----------+ |
* | | internal | | * | | internal | |
* | | client | | * | | client | |
* | +----------+ | * | +----------+ |
* | | * | |
* +-----------------+ * +-----------------+
* *
* 1 - change the ssid/password * 1 - change the ssid/password
* 2 - change BROKER values (or keep emqx.io test broker) * 2 - change BROKER values (or keep emqx.io test broker)
* 3 - you can use mqtt-spy to connect to the same broker and * 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 float temp=19;
static MqttClient client; static MqttClient client;
void setup() void setup()
{ {
Serial.begin(115200); Serial.begin(115200);
delay(500); delay(500);
@@ -50,11 +50,11 @@ void setup()
WiFi.mode(WIFI_STA); WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password); WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) while (WiFi.status() != WL_CONNECTED)
{ delay(500); Serial << '.'; } { 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); client.connect(BROKER, BROKER_PORT);
} }

View File

@@ -8,7 +8,7 @@ class MqttClassBinder
unregister(this); unregister(this);
} }
~MqttClassBinder() { unregister(this); } ~MqttClassBinder() { unregister(this); }
static void onUnpublished(MqttClient::CallBack handler) static void onUnpublished(MqttClient::CallBack handler)
{ {
unrouted_handler = handler; unrouted_handler = handler;

View File

@@ -538,7 +538,7 @@ void MqttClient::processMessage(MqttMessage* mesg)
{ {
if (!mqtt_connected) break; if (!mqtt_connected) break;
payload = header+2; payload = header+2;
debug("un/subscribe loop"); debug("un/subscribe loop");
std::string qoss; std::string qoss;
while(payload < mesg->end()) while(payload < mesg->end())
@@ -862,7 +862,7 @@ void MqttMessage::encodeLength()
buffer[2] = (length >> 7); buffer[2] = (length >> 7);
vheader = 3; vheader = 3;
} }
// We could check that buffer[2] < 128 (end of length encoding) // We could check that buffer[2] < 128 (end of length encoding)
state = Complete; state = Complete;
} }

View File

@@ -154,7 +154,7 @@ test(classbind_one_client_receives_the_message)
client.loop(); client.loop();
broker.loop(); broker.loop();
} }
assertEqual(TestReceiver::messages["receiver"], 1); assertEqual(TestReceiver::messages["receiver"], 1);
assertEqual(unrouted, 0); assertEqual(unrouted, 0);
} }
@@ -190,7 +190,7 @@ test(classbind_routes_should_be_empty_when_receiver_goes_out_of_scope)
client.loop(); client.loop();
broker.loop(); broker.loop();
} }
assertEqual(TestReceiver::messages["receiver"], 0); assertEqual(TestReceiver::messages["receiver"], 0);
assertEqual(MqttClassBinder<TestReceiver>::size(), (size_t)0); assertEqual(MqttClassBinder<TestReceiver>::size(), (size_t)0);
} }
@@ -224,7 +224,7 @@ test(classbind_publish_should_be_dispatched_to_many_receivers)
client.loop(); client.loop();
broker.loop(); broker.loop();
} }
assertEqual(TestReceiver::messages["receiver_1"], 1); assertEqual(TestReceiver::messages["receiver_1"], 1);
assertEqual(TestReceiver::messages["receiver_2"], 1); assertEqual(TestReceiver::messages["receiver_2"], 1);
} }
@@ -274,7 +274,7 @@ test(classbind_register_to_many_clients)
// Ensure publishes are processed // Ensure publishes are processed
for (int i =0; i<5; i++) loop(); for (int i =0; i<5; i++) loop();
assertEqual(TestReceiver::messages["receiver"], 4); assertEqual(TestReceiver::messages["receiver"], 4);
} }

View File

@@ -99,7 +99,7 @@ void onPublish(const MqttClient* srce, const Topic& topic, const char* payload,
{ {
if (srce) if (srce)
published[srce->id()][topic]++; published[srce->id()][topic]++;
if (lastPayload) free(lastPayload); if (lastPayload) free(lastPayload);
lastPayload = strdup(payload); lastPayload = strdup(payload);
lastLength = length; lastLength = length;
@@ -221,7 +221,7 @@ test(network_one_client_one_broker_publish_and_subscribe_through_network)
client.loop(); client.loop();
broker.loop(); broker.loop();
} }
assertEqual(published.size(), (size_t)1); assertEqual(published.size(), (size_t)1);
assertEqual((int)lastLength, (int)2); // sizeof(ab) assertEqual((int)lastLength, (int)2); // sizeof(ab)
} }
@@ -321,7 +321,7 @@ test(network_publish_should_be_dispatched_to_clients)
MqttClient publisher(&broker); MqttClient publisher(&broker);
publisher.publish("a/b"); // A and B should receive this 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.size(), (size_t)2); // 2 clients have received something
assertEqual(published["A"]["a/b"], 1); assertEqual(published["A"]["a/b"], 1);

View File

@@ -24,7 +24,7 @@ void onPublish(const MqttClient* srce, const Topic& topic, const char* payload,
{ {
if (srce) if (srce)
published[srce->id()][topic]++; published[srce->id()][topic]++;
if (lastPayload) free(lastPayload); if (lastPayload) free(lastPayload);
lastPayload = strdup(payload); lastPayload = strdup(payload);
lastLength = length; lastLength = length;
@@ -85,7 +85,7 @@ test(nowifi_publish_should_be_dispatched_to_clients)
MqttClient publisher(&broker); MqttClient publisher(&broker);
publisher.publish("a/b"); // A and B should receive this 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.size(), (size_t)2); // 2 clients have received something
assertEqual(published["A"]["a/b"], 1); assertEqual(published["A"]["a/b"], 1);