-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Default hostname non unique ? #6099
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
Hello, sorry for answering late. Is this still valid? |
I think so? let me check |
Please retest this on v2.0.3-rc1 of Arduino esp32 core, thanks! |
Any updates? |
Missed this will test right now |
Hello @tablatronix, any news? |
Looks ok I usually use full chipid not just 32bit int, but whatever makes more sense. I would have to check what esp8266 does. |
Can I consider this as solved @tablatronix? Thanks for answer! |
@VojtechBartoska please reference the commit that fixed this, I think I found a regression |
It is also missing from release notes |
what is that regression @tablatronix ? |
It is not about the default hostname, but WHEN we can set a custom hostname. So maybe this was an sdk implementation change because there is also a specific note about having to restart
Ill test some more and open a new issue if I find that there is a bad order of operations or overwrite happening instead. |
This is how it is done in IDF. Hostname must be set before the STA interface contacts the DHCP server. 8266 has nothing to do with anything here anymore :) |
Ok i found 2 issues kind of related to this issue
setup(){
Serial.println("[WIFI] HOSTNAME: " + (String)WiFi.getHostname());
}
// [WIFI] HOSTNAME: esp32-02403F
/////////////
setup(){
WiFi.mode(WIFI_STA);
Serial.println("[WIFI] HOSTNAME: " + (String)WiFi.getHostname());
}
// [WIFI] HOSTNAME: esp32-DF857C My code was checking hostname to restart for changes, but I found an issue there also
// get the actual hostname as you would see it on the network
// testing, no safeties or netif or init checking here
const char * WiFiGenericClass::getHostname()
{
const char * hostname = NULL;
esp_netif_get_hostname(get_esp_interface_netif(ESP_IF_WIFI_STA), &hostname);
return hostname;
// return get_esp_netif_hostname();
} |
the thing is that in order to set the hostname, first the network subsystem must be initialized. To actually have that hostname visible by the DHCP server, it must be set before the initial request for IP. Even if you set it after DHCP has started, it will not be applied. So all in all, we have tried to make it as workable as possible, so it is set when the proper event occurs. About getHostname, maybe we can add |
When is the request for ip occuring? , do you know when that happens, is it after esp_wifi_start or inside it? Yeah the biggest issue is that there is no way for user code to know when and if the hostname was set, since it occurs abstracted inside mode() and only if it makes it past the mode already set check. I will work on a workaround for alwyas checking mode when setting hostname ( I assume this all occurs inside esp_wifi_start ). and see what delays are introduced when having to wifistop/wifistart. a As for the first issue which actually refers to this issue, it seems the IDF has its own default hostname now and it is a different bti depth than this fix, so making them match would be the fix here. Chip ID esp32-02403F |
I just looked at the source in IDF. The hostname is sent to the DHCP server on DISCOVER, SELECT, RENEW, REBIND and REBOOT. Maybe restarting the DHCP can help change the hostname. |
Board
esp32 wroom32d
Device Description
Custom
Hardware Configuration
no
Version
latest master
IDE Name
pio
Operating System
osx
Flash frequency
40
PSRAM enabled
no
Upload speed
921600
Description
I expected default hostnames to be ESP-deviceid but I see this instead ?
[WIFI] HOST: esp32-arduino
Other stuff like ota is as expected
[OTA] Hostname: esp32-f008d1be63ac
etc.
Is this an expected change, or documented?
I could not debug or find how this is set or init..
Sketch
Debug Message
Other Steps to Reproduce
No response
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: