From 130fd23235e167c4990d6106bbb9a7f2039a1081 Mon Sep 17 00:00:00 2001 From: technyon Date: Thu, 2 Mar 2023 20:15:16 +0100 Subject: [PATCH] print ip address for W5500 devices --- networkDevices/EthLan8720Device.cpp | 2 +- networkDevices/W5500Device.cpp | 12 +++++++++++- networkDevices/W5500Device.h | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/networkDevices/EthLan8720Device.cpp b/networkDevices/EthLan8720Device.cpp index 98f2e60..f9eb6a4 100644 --- a/networkDevices/EthLan8720Device.cpp +++ b/networkDevices/EthLan8720Device.cpp @@ -107,7 +107,7 @@ bool EthLan8720Device::isConnected() if(_lastConnected == false && connected == true) { - Serial.print("Ethernet connected. IP address: "); + Serial.print(F("Ethernet connected. IP address: ")); Serial.println(ETH.localIP().toString()); } diff --git a/networkDevices/W5500Device.cpp b/networkDevices/W5500Device.cpp index 93c3343..08eec47 100644 --- a/networkDevices/W5500Device.cpp +++ b/networkDevices/W5500Device.cpp @@ -164,7 +164,17 @@ bool W5500Device::supportsEncryption() bool W5500Device::isConnected() { - return Ethernet.linkStatus() == EthernetLinkStatus::LinkON && _maintainResult == 0 && _hasDHCPAddress; + 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; } void W5500Device::initializeMacAddress(byte *mac) diff --git a/networkDevices/W5500Device.h b/networkDevices/W5500Device.h index d6dbd16..12a964d 100644 --- a/networkDevices/W5500Device.h +++ b/networkDevices/W5500Device.h @@ -71,6 +71,7 @@ private: bool _hasDHCPAddress = false; char* _path; W5500Variant _variant; + bool _lastConnected = false; byte _mac[6]; }; \ No newline at end of file