Renamed TCP_ASYNC define to TINY_MQTT_ASYNC for name consistency.

This commit is contained in:
hsaturn
2022-10-31 01:24:41 +01:00
parent b7d44445af
commit 73207e4745
2 changed files with 12 additions and 12 deletions

View File

@@ -8,7 +8,7 @@
MqttBroker::MqttBroker(uint16_t port)
{
server = new TcpServer(port);
#ifdef TCP_ASYNC
#ifdef TINY_MQTT_ASYNC
server->onClient(onClient, this);
#endif
}
@@ -26,7 +26,7 @@ MqttBroker::~MqttBroker()
MqttClient::MqttClient(MqttBroker* parent, TcpClient* new_client)
: parent(parent)
{
#ifdef TCP_ASYNC
#ifdef TINY_MQTT_ASYNC
client = new_client;
client->onData(onData, this);
// client->onConnect() TODO
@@ -91,7 +91,7 @@ void MqttClient::connect(std::string broker, uint16_t port, uint16_t ka)
client = new TcpClient;
debug("Trying to connect to " << broker.c_str() << ':' << port);
#ifdef TCP_ASYNC
#ifdef TINY_MQTT_ASYNC
client->onData(onData, this);
client->onConnect(onConnect, this);
client->connect(broker.c_str(), port);
@@ -146,7 +146,7 @@ void MqttBroker::onClient(void* broker_ptr, TcpClient* client)
void MqttBroker::loop()
{
#ifndef TCP_ASYNC
#ifndef TINY_MQTT_ASYNC
WiFiClient client = server->available();
if (client)
@@ -281,7 +281,7 @@ void MqttClient::loop()
// there is no need to send one PingReq per instance.
}
}
#ifndef TCP_ASYNC
#ifndef TINY_MQTT_ASYNC
while(client && client->available()>0)
{
message.incoming(client->read());
@@ -314,7 +314,7 @@ void MqttClient::onConnect(void *mqttclient_ptr, TcpClient*)
mqtt->clientAlive(0);
}
#ifdef TCP_ASYNC
#ifdef TINY_MQTT_ASYNC
void MqttClient::onData(void* client_ptr, TcpClient*, void* data, size_t len)
{
char* char_ptr = static_cast<char*>(data);

View File

@@ -1,17 +1,17 @@
#pragma once
// TODO Should add a AUnit with both TCP_ASYNC and not TCP_ASYNC
// #define TCP_ASYNC // Uncomment this to use ESPAsyncTCP instead of normal cnx
// TODO Should add a AUnit with both TINY_MQTT_ASYNC and not TINY_MQTT_ASYNC
// #define TINY_MQTT_ASYNC // Uncomment this to use ESPAsyncTCP instead of normal cnx
#if defined(ESP8266) || defined(EPOXY_DUINO)
#ifdef TCP_ASYNC
#ifdef TINY_MQTT_ASYNC
#include <ESPAsyncTCP.h>
#else
#include <ESP8266WiFi.h>
#endif
#elif defined(ESP32)
#include <WiFi.h>
#ifdef TCP_ASYNC
#ifdef TINY_MQTT_ASYNC
#include <AsyncTCP.h> // https://github.com/me-no-dev/AsyncTCP
#endif
#endif
@@ -42,7 +42,7 @@
#define debug(what) {}
#endif
#ifdef TCP_ASYNC
#ifdef TINY_MQTT_ASYNC
using TcpClient = AsyncClient;
using TcpServer = AsyncServer;
#else
@@ -240,7 +240,7 @@ class MqttClient
// event when tcp/ip link established (real or fake)
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);
#endif
MqttError sendTopic(const Topic& topic, MqttMessage::Type type, uint8_t qos);