1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-23 21:01:25 +01:00

MDNS Generic library integration

This commit is contained in:
pmantoine 2024-01-28 13:31:43 +09:00
parent 6cdde5d3c6
commit ad09360a54
4 changed files with 18 additions and 2 deletions

View File

@ -29,6 +29,10 @@
#include "CommandDistributor.h" #include "CommandDistributor.h"
#include "WiThrottle.h" #include "WiThrottle.h"
#include "DCCTimer.h" #include "DCCTimer.h"
#include "MDNS_Generic.h"
EthernetUDP udp;
MDNS mdns(udp);
EthernetInterface * EthernetInterface::singleton=NULL; EthernetInterface * EthernetInterface::singleton=NULL;
/** /**
@ -175,6 +179,8 @@ bool EthernetInterface::checkLink() {
server->begin(); server->begin();
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.addServiceRecord("dccex._withrottle", 2560, 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)
@ -242,7 +248,11 @@ void EthernetInterface::loop2() {
if (!clients[socket].connected()) { // stop any clients which disconnect if (!clients[socket].connected()) { // stop any clients which disconnect
CommandDistributor::forget(socket); CommandDistributor::forget(socket);
clients[socket].stop(); clients[socket].stop();
#if defined(ARDUINO_ARCH_AVR)
clients[socket]=NULL; clients[socket]=NULL;
#else
clients[socket]=(EthernetClient)nullptr;
#endif
//if (Diag::ETHERNET) //if (Diag::ETHERNET)
DIAG(F("Ethernet: disconnect %d "), socket); DIAG(F("Ethernet: disconnect %d "), socket);
return; // Trick: So that we do not continue in this loop with client that is NULL return; // Trick: So that we do not continue in this loop with client that is NULL
@ -262,6 +272,8 @@ void EthernetInterface::loop2() {
} }
} }
mdns.run();
WiThrottle::loop(outboundRing); WiThrottle::loop(outboundRing);
// handle at most 1 outbound transmission // handle at most 1 outbound transmission

View File

@ -46,7 +46,7 @@
#define MAX_SOCK_NUM 10 #define MAX_SOCK_NUM 10
#else #else
#include "Ethernet.h" #include "Ethernet.h"
#define MAX_SOCK_NUM 4 // #define MAX_SOCK_NUM 4
#endif #endif
#include "RingStream.h" #include "RingStream.h"

View File

@ -103,6 +103,7 @@ framework = arduino
lib_deps = lib_deps =
${env.lib_deps} ${env.lib_deps}
arduino-libraries/Ethernet arduino-libraries/Ethernet
MDNS_Generic
SPI SPI
monitor_speed = 115200 monitor_speed = 115200
monitor_echo = yes monitor_echo = yes
@ -251,6 +252,7 @@ framework = arduino
lib_deps = ${env.lib_deps} lib_deps = ${env.lib_deps}
stm32duino/STM32Ethernet @ ^1.3.0 stm32duino/STM32Ethernet @ ^1.3.0
stm32duino/STM32duino LwIP @ ^2.1.2 stm32duino/STM32duino LwIP @ ^2.1.2
MDNS_Generic
build_flags = -std=c++17 -Os -g2 -Wunused-variable build_flags = -std=c++17 -Os -g2 -Wunused-variable
monitor_speed = 115200 monitor_speed = 115200
monitor_echo = yes monitor_echo = yes
@ -266,6 +268,7 @@ framework = arduino
lib_deps = ${env.lib_deps} lib_deps = ${env.lib_deps}
stm32duino/STM32Ethernet @ ^1.3.0 stm32duino/STM32Ethernet @ ^1.3.0
stm32duino/STM32duino LwIP @ ^2.1.2 stm32duino/STM32duino LwIP @ ^2.1.2
MDNS_Generic
build_flags = -std=c++17 -Os -g2 -Wunused-variable build_flags = -std=c++17 -Os -g2 -Wunused-variable
monitor_speed = 115200 monitor_speed = 115200
monitor_echo = yes monitor_echo = yes

View File

@ -3,7 +3,8 @@
#include "StringFormatter.h" #include "StringFormatter.h"
#define VERSION "5.2.27stm32ECvf" #define VERSION "5.2.27stm32ECvfmdns"
// 5.2.XX - MDNS Generic library integration for Ethernet
// 5.2.XX - Variable frequency for DC mode // 5.2.XX - Variable frequency for DC mode
// 5.2.27 - Bugfix: IOExpander memory allocation // 5.2.27 - Bugfix: IOExpander memory allocation
// 5.2.26 - Silently ignore overridden HAL defaults // 5.2.26 - Silently ignore overridden HAL defaults