Skip to content

PR #3860 broke DHCP client Wifi config #4114

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
tve opened this issue Jan 7, 2018 · 5 comments
Closed

PR #3860 broke DHCP client Wifi config #4114

tve opened this issue Jan 7, 2018 · 5 comments

Comments

@tve
Copy link

tve commented Jan 7, 2018

Basic Infos

Hardware

Hardware: ESP12
Core Version: master

Description

As far as I can tell and experience, the change in #3860 broke DHCP. In order to get the dhcp client started one has to set the subnet to 0.0.0.0 in ESP8266WiFiSTAClass::config to pass this check: https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp#L242
and the new code (https://github.com/esp8266/Arduino/blob/master/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp#L221-L235) makes it impossible to get subnet==0.

@devyte
Copy link
Collaborator

devyte commented Jan 7, 2018

@tve please provide a minimal example sketch of what doesn't work, and what does or used to.

@devyte devyte added the waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. label Jan 7, 2018
@tve
Copy link
Author

tve commented Jan 7, 2018

I don't have a simple sketch, alas. I think it's pretty obvious from the code. The only place that _isStaticIp is set to false is line 243. That is guarded by the coditional at line 242:

if (local_ip == 0U && gateway == 0U && subnet == 0U) {

The new code's if statement body lines 222-235 is triggered if subnet is 0:

if(subnet[0] != 255)
    {
      //octet is not 255 => interpret as Arduino order

      if(dns1[0] == 0)
      {
        //arg order is arduino and 4th arg not given => assign it arduino default
        dns1 = IPAddress(255,255,255,0);
      }

      //current order is arduino:                   ip-dns-gway-subnet
      swap(gateway, subnet); //after this, order is ip-gway-dns-subnet
      swap(subnet, dns1);    //after this, order is ip-gway-subnet-dns (correct ESP order)
    } 

Exiting this if statement, it is impossible to get subnet==0, thus it is impossible to set _useStaticIp=false
This may not be noticed by most people because the default at reset is _useStaticIp=false, so it's only if config(0,0,0) is called that it doesn't work.

@devyte
Copy link
Collaborator

devyte commented Jan 7, 2018

@tve your explanation served instead of the sketch to understand the problem, thanks.
I'll catch the case when all are 0U and handle it separately.

@devyte devyte added component: libraries component: web level: easy type: bug and removed waiting for feedback Waiting on additional info. If it's not received, the issue may be closed. labels Jan 7, 2018
@devyte devyte self-assigned this Jan 7, 2018
@devyte devyte added this to the 2.5.0 milestone Jan 7, 2018
@devyte
Copy link
Collaborator

devyte commented Jan 12, 2018

@tve please test PR #4145 .

@igrr igrr modified the milestones: 2.5.0, 2.4.1 Jan 16, 2018
@devyte
Copy link
Collaborator

devyte commented Jan 17, 2018

Fixed via #4145 .

@devyte devyte closed this as completed Jan 17, 2018
TD-er added a commit to TD-er/ESPEasy that referenced this issue Apr 18, 2018
See [this bug report](esp8266/Arduino#4114), which is not fixed in 2.4.0.

This work-around will make sure no dhcp-client will be started when connecting to a network.
The active DHCP client could result in IP conflicts, difficulty in reconnect and other strange issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants