-
Notifications
You must be signed in to change notification settings - Fork 147
[ESP8266/ESP32] Problem setting hostname while on dynamic ip. #17
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to confirm first that the ordering issue doesn't also affect the ESP32 before merging. Bear with me while I investigate.
Both ESP32 and esp8266 will not accept a dhcp hostname until the WiFi is set to an active mode. It looks like the advice is to put the device into the correct mode, and set the hostname before calling WiFi.begin(). Your fix effectively does this, however I'm not able to properly test this approach under ESP32 because there is another issue affecting the DHCP hostname feature at the moment. There is a pending PR to fix the issue: espressif/arduino-esp32#2537 I'll keep an eye on this. Meanwhile would you mind moving the hostname calls for both devices below the begin call, because it's clearly wrong in both instances, so we can merge it in. |
This is getting really interesting/fun :-). I have some thoughts/findings regarding this topic:
Long story short, I tried calling
What do you think? |
While using a dynamic ip the system doesn't take into account the hostname setting. Calling setting hostname after begin solved the issue. This only applies to esp8266, haven't tried on esp32.
Calling WiFi.config() with INADDR_ANY/INADDR_NONE to set dynamic ip / enable dhcp. This solution solved issue on setting hostname for esp8266 and esp32. Also it solved issues moving from static ip to dynamic ip.
34d2fad
to
2a65ed4
Compare
Finally I came up with this. While trying to solve the hostname issue, I found that changing from static ip to dynamic ip was not working. Investing the WiFi API, I found there is a variable named |
Yes, the hostname is only used during the DHCP request - so it is not
needed if using static IP.
Looks like your solution of calling the config function has the side effect
of enabling STA mode and restarting DHCP - this works around the issue on
the ESP32. Very good!
I was aware of the hostname issue, didn't even know of the static IP bug.
Good to have this fixed, thanks!
…On Sun, Apr 28, 2019 at 5:15 AM pcniatic ***@***.***> wrote:
Finally I came up with this. While trying to solve the hostname issue, I
found that changing from static ip to dynamic ip was not working. Investing
the WiFi API, I found there is a variable named _useStaticIp that is only
being set inside WiFi.config. So, I added a new condition in
WiFiSettingService.cpp, and now when _staticIPConfig is false I also call
WiFi.config but with a INADDR_ANY (esp8266) / INADDR_NONE (esp32) value.
This solved the issue of moving from static to dynamic ip on both
platforms, AND IT ALSO SOLVED THE HOSTNAME ISSUE!!
Let me know what you think.
Best, Mauro.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#17 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAKE4VATMONATOXXQKHDHSTPSUQFFANCNFSM4HI4WX7Q>
.
|
While using a dynamic ip the system doesn't take into account the hostname setting.
Calling WiFi.hostname() after begin() solved the issue.
This only applies to esp8266, haven't tried on esp32.