Remove spaces to end of lines
This commit is contained in:
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -1,6 +1,6 @@
|
||||
name: "CI"
|
||||
on:
|
||||
|
||||
|
||||
jobs:
|
||||
ci:
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#include <TinyMqtt.h> // https://github.com/hsaturn/TinyMqtt
|
||||
#include <MqttClassBinder.h>
|
||||
|
||||
/**
|
||||
/**
|
||||
* 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<MqttReceiver>
|
||||
{
|
||||
public:
|
||||
|
||||
|
||||
void onPublish(const MqttClient* source, const Topic& topic, const char* payload, size_t /* length */)
|
||||
{
|
||||
Serial
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include <TinyMqtt.h> // 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
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <TinyMqtt.h> // https://github.com/hsaturn/TinyMqtt
|
||||
|
||||
/** TinyMQTT allows a disconnected mode:
|
||||
*
|
||||
*
|
||||
* +-----------------------------+
|
||||
* | ESP |
|
||||
* | +--------+ |
|
||||
@@ -12,8 +12,8 @@
|
||||
* | v v |
|
||||
* | +----------+ +----------+ |
|
||||
* | | internal | | internal | |
|
||||
* | | client | | client | |
|
||||
* | +----------+ +----------+ |
|
||||
* | | client | | client | |
|
||||
* | +----------+ +----------+ |
|
||||
* | |
|
||||
* +-----------------------------+
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ class MqttClassBinder
|
||||
unregister(this);
|
||||
}
|
||||
~MqttClassBinder() { unregister(this); }
|
||||
|
||||
|
||||
static void onUnpublished(MqttClient::CallBack handler)
|
||||
{
|
||||
unrouted_handler = handler;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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<TestReceiver>::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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user