From 052380267cdcb7b3a3c66c7f755159dba5d24baa Mon Sep 17 00:00:00 2001 From: David Crocker Date: Mon, 19 Sep 2022 15:45:12 +0100 Subject: Fixed MB6HC network initialisation issues --- src/Networking/Network.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Networking/Network.cpp b/src/Networking/Network.cpp index 91193ca5..e7140eb3 100644 --- a/src/Networking/Network.cpp +++ b/src/Networking/Network.cpp @@ -186,10 +186,8 @@ void Network::Init() noexcept SafeStrncpy(hostname, DEFAULT_HOSTNAME, ARRAY_SIZE(hostname)); - for (NetworkInterface *iface : interfaces) - { - iface->Init(); - } + // Only the MB6HC has more than one interface, and at this point we haven't created the second one yet. So initialise just the first. + interfaces[0]->Init(); #endif fastLoop = UINT32_MAX; @@ -205,6 +203,8 @@ void Network::CreateAdditionalInterface() noexcept { interfaces[1] = new WiFiInterface(platform); numActualNetworkInterfaces = 2; + interfaces[1]->Init(); + interfaces[1]->UpdateHostname(hostname); } } @@ -695,9 +695,9 @@ void Network::SetHostname(const char *name) noexcept strcpy(hostname, DEFAULT_HOSTNAME); } - for (NetworkInterface *iface : interfaces) + for (unsigned int i = 0; i < GetNumNetworkInterfaces(); ++i) { - iface->UpdateHostname(hostname); + interfaces[i]->UpdateHostname(hostname); } #endif } -- cgit v1.2.3