fix inital printing of IP address

This commit is contained in:
technyon
2024-07-07 14:08:24 +02:00
parent 53243fe045
commit da0390df63
6 changed files with 12 additions and 25 deletions

View File

@@ -380,7 +380,8 @@ bool NukiNetwork::update()
break;
case ReconnectStatus::Success:
memset(WiFi_fallbackDetect, 0, sizeof(WiFi_fallbackDetect));
Log->println(F("Reconnect successful"));
Log->print(F("Reconnect successful: IP: "));
Log->println(_device->localIP());
break;
case ReconnectStatus::Failure:
Log->println(F("Reconnect failed"));
@@ -388,6 +389,13 @@ bool NukiNetwork::update()
}
}
if(_logIp && device()->isConnected() && !_device->localIP().equals("0.0.0.0"))
{
_logIp = false;
Log->print(F("IP: "));
Log->println(_device->localIP());
}
if(!_device->mqttConnected() && _device->isConnected())
{
if(_networkTimeout > 0 && (ts - _lastConnectedTs > _networkTimeout * 1000) && ts > 60000)

View File

@@ -167,6 +167,7 @@ private:
bool _restartOnDisconnect = false;
bool _firstConnect = true;
bool _publishDebugInfo = false;
bool _logIp = true;
std::vector<String> _subscribedTopics;
std::map<String, String> _initTopics;

View File

@@ -112,17 +112,7 @@ bool EthLan8720Device::supportsEncryption()
bool EthLan8720Device::isConnected()
{
bool connected = ETH.linkUp();
if(_lastConnected == false && connected == true)
{
Serial.print(F("Ethernet connected. IP address: "));
Serial.println(ETH.localIP().toString());
}
_lastConnected = connected;
return connected;
return ETH.linkUp();
}
ReconnectStatus EthLan8720Device::reconnect()

View File

@@ -72,7 +72,6 @@ private:
bool _startAp = false;
char* _path;
bool _hardwareInitialized = false;
bool _lastConnected = false;
const std::string _deviceName;
uint8_t _phy_addr;

View File

@@ -180,17 +180,7 @@ bool W5500Device::supportsEncryption()
bool W5500Device::isConnected()
{
bool connected = (Ethernet.linkStatus() == EthernetLinkStatus::LinkON && _maintainResult == 0 && _hasDHCPAddress);
if(_lastConnected == false && connected == true)
{
Serial.print(F("Ethernet connected. IP address: "));
Serial.println(Ethernet.localIP().toString());
}
_lastConnected = connected;
return connected;
return (Ethernet.linkStatus() == EthernetLinkStatus::LinkON && _maintainResult == 0 && _hasDHCPAddress);
}
void W5500Device::initializeMacAddress(byte *mac)

View File

@@ -48,7 +48,6 @@ private:
bool _hasDHCPAddress = false;
char* _path;
W5500Variant _variant;
bool _lastConnected = false;
byte _mac[6];
};