diff --git a/include/network.h b/include/network.h index b2f6460..2a85d24 100644 --- a/include/network.h +++ b/include/network.h @@ -61,6 +61,7 @@ class Network { * @return false if not connected */ static bool checkMQTT(); + static bool initMQTT(); /** * @brief Checks if WiFi is still connected diff --git a/lib/NtripClient/ntripClient.h b/lib/NtripClient/ntripClient.h index df1a592..900c6eb 100644 --- a/lib/NtripClient/ntripClient.h +++ b/lib/NtripClient/ntripClient.h @@ -110,7 +110,7 @@ class NTRIPClient { WiFiClient* ntripClient; NTRIPClientStates state = NTRIPClientStates::notAvailable; - bool transmitLocation = true; + bool transmitLocation = false; bool activated = true; bool autoReconnect = false; diff --git a/src/main.cpp b/src/main.cpp index 5d527ed..3f9ca94 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -92,6 +92,7 @@ void setup() { Network::setupMQTT(); wifiIsActive = Network::connectWifi(); if (wifiIsActive) { + Network::initMQTT(); if (Network::checkMQTT()) { DebugMqtt::init(Network::getMqttClient(), Loglevel::debug); std::cout << "Activate additional output via MQTT..." << std::endl; @@ -111,7 +112,7 @@ void setup() { driveManager = new DriveManager(&moveController, spiPort, controlPad->getControlPadDataPtr(), wifiIsActive); - outputBuf->activateMqtt(false); + outputBuf->activateMqtt(true); lcd->backlight(); lcd->printf("%c Kleiax-Rover %c", wifiIndicator, wifiIndicator); @@ -129,7 +130,9 @@ void loop() { if (wifiIsActive) { DebugTimes wifiTime; Network::checkWiFi(); - Network::checkMQTT(); + bool err = Network::checkMQTT(); + if (!err) + std::cout << "loop(): checkMQTT returns false" << std::endl; wifiTime.stopConsol("WiFi-Time", 10); } driveManager->loop(); diff --git a/src/network.cpp b/src/network.cpp index 11d97f9..8d1a1e0 100644 --- a/src/network.cpp +++ b/src/network.cpp @@ -121,7 +121,7 @@ bool Network::checkMQTT() { lastReconnectAttempt = now; // Attempt to reconnect if (connectMQTT()) - lastReconnectAttempt = 0; + return true; } return false; } @@ -129,6 +129,12 @@ bool Network::checkMQTT() { return true; } +bool Network::initMQTT() { + if (connectMQTT()) + return true; + return false; +} + int32_t Network::getWiFiChannel(const char *ssid) { if (int32_t n = WiFi.scanNetworks()) for (uint8_t i=0; i