From 664d92fbd04cabfdf21e96f5cf174219db64ada4 Mon Sep 17 00:00:00 2001 From: Martin Ayotte Date: Thu, 20 Aug 2015 23:43:01 -0400 Subject: [PATCH] add toCharArray() to IPAddress class --- cores/esp8266/IPAddress.cpp | 14 ++++++++++++++ cores/esp8266/IPAddress.h | 1 + 2 files changed, 15 insertions(+) diff --git a/cores/esp8266/IPAddress.cpp b/cores/esp8266/IPAddress.cpp index dea1d18a9..dff91d8af 100644 --- a/cores/esp8266/IPAddress.cpp +++ b/cores/esp8266/IPAddress.cpp @@ -64,3 +64,17 @@ size_t IPAddress::printTo(Print& p) const { return n; } +char *IPAddress::toCharArray() +{ + static char szRet[20]; + String str = String(_address.bytes[0]); + str += "."; + str += String(_address.bytes[1]); + str += "."; + str += String(_address.bytes[2]); + str += "."; + str += String(_address.bytes[3]); + str.toCharArray(szRet, 20); + return szRet; +} + diff --git a/cores/esp8266/IPAddress.h b/cores/esp8266/IPAddress.h index 73c6cbdf4..21e775ef5 100644 --- a/cores/esp8266/IPAddress.h +++ b/cores/esp8266/IPAddress.h @@ -70,6 +70,7 @@ class IPAddress: public Printable { IPAddress& operator=(uint32_t address); virtual size_t printTo(Print& p) const; + char * toCharArray(); friend class EthernetClass; friend class UDP;