platform: arduno: mqtt: fix mqtt build
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
Torrie Fischer 2023-02-18 19:36:43 +01:00
parent a598d62523
commit e994f1f20c
3 changed files with 8 additions and 6 deletions

View File

@ -37,8 +37,8 @@ struct Variant {
CRGB asRGB() const; CRGB asRGB() const;
int asInt() const; int asInt() const;
bool asBool() const; bool asBool() const;
template<typename T> T* as() const { template<typename T> const T& as() const {
return (T*)m_value.asPointer; return *static_cast<const T*>(m_value.asPointer);
} }
private: private:
@ -183,6 +183,8 @@ class ConfigTaskMixin : public virtual Loopable {
} }
} }
void loop() override {}
virtual void handleConfigChange(const InputEvent& evt) {} virtual void handleConfigChange(const InputEvent& evt) {}
}; };

View File

@ -201,8 +201,8 @@ MQTTTelemetry::handleEventOnline(const InputEvent& evt)
void void
MQTTTelemetry::handleConfigChange(const InputEvent& event) MQTTTelemetry::handleConfigChange(const InputEvent& event)
{ {
const JsonObject* obj = static_cast<JsonObject*>(event.value().asPointer()); const JsonObject& obj = event.as<JsonObject>();
strncpy(m_hostBuf, obj["mqtt.ip"].c_str(), sizeof(m_hostBuf)); strncpy(m_hostBuf, obj["mqtt.ip"].as<JsonString>().c_str(), sizeof(m_hostBuf));
m_mqtt.disconnect(); m_mqtt.disconnect();
} }
@ -217,7 +217,7 @@ MQTTTelemetry::loop()
void void
MQTTTelemetry::handleEvent(const InputEvent& evt) MQTTTelemetry::handleEvent(const InputEvent& evt)
{ {
OnlineTaskMixin::handle(evt); OnlineTaskMixin::handleEvent(evt);
ConfigTaskMixin::handleEvent(evt); ConfigTaskMixin::handleEvent(evt);
} }

View File

@ -67,7 +67,7 @@ class MQTTTelemetry : public BufferedInputSource, OnlineTaskMixin, ConfigTaskMix
bool m_isOn = true; bool m_isOn = true;
static char s_topicBuf[128]; static char s_topicBuf[128];
static char s_payloadBuf[512]; static char s_payloadBuf[512];
static char s_hostBuf[15]; char m_hostBuf[15];
void publishDoc(const char* topic); void publishDoc(const char* topic);
void publishDoc(const char* topic, bool retain); void publishDoc(const char* topic, bool retain);