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

Fixed hostname on ESP32 #141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

1Prototype1
Copy link

This commit fixes the hostname not getting applied on ESP32 since WiFi.mode() was called before setting the hostname.

Explanation

Taking a look at the WiFi library,
you can see setHostname method calls set_esp_netif_hostname which sets the default_hostname variable with the provided hostname.
This variable is read only by get_esp_netif_hostname which gets called in mode and only when the mode is changed to WIFI_MODE_STA ref

TL;DR

  1. Call WiFi.setHostname() to set internal variable default_hostname with desired hostname.
  2. Call WiFi.mode() with parameter WIFI_STA which will apply the hostname.

Tested and working on ESP32 (Arduino-ESP32 v2.0.17) and no breaking changes found on ESP8266.

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

Successfully merging this pull request may close these issues.

1 participant