File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -42,3 +42,13 @@ bool IPAddress::operator==(const uint8_t* addr)
4242 return memcmp (addr, _address, sizeof (_address)) == 0 ;
4343}
4444
45+ void IPAddress::printTo (Print& p) const
46+ {
47+ for (int i =0 ; i < 3 ; i++)
48+ {
49+ p.print (_address[i], DEC);
50+ p.print (' .' );
51+ }
52+ p.print (_address[3 ], DEC);
53+ }
54+
Original file line number Diff line number Diff line change 2626#ifndef IPAddress_h
2727#define IPAddress_h
2828
29+ #include < Printable.h>
30+
2931// A class to make it easier to handle and pass around IP addresses
3032
31- class IPAddress {
33+ class IPAddress : public Printable {
3234private:
3335 uint8_t _address[4 ]; // IPv4 address
3436 // Access the raw byte array containing the address. Because this returns a pointer
@@ -58,6 +60,8 @@ class IPAddress {
5860 IPAddress& operator =(const uint8_t *address);
5961 IPAddress& operator =(uint32_t address);
6062
63+ virtual void printTo (Print& p) const ;
64+
6165 friend class EthernetClass ;
6266 friend class UDP ;
6367 friend class Client ;
You can’t perform that action at this time.
0 commit comments