You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have been wondering why there are 3 options for a name.
Maybe a checkbox [ ] Single host / ap / server name where "Single" gets replaced by "Different" once it is selected. The implication is the default setting is [Single] rather than [Different] Host / AP / Server Names
I actually would like to keep the Server Name separate from the DNS/DHCP hostname.
Having the MDNS and DNS/DHCP names identical (without the .local of course) makes more sense.
The Server Name which could be seen as a Friendly Name is usually longer and gets truncated badly in a character limited DNS name.
AP name could be inherited from either, probably from the Server Name.
I would assume most people would want 2 names: mDNS/DHCP/hostname and device name/UI name.
Currently WLED also stores 2 names cmDNS and serverDescription but their use is a bit odd. cmDNS is used for mDNS but not hostname (which is associated with DHCP registration). Instead serverDescription is used as hostname/DHCP registration and UI device name. It is also used in Improv and E1.31.
I think cmDNs (a field in WiFi settings) should be used for hostname and have serverDescription(field in UI settings) used only for UI/Improv/E1.31.
Another oddity is how current hostname is constructed from serverDescription.
I was looking at the code for mDNS and hostname and did find it a bit odd.
Should we change how hostname/mDNS/DHCP name is constructed?
Oh good, it's not just me - I was definitely surprised that the mDNS name and DHCP hostname were different!
I agree that we should have 3 settings:
hostname (mDNS and DHCP; character set restricted to what's allowable for DNS)
UI display name
AP name
In a clean-sheet design I would suggest:
If unset, hostname defaults to WLED-abcdef, where abcdef are the last three bytes of the MAC address;
If unset, UI display name defaults to the hostname;
If unset, AP name defaults to either hostname or WLED-AP (compile time option)
..and for the latter two cases, we store "unset" explicitly (perhaps as an empty string), so it will functionally track changes to the hostname.
I'd also suggest putting the hostname box at the top of the network settings page, before the wifi SSIDs. During initial setup, it makes it easy to see (or change) how you'll refer to your device before we lose network connectivity to it. (I'll admit that I have one long-lived WLED board on my test network with no LEDs actually connected that I principally use as a way to find new boards via the nodes list after I join them to the wifi!)
This would let us leverage the hostname as a "device name" in the default/common state.
// prepare a unique hostname based on the last 6 digits of the MAC address// if no mDNS name or serverDescription is set, otherwise use cmDNS or serverDescription// the hostname will be at most 24 characters long, starting with "wled-"// and containing only alphanumeric characters and hyphens// the hostname will not end with a hyphen and will be null-terminatedvoidprepareHostname(char* hostname)
{
// create a unique hostname based on the last 6 digits of the MAC address if no mDNS name or serverDescription is setsprintf_P(hostname, PSTR("wled-%*s"), 6, escapedMac.c_str() + 6);
constchar *pC = cmDNS; // use cmDNS as hostname if setif (strlen(pC) == 0) pC = serverDescription; // else use serverDescriptionunsigned pos = 5; // keep "wled-" from unique namewhile (*pC && pos < 24) { // while !null and not over lengthif (isalnum(*pC)) { // if the current char is alpha-numeric append it to the hostname
hostname[pos++] = *pC;
} elseif (*pC == '' || *pC == '_' || *pC == '-' || *pC == '+' || *pC == '!' || *pC == '?' || *pC == '*') {
hostname[pos++] = '-';
}
// else do nothing - no leading hyphens and do not include hyphens for all other characters.
pC++;
}
// last character must not be hyphenwhile (pos > 4 && hostname[pos-1] == '-') pos--;
hostname[pos] = '\0'; // terminate string (leave at least "wled")
}
Activity
huggy-d1 commentedon Oct 13, 2020
I have been wondering why there are 3 options for a name.
Maybe a checkbox [ ] Single host / ap / server name where "Single" gets replaced by "Different" once it is selected. The implication is the default setting is [Single] rather than [Different] Host / AP / Server Names
tablatronix commentedon Oct 14, 2020
Or just a checkbox for each input [use device name] for apname and hostname fields
mateuszdrab commentedon Dec 24, 2024
I actually would like to keep the Server Name separate from the DNS/DHCP hostname.
Having the MDNS and DNS/DHCP names identical (without the .local of course) makes more sense.
The Server Name which could be seen as a Friendly Name is usually longer and gets truncated badly in a character limited DNS name.
AP name could be inherited from either, probably from the Server Name.
netmindz commentedon Dec 26, 2024
You definitely want to retain the ability for the AP name to have the mac address based suffix
mateuszdrab commentedon Dec 26, 2024
Yup, same with hostname, all I need is that name to be equal to the mdns hostname.
blazoncek commentedon Jun 6, 2025
Let me revive tis issue (in regards to #4586).
I was looking at the code for mDNS and hostname and did find it a bit odd.
WLED/wled00/wled.cpp
Line 466 in a87b562
WLED/wled00/wled.cpp
Lines 658 to 670 in a87b562
WLED/wled00/cfg.cpp
Lines 59 to 61 in a87b562
I would assume most people would want 2 names: mDNS/DHCP/hostname and device name/UI name.
Currently WLED also stores 2 names
cmDNSandserverDescriptionbut their use is a bit odd.cmDNSis used for mDNS but not hostname (which is associated with DHCP registration). InsteadserverDescriptionis used as hostname/DHCP registration and UI device name. It is also used in Improv and E1.31.I think
cmDNs(a field in WiFi settings) should be used for hostname and haveserverDescription(field in UI settings) used only for UI/Improv/E1.31.Another oddity is how current hostname is constructed from
serverDescription.WLED/wled00/util.cpp
Lines 118 to 139 in a87b562
As for AP name, IMO that should be independent from anything else.
Should we change how hostname/mDNS/DHCP name is constructed?
willmmiles commentedon Jun 6, 2025
Oh good, it's not just me - I was definitely surprised that the mDNS name and DHCP hostname were different!
I agree that we should have 3 settings:
In a clean-sheet design I would suggest:
..and for the latter two cases, we store "unset" explicitly (perhaps as an empty string), so it will functionally track changes to the hostname.
I'd also suggest putting the hostname box at the top of the network settings page, before the wifi SSIDs. During initial setup, it makes it easy to see (or change) how you'll refer to your device before we lose network connectivity to it. (I'll admit that I have one long-lived WLED board on my test network with no LEDs actually connected that I principally use as a way to find new boards via the nodes list after I join them to the wifi!)
This would let us leverage the hostname as a "device name" in the default/common state.
blazoncek commentedon Jun 6, 2025
Like so?
willmmiles commentedon Jun 6, 2025
I guess I was proposing scrapping the use of
serverDescriptionin hostnames altogether. I was thinking something more like:blazoncek commentedon Jun 7, 2025
cmDNSwould still need cleaning which is not done currently.willmmiles commentedon Jun 7, 2025
Good point; I'd assumed that would be done in
deserialzeJson().Hostname unification
Hostname unification