Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2022-07-13 13:31:58 +0300
committerDavid Crocker <dcrocker@eschertech.com>2022-07-13 13:31:58 +0300
commitddba608f63a0664a3bb39c258bfc43b8b6ac2958 (patch)
tree4bcacb0b874232bd5f53cc0abe8071edf2956e43
parentc6f0aeb4fc1586712b81b094317b8a9eec9e8ede (diff)
Multicast bug fixes
-rw-r--r--src/Networking/LwipEthernet/Lwip/lwipopts.h2
-rw-r--r--src/Networking/LwipEthernet/LwipEthernetInterface.cpp9
-rw-r--r--src/Networking/MulticastResponder.cpp13
-rw-r--r--src/Networking/Network.cpp3
4 files changed, 22 insertions, 5 deletions
diff --git a/src/Networking/LwipEthernet/Lwip/lwipopts.h b/src/Networking/LwipEthernet/Lwip/lwipopts.h
index dc747e95..ec45aee7 100644
--- a/src/Networking/LwipEthernet/Lwip/lwipopts.h
+++ b/src/Networking/LwipEthernet/Lwip/lwipopts.h
@@ -267,7 +267,7 @@ extern uint32_t random32(void) noexcept;
#define LWIP_NETIF_HOSTNAME 1
/** The maximum number of services per netif */
-#define MDNS_MAX_SERVICES 4
+#define MDNS_MAX_SERVICES 5 // increased from 4 to 5 to include _duet_discovery service
/*
diff --git a/src/Networking/LwipEthernet/LwipEthernetInterface.cpp b/src/Networking/LwipEthernet/LwipEthernetInterface.cpp
index 58c9da14..027c4daa 100644
--- a/src/Networking/LwipEthernet/LwipEthernetInterface.cpp
+++ b/src/Networking/LwipEthernet/LwipEthernetInterface.cpp
@@ -50,7 +50,14 @@ extern "C"
extern struct netif gs_net_if;
}
-const char * const MdnsServiceStrings[NumProtocols] = { "_http", "_ftp", "_telnet" };
+const char * const MdnsServiceStrings[NumProtocols] =
+{
+ "_http", "_ftp", "_telnet",
+#if SUPPORT_MULTICAST_DISCOVERY
+ "_duet_discovery"
+#endif
+};
+
const char * const MdnsTxtRecords[2] = { "product=" FIRMWARE_NAME, "version=" VERSION };
const unsigned int MdnsTtl = 10 * 60; // same value as on the Duet 0.6/0.8.5
diff --git a/src/Networking/MulticastResponder.cpp b/src/Networking/MulticastResponder.cpp
index 9fe7e3aa..f39d120a 100644
--- a/src/Networking/MulticastResponder.cpp
+++ b/src/Networking/MulticastResponder.cpp
@@ -51,7 +51,7 @@ void MulticastResponder::Spin() noexcept
{
debugPrintf("Rx UDP: addr %u.%u.%u.%u port %u data",
(unsigned int)((receivedIpAddr >> 24) & 0xFF), (unsigned int)((receivedIpAddr >> 16) & 0xFF), (unsigned int)((receivedIpAddr >> 8) & 0xFF), (unsigned int)(receivedIpAddr & 0xFF), receivedPort);
- for (size_t i = 0; i < receivedPbuf->len; ++i)
+ for (size_t i = 0; i < rxPbuf->len; ++i)
{
debugPrintf(" %02x", ((const uint8_t*)(rxPbuf->payload))[i]);
}
@@ -64,26 +64,28 @@ void MulticastResponder::Spin() noexcept
void MulticastResponder::Diagnostics(MessageType mtype) noexcept
{
- reprap.GetPlatform().MessageF(mtype, "=== Multicast handler ===\nMessages processed %u\n", messagesProcessed);
+ reprap.GetPlatform().MessageF(mtype, "=== Multicast handler ===\nResponder is %s, messages processed %u\n", (active) ? "active" : "inactive", messagesProcessed);
}
void MulticastResponder::Start(TcpPort port) noexcept
{
if (ourPcb == nullptr)
{
- ourPcb = udp_new();
+ ourPcb = udp_new_ip_type(IPADDR_TYPE_ANY);
if (ourPcb == nullptr)
{
reprap.GetPlatform().Message(ErrorMessage, "unable to allocate a pcb\n");
}
else
{
+ udp_set_multicast_ttl(ourPcb, 255);
if (udp_bind(ourPcb, IP_ADDR_ANY, port) != ERR_OK)
{
reprap.GetPlatform().Message(ErrorMessage, "udp_bind call failed\n");
}
else
{
+ debugPrintf("udp_bind call succeeded\n");
udp_recv(ourPcb, rcvFunc, nullptr);
}
}
@@ -94,6 +96,11 @@ void MulticastResponder::Start(TcpPort port) noexcept
void MulticastResponder::Stop() noexcept
{
+ if (ourPcb != nullptr)
+ {
+ udp_remove(ourPcb);
+ ourPcb = nullptr;
+ }
active = false;
}
diff --git a/src/Networking/Network.cpp b/src/Networking/Network.cpp
index 046ee636..0b6f60fe 100644
--- a/src/Networking/Network.cpp
+++ b/src/Networking/Network.cpp
@@ -531,6 +531,9 @@ void Network::Spin() noexcept
if (nr == nullptr)
{
nr = responders; // 'responders' can't be null at this point
+#if SUPPORT_MULTICAST_DISCOVERY
+ MulticastResponder::Spin();
+#endif
}
doneSomething = nr->Spin();
nr = nr->GetNext();