mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
add option to switch mDNS off/on
This commit is contained in:
@@ -38,6 +38,7 @@
|
||||
- Added Shower Alert trigger time and cold shot time [#436](https://github.com/emsesp/EMS-ESP32/issues/436)
|
||||
- Improved Table layout in Web UI (searching, filtering, sorting, exporting to CSV)
|
||||
- API fetch individual attributes from an entity [#462](https://github.com/emsesp/EMS-ESP32/issues/462)
|
||||
- Option to disable mDNS
|
||||
|
||||
### Fixed
|
||||
|
||||
|
||||
@@ -56,7 +56,8 @@ const WiFiSettingsForm: FC = () => {
|
||||
enableIPv6: false,
|
||||
bandwidth20: false,
|
||||
tx_power: 20,
|
||||
nosleep: false
|
||||
nosleep: false,
|
||||
enableMDNS: true
|
||||
});
|
||||
}
|
||||
setInitialized(true);
|
||||
@@ -153,6 +154,11 @@ const WiFiSettingsForm: FC = () => {
|
||||
label="Use Lower WiFi Bandwidth"
|
||||
/>
|
||||
|
||||
<BlockFormControlLabel
|
||||
control={<Checkbox name="enableMDNS" checked={data.enableMDNS} onChange={updateFormValue} />}
|
||||
label="Enable mDNS Service"
|
||||
/>
|
||||
|
||||
<Typography sx={{ pt: 2 }} variant="h6" color="primary">
|
||||
General
|
||||
</Typography>
|
||||
|
||||
@@ -47,6 +47,7 @@ export interface NetworkSettings {
|
||||
subnet_mask?: string;
|
||||
dns_ip_1?: string;
|
||||
dns_ip_2?: string;
|
||||
enableMDNS: boolean;
|
||||
}
|
||||
|
||||
export interface WiFiNetworkList {
|
||||
|
||||
@@ -38,6 +38,7 @@ class NetworkSettings {
|
||||
bool bandwidth20;
|
||||
int8_t tx_power;
|
||||
bool nosleep;
|
||||
bool enableMDNS;
|
||||
|
||||
// optional configuration for static IP address
|
||||
IPAddress localIP;
|
||||
@@ -56,6 +57,7 @@ class NetworkSettings {
|
||||
root["bandwidth20"] = settings.bandwidth20;
|
||||
root["tx_power"] = settings.tx_power;
|
||||
root["nosleep"] = settings.nosleep;
|
||||
root["enableMDNS"] = settings.enableMDNS;
|
||||
|
||||
// extended settings
|
||||
JsonUtils::writeIP(root, "local_ip", settings.localIP);
|
||||
@@ -74,6 +76,7 @@ class NetworkSettings {
|
||||
settings.bandwidth20 = root["bandwidth20"] | false;
|
||||
settings.tx_power = root["tx_power"] | 20;
|
||||
settings.nosleep = root["nosleep"] | false;
|
||||
settings.enableMDNS = root["enableMDNS"] | true;
|
||||
|
||||
// extended settings
|
||||
JsonUtils::readIP(root, "local_ip", settings.localIP);
|
||||
|
||||
@@ -189,6 +189,8 @@ void WebStatusService::webStatusService(AsyncWebServerRequest * request) {
|
||||
void WebStatusService::mDNS_start() const {
|
||||
#ifndef EMSESP_STANDALONE
|
||||
MDNS.end();
|
||||
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) {
|
||||
if (networkSettings.enableMDNS) {
|
||||
if (!MDNS.begin(EMSESP::system_.hostname().c_str())) {
|
||||
EMSESP::logger().warning(F("Failed to start mDNS responder service"));
|
||||
return;
|
||||
@@ -201,9 +203,17 @@ void WebStatusService::mDNS_start() const {
|
||||
|
||||
MDNS.addServiceTxt("http", "tcp", "version", EMSESP_APP_VERSION);
|
||||
MDNS.addServiceTxt("http", "tcp", "address", address_s.c_str());
|
||||
#endif
|
||||
|
||||
EMSESP::logger().info(F("mDNS responder service started"));
|
||||
}
|
||||
});
|
||||
#else
|
||||
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) {
|
||||
if (networkSettings.enableMDNS) {
|
||||
EMSESP::logger().info(F("mDNS responder service started"));
|
||||
}
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace emsesp
|
||||
Reference in New Issue
Block a user