Make hostname prefix configurable
This commit is contained in:
parent
43bf05ffb9
commit
03617b4e04
7 changed files with 184 additions and 3 deletions
|
@ -10,8 +10,9 @@ String getMyHostname() {
|
|||
//WiFi.macAddress(mac);
|
||||
esp_efuse_mac_get_default(mac);
|
||||
char hostname[15];
|
||||
snprintf(hostname, sizeof(hostname), "btclock-%02x%02x%02x",
|
||||
mac[3], mac[4], mac[5]);
|
||||
String hostnamePrefix = preferences.getString("hostnamePrefix", "btclock");
|
||||
snprintf(hostname, sizeof(hostname), "%s-%02x%02x%02x",
|
||||
hostnamePrefix, mac[3], mac[4], mac[5]);
|
||||
return hostname;
|
||||
}
|
||||
|
||||
|
|
|
@ -272,6 +272,7 @@ void onApiSettingsGet(AsyncWebServerRequest *request)
|
|||
root["mdnsEnabled"] = preferences.getBool("mdnsEnabled", true);
|
||||
root["otaEnabled"] = preferences.getBool("otaEnabled", true);
|
||||
root["fetchEurPrice"] = preferences.getBool("fetchEurPrice", false);
|
||||
root["hostnamePrefix"] = preferences.getString("hostnamePrefix", "btclock");
|
||||
root["hostname"] = getMyHostname();
|
||||
root["ip"] = WiFi.localIP();
|
||||
|
||||
|
@ -431,6 +432,14 @@ void onApiSettingsPost(AsyncWebServerRequest *request)
|
|||
settingsChanged = true;
|
||||
}
|
||||
|
||||
if (request->hasParam("hostnamePrefix", true))
|
||||
{
|
||||
AsyncWebParameter *hostnamePrefix = request->getParam("hostnamePrefix", true);
|
||||
|
||||
preferences.putString("hostnamePrefix", hostnamePrefix->value().c_str());
|
||||
settingsChanged = true;
|
||||
}
|
||||
|
||||
if (request->hasParam("ledBrightness", true))
|
||||
{
|
||||
AsyncWebParameter *ledBrightness = request->getParam("ledBrightness", true);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue