Skip to content

Commit

Permalink
feat: add "toString" function to IPAddress (#2306)
Browse files Browse the repository at this point in the history
Signed-off-by: Virens <[email protected]>
  • Loading branch information
VirensCn committed Mar 26, 2024
1 parent f67f03b commit 79579d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cores/arduino/IPAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
1 change: 1 addition & 0 deletions cores/arduino/IPAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 79579d7

Please sign in to comment.