mirror of
https://github.com/lora-aprs/LoRa_APRS_iGate.git
synced 2026-01-27 02:44:15 +01:00
Merge pull request #203 from dahuafschmied/master
fix for NTP booting on ETH Board
This commit is contained in:
commit
3d7a69e424
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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,8 @@ private:
|
|||
Configuration const *_userConfig;
|
||||
TaskManager _taskManager;
|
||||
Display _display;
|
||||
bool _isWifiEthConnected;
|
||||
bool _isEthConnected;
|
||||
bool _isWifiConnected;
|
||||
logging::Logger _logger;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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()) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ bool MQTTTask::setup(System &system) {
|
|||
}
|
||||
|
||||
bool MQTTTask::loop(System &system) {
|
||||
if (!system.isWifiEthConnected()) {
|
||||
if (!system.isWifiOrEthConnected()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ bool NTPTask::setup(System &system) {
|
|||
}
|
||||
|
||||
bool NTPTask::loop(System &system) {
|
||||
if (!system.isWifiEthConnected()) {
|
||||
if (!system.isWifiOrEthConnected()) {
|
||||
return false;
|
||||
}
|
||||
if (!_beginCalled) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue