Skip to content

Hostname unification #4751

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Hostname unification #4751

wants to merge 3 commits into from

Conversation

blazoncek
Copy link
Collaborator

@blazoncek blazoncek commented Jun 27, 2025

Summary by CodeRabbit

  • New Features

    • Added a hostname input and mDNS enable checkbox in Network Settings with pattern validation and dynamic mDNS URL display.
    • Introduced Ethernet Type selection with mutual exclusivity enforced between Ethernet and ESP-NOW options.
    • Hostname and MQTT client/device IDs now default to unique values based on the device MAC address if left empty.
  • Improvements

    • Consolidated mDNS and hostname handling across setup and runtime for consistent behavior.
    • Enhanced WiFi and button configuration safety using dynamic buffer sizing.
    • Updated network settings UI for clearer organization and improved validation feedback.
    • Improved captive portal logic to rely on updated hostname handling.
  • Bug Fixes

    • Fixed unsafe string handling and buffer size issues in configuration deserialization and serialization.
    • Prevented unconditional mDNS updates when mDNS is disabled.
  • Style

    • Renamed several settings page buttons for clarity (e.g., "WiFi Setup" to "Network Setup").
    • Expanded invalid input styling to highlight invalid form fields in red.

- fixes #1242
- fixes empty MQTT topic
- fixes missing hostname on change #4586
Copy link
Contributor

coderabbitai bot commented Jun 27, 2025

Walkthrough

The changes unify and improve hostname and mDNS handling across the codebase, replacing legacy fixed-size buffers with safer sizeof() usage. They add dynamic hostname generation based on MAC address, consolidate mDNS enable flags, and update UI elements for hostname and network settings with validation and mutual exclusivity logic between Ethernet and ESP-NOW. The prepareHostname function was removed and replaced by direct hostname usage, and hostname resolution was enhanced with a new function.

Changes

File(s) Change Summary
wled00/cfg.cpp, wled00/set.cpp, wled00/wled.cpp, wled00/wled.h, wled00/wled_server.cpp, wled00/xml.cpp Improved hostname and mDNS handling: replaced fixed-size copies with sizeof(), added mDNSenabled flag, unified hostname usage, and updated captive portal logic.
wled00/data/settings_wifi.htm, wled00/data/settings.htm, wled00/data/settings_ui.htm, wled00/data/style.css UI updates: renamed and reorganized network settings, added hostname input with validation, enforced Ethernet/ESP-NOW exclusivity, updated button labels, and enhanced input validation styling.
wled00/fcn_declare.h, wled00/network.cpp Added resolveHostname function; removed prepareHostname declaration; simplified Ethernet hostname setting to use global hostname directly.
wled00/util.cpp Removed prepareHostname function entirely.
wled00/improv.cpp Adjusted version string formatting and replaced use of cmDNS with hostName in Improv info response.

Estimated code review effort

3 (30–60 minutes)

Suggested reviewers

  • netmindz

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e2edd38 and 31cdbb1.

📒 Files selected for processing (14)
  • wled00/cfg.cpp (4 hunks)
  • wled00/data/settings.htm (1 hunks)
  • wled00/data/settings_ui.htm (2 hunks)
  • wled00/data/settings_wifi.htm (5 hunks)
  • wled00/data/style.css (1 hunks)
  • wled00/fcn_declare.h (1 hunks)
  • wled00/improv.cpp (1 hunks)
  • wled00/network.cpp (3 hunks)
  • wled00/set.cpp (3 hunks)
  • wled00/util.cpp (0 hunks)
  • wled00/wled.cpp (4 hunks)
  • wled00/wled.h (1 hunks)
  • wled00/wled_server.cpp (1 hunks)
  • wled00/xml.cpp (3 hunks)
💤 Files with no reviewable changes (1)
  • wled00/util.cpp
✅ Files skipped from review due to trivial changes (2)
  • wled00/data/settings.htm
  • wled00/data/style.css
🚧 Files skipped from review as they are similar to previous changes (4)
  • wled00/network.cpp
  • wled00/fcn_declare.h
  • wled00/set.cpp
  • wled00/cfg.cpp
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: blazoncek
PR: wled/WLED#4482
File: wled00/udp.cpp:147-149
Timestamp: 2025-02-19T12:43:34.199Z
Learning: ESP8266 and ESP32 platforms have different maximum segment name lengths in WLED, which can cause truncation when syncing segment names between devices. This platform difference affects the user experience when using the segment name sync feature.
Learnt from: blazoncek
PR: wled/WLED#4482
File: wled00/udp.cpp:147-149
Timestamp: 2025-02-19T12:43:34.200Z
Learning: In WLED, maximum segment name length varies by platform:
- ESP8266: 32 characters (WLED_MAX_SEGNAME_LEN = 32)
- ESP32: 64 characters (WLED_MAX_SEGNAME_LEN = 64)
This platform difference can cause truncation when syncing longer names from ESP32 to ESP8266. Additionally, the WLED UI has limitations regarding modified maximum segment name lengths.
wled00/data/settings_ui.htm (2)

Learnt from: blazoncek
PR: #4482
File: wled00/udp.cpp:147-149
Timestamp: 2025-02-19T12:43:34.199Z
Learning: ESP8266 and ESP32 platforms have different maximum segment name lengths in WLED, which can cause truncation when syncing segment names between devices. This platform difference affects the user experience when using the segment name sync feature.

Learnt from: blazoncek
PR: #4482
File: wled00/udp.cpp:147-149
Timestamp: 2025-02-19T12:43:34.200Z
Learning: In WLED, maximum segment name length varies by platform:

  • ESP8266: 32 characters (WLED_MAX_SEGNAME_LEN = 32)
  • ESP32: 64 characters (WLED_MAX_SEGNAME_LEN = 64)
    This platform difference can cause truncation when syncing longer names from ESP32 to ESP8266. Additionally, the WLED UI has limitations regarding modified maximum segment name lengths.
wled00/wled_server.cpp (4)

Learnt from: blazoncek
PR: #4700
File: wled00/wled_server.cpp:409-414
Timestamp: 2025-05-26T16:09:34.325Z
Learning: In wled00/wled_server.cpp, the OTA update access control logic intentionally allows OTA updates from different subnets when otaSameSubnet is true AND a PIN is set. This was a conscious design decision by blazoncek to provide flexibility for remote OTA updates with PIN protection, though they acknowledged it may not be the optimal security model.

Learnt from: blazoncek
PR: #4482
File: wled00/udp.cpp:147-149
Timestamp: 2025-02-19T12:43:34.199Z
Learning: ESP8266 and ESP32 platforms have different maximum segment name lengths in WLED, which can cause truncation when syncing segment names between devices. This platform difference affects the user experience when using the segment name sync feature.

Learnt from: KrX3D
PR: #4237
File: usermods/INA219_v2/INA219_v2.cpp:265-276
Timestamp: 2025-04-18T22:27:58.634Z
Learning: When implementing MQTT message handling in WLED usermods, use strstr(topic, "/specific/path") instead of strcmp_P(topic, PSTR("/specific/path")) to properly match topics that include the device prefix. The full MQTT topic typically follows the pattern <mqttDeviceTopic>/specific/path.

Learnt from: KrX3D
PR: #4664
File: wled00/syslog.cpp:50-51
Timestamp: 2025-04-26T12:51:04.993Z
Learning: In the WLED codebase, syslog configuration variables (syslogHost, syslogPort, syslogProtocol, syslogFacility, syslogSeverity) are defined as global variables in wled.h and are accessed directly in the SyslogPrinter implementation, rather than being class members.

wled00/xml.cpp (2)

Learnt from: blazoncek
PR: #4482
File: wled00/udp.cpp:147-149
Timestamp: 2025-02-19T12:43:34.199Z
Learning: ESP8266 and ESP32 platforms have different maximum segment name lengths in WLED, which can cause truncation when syncing segment names between devices. This platform difference affects the user experience when using the segment name sync feature.

Learnt from: blazoncek
PR: #4700
File: wled00/wled_server.cpp:409-414
Timestamp: 2025-05-26T16:09:34.325Z
Learning: In wled00/wled_server.cpp, the OTA update access control logic intentionally allows OTA updates from different subnets when otaSameSubnet is true AND a PIN is set. This was a conscious design decision by blazoncek to provide flexibility for remote OTA updates with PIN protection, though they acknowledged it may not be the optimal security model.

wled00/improv.cpp (2)

Learnt from: blazoncek
PR: #4482
File: wled00/udp.cpp:147-149
Timestamp: 2025-02-19T12:43:34.200Z
Learning: In WLED, maximum segment name length varies by platform:

  • ESP8266: 32 characters (WLED_MAX_SEGNAME_LEN = 32)
  • ESP32: 64 characters (WLED_MAX_SEGNAME_LEN = 64)
    This platform difference can cause truncation when syncing longer names from ESP32 to ESP8266. Additionally, the WLED UI has limitations regarding modified maximum segment name lengths.

Learnt from: blazoncek
PR: #4482
File: wled00/udp.cpp:147-149
Timestamp: 2025-02-19T12:43:34.199Z
Learning: ESP8266 and ESP32 platforms have different maximum segment name lengths in WLED, which can cause truncation when syncing segment names between devices. This platform difference affects the user experience when using the segment name sync feature.

wled00/wled.cpp (7)

Learnt from: blazoncek
PR: #4700
File: wled00/wled_server.cpp:409-414
Timestamp: 2025-05-26T16:09:34.325Z
Learning: In wled00/wled_server.cpp, the OTA update access control logic intentionally allows OTA updates from different subnets when otaSameSubnet is true AND a PIN is set. This was a conscious design decision by blazoncek to provide flexibility for remote OTA updates with PIN protection, though they acknowledged it may not be the optimal security model.

Learnt from: blazoncek
PR: #4482
File: wled00/udp.cpp:147-149
Timestamp: 2025-02-19T12:43:34.199Z
Learning: ESP8266 and ESP32 platforms have different maximum segment name lengths in WLED, which can cause truncation when syncing segment names between devices. This platform difference affects the user experience when using the segment name sync feature.

Learnt from: KrX3D
PR: #4664
File: wled00/syslog.cpp:50-51
Timestamp: 2025-04-26T12:51:04.993Z
Learning: In the WLED codebase, syslog configuration variables (syslogHost, syslogPort, syslogProtocol, syslogFacility, syslogSeverity) are defined as global variables in wled.h and are accessed directly in the SyslogPrinter implementation, rather than being class members.

Learnt from: blazoncek
PR: #4482
File: wled00/udp.cpp:147-149
Timestamp: 2025-02-19T12:43:34.200Z
Learning: In WLED, maximum segment name length varies by platform:

  • ESP8266: 32 characters (WLED_MAX_SEGNAME_LEN = 32)
  • ESP32: 64 characters (WLED_MAX_SEGNAME_LEN = 64)
    This platform difference can cause truncation when syncing longer names from ESP32 to ESP8266. Additionally, the WLED UI has limitations regarding modified maximum segment name lengths.

Learnt from: KrX3D
PR: #4237
File: usermods/INA219_v2/INA219_v2.cpp:265-276
Timestamp: 2025-04-18T22:27:58.634Z
Learning: When implementing MQTT message handling in WLED usermods, use strstr(topic, "/specific/path") instead of strcmp_P(topic, PSTR("/specific/path")) to properly match topics that include the device prefix. The full MQTT topic typically follows the pattern <mqttDeviceTopic>/specific/path.

Learnt from: blazoncek
PR: #4482
File: wled00/udp.cpp:343-347
Timestamp: 2025-02-19T12:41:22.676Z
Learning: The setName() method in WLED's Segment class (FX_fcn.cpp) handles all necessary validation internally, including:

  1. Null pointer checks
  2. Length validation against WLED_MAX_SEGNAME_LEN
  3. Memory allocation/reallocation
    No additional validation or name clearing is needed before calling setName().

Learnt from: blazoncek
PR: #4482
File: wled00/udp.cpp:343-347
Timestamp: 2025-02-19T12:41:22.676Z
Learning: The setName() method in WLED handles segment name validation internally. No additional length checks or name clearing is needed before calling setName().

wled00/data/settings_wifi.htm (1)

Learnt from: blazoncek
PR: #4482
File: wled00/udp.cpp:147-149
Timestamp: 2025-02-19T12:43:34.199Z
Learning: ESP8266 and ESP32 platforms have different maximum segment name lengths in WLED, which can cause truncation when syncing segment names between devices. This platform difference affects the user experience when using the segment name sync feature.

wled00/wled.h (7)

Learnt from: KrX3D
PR: #4664
File: wled00/syslog.cpp:50-51
Timestamp: 2025-04-26T12:51:04.993Z
Learning: In the WLED codebase, syslog configuration variables (syslogHost, syslogPort, syslogProtocol, syslogFacility, syslogSeverity) are defined as global variables in wled.h and are accessed directly in the SyslogPrinter implementation, rather than being class members.

Learnt from: blazoncek
PR: #4482
File: wled00/udp.cpp:147-149
Timestamp: 2025-02-19T12:43:34.200Z
Learning: In WLED, maximum segment name length varies by platform:

  • ESP8266: 32 characters (WLED_MAX_SEGNAME_LEN = 32)
  • ESP32: 64 characters (WLED_MAX_SEGNAME_LEN = 64)
    This platform difference can cause truncation when syncing longer names from ESP32 to ESP8266. Additionally, the WLED UI has limitations regarding modified maximum segment name lengths.

Learnt from: blazoncek
PR: #4482
File: wled00/udp.cpp:147-149
Timestamp: 2025-02-19T12:43:34.199Z
Learning: ESP8266 and ESP32 platforms have different maximum segment name lengths in WLED, which can cause truncation when syncing segment names between devices. This platform difference affects the user experience when using the segment name sync feature.

Learnt from: KrX3D
PR: #4585
File: usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.cpp:430-435
Timestamp: 2025-04-28T20:51:29.773Z
Learning: In WLED, bri is a global variable used for brightness control.

Learnt from: blazoncek
PR: #4658
File: wled00/const.h:140-141
Timestamp: 2025-04-26T19:19:07.600Z
Learning: In WLED, the WLED_MAX_PANELS macro is intentionally defined as a fixed constant value (18) with no redefinition mechanism, making it "unoverridable" - there's no need for a static assertion to check its maximum value.

Learnt from: blazoncek
PR: #4700
File: wled00/wled_server.cpp:409-414
Timestamp: 2025-05-26T16:09:34.325Z
Learning: In wled00/wled_server.cpp, the OTA update access control logic intentionally allows OTA updates from different subnets when otaSameSubnet is true AND a PIN is set. This was a conscious design decision by blazoncek to provide flexibility for remote OTA updates with PIN protection, though they acknowledged it may not be the optimal security model.

Learnt from: KrX3D
PR: #4585
File: usermods/seven_segment_display_reloaded_v2/seven_segment_display_reloaded_v2.h:121-136
Timestamp: 2025-04-27T09:37:28.415Z
Learning: Using PROGMEM for the seven-segment font array (umSSDRNumbers) in the WLED SSDR usermod causes compilation problems, so it should be left as a regular array.

🔇 Additional comments (20)
wled00/wled.h (1)

339-340: LGTM! Well-structured hostname unification changes.

The variable renaming from cmDNS to hostName and the addition of mDNSenabled flag provide clearer semantics and explicit control over mDNS functionality while maintaining backward compatibility.

wled00/wled_server.cpp (1)

235-235: LGTM! Consistent hostname variable usage.

The captive portal logic correctly uses the new hostName variable instead of the legacy cmDNS, maintaining identical functionality while aligning with the hostname unification effort.

wled00/improv.cpp (1)

209-212: Excellent security and consistency improvements.

The changes enhance buffer safety by using snprintf_P with size limits, align with the hostname unification by switching from cmDNS to hostName, and maintain identical functionality while improving code security.

wled00/xml.cpp (3)

175-175: LGTM - Improved buffer scope management.

Moving the buffer declaration to the broader function scope avoids redeclaration and improves code organization.


198-199: LGTM - Hostname unification implemented correctly.

The changes properly replace the legacy cmDNS variable with hostName and introduce the new mDNSenabled flag, aligning with the PR's hostname unification objectives.


252-259: LGTM - Security and logic improvements.

Good improvements:

  • Added apActive check for more robust condition logic
  • Replaced sprintf with snprintf using sizeof(s)-1 to prevent buffer overflow
  • Added informative comment about AP MAC address availability

The use of sizeof(s)-1 correctly preserves space for null termination.

wled00/data/settings_ui.htm (3)

158-158: LGTM - Sync toggle reference cleanup.

Proper removal of the sync toggle (ST) reference from the form submission logic, aligning with the broader cleanup mentioned in the AI summary.


221-221: LGTM - Improved device name labeling and validation.

Good changes:

  • "Device name" is more intuitive than "Server description"
  • Added minlength="2" provides reasonable validation
  • Aligns with the hostname unification objectives

223-223: LGTM - Consistent warning text styling.

Adding the "warn" CSS class provides consistent styling for informational text across the UI.

wled00/wled.cpp (4)

141-141: LGTM - Proper mDNS control implementation.

Correctly conditionalizes mDNS updates on ESP8266 based on the mDNSenabled flag, preventing unnecessary updates when mDNS is disabled.


423-423: LGTM - Smart hostname generation.

Excellent approach to generate unique hostnames automatically when the default is detected. Using the MAC address suffix ensures uniqueness across devices while maintaining readable hostnames.


489-489: LGTM - Hostname unification for OTA.

Properly replaces the legacy cmDNS variable with hostName for ArduinoOTA, ensuring consistent hostname usage across all network services.


703-707: LGTM - Proper mDNS initialization with user control.

Excellent implementation:

  • Conditionally initializes mDNS based on mDNSenabled flag
  • Uses unified hostName instead of legacy cmDNS
  • Maintains safety pattern of calling MDNS.end() before begin()

This provides users proper control over mDNS functionality while ensuring consistent hostname usage.

wled00/data/settings_wifi.htm (7)

6-6: LGTM - Enhanced network settings UI.

Good improvements:

  • Changed title to "Network Settings" reflecting broader scope
  • Added hostname input with appropriate pattern validation [a-zA-Z0-9_\-]*
  • Implemented real-time mDNS URL generation with oninput and onchange handlers
  • Dynamic visibility control for mDNS URL display

The hostname validation pattern appropriately restricts to safe characters for network identifiers.

Also applies to: 194-197


199-211: LGTM - Improved WiFi section organization.

Good reorganization that simplifies the WiFi section structure and removes redundant elements, improving the overall user experience and clarity.


211-211: LGTM - Consistent AP SSID validation.

Adding pattern validation to the AP SSID input using the same safe character set as hostname validation ensures consistency and security across network identifiers.


227-243: LGTM - Proper Ethernet/ESP-NOW mutual exclusivity.

Excellent implementation:

  • Comprehensive Ethernet board support options
  • Clear mutual exclusivity logic preventing invalid configurations
  • Informative warning about ESP-NOW/Ethernet incompatibility
  • JavaScript handler properly enforces the constraint by disabling ESP-NOW when Ethernet is selected

This prevents user confusion and invalid configurations.


245-261: LGTM - Enhanced ESP-NOW section.

Good improvements:

  • Better positioning above experimental section
  • Enhanced remote device management UI
  • Bidirectional mutual exclusivity enforcement (ESP-NOW disables Ethernet and vice versa)
  • Improved user guidance with clear explanations

The mutual exclusivity logic works in both directions, providing consistent user experience.


147-147: LGTM - Bidirectional mutual exclusivity enforcement.

Good addition to disable Ethernet when ESP-NOW is enabled, ensuring consistent mutual exclusivity regardless of which setting the user changes first.


180-183: LGTM - Clean mDNS URL generation.

Well-implemented function that:

  • Updates mDNS URL display in real-time based on hostname input
  • Properly toggles visibility based on mDNS enable state
  • Provides immediate user feedback for better UX

Clean implementation with appropriate DOM manipulation.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@blazoncek blazoncek requested a review from willmmiles June 27, 2025 14:33
char hostname[64];
prepareHostname(hostname);
char hostname[33];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the change from 64 to 33 and this seems out of step with other parts of the code where you are using 25

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the UI fields are 64 bytes.

@netmindz
Copy link
Member

netmindz commented Jul 6, 2025

With this change, can we still have no mDNS but still the user-defined hostname? (used in DHCP request for "regular" DNS)

@blazoncek
Copy link
Collaborator Author

With this change, can we still have no mDNS but still the user-defined hostname?

Yes, the fallback is UI device name.

@netmindz
Copy link
Member

netmindz commented Jul 9, 2025

Yeah that doesn't quite make sense then.

While I accept that not putting anything in there will maintain existing behaviour, I thought that part of the reason for this change is that current behaviour is unclear.

Most users would expect the network hostname to be with the network settings, not automatically generated from a setting under UI.

So this change to move hostname to be consistent for regular DNS and mDNS is an improvement, but it would be sad if you couldn't see your own regular hostname without being forced to enable mDNS as the only way to disable is to remove the hostname

@blazoncek
Copy link
Collaborator Author

Then the only option is to add a checkmark for enabling mDNS.
I would postpone that for a later time.

@blazoncek
Copy link
Collaborator Author

@netmindz @willmmiles @DedeHai @softhack007 @Aircoookie I would like we all agree on the proposed change since it may disrupt some people's network configuration and we should be aware of this change.
Unfortunately I do not see a solution apart from adding another field for (non-mDNS) hostname or adding checkmark for enabling mDNS (slightly bigger change).

As a pro for this change it fixes wrong/missing hostname on change or boot.

@DedeHai
Copy link
Collaborator

DedeHai commented Jul 16, 2025

this is above my networking know-how. I exclusively work with IPs.

@blazoncek
Copy link
Collaborator Author

this is above my networking know-how. I exclusively work with IPs.

It is not really technical. This PR switches the hostname generation to mDNS name instead of UI name (by default). UI name is used as a fallback when user does not want to use mDNS and empties mDNS name.

In current situation UI name is WLED by default and if user does not change that there may be several devices with same hostname. Default mDNS name is a combination of "wled-" and MAC address.

@DedeHai
Copy link
Collaborator

DedeHai commented Jul 16, 2025

Ah I get it, still don't really understand the background, did not have time yet to read the issues solved with this.
I never had any issues with all devices having the same name and adding a cryptic hex number to it does not change the situation from my point of view. If I need to know what device it is, I rename it manually. So if there is a technical reason to do so, no objection.

Can't really comment on "disrupting network". I do not use names, I assign fixed IPs.

All I want to add: it must not be convoluted, like input fields need to be clear. If I change mDNS name, it should not change the host name and vice versa (if that is how it currently is). If any naming settings are linked, they MUST be in the same settings page and synced directly in that page so its obvious.

edit:
I glanced at the issues this is solving and uinifying makes sense.

@blazoncek blazoncek marked this pull request as draft July 18, 2025 07:38
@blazoncek
Copy link
Collaborator Author

I'm pulling this to draft as perhaps we need to discuss the following:

  • mDNS name
  • hostname for DHCP (dnsmasq), Arduino, WiFi identification, etc
  • device name (UI)

IMO hostname and mDNS name should be identical (not necessarily the case with this PR) however device name should not be used in the networking context (it is with this PR if user erases mDNS).

I have modified the entire name handling and introduced explicit mDNS selection as a POC in my fork (unpublished ATM).

…hostname to "nw" key in config JSON - add new config key in "nw" for mDNS (bool) - remove `prepareHostname()` function - update mDNS calls - add hostname update for Ethernet - move WiFi configuration to cfg.json - rename LED and WiFi to Hardware and Network in settings - reorder network settings
@blazoncek blazoncek marked this pull request as ready for review July 21, 2025 12:04
<div id="ESPNOW">
Enable ESP-NOW: <input type="checkbox" name="RE" onchange="tE()"><br>
<i>Listen for events over ESP-NOW<br>
Keep disabled if not using a remote or wireless sync, increases power consumption.<br></i>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name it ESPNow-Sync instead of wireless sync?

@blazoncek
Copy link
Collaborator Author

@willmmiles does the latest push fulfill what we talked about (single hostname across all networking options)? It does not change UI name, though, which remains WLED by default but can be overridden during compile.

@blazoncek blazoncek added the connectivity Issue regarding protocols, WiFi connection or availability of interfaces label Jul 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
connectivity Issue regarding protocols, WiFi connection or availability of interfaces
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Simplify "device name" across app
3 participants