From e994f1f20c9c27385b5b8de2440b8416b3589941 Mon Sep 17 00:00:00 2001 From: Torrie Fischer Date: Sat, 18 Feb 2023 19:36:43 +0100 Subject: [PATCH] platform: arduno: mqtt: fix mqtt build --- lib/Figments/Input.h | 6 ++++-- src/platform/arduino/MQTTTelemetry.cpp | 6 +++--- src/platform/arduino/MQTTTelemetry.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/Figments/Input.h b/lib/Figments/Input.h index 30b6e36..982c9f7 100644 --- a/lib/Figments/Input.h +++ b/lib/Figments/Input.h @@ -37,8 +37,8 @@ struct Variant { CRGB asRGB() const; int asInt() const; bool asBool() const; - template T* as() const { - return (T*)m_value.asPointer; + template const T& as() const { + return *static_cast(m_value.asPointer); } private: @@ -183,6 +183,8 @@ class ConfigTaskMixin : public virtual Loopable { } } + void loop() override {} + virtual void handleConfigChange(const InputEvent& evt) {} }; diff --git a/src/platform/arduino/MQTTTelemetry.cpp b/src/platform/arduino/MQTTTelemetry.cpp index 8a317ae..b0acfce 100644 --- a/src/platform/arduino/MQTTTelemetry.cpp +++ b/src/platform/arduino/MQTTTelemetry.cpp @@ -201,8 +201,8 @@ MQTTTelemetry::handleEventOnline(const InputEvent& evt) void MQTTTelemetry::handleConfigChange(const InputEvent& event) { - const JsonObject* obj = static_cast(event.value().asPointer()); - strncpy(m_hostBuf, obj["mqtt.ip"].c_str(), sizeof(m_hostBuf)); + const JsonObject& obj = event.as(); + strncpy(m_hostBuf, obj["mqtt.ip"].as().c_str(), sizeof(m_hostBuf)); m_mqtt.disconnect(); } @@ -217,7 +217,7 @@ MQTTTelemetry::loop() void MQTTTelemetry::handleEvent(const InputEvent& evt) { - OnlineTaskMixin::handle(evt); + OnlineTaskMixin::handleEvent(evt); ConfigTaskMixin::handleEvent(evt); } diff --git a/src/platform/arduino/MQTTTelemetry.h b/src/platform/arduino/MQTTTelemetry.h index e257ff4..fe1541b 100644 --- a/src/platform/arduino/MQTTTelemetry.h +++ b/src/platform/arduino/MQTTTelemetry.h @@ -67,7 +67,7 @@ class MQTTTelemetry : public BufferedInputSource, OnlineTaskMixin, ConfigTaskMix bool m_isOn = true; static char s_topicBuf[128]; static char s_payloadBuf[512]; - static char s_hostBuf[15]; + char m_hostBuf[15]; void publishDoc(const char* topic); void publishDoc(const char* topic, bool retain);