Revert ESP-MQTT (#508)
* Revert ESP-MQTT * Revert ESP-MQTT * Update sdkconfig.defaults
This commit is contained in:
@@ -7,7 +7,7 @@ MqttLogger::MqttLogger(MqttLoggerMode mode)
|
||||
this->setBufferSize(MQTT_MAX_PACKET_SIZE);
|
||||
}
|
||||
|
||||
MqttLogger::MqttLogger(esp_mqtt_client_handle_t client, const char* topic, MqttLoggerMode mode)
|
||||
MqttLogger::MqttLogger(MqttClient& client, const char* topic, MqttLoggerMode mode)
|
||||
{
|
||||
this->setClient(client);
|
||||
this->setTopic(topic);
|
||||
@@ -19,9 +19,9 @@ MqttLogger::~MqttLogger()
|
||||
{
|
||||
}
|
||||
|
||||
void MqttLogger::setClient(esp_mqtt_client_handle_t client)
|
||||
void MqttLogger::setClient(MqttClient& client)
|
||||
{
|
||||
this->client = client;
|
||||
this->client = &client;
|
||||
}
|
||||
|
||||
void MqttLogger::setTopic(const char* topic)
|
||||
@@ -75,10 +75,9 @@ void MqttLogger::sendBuffer()
|
||||
{
|
||||
bool doSerial = this->mode==MqttLoggerMode::SerialOnly || this->mode==MqttLoggerMode::MqttAndSerial || this->mode==MqttLoggerMode::MqttAndSerialAndWeb || this->mode==MqttLoggerMode::SerialAndWeb;
|
||||
bool doWebSerial = this->mode==MqttLoggerMode::MqttAndSerialAndWeb || this->mode==MqttLoggerMode::SerialAndWeb;
|
||||
|
||||
if (this->mode!=MqttLoggerMode::SerialOnly && this->mode!=MqttLoggerMode::SerialAndWeb)
|
||||
if (this->mode!=MqttLoggerMode::SerialOnly && this->mode!=MqttLoggerMode::SerialAndWeb && this->client != NULL && this->client->connected())
|
||||
{
|
||||
esp_mqtt_client_publish(this->client, topic, (const char*)this->buffer, this->bufferCnt, 1, 1);
|
||||
this->client->publish(topic, 0, true, this->buffer, this->bufferCnt);
|
||||
}
|
||||
else if (this->mode == MqttLoggerMode::MqttAndSerialFallback)
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Print.h>
|
||||
#include <mqtt_client.h>
|
||||
#include <espMqttClient.h>
|
||||
//#include "MycilaWebSerial.h"
|
||||
|
||||
#define MQTT_MAX_PACKET_SIZE 1024
|
||||
@@ -33,16 +33,16 @@ private:
|
||||
uint8_t* bufferEnd;
|
||||
uint16_t bufferCnt = 0;
|
||||
uint16_t bufferSize = 0;
|
||||
esp_mqtt_client_handle_t client;
|
||||
MqttClient* client;
|
||||
MqttLoggerMode mode;
|
||||
void sendBuffer();
|
||||
|
||||
public:
|
||||
MqttLogger(MqttLoggerMode mode=MqttLoggerMode::MqttAndSerialFallback);
|
||||
MqttLogger(esp_mqtt_client_handle_t client, const char* topic, MqttLoggerMode mode=MqttLoggerMode::MqttAndSerialFallback);
|
||||
MqttLogger(MqttClient& client, const char* topic, MqttLoggerMode mode=MqttLoggerMode::MqttAndSerialFallback);
|
||||
~MqttLogger();
|
||||
|
||||
void setClient(esp_mqtt_client_handle_t client);
|
||||
void setClient(MqttClient& client);
|
||||
void setTopic(const char* topic);
|
||||
void setMode(MqttLoggerMode mode);
|
||||
void setRetained(boolean retained);
|
||||
|
||||
Reference in New Issue
Block a user