If the code hasn't been touched in this long, its probably release-worthy.
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <WiFi.h>
|
||||
#endif
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
class MQTTTelemetry : public BufferedInputSource, OnlineTaskMixin {
|
||||
public:
|
||||
@@ -25,13 +26,16 @@ class MQTTTelemetry : public BufferedInputSource, OnlineTaskMixin {
|
||||
public:
|
||||
LogPrinter(MQTTTelemetry* telemetry) : telemetry(telemetry) {};
|
||||
size_t write(uint8_t byte) {
|
||||
char outBuf[512];
|
||||
if (byte == '\n') {
|
||||
size_t bufSize = buf.write(outBuf);
|
||||
outBuf[std::min(sizeof(outBuf), bufSize)] = 0;
|
||||
Serial.println(outBuf);
|
||||
char c;
|
||||
String logTopic = telemetry->m_debugTopic + "/log";
|
||||
telemetry->m_mqtt.publish(logTopic.c_str(), outBuf);
|
||||
telemetry->m_mqtt.beginPublish(logTopic.c_str(), buf.size(), false);
|
||||
while (buf.take(c)) {
|
||||
Serial.write(c);
|
||||
telemetry->m_mqtt.write(c);
|
||||
}
|
||||
Serial.println();
|
||||
telemetry->m_mqtt.endPublish();
|
||||
} else {
|
||||
buf.insert(byte);
|
||||
}
|
||||
@@ -61,9 +65,15 @@ class MQTTTelemetry : public BufferedInputSource, OnlineTaskMixin {
|
||||
char m_patternBuf[48];
|
||||
bool m_needHeartbeat = false;
|
||||
bool m_isOn = true;
|
||||
static char s_topicBuf[128];
|
||||
static char s_payloadBuf[512];
|
||||
|
||||
void publishDoc(const char* topic);
|
||||
void publishDoc(const char* topic, bool retain);
|
||||
|
||||
Sequencer *m_sequencer = 0;
|
||||
WiFiClient m_wifi;
|
||||
PubSubClient m_mqtt;
|
||||
LogPrinter m_logPrinter;
|
||||
StaticJsonDocument<1024> m_json;
|
||||
};
|
||||
|
Reference in New Issue
Block a user