Skip to content

Commit

Permalink
add toString() helper to IPAddress class
Browse files Browse the repository at this point in the history
  • Loading branch information
martinayotte committed Feb 29, 2016
1 parent ba5d405 commit 3d15c75
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
13 changes: 13 additions & 0 deletions STM32F1/cores/maple/IPAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <Arduino.h>
#include <IPAddress.h>
#include <Print.h>

IPAddress::IPAddress()
{
Expand Down Expand Up @@ -72,3 +73,15 @@ size_t IPAddress::printTo(Print& p) const
return n;
}

String IPAddress::toString()
{
String str = String(_address.bytes[0]);
str += ".";
str += String(_address.bytes[1]);
str += ".";
str += String(_address.bytes[2]);
str += ".";
str += String(_address.bytes[3]);
return str;
}

2 changes: 2 additions & 0 deletions STM32F1/cores/maple/IPAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#define IPAddress_h

#include <stdint.h>
#include <WString.h>
#include <Printable.h>

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

virtual size_t printTo(Print& p) const;
String toString();

friend class EthernetClass;
friend class UDP;
Expand Down

0 comments on commit 3d15c75

Please sign in to comment.