Skip to content

WiFi.localIP() reports 0.0.0.0 after succesfull connect - Arduino Core 3.0.7 #10580

Closed
@CelliesProjects

Description

@CelliesProjects

Board

esp32-s3

Device Description

Just a plain old esp32-s3

Hardware Configuration

Nothing of consequence

Version

v3.0.7

IDE Name

PlatformIO

Operating System

Mint Linux

Flash frequency

80

PSRAM enabled

yes

Upload speed

921600

Description

WiFi.localIP() should report the IP address. Instead it displays 0.0.0.0 after a succesfull connection. After a while it does show the correct IP.

Fix

A quick fix here was to change isConnected() in WiFiSTA.cpp to the snippet below.

This change gives the expected behaviour.

/**
 * is STA interface connected?
 * @return true if STA is connected and has a IP
 */
bool WiFiSTAClass::isConnected() {
  return STA.connected() && STA.hasIP();
}

Sketch

#include <Arduino.h>
#include <WiFi.h>

const char *SSID = "xxx";
const char *PSK = "xxx";

void setup()
{
    Serial.begin(115200);
    while (!Serial)
        delay(10);

    Serial.println("connecting..");

    WiFi.begin(SSID, PSK);

    while (!WiFi.isConnected())
        delay(10);

    Serial.println(WiFi.localIP());
}

void loop()
{
    delay(1000);
    Serial.println(WiFi.localIP());
}

Debug Message

connecting..
0.0.0.0
192.168.0.253
192.168.0.253
192.168.0.253
192.168.0.253
192.168.0.253
192.168.0.253
192.168.0.253
192.168.0.253

Other Steps to Reproduce

I did not try any other hw.

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions