[nrfconnect] Initial Matter over WiFi implementation. (#23607)
* [nrfconnect] Initial Matter over WiFi implementation.
Some WiFi related features might not work as expected yet.
This will be fixed when the Zephyr NRF WiFi module is improved.
All implementations have been synchronized to sdk-nrf v2.1.1.
Commits included:
- Prepare configuration for hci_rpmsg
- Adapt Android CHIPTool guide to Wi-Fi devices
Make the guide a little bit more aware of the world of
Wi-Fi devices.
- Disable Wi-Fi low-power mode
Noticed Wi-Fi low-power mode causes performance issues,
at least with some APs.
- Implemented the WiFiNetworkIterator.
Replaced dummy implementation of WiFiNetworkIterator
This fixes an issue with infinite loop when using this iterator in Matter core.
- Added including CHIPMemString.h to fix WiFi build
Signed-off-by: Marcin Kajor <marcin.kajor@nordicsemi.no>
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
Signed-off-by: Arkadiusz Balys <arkadiusz.balys@nordicsemi.no>
* Restyled by prettier-markdown
Restyled by gn
Signed-off-by: Marcin Kajor <marcin.kajor@nordicsemi.no>
Signed-off-by: Damian Krolik <damian.krolik@nordicsemi.no>
Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
Signed-off-by: Arkadiusz Balys <arkadiusz.balys@nordicsemi.no>
Co-authored-by: Restyled.io <commits@restyled.io>
diff --git a/src/platform/Zephyr/BLEManagerImpl.cpp b/src/platform/Zephyr/BLEManagerImpl.cpp
index d65b7a9..88edbd3 100644
--- a/src/platform/Zephyr/BLEManagerImpl.cpp
+++ b/src/platform/Zephyr/BLEManagerImpl.cpp
@@ -28,6 +28,7 @@
#include <platform/Zephyr/BLEManagerImpl.h>
#include <ble/CHIPBleServiceData.h>
+#include <lib/support/CHIPMemString.h>
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/CHIPLogging.h>
#include <platform/DeviceInstanceInfoProvider.h>
diff --git a/src/platform/Zephyr/ConfigurationManagerImpl.cpp b/src/platform/Zephyr/ConfigurationManagerImpl.cpp
index 107579a..378e35e 100644
--- a/src/platform/Zephyr/ConfigurationManagerImpl.cpp
+++ b/src/platform/Zephyr/ConfigurationManagerImpl.cpp
@@ -27,8 +27,11 @@
#include <platform/internal/GenericConfigurationManagerImpl.ipp>
#include <lib/core/CHIPVendorIdentifiers.hpp>
+
#include <platform/Zephyr/ZephyrConfig.h>
+#include "InetUtils.h"
+
#include <lib/support/CodeUtils.h>
#include <lib/support/logging/CHIPLogging.h>
@@ -201,6 +204,21 @@
PlatformMgr().Shutdown();
}
+CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf)
+{
+#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
+ const net_if * const iface = InetUtils::GetInterface();
+ VerifyOrReturnError(iface != nullptr && iface->if_dev != nullptr, CHIP_ERROR_INTERNAL);
+
+ const auto linkAddrStruct = iface->if_dev->link_addr;
+ memcpy(buf, linkAddrStruct.addr, linkAddrStruct.len);
+
+ return CHIP_NO_ERROR;
+#else
+ return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
+#endif
+}
+
ConfigurationManager & ConfigurationMgrImpl()
{
return ConfigurationManagerImpl::GetDefaultInstance();
diff --git a/src/platform/Zephyr/ConfigurationManagerImpl.h b/src/platform/Zephyr/ConfigurationManagerImpl.h
index 166237f..87f9e30 100644
--- a/src/platform/Zephyr/ConfigurationManagerImpl.h
+++ b/src/platform/Zephyr/ConfigurationManagerImpl.h
@@ -94,11 +94,6 @@
return Internal::ZephyrConfig::WriteConfigValueCounter(key, value);
}
-inline CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * /* buf */)
-{
- return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
-}
-
/**
* Returns the platform-specific implementation of the ConfigurationManager object.
*
diff --git a/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp b/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp
index 1eb2439..c1fb842 100644
--- a/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp
+++ b/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp
@@ -116,7 +116,7 @@
return sInstance;
}
-inline DiagnosticDataProviderImpl::DiagnosticDataProviderImpl() : mBootReason(DetermineBootReason())
+DiagnosticDataProviderImpl::DiagnosticDataProviderImpl() : mBootReason(DetermineBootReason())
{
ChipLogDetail(DeviceLayer, "Boot reason: %u", static_cast<uint16_t>(mBootReason));
}
@@ -328,10 +328,5 @@
}
}
-DiagnosticDataProvider & GetDiagnosticDataProviderImpl()
-{
- return DiagnosticDataProviderImpl::GetDefaultInstance();
-}
-
} // namespace DeviceLayer
} // namespace chip
diff --git a/src/platform/Zephyr/DiagnosticDataProviderImpl.h b/src/platform/Zephyr/DiagnosticDataProviderImpl.h
index 2b46051..69bbae5 100644
--- a/src/platform/Zephyr/DiagnosticDataProviderImpl.h
+++ b/src/platform/Zephyr/DiagnosticDataProviderImpl.h
@@ -52,9 +52,10 @@
CHIP_ERROR GetNetworkInterfaces(NetworkInterface ** netifpp) override;
void ReleaseNetworkInterfaces(NetworkInterface * netifp) override;
-private:
+protected:
DiagnosticDataProviderImpl();
+private:
const BootReasonType mBootReason;
};
diff --git a/src/platform/Zephyr/DiagnosticDataProviderImplGetter.cpp b/src/platform/Zephyr/DiagnosticDataProviderImplGetter.cpp
new file mode 100644
index 0000000..6b920d1
--- /dev/null
+++ b/src/platform/Zephyr/DiagnosticDataProviderImplGetter.cpp
@@ -0,0 +1,29 @@
+/*
+ *
+ * Copyright (c) 2022 Project CHIP Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "DiagnosticDataProviderImpl.h"
+
+namespace chip {
+namespace DeviceLayer {
+
+DiagnosticDataProvider & GetDiagnosticDataProviderImpl()
+{
+ return DiagnosticDataProviderImpl::GetDefaultInstance();
+}
+
+} // namespace DeviceLayer
+} // namespace chip
diff --git a/src/platform/Zephyr/InetUtils.cpp b/src/platform/Zephyr/InetUtils.cpp
new file mode 100644
index 0000000..1169cf6
--- /dev/null
+++ b/src/platform/Zephyr/InetUtils.cpp
@@ -0,0 +1,41 @@
+/*
+ *
+ * Copyright (c) 2022 Project CHIP Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "InetUtils.h"
+
+namespace chip {
+namespace DeviceLayer {
+namespace InetUtils {
+
+in6_addr ToZephyrAddr(const chip::Inet::IPAddress & address)
+{
+ in6_addr zephyrAddr;
+
+ static_assert(sizeof(zephyrAddr.s6_addr) == sizeof(address.Addr), "Unexpected address size");
+ memcpy(zephyrAddr.s6_addr, address.Addr, sizeof(address.Addr));
+
+ return zephyrAddr;
+}
+
+net_if * GetInterface(chip::Inet::InterfaceId ifaceId)
+{
+ return ifaceId.IsPresent() ? net_if_get_by_index(ifaceId.GetPlatformInterface()) : net_if_get_default();
+}
+
+} // namespace InetUtils
+} // namespace DeviceLayer
+} // namespace chip
diff --git a/src/platform/Zephyr/InetUtils.h b/src/platform/Zephyr/InetUtils.h
new file mode 100644
index 0000000..ad7c5e1
--- /dev/null
+++ b/src/platform/Zephyr/InetUtils.h
@@ -0,0 +1,32 @@
+/*
+ *
+ * Copyright (c) 2022 Project CHIP Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <inet/InetInterface.h>
+
+struct in6_addr;
+struct net_if;
+
+namespace chip {
+namespace DeviceLayer {
+namespace InetUtils {
+
+in6_addr ToZephyrAddr(const chip::Inet::IPAddress & address);
+net_if * GetInterface(chip::Inet::InterfaceId ifaceId = chip::Inet::InterfaceId::Null());
+
+} // namespace InetUtils
+} // namespace DeviceLayer
+} // namespace chip