reactivate mqtt output

This commit is contained in:
2023-05-31 09:11:26 +02:00
parent 22eb6788c3
commit e0d6853961
4 changed files with 14 additions and 4 deletions
+1
View File
@@ -61,6 +61,7 @@ class Network {
* @return false if not connected
*/
static bool checkMQTT();
static bool initMQTT();
/**
* @brief Checks if WiFi is still connected
+1 -1
View File
@@ -110,7 +110,7 @@ class NTRIPClient {
WiFiClient* ntripClient;
NTRIPClientStates state = NTRIPClientStates::notAvailable;
bool transmitLocation = true;
bool transmitLocation = false;
bool activated = true;
bool autoReconnect = false;
+5 -2
View File
@@ -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();
+7 -1
View File
@@ -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<n; i++)