From 932373d4cfe602d97453afd0666482d580323137 Mon Sep 17 00:00:00 2001 From: Kamil Kasperczyk <66371704+kkasperczyk-no@users.noreply.github.com> Date: Tue, 17 Jan 2023 22:14:53 +0100 Subject: [PATCH] [icd] Removed ICD related methods (former SED) from NoThreadImpl (#24444) There are several methods related to ICD (former SED) used for setting expected communication intervals. Currently they are implemented only for Thread devices and for Wi-Fi the implementation returns unsupported feature through NoThreadImpl. Including this sleep intervals could be useful for some low power Wi-Fi modes too. Changes: * Removed methods implementation from NoThread impl. Now after enabling CHIP_DEVICE_CONFIG_ENABLE_SED (I believe it should be renamed to ICD in the future), the implementation will have to be provided by the proper platform. * Implemented methods for nrfconnect Wi-Fi platform. --- examples/light-switch-app/nrfconnect/Kconfig | 7 ++++++ examples/lock-app/nrfconnect/Kconfig | 7 ++++++ .../GenericConnectivityManagerImpl_NoThread.h | 23 ------------------- .../nrfconnect/CHIPDevicePlatformConfig.h | 4 ++++ .../wifi/ConnectivityManagerImplWiFi.cpp | 20 ++++++++++++++++ .../wifi/ConnectivityManagerImplWiFi.h | 6 +++++ src/platform/nrfconnect/wifi/WiFiManager.h | 5 ++++ 7 files changed, 49 insertions(+), 23 deletions(-) diff --git a/examples/light-switch-app/nrfconnect/Kconfig b/examples/light-switch-app/nrfconnect/Kconfig index 042bdac8f72b68..52da3138003335 100644 --- a/examples/light-switch-app/nrfconnect/Kconfig +++ b/examples/light-switch-app/nrfconnect/Kconfig @@ -40,6 +40,13 @@ config CHIP_ENABLE_SLEEPY_END_DEVICE_SUPPORT endif # NET_L2_OPENTHREAD +if CHIP_WIFI + +config NRF_WIFI_LOW_POWER + default y + +endif # CHIP_WIFI + rsource "../../../config/nrfconnect/chip-module/Kconfig.features" rsource "../../../config/nrfconnect/chip-module/Kconfig.defaults" source "Kconfig.zephyr" diff --git a/examples/lock-app/nrfconnect/Kconfig b/examples/lock-app/nrfconnect/Kconfig index 98ed2d5ce9a9b8..622d825f80e3ef 100644 --- a/examples/lock-app/nrfconnect/Kconfig +++ b/examples/lock-app/nrfconnect/Kconfig @@ -52,6 +52,13 @@ config CHIP_ENABLE_SLEEPY_END_DEVICE_SUPPORT endif # NET_L2_OPENTHREAD +if CHIP_WIFI + +config NRF_WIFI_LOW_POWER + default y + +endif # CHIP_WIFI + rsource "../../../config/nrfconnect/chip-module/Kconfig.features" rsource "../../../config/nrfconnect/chip-module/Kconfig.defaults" source "Kconfig.zephyr" diff --git a/src/include/platform/internal/GenericConnectivityManagerImpl_NoThread.h b/src/include/platform/internal/GenericConnectivityManagerImpl_NoThread.h index 20eec682c8c79c..826430bdc0c143 100755 --- a/src/include/platform/internal/GenericConnectivityManagerImpl_NoThread.h +++ b/src/include/platform/internal/GenericConnectivityManagerImpl_NoThread.h @@ -50,9 +50,6 @@ class GenericConnectivityManagerImpl_NoThread bool _IsThreadApplicationControlled(void); ConnectivityManager::ThreadDeviceType _GetThreadDeviceType(void); CHIP_ERROR _SetThreadDeviceType(ConnectivityManager::ThreadDeviceType deviceType); - CHIP_ERROR _GetSEDIntervalsConfig(ConnectivityManager::SEDIntervalsConfig & intervalsConfig); - CHIP_ERROR _SetSEDIntervalsConfig(const ConnectivityManager::SEDIntervalsConfig & intervalsConfig); - CHIP_ERROR _RequestSEDActiveMode(bool onOff, bool delayIdle = false); bool _IsThreadAttached(void); bool _IsThreadProvisioned(void); void _ErasePersistentInfo(void); @@ -115,26 +112,6 @@ GenericConnectivityManagerImpl_NoThread::_SetThreadDeviceType(Connect return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } -template -inline CHIP_ERROR GenericConnectivityManagerImpl_NoThread::_GetSEDIntervalsConfig( - ConnectivityManager::SEDIntervalsConfig & intervalsConfig) -{ - return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; -} - -template -inline CHIP_ERROR GenericConnectivityManagerImpl_NoThread::_SetSEDIntervalsConfig( - const ConnectivityManager::SEDIntervalsConfig & intervalsConfig) -{ - return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; -} - -template -inline CHIP_ERROR GenericConnectivityManagerImpl_NoThread::_RequestSEDActiveMode(bool onOff, bool delayIdle) -{ - return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; -} - template inline void GenericConnectivityManagerImpl_NoThread::_ResetThreadNetworkDiagnosticsCounts() {} diff --git a/src/platform/nrfconnect/CHIPDevicePlatformConfig.h b/src/platform/nrfconnect/CHIPDevicePlatformConfig.h index 5a82f16ad4e9d8..098cf0786816fc 100644 --- a/src/platform/nrfconnect/CHIPDevicePlatformConfig.h +++ b/src/platform/nrfconnect/CHIPDevicePlatformConfig.h @@ -216,6 +216,10 @@ #define CHIP_DEVICE_CONFIG_THREAD_SSED CONFIG_CHIP_THREAD_SSED #endif // CONFIG_CHIP_ENABLE_SLEEPY_END_DEVICE_SUPPORT +#ifdef CONFIG_NRF_WIFI_LOW_POWER +#define CHIP_DEVICE_CONFIG_ENABLE_SED 1 +#endif // CONFIG_NRF_WIFI_LOW_POWER + #ifndef CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL #ifdef CONFIG_CHIP_SED_IDLE_INTERVAL #define CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL chip::System::Clock::Milliseconds32(CONFIG_CHIP_SED_IDLE_INTERVAL) diff --git a/src/platform/nrfconnect/wifi/ConnectivityManagerImplWiFi.cpp b/src/platform/nrfconnect/wifi/ConnectivityManagerImplWiFi.cpp index b3bdede0f2f852..93559822ef6d82 100644 --- a/src/platform/nrfconnect/wifi/ConnectivityManagerImplWiFi.cpp +++ b/src/platform/nrfconnect/wifi/ConnectivityManagerImplWiFi.cpp @@ -123,6 +123,26 @@ CHIP_ERROR ConnectivityManagerImplWiFi::_GetAndLogWiFiStatsCounters(void) return CHIP_NO_ERROR; } +#if CHIP_DEVICE_CONFIG_ENABLE_SED +CHIP_ERROR ConnectivityManagerImplWiFi::_GetSEDIntervalsConfig(ConnectivityManager::SEDIntervalsConfig & SEDIntervalsConfig) +{ + // For now Wi-Fi uses legacy power save mode that has fixed inactivity interval + SEDIntervalsConfig.ActiveIntervalMS = + chip::System::Clock::Milliseconds32(WiFiManager::kDefaultDTIMInterval * WiFiManager::kBeaconIntervalMs); + SEDIntervalsConfig.IdleIntervalMS = + chip::System::Clock::Milliseconds32(WiFiManager::kDefaultDTIMInterval * WiFiManager::kBeaconIntervalMs); + return CHIP_NO_ERROR; +} +CHIP_ERROR ConnectivityManagerImplWiFi::_SetSEDIntervalsConfig(const ConnectivityManager::SEDIntervalsConfig & intervalsConfig) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} +CHIP_ERROR ConnectivityManagerImplWiFi::_RequestSEDActiveMode(bool onOff, bool delayIdle) +{ + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; +} +#endif + ConnectivityManager::WiFiAPMode ConnectivityManagerImplWiFi::_GetWiFiAPMode(void) { /* AP mode is unsupported */ diff --git a/src/platform/nrfconnect/wifi/ConnectivityManagerImplWiFi.h b/src/platform/nrfconnect/wifi/ConnectivityManagerImplWiFi.h index dfa6a05f0b7ae4..407bb2044ed77c 100644 --- a/src/platform/nrfconnect/wifi/ConnectivityManagerImplWiFi.h +++ b/src/platform/nrfconnect/wifi/ConnectivityManagerImplWiFi.h @@ -55,6 +55,12 @@ class ConnectivityManagerImplWiFi void _OnWiFiScanDone(); void _OnWiFiStationProvisionChange(); +#if CHIP_DEVICE_CONFIG_ENABLE_SED + CHIP_ERROR _GetSEDIntervalsConfig(ConnectivityManager::SEDIntervalsConfig & intervalsConfig); + CHIP_ERROR _SetSEDIntervalsConfig(const ConnectivityManager::SEDIntervalsConfig & intervalsConfig); + CHIP_ERROR _RequestSEDActiveMode(bool onOff, bool delayIdle = false); +#endif + // Wi-Fi access point - not supported ConnectivityManager::WiFiAPMode _GetWiFiAPMode(void); CHIP_ERROR _SetWiFiAPMode(ConnectivityManager::WiFiAPMode val); diff --git a/src/platform/nrfconnect/wifi/WiFiManager.h b/src/platform/nrfconnect/wifi/WiFiManager.h index 920df4dd778597..99fd74f3cf8fb0 100644 --- a/src/platform/nrfconnect/wifi/WiFiManager.h +++ b/src/platform/nrfconnect/wifi/WiFiManager.h @@ -169,6 +169,11 @@ class WiFiManager static constexpr uint16_t kMaxInitialRouterSolicitationDelayMs = 1000; static constexpr uint8_t kRouterSolicitationMaxCount = 3; +#if CHIP_DEVICE_CONFIG_ENABLE_SED + static constexpr uint8_t kDefaultDTIMInterval = 3; + static constexpr uint8_t kBeaconIntervalMs = 100; +#endif + CHIP_ERROR Init(); CHIP_ERROR Scan(const ByteSpan & ssid, ScanResultCallback resultCallback, ScanDoneCallback doneCallback, bool internalScan = false);