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

Allow changing WiFi Hostname at compile time from user_config_override.h #21236

Closed
wants to merge 3 commits into from

Conversation

ascillato
Copy link
Contributor

@ascillato ascillato commented Apr 21, 2024

Description:

This small PR adds the option to allow changing the WiFi Hostname at compile time from user_config_override.h.

Usage:

  • Add in user_config_override.h file the following so the hostname can be customized at compile time:
#undef DEFAULT_WIFI_HOSTNAME
#define DEFAULT_WIFI_HOSTNAME  "MyDevice"

Notes:

  • The default value is "%s-%04d" which expands to <MQTT_TOPIC>-<last 4 decimal chars of MAC address>
  • This PR does not change the FLASH or RAM usage.

Related issue (if applicable): NA

Checklist:

  • The pull request is done against the latest development branch
  • Only relevant files were touched
  • Only one feature/fix was added per PR and the code change compiles without warnings
  • The code change is tested and works with Tasmota core ESP8266 V.2.7.6
  • The code change is tested and works with Tasmota core ESP32 V.3.0.0
  • I accept the CLA.

NOTE: The code change must pass CI tests. Your PR cannot be merged unless tests pass

@ascillato ascillato changed the title Allow to change WiFi Hostname at compile time from user_config_override.h Allow changing WiFi Hostname at compile time from user_config_override.h Apr 21, 2024
@Jason2866
Copy link
Collaborator

LGTM

@sfromis
Copy link
Contributor

sfromis commented Apr 21, 2024

You can have hostname included in the build without a new #define, by using the regular Hostname command in USER_BACKLOG. Commands given there will be executed first boot with new settings.

@barbudor
Copy link
Contributor

There's a lot of consts for which I would have loved to do that in the past but I was so afraid of changing that order... 🥶
Thank you for your bravery @ascillato 👍

@ascillato
Copy link
Contributor Author

@sfromis Hi, you are right with that. In fact, I was using that in my devices at home, but there is the issue with the user backlog approach (for this case in particular) that takes time and require a restart making other issues like the WiFi AP name (which uses the Hostname) not taking the change right away showing the previous naming. With this simple change, which adds no extra code to the Firmware, we can allow the user to set the HOSTNAME (or a custom template of the hostname like "%s-%06d") at compile time simplifing the process.

@Jason2866
Copy link
Collaborator

Let us merge and see what happens ;-)

@arendst arendst self-assigned this May 5, 2024
@arendst
Copy link
Owner

arendst commented May 5, 2024

Implemented differently but same result.

#define WIFI_DEFAULT_HOSTNAME  "%s-%04d"         // [Hostname] Expands to <MQTT_TOPIC>-<last 4 decimal chars of MAC address>

@arendst arendst closed this May 5, 2024
@ascillato ascillato deleted the patch-1 branch May 6, 2024 17:19
@ascillato
Copy link
Contributor Author

Awesome. Thanks!

hawa-lc4 pushed a commit to hawa-lc4/Tasmota-dev that referenced this pull request May 7, 2024
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.

6 participants