Establish MQTT connection only from MQTT::runOnce (#6057)

Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
pull/6061/head
Eric Severance 2025-02-14 18:32:41 -08:00 zatwierdzone przez GitHub
rodzic c83ffd4911
commit 50b7d6a0f7
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
4 zmienionych plików z 6 dodań i 23 usunięć

Wyświetl plik

@ -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 <RAK13800_W5100S.h>
#include <SPI.h>
@ -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

Wyświetl plik

@ -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 <WiFi.h>
#include <WiFiUdp.h>
@ -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()

Wyświetl plik

@ -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();

Wyświetl plik

@ -242,6 +242,7 @@ class MQTTUnitTest : public MQTT
mqttClient.release();
delete pubsub;
}
using MQTT::reconnect;
int queueSize() { return mqttQueue.numUsed(); }
void reportToMap(std::optional<uint32_t> 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_);
}