From a00a25b1244016ee739dfc527771b307c9243a8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damian=20Kr=C3=B3lik?= <66667989+Damian-Nordic@users.noreply.github.com> Date: Thu, 9 Feb 2023 12:54:40 +0100 Subject: [PATCH] [Zephyr] Fix General Diagnostics Hardware Address (#24941) 15.4 drivers in Zephyr set EUI-64 as the link-layer address of the corresponding interface. However, Hardware Address field in the General Diagnostics cluster is supposed to return Extended Address for Thread interfaces according to the specification. Make sure the diagnostic data provider returns the extended address for the concerned field. Signed-off-by: Damian Krolik --- .../Zephyr/DiagnosticDataProviderImpl.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp b/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp index 9398359f1cb021..a735d3e0162b79 100644 --- a/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp @@ -282,8 +282,23 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** ifp->offPremiseServicesReachableIPv4.SetNull(); ifp->offPremiseServicesReachableIPv6.SetNull(); + CHIP_ERROR error; uint8_t addressSize; - if (interfaceIterator.GetHardwareAddress(ifp->MacAddress, addressSize, sizeof(ifp->MacAddress)) != CHIP_NO_ERROR) + +#if CHIP_DEVICE_CONFIG_ENABLE_THREAD + if (interfaceType == Inet::InterfaceType::Thread) + { + static_assert(OT_EXT_ADDRESS_SIZE <= sizeof(ifp->MacAddress), "Unexpected extended address size"); + error = ThreadStackMgr().GetPrimary802154MACAddress(ifp->MacAddress); + addressSize = OT_EXT_ADDRESS_SIZE; + } + else +#endif + { + error = interfaceIterator.GetHardwareAddress(ifp->MacAddress, addressSize, sizeof(ifp->MacAddress)); + } + + if (error != CHIP_NO_ERROR) { ChipLogError(DeviceLayer, "Failed to get network hardware address"); }