Skip to content
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

esp32 arduinoOTA sethostname() not working #3438

Closed
Kiuman opened this issue Oct 31, 2019 · 4 comments
Closed

esp32 arduinoOTA sethostname() not working #3438

Kiuman opened this issue Oct 31, 2019 · 4 comments

Comments

@Kiuman
Copy link

Kiuman commented Oct 31, 2019

Hi,
I'm using ArduinoOTA.sethostname("esp32-entrance-device"); and the hostname in the Arduino IDE Network ports is always showing as esp32-[MAC address].
Maybe I'm a little bit rusty with my code abilities, but isn't _hostname missing in the ArduinoOTAClass::ArduinoOTAClass() definition?

Link to code: https://github.com/esp8266/Arduino/blob/master/libraries/ArduinoOTA/ArduinoOTA.cpp

Thanks!

@lbernstone
Copy link
Contributor

esp32 != esp8266. https://github.com/espressif/arduino-esp32/blob/master/libraries/ArduinoOTA/src/ArduinoOTA.h#L82
Call setHostname before begin.

@EsserPrototyping
Copy link

The following worked, but i don´t think you really need the disconnect and config parts..

In my case it wasnt the ESP32, it was my router. Check that you don´t have the mac or ip assigned anywhere in the router and change the lease time of dhcp to something like one minute.. now the router should see the ESP with it´s new hostname..

`
char hname[] = "ESP32_1234";

void setup () {

WiFi.disconnect(); // probalbly not needed
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE); // probalbly not needed
WiFi.setHostname(hname);
WiFi.mode(WIFI_STA);

WiFi.begin(ssid, password);

}
`

@Kiuman
Copy link
Author

Kiuman commented Nov 6, 2019

Well thanks to both, indeed ArduinoOTA.setHostname(hostname); (from ArduinoOTA.h) doesn't work as it is described, but WiFi.setHostname(hostname); (from WiFi.h) does work as intended.
Issue closed.
Edit: typos.

@mepster
Copy link

mepster commented Nov 3, 2020

@EsserPrototyping thanks for the tip!

Turns out for me it was

WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE);

that was needed... although I actually used

WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);

I found in addition that WiFi.mode(WIFI_STA); and WiFi.disconnect(); were not necessary.

My complete code:

WiFi.begin(ssid, pass);
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE); // required to set hostname properly
WiFi.setHostname(hostname);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants