Skip to content

Commit

Permalink
Move mDNS initialization (#3412)
Browse files Browse the repository at this point in the history
  • Loading branch information
haslinghuis committed Apr 9, 2023
1 parent 5344781 commit ef40e88
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/js/mdns_discovery.js
Expand Up @@ -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) {
Expand All @@ -47,7 +46,8 @@ MdnsDiscovery.initialize = function() {
}
});
}
reinit();

reinit();
} else {
const bonjour = require('bonjour')();

Expand Down
4 changes: 4 additions & 0 deletions src/js/port_handler.js
Expand Up @@ -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
};

Expand Down
2 changes: 0 additions & 2 deletions src/js/serial_backend.js
Expand Up @@ -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";
Expand Down Expand Up @@ -171,7 +170,6 @@ export function initializeSerialBackend() {
setConfig({'auto_connect': GUI.auto_connect});
});

MdnsDiscovery.initialize();
PortHandler.initialize();
PortUsage.initialize();
}
Expand Down

0 comments on commit ef40e88

Please sign in to comment.