From 6d2dc6441a22e7eb87de0fe34bd575b7bacb636b Mon Sep 17 00:00:00 2001 From: David Crocker Date: Tue, 4 Oct 2022 13:50:10 +0100 Subject: Fixed network starup issues on MB6HC --- src/Networking/Network.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Networking/Network.cpp b/src/Networking/Network.cpp index 428c097f..78cbd2d8 100644 --- a/src/Networking/Network.cpp +++ b/src/Networking/Network.cpp @@ -97,6 +97,9 @@ Network::Network(Platform& p) noexcept : platform(p) # else # error Unknown board # endif +# if defined(DUET3_MB6HC) + interfaces[1] = nullptr; // no WiFi interface yet +# endif #endif // HAS_NETWORKING } @@ -344,7 +347,7 @@ WiFiInterface *Network::FindWiFiInterface() const noexcept #if HAS_WIFI_NETWORKING for (NetworkInterface *iface : interfaces) { - if (iface->IsWiFiInterface()) + if (iface != nullptr && iface->IsWiFiInterface()) { return static_cast(iface); } @@ -527,7 +530,10 @@ void Network::Spin() noexcept // Keep the network modules running for (NetworkInterface *iface : interfaces) { - iface->Spin(); + if (iface != nullptr) + { + iface->Spin(); + } } #if HAS_RESPONDERS @@ -597,7 +603,10 @@ void Network::Diagnostics(MessageType mtype) noexcept for (NetworkInterface *iface : interfaces) { - iface->Diagnostics(mtype); + if (iface != nullptr) + { + iface->Diagnostics(mtype); + } } #endif @@ -622,7 +631,7 @@ void Network::SetEthernetIPAddress(IPAddress p_ipAddress, IPAddress p_netmask, I #if HAS_NETWORKING for (NetworkInterface *iface : interfaces) { - if (!iface->IsWiFiInterface()) + if (iface != nullptr && !iface->IsWiFiInterface()) { iface->SetIPAddress(p_ipAddress, p_netmask, p_gateway); } @@ -693,9 +702,12 @@ void Network::SetHostname(const char *name) noexcept strcpy(hostname, DEFAULT_HOSTNAME); } - for (unsigned int i = 0; i < GetNumNetworkInterfaces(); ++i) + for (NetworkInterface *iface : interfaces) { - interfaces[i]->UpdateHostname(hostname); + if (iface != nullptr) + { + iface->UpdateHostname(hostname); + } } #endif } -- cgit v1.2.3