diff --git a/cores/arduino/IPAddress.cpp b/cores/arduino/IPAddress.cpp index 68439d1a5a..d0b82f3adb 100644 --- a/cores/arduino/IPAddress.cpp +++ b/cores/arduino/IPAddress.cpp @@ -107,3 +107,9 @@ size_t IPAddress::printTo(Print &p) const return n; } +String IPAddress::toString() const +{ + char szRet[16]; + sprintf(szRet, "%u.%u.%u.%u", _address.bytes[0], _address.bytes[1], _address.bytes[2], _address.bytes[3]); + return String(szRet); +} diff --git a/cores/arduino/IPAddress.h b/cores/arduino/IPAddress.h index c73f011982..b8b1092d3b 100644 --- a/cores/arduino/IPAddress.h +++ b/cores/arduino/IPAddress.h @@ -82,6 +82,7 @@ class IPAddress : public Printable { IPAddress &operator=(uint32_t address); virtual size_t printTo(Print &p) const; + String toString() const; friend class EthernetClass; friend class UDP;