From 79df4b88ed68875cd58ef4e1ec5ea22f9ab9d55e Mon Sep 17 00:00:00 2001 From: David Crocker Date: Sun, 26 Jan 2020 20:56:03 +0000 Subject: Refactored MAC address code M540 on Duet WiFi now returns correct MAC address MAC address added to object model WiFi firmware version now returned correctly in object model --- src/Networking/LwipEthernet/LwipEthernetInterface.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/Networking/LwipEthernet/LwipEthernetInterface.cpp') diff --git a/src/Networking/LwipEthernet/LwipEthernetInterface.cpp b/src/Networking/LwipEthernet/LwipEthernetInterface.cpp index 4fa2dd36..ba6f0f85 100644 --- a/src/Networking/LwipEthernet/LwipEthernetInterface.cpp +++ b/src/Networking/LwipEthernet/LwipEthernetInterface.cpp @@ -112,8 +112,8 @@ constexpr ObjectModelTableEntry LwipEthernetInterface::objectModelTable[] = { // These entries must be in alphabetical order { "actualIP", OBJECT_MODEL_FUNC(self->ipAddress), ObjectModelEntryFlags::none }, - { "firmwareVersion", OBJECT_MODEL_FUNC_NOSELF(nullptr), ObjectModelEntryFlags::none }, { "gateway", OBJECT_MODEL_FUNC(self->gateway), ObjectModelEntryFlags::none }, + { "mac", OBJECT_MODEL_FUNC(self->macAddress), ObjectModelEntryFlags::none }, { "subnet", OBJECT_MODEL_FUNC(self->netmask), ObjectModelEntryFlags::none }, { "type", OBJECT_MODEL_FUNC_NOSELF("ethernet"), ObjectModelEntryFlags::none }, }; @@ -137,7 +137,7 @@ void LwipEthernetInterface::Init() noexcept listeningPcbs[i] = nullptr; } - memcpy(macAddress, platform.GetDefaultMacAddress(), sizeof(macAddress)); + macAddress = platform.GetDefaultMacAddress(); } GCodeResult LwipEthernetInterface::EnableProtocol(NetworkProtocol protocol, int port, int secure, const StringRef& reply) noexcept @@ -338,7 +338,7 @@ void LwipEthernetInterface::Start() noexcept const char *hostname = reprap.GetNetwork().GetHostname(); // Allow the MAC address to be set only before LwIP is started... - ethernet_configure_interface(platform.GetDefaultMacAddress(), hostname); + ethernet_configure_interface(platform.GetDefaultMacAddress().bytes, hostname); init_ethernet(DefaultIpAddress, DefaultNetMask, DefaultGateway); // Initialise mDNS subsystem @@ -589,9 +589,10 @@ void LwipEthernetInterface::UpdateHostname(const char *hostname) noexcept } } -void LwipEthernetInterface::SetMacAddress(const uint8_t mac[]) noexcept +GCodeResult LwipEthernetInterface::SetMacAddress(const MacAddress& mac, const StringRef& reply) noexcept { - memcpy(macAddress, mac, sizeof(macAddress)); + macAddress = mac; + return GCodeResult::ok; } void LwipEthernetInterface::OpenDataPort(Port port) noexcept -- cgit v1.2.3