build for esp32 mask project
This commit is contained in:
@@ -6,6 +6,13 @@
|
||||
|
||||
#include "../../Sequencer.h"
|
||||
|
||||
#ifdef BOARD_ESP8266
|
||||
#include <ESP8266WiFi.h>
|
||||
#elif defined(BOARD_ESP32)
|
||||
#include <WiFi.h>
|
||||
#endif
|
||||
|
||||
|
||||
class MQTTTelemetry : public BufferedInputSource, OnlineTaskMixin {
|
||||
public:
|
||||
MQTTTelemetry();
|
||||
@@ -22,7 +29,9 @@ class MQTTTelemetry : public BufferedInputSource, OnlineTaskMixin {
|
||||
if (byte == '\n') {
|
||||
size_t bufSize = buf.write(outBuf);
|
||||
outBuf[std::min(sizeof(outBuf), bufSize)] = 0;
|
||||
telemetry->m_mqtt.publish(telemetry->m_logTopic, outBuf);
|
||||
Serial.println(outBuf);
|
||||
String logTopic = telemetry->m_debugTopic + "/log";
|
||||
telemetry->m_mqtt.publish(logTopic.c_str(), outBuf);
|
||||
} else {
|
||||
buf.insert(byte);
|
||||
}
|
||||
@@ -39,20 +48,22 @@ class MQTTTelemetry : public BufferedInputSource, OnlineTaskMixin {
|
||||
|
||||
void loopOnline() override;
|
||||
|
||||
private:
|
||||
char m_statTopic[100];
|
||||
char m_attrTopic[100];
|
||||
char m_cmdTopic[100];
|
||||
char m_logTopic[100];
|
||||
char m_heartbeatTopic[100];
|
||||
void onOnline() override;
|
||||
void onOffline() override;
|
||||
|
||||
void callback(char* topic, byte* payload, unsigned int length);
|
||||
private:
|
||||
String m_rootTopic;
|
||||
String m_debugTopic;
|
||||
|
||||
void callback(char* topic, const char* payload);
|
||||
|
||||
static void s_callback(char* topic, byte* payload, unsigned int length);
|
||||
char m_patternBuf[48];
|
||||
bool m_needHeartbeat = false;
|
||||
bool m_isOn = true;
|
||||
|
||||
Sequencer *m_sequencer = 0;
|
||||
WiFiClient m_wifi;
|
||||
PubSubClient m_mqtt;
|
||||
LogPrinter m_logPrinter;
|
||||
};
|
||||
|
Reference in New Issue
Block a user