Skip to content

Commit

Permalink
mDNS restored on mega
Browse files Browse the repository at this point in the history
  • Loading branch information
Asbelos committed Aug 25, 2024
1 parent 06a353c commit 4ed2ee9
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions EthernetInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
#include "DCCTimer.h"
#if __has_include ( "MDNS_Generic.h")
#include "MDNS_Generic.h"
// #define DO_MDNS !!!!!!!!!!!!! breaks mega
#define DO_MDNS
EthernetUDP udp;
MDNS mdns(udp);
#endif


//extern void looptimer(unsigned long timeout, const FSH* message);
extern void looptimer(unsigned long timeout, const FSH* message);

bool EthernetInterface::connected=false;
EthernetServer * EthernetInterface::server= nullptr;
Expand All @@ -52,7 +52,11 @@ RingStream * EthernetInterface::outboundRing = nullptr;

void EthernetInterface::setup() // STM32 VERSION
{
DIAG(F("Ethernet begin"));
DIAG(F("Ethernet begin"
#ifdef DO_MDNS
" with mDNS"
#endif
));

#ifdef STM32_ETHERNET
// Set a HOSTNAME for the DHCP request - a nice to have, but hard it seems on LWIP for STM32
Expand Down Expand Up @@ -126,15 +130,17 @@ void EthernetInterface::setup() // STM32 VERSION
void EthernetInterface::loop()
{
if (!connected) return;

looptimer(5000, F("E.loop"));

static bool warnedAboutLink=false;
if (Ethernet.linkStatus() == LinkOFF){
if (warnedAboutLink) return;
DIAG(F("Ethernet link OFF"));
warnedAboutLink=true;
return;
}

looptimer(5000, F("E.loop warn"));

// link status must be ok here
if (warnedAboutLink) {
DIAG(F("Ethernet link RESTORED"));
Expand All @@ -144,6 +150,8 @@ void EthernetInterface::loop()
#ifdef DO_MDNS
// Always do this because we don't want traffic to intefere with being found!
mdns.run();
looptimer(5000, F("E.mdns"));

#endif

//
Expand All @@ -163,7 +171,8 @@ void EthernetInterface::loop()
//DIAG(F("maintained"));
break;
}

looptimer(5000, F("E.maintain"));

// get client from the server
#if defined (STM32_ETHERNET)
// STM32Ethernet doesn't use accept(), just available()
Expand Down

0 comments on commit 4ed2ee9

Please sign in to comment.