-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Dependency of soft AP DHCP addresses on selected debug level, 'Generic ESP8266 Module' #2728
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
Comments
Errata: In Description, 'DHCP address range being inverted (end > start)' should read 'DHCP address range being inverted (start > end)' |
I have noticed that even when I set Wifi.softAPConfig() before softAP mode is started (I have it in STA mode before that), the debug information states that the dhcp server is started with ip 192.168.4.1 even if I set a different IP in the config. |
The sdk docs clearly state
Not sure how the debug comes into play, but I had similar issues with softap_disconnect, until I read the same disclaimer on that also. |
@mrwgx3 I can't reproduce this behavior with latest git, but then again I'm not sure I fully understand the entire description. |
Hi devyte
Yes, I believe so, but we both need to get on the same page to crosscheck results. Again here are the tools and part I tested with; please list yours:
Next, could you verify the STAT+AP initialization within 'setup()' show in my SKETCH codeblock:
Aside from the concerns expressed by @eketjall and @tablatronix about the ordering of the 'WiFi.softAPdisconnect()' statement, I see no issues (copy @igrr as well) I'll return later with further clarifications after I re-protoboard my hardware setup. |
Note that in the original post, the 'debug level' link under the 'Description' header is broken; here is the corrected link. |
@mrwgx3 I don't remember what I tested back when I said I couldn't reproduce it, and I also don't remember the details currently contained in the description. About the debug message having an impact, I suspect you're facing some mem corruption, as it should have no impact whatsoever on the behavior. You're welcome to give this a shot, I wouldn't mind seeing this improved. |
Hi again, devyte Got my hardware set back up, and finished working through my original notes. Surprisingly, I could reproduce my initial results using the Arduino IDE under Linux Ubuntu 16.04LTS, but not so running under Windows 10 Pro (baffling?!). To eliminate the possibility of an accidently modified SDK and/or ESD damaged hardware, I again re-tested using both the lastest Arduino IDE (version 1.8.5) and new ESP Huzzah hardware, again with the same results. Now for some backstory... My initial task was to connect and address some 30+ ESP's together for data collection purposes. Rather than jumping into the complexities of mesh-networking, I explored the possibility of chaining STA+AP configured ESP's into a statically addressed hierarchy. This required that I work in Linux in order to easily modify and recompile the required SDK libraries. I turned on debugging using IDE's generic ESP settings and got things partially working, but everything broke when I turned debugging OFF. Testing via 'ifconfig' and 'ping' showed that the DCHP addressing being handed out by the ESP access point were nothing close to those requested, hence this issues post. Now back to the present... I agree with you that the status of the debug flags should make no difference on how the code performs. Apparently this is now the case for the IDE running under Windows 10; the code generates erroneous DCHP addresses regardless of debug flag state. This makes sense given what the code contains! Running under Ubuntu Linux, however, the assigned DCHP address DO depend on debug flag status. Even more disturbing is that
This odd behavior does imply a memory corruption issue, but at how deep a level is it occuring at? Given that...
I suspect that only detailed knowledge of the closed SDK plus a true hardware emulator will resolve the problem. |
I am having the same issue, but I have tried the same code on multiple different ESP-12E chips, and it will work without fail on some of them, on others it seems to break very randomly, and it appears more likely to work the more logging I add to my sketch, which makes this very hard to figure out. |
The same failure for me. |
If logging changes this "bug" then it is most likely a race condition. I didn't see any references used in debug messages, but maybe the serial interrupts change the lifetime of something.. |
Basic Infos
Hardware
OS, IDE, and SDK
Description
While in AP+STA mode, it was observed that DHCP addresses assigned by the AP side sometimes differed from those specified by the network parameters passed in Wifi.softAPConfig(). These variations were traced to the debug level chosen for the 'Generic ESP8266 Module' board setting, with erroneous addresses being generated for levels not containing a 'Wifi' entry. Incorrect addresses were also seen for the 'Adafruit HUZZAH ESP8266' board setting, which doesn't expose any debug levels at all.
Further tests revealed that when a specific DEBUG_WIFI() call is NOT made within Wifi.softAPConfig(), the results of a puzzling (perhaps incomplete) DCHP address calculation are used. With the 'Wifi' flag set, however, the critical DEBUG_WIFI() call is made, and the correct DHCP addresses are somehow calculated and set; where and how is not readily apparent.
Also noted was that some address ranges caused Wifi.softAPConfig() to fail due to the calculated starting/ending DHCP address range being inverted (end > start); an example is included in the attached sketch.
Additional items:
Settings in IDE
Sketch Outline
History
This issue was noticed while developing the attached sketch in 'Generic ESP8266 / Core+Wifi' mode. The debug messages from the soft-AP configuration and startup are:
The expected DHCP starting and ending addresses expected from the sketch's WiFi.softAPConfig( ip:192.168.4.9, gw:192.168.4.9, mask:255.255.255.248 ) call would be 192.168.4.9 and 182.168.4.14; quite different from reported addresses of 192.168.4.108 and 192.168.4.208. A check via an 'ipconfig /all' after connecting to the AP, however, shows all but the subnet mask to be in order:
Both the gateway (192.168.4.9) and wireless adapter (192.168.4.10) were also pingable, and the webserver root response was observed after entering '192.168.4.9/' into a browser. Given that everything seemingly works, it was concluded that the DHCP addresses were mis-reported.
After debugging, the 'Adafruit HUZZAH ESP8266' configuration was selected and the sketch recompiled. Everything matches the prior debug output, except for the now absent [APConfig] starting and ending DHCP messages. An 'ipconfig /all' check, however, revealed the actual starting DHCP address now matched the "mis-reported" starting address seen earlier:
The wireless adapter (192.168.4.108) was pingable, but the gateway address (192.168.4.9) was not. The webserver root response was no longer observable as well.
Additional Troubleshooting
The DHCP address calculations are found in ESP8266WiFiAPClass::softAPConfig():
The errant '192.168.4.108' address arises from the 'ip[3] += 99' addition, i.e., 99 + 9 = 108.
Given correct DHCP addresses were seen while 'Wifi+Core' debug messages were active, while erroneous ones occured for the 'Huzzah' configuration, all other 'Generic' debug message configurations were checked. Erroneous addresses were observed only when the 'Wifi' debug flag was OFF.
Systematic comment/uncommenting of active DEBUG_WIFI() lines isolated the 1st message line in 'softAPConfig()' as the critical one; commenting this line out while the 'Wifi' debug level was active caused erroneous DHCP addresses. More expermentation showed that the length of the variable arglist to be important:
Lastly, inspection of 'wifi_softap_set_dhcps_lease()' of the LWIP libraries indicated that some IP addresses may cause a 'fail' to be returned by softAPConfig(). To demonstrate this, set the sketch compiler variable 'AP_CFGERR' to a non-zero value and re-compile:
An 'ipconfig /all' check showed correct DHCP addresses, a result comfirmed again with pings and a webserver root response:
This result, however, is now obtained regardless of debug mode status or comment state of the 1st DEBUG_WIFI line.
Sketch
The text was updated successfully, but these errors were encountered: