Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By martinayotte
#25466 No, not yet !
I have a pending PR in IGRR's GitHub, and I don't want to mix things together.
But I will ... There is also the SPIFFS fileSize() enhancement I did this morning.
I think IGRR is busy these days at a meeting in Boston.

In the mean time, merging my above code is pretty trivial.
User avatar
By Deggle
#38315 Hi,

I'm new to the forum, thought it's time I join (read pages here occasionally and there's lots of great info, thanks). Just started playing with the ESP devices: versatile, simple to program and low cost - pretty impressive! My focus is on home automation at this time.

Anyway, I know this is an older thread but thought I'd reply as I had the same issue. I was able to write out the IP via Serial.print(WiFi.localIP()) fine but was struggling to get the formatted IP into a string.

I'm on the latest versions, so not sure if this would have solved your problem at the time.
If it does, you'll kick yourselves :D ...

String ipaddress = WiFi.localIP().toString();

Thought I'd leave that there for anyone Googling (this thread came up for me)!

Cheers,

Tim
User avatar
By WereCatf
#38879
martinayotte wrote:Personally, I've added a new method in IPAddress class.
In IPAddress.h
Code: Select allchar * toCharArray();

In IPAddress.cpp
Code: Select allchar *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;
}

So, you can easily print IP under almost and Printable, such as Serial.println(Wifi.localIP().toCharArray());


Why szRet[20]? An IPv4-address would at most be 15 characters + the ending NULL-character, ie. szRet[16] should be enough and you're wasting 4 bytes for nothing. Am I missing something here?