From 0d0f0d922fdfcf11c458429e6103ab61c8d5559e Mon Sep 17 00:00:00 2001 From: dahuafschmied <3955019+dahuafschmied@users.noreply.github.com> Date: Tue, 28 Jun 2022 21:26:53 +0200 Subject: [PATCH] fix for NTP booting on ETH Board eht and wifi status has been mutually overwritten --- lib/System/System.cpp | 14 +++++++++----- lib/System/System.h | 7 ++++--- src/LoRa_APRS_iGate.cpp | 2 +- src/TaskAprsIs.cpp | 2 +- src/TaskEth.cpp | 4 ++-- src/TaskMQTT.cpp | 2 +- src/TaskNTP.cpp | 2 +- src/TaskWifi.cpp | 4 ++-- 8 files changed, 21 insertions(+), 16 deletions(-) diff --git a/lib/System/System.cpp b/lib/System/System.cpp index 18b89d4..008e3a4 100644 --- a/lib/System/System.cpp +++ b/lib/System/System.cpp @@ -1,7 +1,7 @@ #include "System.h" -System::System() : _boardConfig(0), _userConfig(0), _isWifiEthConnected(false) { +System::System() : _boardConfig(0), _userConfig(0), _isEthConnected(false), _isWifiConnected(false) { } System::~System() { @@ -31,12 +31,16 @@ Display &System::getDisplay() { return _display; } -bool System::isWifiEthConnected() const { - return _isWifiEthConnected; +bool System::isWifiOrEthConnected() const { + return _isEthConnected || _isWifiConnected; } -void System::connectedViaWifiEth(bool status) { - _isWifiEthConnected = status; +void System::connectedViaEth(bool status) { + _isEthConnected = status; +} + +void System::connectedViaWifi(bool status) { + _isWifiConnected = status; } logging::Logger &System::getLogger() { diff --git a/lib/System/System.h b/lib/System/System.h index 6c7e9d4..6e7daa2 100644 --- a/lib/System/System.h +++ b/lib/System/System.h @@ -21,8 +21,9 @@ public: Configuration const *const getUserConfig() const; TaskManager & getTaskManager(); Display & getDisplay(); - bool isWifiEthConnected() const; - void connectedViaWifiEth(bool status); + bool isWifiOrEthConnected() const; + void connectedViaEth(bool status); + void connectedViaWifi(bool status); logging::Logger & getLogger(); private: @@ -30,7 +31,7 @@ private: Configuration const *_userConfig; TaskManager _taskManager; Display _display; - bool _isWifiEthConnected; + bool _isEthConnected, _isWifiConnected; logging::Logger _logger; }; diff --git a/src/LoRa_APRS_iGate.cpp b/src/LoRa_APRS_iGate.cpp index 11adfdf..da05b99 100644 --- a/src/LoRa_APRS_iGate.cpp +++ b/src/LoRa_APRS_iGate.cpp @@ -167,7 +167,7 @@ volatile bool syslogSet = false; void loop() { LoRaSystem.getTaskManager().loop(LoRaSystem); - if (LoRaSystem.isWifiEthConnected() && LoRaSystem.getUserConfig()->syslog.active && !syslogSet) { + if (LoRaSystem.isWifiOrEthConnected() && LoRaSystem.getUserConfig()->syslog.active && !syslogSet) { LoRaSystem.getLogger().setSyslogServer(LoRaSystem.getUserConfig()->syslog.server, LoRaSystem.getUserConfig()->syslog.port, LoRaSystem.getUserConfig()->callsign); LoRaSystem.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_INFO, MODULE_NAME, "System connected after a restart to the network, syslog server set"); syslogSet = true; diff --git a/src/TaskAprsIs.cpp b/src/TaskAprsIs.cpp index 680a2c4..3fa3da6 100644 --- a/src/TaskAprsIs.cpp +++ b/src/TaskAprsIs.cpp @@ -16,7 +16,7 @@ bool AprsIsTask::setup(System &system) { } bool AprsIsTask::loop(System &system) { - if (!system.isWifiEthConnected()) { + if (!system.isWifiOrEthConnected()) { return false; } if (!_aprs_is.connected()) { diff --git a/src/TaskEth.cpp b/src/TaskEth.cpp index 03f211f..1efdad9 100644 --- a/src/TaskEth.cpp +++ b/src/TaskEth.cpp @@ -111,12 +111,12 @@ bool EthTask::setup(System &system) { bool EthTask::loop(System &system) { if (!eth_connected) { - system.connectedViaWifiEth(false); + system.connectedViaEth(false); _stateInfo = "Ethernet not connected"; _state = Error; return false; } - system.connectedViaWifiEth(true); + system.connectedViaEth(true); _stateInfo = ETH.localIP().toString(); _state = Okay; return true; diff --git a/src/TaskMQTT.cpp b/src/TaskMQTT.cpp index fe6ee3f..e065a1d 100644 --- a/src/TaskMQTT.cpp +++ b/src/TaskMQTT.cpp @@ -18,7 +18,7 @@ bool MQTTTask::setup(System &system) { } bool MQTTTask::loop(System &system) { - if (!system.isWifiEthConnected()) { + if (!system.isWifiOrEthConnected()) { return false; } diff --git a/src/TaskNTP.cpp b/src/TaskNTP.cpp index 569eecc..7622032 100644 --- a/src/TaskNTP.cpp +++ b/src/TaskNTP.cpp @@ -18,7 +18,7 @@ bool NTPTask::setup(System &system) { } bool NTPTask::loop(System &system) { - if (!system.isWifiEthConnected()) { + if (!system.isWifiOrEthConnected()) { return false; } if (!_beginCalled) { diff --git a/src/TaskWifi.cpp b/src/TaskWifi.cpp index d7e1868..2756cd7 100644 --- a/src/TaskWifi.cpp +++ b/src/TaskWifi.cpp @@ -40,7 +40,7 @@ bool WifiTask::setup(System &system) { bool WifiTask::loop(System &system) { const uint8_t wifi_status = _wiFiMulti.run(); if (wifi_status != WL_CONNECTED) { - system.connectedViaWifiEth(false); + system.connectedViaWifi(false); system.getLogger().log(logging::LoggerLevel::LOGGER_LEVEL_ERROR, getName(), "WiFi not connected!"); _oldWifiStatus = wifi_status; _stateInfo = "WiFi not connected"; @@ -51,7 +51,7 @@ bool WifiTask::loop(System &system) { _oldWifiStatus = wifi_status; return false; } - system.connectedViaWifiEth(true); + system.connectedViaWifi(true); _stateInfo = WiFi.localIP().toString(); _state = Okay; return true;