diff --git a/src/js/mdns_discovery.js b/src/js/mdns_discovery.js index fb8fd0c8..4bc62f83 100644 --- a/src/js/mdns_discovery.js +++ b/src/js/mdns_discovery.js @@ -35,8 +35,7 @@ MdnsDiscovery.initialize = function() { fqdn: `${service.name}._http._tcp.local.`, ready: true, }); - } - else if (action === 'added' && service.name.includes("elrs_rx")) { + } else if (action === 'added' && service.name.includes("elrs_rx")) { //restart zeroconf if service ip doesn't arrive in 1000ms setTimeout(() => { if (self.mdnsBrowser.services.length === 0 || self.mdnsBrowser.services.filter(s => s.fqdn === `${service.name}._http._tcp.local.`)[0].ready === false) { @@ -47,7 +46,8 @@ MdnsDiscovery.initialize = function() { } }); } - reinit(); + + reinit(); } else { const bonjour = require('bonjour')(); diff --git a/src/js/port_handler.js b/src/js/port_handler.js index 678f858a..b077566e 100644 --- a/src/js/port_handler.js +++ b/src/js/port_handler.js @@ -50,6 +50,10 @@ PortHandler.reinitialize = function () { this.showAllSerialDevices = getConfig('showAllSerialDevices').showAllSerialDevices; this.useMdnsBrowser = getConfig('useMdnsBrowser').useMdnsBrowser; + if (this.useMdnsBrowser) { + MdnsDiscovery.initialize(); + } + this.check(); // start listening, check after TIMEOUT_CHECK ms }; diff --git a/src/js/serial_backend.js b/src/js/serial_backend.js index 304c937b..38a42156 100644 --- a/src/js/serial_backend.js +++ b/src/js/serial_backend.js @@ -12,7 +12,6 @@ import PortUsage from "./port_usage"; import PortHandler from "./port_handler"; import CONFIGURATOR, { API_VERSION_1_45, API_VERSION_1_46 } from "./data_storage"; import serial from "./serial"; -import MdnsDiscovery from "./mdns_discovery"; import UI_PHONES from "./phones_ui"; import { bit_check } from './bit.js'; import { sensor_status, have_sensor } from "./sensor_helpers"; @@ -171,7 +170,6 @@ export function initializeSerialBackend() { setConfig({'auto_connect': GUI.auto_connect}); }); - MdnsDiscovery.initialize(); PortHandler.initialize(); PortUsage.initialize(); }