1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-23 16:16:13 +01:00

mDNS entry now uses IP_PORT and WIFI_HOSTNAME

This commit is contained in:
pmantoine 2024-02-01 20:22:32 +09:00
parent d1f558d64f
commit c0f69cd278

View File

@ -187,8 +187,8 @@ bool EthernetInterface::checkLink() {
} }
LCD(4,F("IP: %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]); LCD(4,F("IP: %d.%d.%d.%d"), ip[0], ip[1], ip[2], ip[3]);
LCD(5,F("Port:%d"), IP_PORT); LCD(5,F("Port:%d"), IP_PORT);
mdns.begin(Ethernet.localIP(), "dccex"); // hostname mdns.begin(Ethernet.localIP(), WIFI_HOSTNAME); // hostname
mdns.addServiceRecord("dccex._withrottle", 2560, MDNSServiceTCP); mdns.addServiceRecord(WIFI_HOSTNAME "._withrottle", IP_PORT, MDNSServiceTCP);
// only create a outboundRing it none exists, this may happen if the cable // only create a outboundRing it none exists, this may happen if the cable
// gets disconnected and connected again // gets disconnected and connected again
if(!outboundRing) if(!outboundRing)
@ -196,7 +196,7 @@ bool EthernetInterface::checkLink() {
} }
return true; return true;
} else { // LinkOFF } else { // LinkOFF
if (connected) { if (connected) { // Were connected, but no longer without a LINK!
DIAG(F("Ethernet cable disconnected")); DIAG(F("Ethernet cable disconnected"));
connected=false; connected=false;
//clean up any client //clean up any client
@ -204,6 +204,7 @@ bool EthernetInterface::checkLink() {
if(clients[socket].connected()) if(clients[socket].connected())
clients[socket].stop(); clients[socket].stop();
} }
mdns.removeServiceRecord(IP_PORT, MDNSServiceTCP);
// tear down server // tear down server
delete server; delete server;
server = nullptr; server = nullptr;