[TinyMqtt.h] Added TINY_MQTT_ETHERNET compilation option

This commit is contained in:
hsaturn
2023-04-21 22:29:36 +02:00
parent bd566945cc
commit 65e22c85c6
2 changed files with 16 additions and 8 deletions

View File

@@ -550,7 +550,7 @@ void MqttClient::processMessage(MqttMessage* mesg)
{ {
MqttMessage msg(MqttMessage::Type::ConnAck); MqttMessage msg(MqttMessage::Type::ConnAck);
msg.add(0); // Session present (not implemented) msg.add(0); // Session present (not implemented)
msg.add(0); // Connection accepted msg.add(0); // Connection accepted
msg.sendTo(this); msg.sendTo(this);
} }
break; break;

View File

@@ -8,7 +8,10 @@
// TODO Should add a AUnit with both TINY_MQTT_ASYNC and not TINY_MQTT_ASYNC // 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 // #define TINY_MQTT_ASYNC // Uncomment this to use ESPAsyncTCP instead of normal cnx
#if defined(ESP8266) || defined(EPOXY_DUINO)
#if defined(TINY_MQTT_ETHERNET)
#include <Ethernet.h>
#elif defined(ESP8266) || defined(EPOXY_DUINO)
#ifdef TINY_MQTT_ASYNC #ifdef TINY_MQTT_ASYNC
#include <ESPAsyncTCP.h> #include <ESPAsyncTCP.h>
#else #else
@@ -20,7 +23,7 @@
#include <AsyncTCP.h> // https://github.com/me-no-dev/AsyncTCP #include <AsyncTCP.h> // https://github.com/me-no-dev/AsyncTCP
#endif #endif
#elif defined(ARDUINO_ARCH_RP2040) #elif defined(ARDUINO_ARCH_RP2040)
#include <WiFi.h> #include <WiFi.h> // works with Raspberry Pi Pico W, earlephilhower
#endif #endif
#ifdef EPOXY_DUINO #ifdef EPOXY_DUINO
#define dbg_ptr uint64_t #define dbg_ptr uint64_t
@@ -55,12 +58,17 @@
#define debug(what) {} #define debug(what) {}
#endif #endif
#ifdef TINY_MQTT_ASYNC #if defined(TINY_MQTT_ETHERNET)
using TcpClient = AsyncClient; using TcpClient = EthernetClient;
using TcpServer = AsyncServer; using TcpServer = EthernetServer;
#else #else
using TcpClient = WiFiClient; #ifdef TINY_MQTT_ASYNC
using TcpServer = WiFiServer; using TcpClient = AsyncClient;
using TcpServer = AsyncServer;
#else
using TcpClient = WiFiClient;
using TcpServer = WiFiServer;
#endif
#endif #endif
enum __attribute__((packed)) MqttError enum __attribute__((packed)) MqttError