diff --git a/src/mesh/eth/ethClient.cpp b/src/mesh/eth/ethClient.cpp index 24c4f0db1..70c6e3fe4 100644 --- a/src/mesh/eth/ethClient.cpp +++ b/src/mesh/eth/ethClient.cpp @@ -5,9 +5,6 @@ #include "configuration.h" #include "main.h" #include "mesh/api/ethServerAPI.h" -#if !MESHTASTIC_EXCLUDE_MQTT -#include "mqtt/MQTT.h" -#endif #include "target_specific.h" #include #include @@ -72,12 +69,6 @@ static int32_t reconnectETH() ethStartupComplete = true; } -#if !MESHTASTIC_EXCLUDE_MQTT - // FIXME this is kinda yucky, instead we should just have an observable for 'wifireconnected' - if (mqtt && !moduleConfig.mqtt.proxy_to_client_enabled && !mqtt->isConnectedDirectly()) { - mqtt->reconnect(); - } -#endif } #ifndef DISABLE_NTP diff --git a/src/mesh/wifi/WiFiAPClient.cpp b/src/mesh/wifi/WiFiAPClient.cpp index 41de89794..d4a5dbf94 100644 --- a/src/mesh/wifi/WiFiAPClient.cpp +++ b/src/mesh/wifi/WiFiAPClient.cpp @@ -7,9 +7,6 @@ #include "main.h" #include "mesh/api/WiFiServerAPI.h" -#if !MESHTASTIC_EXCLUDE_MQTT -#include "mqtt/MQTT.h" -#endif #include "target_specific.h" #include #include @@ -111,12 +108,6 @@ static void onNetworkConnected() #endif APStartupComplete = true; } - - // FIXME this is kinda yucky, instead we should just have an observable for 'wifireconnected' -#ifndef MESHTASTIC_EXCLUDE_MQTT - if (mqtt) - mqtt->reconnect(); -#endif } static int32_t reconnectWiFi() diff --git a/src/mqtt/MQTT.h b/src/mqtt/MQTT.h index cf52ad877..42157fda9 100644 --- a/src/mqtt/MQTT.h +++ b/src/mqtt/MQTT.h @@ -47,10 +47,6 @@ class MQTT : private concurrency::OSThread */ void onSend(const meshtastic_MeshPacket &mp_encrypted, const meshtastic_MeshPacket &mp_decoded, ChannelIndex chIndex); - /** Attempt to connect to server if necessary - */ - void reconnect(); - bool isConnectedDirectly(); bool publish(const char *topic, const char *payload, bool retained); @@ -115,6 +111,10 @@ class MQTT : private concurrency::OSThread */ bool wantsLink() const; + /** Attempt to connect to server if necessary + */ + void reconnect(); + /** Tell the server what subscriptions we want (based on channels.downlink_enabled) */ void sendSubscriptions(); diff --git a/test/test_mqtt/MQTT.cpp b/test/test_mqtt/MQTT.cpp index 55ba479e2..3a4625aed 100644 --- a/test/test_mqtt/MQTT.cpp +++ b/test/test_mqtt/MQTT.cpp @@ -242,6 +242,7 @@ class MQTTUnitTest : public MQTT mqttClient.release(); delete pubsub; } + using MQTT::reconnect; int queueSize() { return mqttQueue.numUsed(); } void reportToMap(std::optional precision = std::nullopt) { @@ -488,7 +489,7 @@ void test_reconnectProxyDoesNotReconnectMqtt(void) moduleConfig.mqtt.proxy_to_client_enabled = true; MQTTUnitTest::restart(); - mqtt->reconnect(); + unitTest->reconnect(); TEST_ASSERT_FALSE(pubsub->connected_); }