Skip to content

Wifi.softAPConfig() sometimes set the wrong IP address #985

@henricazottes

Description

@henricazottes

Hardware:

Board: Lolin32 Lite
Core Installation/update date: ?11/jul/2017?
IDE name: Platform.Io
Flash Frequency: ?
Upload Speed: ?

Description:

I'm using my esp as an AP to serve a little webserver. To do so, I start the ESP in AP mode like this:

int startAP() {
  digitalWrite(LED_BUILTIN, LOW);
  Serial.println("Running config server");
  delay(500);
  digitalWrite(LED_BUILTIN, HIGH);
  WiFi.mode(WIFI_OFF);
  delay(1000);
  WiFi.mode(WIFI_AP);
  if(!WiFi.softAPConfig(IPAddress(192, 168, 5, 1), IPAddress(192, 168, 5, 1), IPAddress(255, 255, 255, 0))){
      Serial.println("AP Config Failed");
  }
  if(WiFi.softAP(gw_ssid, gw_pwd)){
    Serial.println("");
    IPAddress myIP = WiFi.softAPIP();
    Serial.println("Network " + String(gw_ssid) + " running");
    Serial.print("AP IP address: ");
    Serial.println(myIP);
    return 0;
  } else {
      Serial.println("Starting AP failed.");
      return 1;
  }
}

As you can see I'm giving a static IP to the ESP which is supposed to be 192.168.5.1. Moreover, the sub network mask is set to /24. However despite this given configuration I sometimes get my ESP adressed as 192.168.4.1 (which is confirmed when I try to access the webserver).

Am I missing a configuration option ? Thanks :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions