Skip to content

Commit 79579d7

Browse files
authored
feat: add "toString" function to IPAddress (#2306)
Signed-off-by: Virens <[email protected]>
1 parent f67f03b commit 79579d7

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Diff for: cores/arduino/IPAddress.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,9 @@ size_t IPAddress::printTo(Print &p) const
107107
return n;
108108
}
109109

110+
String IPAddress::toString() const
111+
{
112+
char szRet[16];
113+
sprintf(szRet, "%u.%u.%u.%u", _address.bytes[0], _address.bytes[1], _address.bytes[2], _address.bytes[3]);
114+
return String(szRet);
115+
}

Diff for: cores/arduino/IPAddress.h

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class IPAddress : public Printable {
8282
IPAddress &operator=(uint32_t address);
8383

8484
virtual size_t printTo(Print &p) const;
85+
String toString() const;
8586

8687
friend class EthernetClass;
8788
friend class UDP;

0 commit comments

Comments
 (0)