Renamed TCP_ASYNC define to TINY_MQTT_ASYNC for name consistency.
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
MqttBroker::MqttBroker(uint16_t port)
|
MqttBroker::MqttBroker(uint16_t port)
|
||||||
{
|
{
|
||||||
server = new TcpServer(port);
|
server = new TcpServer(port);
|
||||||
#ifdef TCP_ASYNC
|
#ifdef TINY_MQTT_ASYNC
|
||||||
server->onClient(onClient, this);
|
server->onClient(onClient, this);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ MqttBroker::~MqttBroker()
|
|||||||
MqttClient::MqttClient(MqttBroker* parent, TcpClient* new_client)
|
MqttClient::MqttClient(MqttBroker* parent, TcpClient* new_client)
|
||||||
: parent(parent)
|
: parent(parent)
|
||||||
{
|
{
|
||||||
#ifdef TCP_ASYNC
|
#ifdef TINY_MQTT_ASYNC
|
||||||
client = new_client;
|
client = new_client;
|
||||||
client->onData(onData, this);
|
client->onData(onData, this);
|
||||||
// client->onConnect() TODO
|
// client->onConnect() TODO
|
||||||
@@ -91,7 +91,7 @@ void MqttClient::connect(std::string broker, uint16_t port, uint16_t ka)
|
|||||||
client = new TcpClient;
|
client = new TcpClient;
|
||||||
|
|
||||||
debug("Trying to connect to " << broker.c_str() << ':' << port);
|
debug("Trying to connect to " << broker.c_str() << ':' << port);
|
||||||
#ifdef TCP_ASYNC
|
#ifdef TINY_MQTT_ASYNC
|
||||||
client->onData(onData, this);
|
client->onData(onData, this);
|
||||||
client->onConnect(onConnect, this);
|
client->onConnect(onConnect, this);
|
||||||
client->connect(broker.c_str(), port);
|
client->connect(broker.c_str(), port);
|
||||||
@@ -146,7 +146,7 @@ void MqttBroker::onClient(void* broker_ptr, TcpClient* client)
|
|||||||
|
|
||||||
void MqttBroker::loop()
|
void MqttBroker::loop()
|
||||||
{
|
{
|
||||||
#ifndef TCP_ASYNC
|
#ifndef TINY_MQTT_ASYNC
|
||||||
WiFiClient client = server->available();
|
WiFiClient client = server->available();
|
||||||
|
|
||||||
if (client)
|
if (client)
|
||||||
@@ -281,7 +281,7 @@ void MqttClient::loop()
|
|||||||
// there is no need to send one PingReq per instance.
|
// there is no need to send one PingReq per instance.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef TCP_ASYNC
|
#ifndef TINY_MQTT_ASYNC
|
||||||
while(client && client->available()>0)
|
while(client && client->available()>0)
|
||||||
{
|
{
|
||||||
message.incoming(client->read());
|
message.incoming(client->read());
|
||||||
@@ -314,7 +314,7 @@ void MqttClient::onConnect(void *mqttclient_ptr, TcpClient*)
|
|||||||
mqtt->clientAlive(0);
|
mqtt->clientAlive(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TCP_ASYNC
|
#ifdef TINY_MQTT_ASYNC
|
||||||
void MqttClient::onData(void* client_ptr, TcpClient*, void* data, size_t len)
|
void MqttClient::onData(void* client_ptr, TcpClient*, void* data, size_t len)
|
||||||
{
|
{
|
||||||
char* char_ptr = static_cast<char*>(data);
|
char* char_ptr = static_cast<char*>(data);
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// TODO Should add a AUnit with both TCP_ASYNC and not TCP_ASYNC
|
// TODO Should add a AUnit with both TINY_MQTT_ASYNC and not TINY_MQTT_ASYNC
|
||||||
// #define TCP_ASYNC // Uncomment this to use ESPAsyncTCP instead of normal cnx
|
// #define TINY_MQTT_ASYNC // Uncomment this to use ESPAsyncTCP instead of normal cnx
|
||||||
|
|
||||||
#if defined(ESP8266) || defined(EPOXY_DUINO)
|
#if defined(ESP8266) || defined(EPOXY_DUINO)
|
||||||
#ifdef TCP_ASYNC
|
#ifdef TINY_MQTT_ASYNC
|
||||||
#include <ESPAsyncTCP.h>
|
#include <ESPAsyncTCP.h>
|
||||||
#else
|
#else
|
||||||
#include <ESP8266WiFi.h>
|
#include <ESP8266WiFi.h>
|
||||||
#endif
|
#endif
|
||||||
#elif defined(ESP32)
|
#elif defined(ESP32)
|
||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#ifdef TCP_ASYNC
|
#ifdef TINY_MQTT_ASYNC
|
||||||
#include <AsyncTCP.h> // https://github.com/me-no-dev/AsyncTCP
|
#include <AsyncTCP.h> // https://github.com/me-no-dev/AsyncTCP
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
#define debug(what) {}
|
#define debug(what) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef TCP_ASYNC
|
#ifdef TINY_MQTT_ASYNC
|
||||||
using TcpClient = AsyncClient;
|
using TcpClient = AsyncClient;
|
||||||
using TcpServer = AsyncServer;
|
using TcpServer = AsyncServer;
|
||||||
#else
|
#else
|
||||||
@@ -240,7 +240,7 @@ class MqttClient
|
|||||||
|
|
||||||
// event when tcp/ip link established (real or fake)
|
// event when tcp/ip link established (real or fake)
|
||||||
static void onConnect(void * client_ptr, TcpClient*);
|
static void onConnect(void * client_ptr, TcpClient*);
|
||||||
#ifdef TCP_ASYNC
|
#ifdef TINY_MQTT_ASYNC
|
||||||
static void onData(void* client_ptr, TcpClient*, void* data, size_t len);
|
static void onData(void* client_ptr, TcpClient*, void* data, size_t len);
|
||||||
#endif
|
#endif
|
||||||
MqttError sendTopic(const Topic& topic, MqttMessage::Type type, uint8_t qos);
|
MqttError sendTopic(const Topic& topic, MqttMessage::Type type, uint8_t qos);
|
||||||
|
|||||||
Reference in New Issue
Block a user