Skip to content

Commit 3d15c75

Browse files
committed
add toString() helper to IPAddress class
1 parent ba5d405 commit 3d15c75

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

STM32F1/cores/maple/IPAddress.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <Arduino.h>
2121
#include <IPAddress.h>
22+
#include <Print.h>
2223

2324
IPAddress::IPAddress()
2425
{
@@ -72,3 +73,15 @@ size_t IPAddress::printTo(Print& p) const
7273
return n;
7374
}
7475

76+
String IPAddress::toString()
77+
{
78+
String str = String(_address.bytes[0]);
79+
str += ".";
80+
str += String(_address.bytes[1]);
81+
str += ".";
82+
str += String(_address.bytes[2]);
83+
str += ".";
84+
str += String(_address.bytes[3]);
85+
return str;
86+
}
87+

STM32F1/cores/maple/IPAddress.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#define IPAddress_h
2222

2323
#include <stdint.h>
24+
#include <WString.h>
2425
#include <Printable.h>
2526

2627
// A class to make it easier to handle and pass around IP addresses
@@ -60,6 +61,7 @@ class IPAddress : public Printable {
6061
IPAddress& operator=(uint32_t address);
6162

6263
virtual size_t printTo(Print& p) const;
64+
String toString();
6365

6466
friend class EthernetClass;
6567
friend class UDP;

0 commit comments

Comments
 (0)