1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-27 18:02:17 +03:00

Merge pull request #714 from martinayotte/esp8266

add toCharArray() to IPAddress class
This commit is contained in:
Ivan Grokhotkov
2015-08-31 09:37:22 +03:00
4 changed files with 49 additions and 5 deletions

View File

@ -64,3 +64,10 @@ size_t IPAddress::printTo(Print& p) const {
return n;
}
String IPAddress::toString()
{
char szRet[16];
sprintf(szRet,"%u.%u.%u.%u", _address.bytes[0], _address.bytes[1], _address.bytes[2], _address.bytes[3]);
return String(szRet);
}

View File

@ -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
@ -70,6 +71,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;