diff --git a/api/IPAddress.cpp b/api/IPAddress.cpp index ee941f6d..4b729319 100644 --- a/api/IPAddress.cpp +++ b/api/IPAddress.cpp @@ -89,6 +89,11 @@ IPAddress::IPAddress(IPType ip_type, const uint8_t *address) } } +IPAddress::IPAddress(const char *address) +{ + fromString(address); +} + bool IPAddress::fromString(const char *address) { if (!fromString4(address)) { return fromString6(address); @@ -225,6 +230,12 @@ IPAddress& IPAddress::operator=(const uint8_t *address) return *this; } +IPAddress& IPAddress::operator=(const char *address) +{ + fromString(address); + return *this; +} + IPAddress& IPAddress::operator=(uint32_t address) { // IPv4 conversion diff --git a/api/IPAddress.h b/api/IPAddress.h index 03f2e8e2..964faa67 100644 --- a/api/IPAddress.h +++ b/api/IPAddress.h @@ -67,6 +67,8 @@ class IPAddress : public Printable { // Default IPv4 IPAddress(const uint8_t *address); IPAddress(IPType ip_type, const uint8_t *address); + // If IPv4 fails tries IPv6 see fromString function + IPAddress(const char *address); bool fromString(const char *address); bool fromString(const String &address) { return fromString(address.c_str()); } @@ -90,6 +92,8 @@ class IPAddress : public Printable { IPAddress& operator=(const uint8_t *address); // NOTE: IPv4 only; see implementation note IPAddress& operator=(uint32_t address); + // If IPv4 fails tries IPv6 see fromString function + IPAddress& operator=(const char *address); virtual size_t printTo(Print& p) const;