Skip to content

Activating static IP makes WiFi.status() return WL_CONNECTED #6191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
6 tasks done
aerlon opened this issue Jun 10, 2019 · 2 comments · Fixed by #6194
Closed
6 tasks done

Activating static IP makes WiFi.status() return WL_CONNECTED #6191

aerlon opened this issue Jun 10, 2019 · 2 comments · Fixed by #6194
Assignees

Comments

@aerlon
Copy link
Contributor

aerlon commented Jun 10, 2019

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: ESP-12
  • Core Version: Latest Git as of 2019-06-10
  • Development Env: Arduino IDE
  • Operating System: Windows

Settings in IDE

  • Module: NodeMCU 1.0
  • Flash Mode: dio
  • Flash Size: 4MB
  • lwip Variant: v2 Lower Memory
  • Reset Method: nodemcu
  • Flash Frequency: 40Mhz
  • CPU Frequency: 80Mhz
  • Upload Using: SERIAL
  • Upload Speed: 115200

Problem Description

The changes made in PR #6026 by @d-a-v makes WiFi.status() == WL_CONNECTED become true whenever one activates static IP via WiFi.config. This was not the case before the change, and it also seems strange that the status would be connected even when no connection has been made, so it is likely a bug. Calling WiFi.disconnect() after static IP activation makes WiFi.status() return 0 (WL_IDLE_STATUS), as was the case before the PR change.

MCVE Sketch

#include <ESP8266WiFi.h>

void activateStaticIP()
{
  // WiFi mode does not matter 
  WiFi.mode(WIFI_STA);
  //WiFi.mode(WIFI_AP_STA); 
  
  WiFi.config(IPAddress(192,168,4,22), IPAddress(192,168,4,1), IPAddress(255,255,255,0)); 
}

void setup() {
  // put your setup code here, to run once:

  WiFi.persistent(false);
  
  Serial.begin(115200);
  delay(50); // Wait for Serial.

  Serial.println();
  Serial.println();

  WiFi.disconnect();
    
  activateStaticIP();
}

void loop() {
  // put your main code here, to run repeatedly:
  
  Serial.print("status pre " + String(WiFi.status()));
  if(WiFi.status() == WL_CONNECTED)
    Serial.println(", this means WiFi.status() == WL_CONNECTED");
  else
    Serial.println();
    
  WiFi.disconnect(); // Adding this disconnect seems to fix WiFi status.
  Serial.println("status post " + String(WiFi.status()));

  delay(3000);
}
@d-a-v
Copy link
Collaborator

d-a-v commented Jun 10, 2019

@aerlon can you give #6194 a try ?

@d-a-v d-a-v added the waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. label Jun 11, 2019
@aerlon
Copy link
Contributor Author

aerlon commented Jun 11, 2019

@d-a-v I can confirm #6194 fixes the problem.

@aerlon aerlon closed this as completed Jun 11, 2019
@d-a-v d-a-v removed the waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. label Jun 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants