From e556daac2e1ed3a141034a6dcc7e410e4cd1f8f6 Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Mon, 25 Jul 2022 22:50:55 -0700 Subject: [PATCH] Do not setup ConfigurationMgr via PlatformMgr on each platform (#21075) (#21197) Co-authored-by: Yufeng Wang --- src/include/platform/ConfigurationManager.h | 15 ++++++-- .../Ameba/ConfigurationManagerImpl.cpp | 5 +++ src/platform/Ameba/ConfigurationManagerImpl.h | 8 +++++ src/platform/Ameba/PlatformManagerImpl.cpp | 2 -- .../CYW30739/ConfigurationManagerImpl.cpp | 5 +++ .../CYW30739/ConfigurationManagerImpl.h | 8 +++++ src/platform/CYW30739/PlatformManagerImpl.cpp | 2 -- .../Darwin/ConfigurationManagerImpl.cpp | 5 +++ .../Darwin/ConfigurationManagerImpl.h | 8 +++++ src/platform/Darwin/PlatformManagerImpl.cpp | 1 - .../EFR32/ConfigurationManagerImpl.cpp | 5 +++ src/platform/EFR32/ConfigurationManagerImpl.h | 10 +++++- src/platform/EFR32/PlatformManagerImpl.cpp | 2 -- .../ESP32/ConfigurationManagerImpl.cpp | 5 +++ src/platform/ESP32/ConfigurationManagerImpl.h | 8 +++++ src/platform/ESP32/PlatformManagerImpl.cpp | 2 -- .../Linux/ConfigurationManagerImpl.cpp | 5 +++ src/platform/Linux/ConfigurationManagerImpl.h | 8 +++++ src/platform/Linux/PlatformManagerImpl.cpp | 1 - src/platform/P6/ConfigurationManagerImpl.cpp | 5 +++ src/platform/P6/ConfigurationManagerImpl.h | 8 +++++ src/platform/P6/PlatformManagerImpl.cpp | 2 -- .../SingletonConfigurationManager.cpp | 9 +++-- .../Tizen/ConfigurationManagerImpl.cpp | 5 +++ src/platform/Tizen/ConfigurationManagerImpl.h | 8 +++++ src/platform/Tizen/PlatformManagerImpl.cpp | 1 - .../Zephyr/ConfigurationManagerImpl.cpp | 5 +++ .../Zephyr/ConfigurationManagerImpl.h | 8 +++++ src/platform/Zephyr/PlatformManagerImpl.cpp | 1 - .../android/ConfigurationManagerImpl.cpp | 5 +++ .../android/ConfigurationManagerImpl.h | 8 +++++ src/platform/android/PlatformManagerImpl.cpp | 1 - .../BL602/ConfigurationManagerImpl.cpp | 5 +++ .../BL602/ConfigurationManagerImpl.h | 31 ++++------------- .../bouffalolab/BL602/PlatformManagerImpl.cpp | 2 -- .../cc13x2_26x2/ConfigurationManagerImpl.cpp | 5 +++ .../cc13x2_26x2/ConfigurationManagerImpl.h | 8 +++++ .../cc13x2_26x2/PlatformManagerImpl.cpp | 1 - .../cc32xx/ConfigurationManagerImpl.cpp | 5 +++ .../cc32xx/ConfigurationManagerImpl.h | 8 +++++ src/platform/cc32xx/PlatformManagerImpl.cpp | 1 - src/platform/fake/BUILD.gn | 1 + .../fake/ConfigurationManagerImpl.cpp | 4 +-- src/platform/fake/ConfigurationManagerImpl.h | 8 +++++ .../mbed/ConfigurationManagerImpl.cpp | 5 +++ src/platform/mbed/ConfigurationManagerImpl.h | 8 +++++ src/platform/mbed/PlatformManagerImpl.cpp | 2 -- .../k32w/k32w0/ConfigurationManagerImpl.cpp | 5 +++ .../nxp/k32w/k32w0/ConfigurationManagerImpl.h | 8 +++++ .../nxp/k32w/k32w0/PlatformManagerImpl.cpp | 2 -- src/platform/nxp/mw320/BUILD.gn | 1 + .../nxp/mw320/ConfigurationManagerImpl.cpp | 10 +++--- .../nxp/mw320/ConfigurationManagerImpl.h | 34 +++++-------------- .../nxp/mw320/PlatformManagerImpl.cpp | 2 -- src/platform/qpg/ConfigurationManagerImpl.cpp | 5 +++ src/platform/qpg/ConfigurationManagerImpl.h | 8 +++++ src/platform/qpg/PlatformManagerImpl.cpp | 1 - .../webos/ConfigurationManagerImpl.cpp | 5 +++ src/platform/webos/ConfigurationManagerImpl.h | 8 +++++ src/platform/webos/PlatformManagerImpl.cpp | 1 - 60 files changed, 264 insertions(+), 91 deletions(-) diff --git a/src/include/platform/ConfigurationManager.h b/src/include/platform/ConfigurationManager.h index 99c49331cb30bb..607f9776980e29 100644 --- a/src/include/platform/ConfigurationManager.h +++ b/src/include/platform/ConfigurationManager.h @@ -181,9 +181,18 @@ class ConfigurationManager /** * Returns a reference to a ConfigurationManager object. * - * Applications should use this to access the features of the ConfigurationManager. + * Applications should use this to access features of the ConfigurationManager object + * that are common to all platforms. */ -extern ConfigurationManager & ConfigurationMgr(); +ConfigurationManager & ConfigurationMgr(); + +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +extern ConfigurationManager & ConfigurationMgrImpl(); /** * Sets a reference to a ConfigurationManager object. @@ -191,7 +200,7 @@ extern ConfigurationManager & ConfigurationMgr(); * This must be called before any calls to ConfigurationMgr. If a nullptr is passed in, * no changes will be made. */ -extern void SetConfigurationMgr(ConfigurationManager * configurationManager); +void SetConfigurationMgr(ConfigurationManager * configurationManager); inline CHIP_ERROR ConfigurationManager::GetLocationCapability(uint8_t & location) { diff --git a/src/platform/Ameba/ConfigurationManagerImpl.cpp b/src/platform/Ameba/ConfigurationManagerImpl.cpp index a1f4f00eac306b..e64b097b86c253 100644 --- a/src/platform/Ameba/ConfigurationManagerImpl.cpp +++ b/src/platform/Ameba/ConfigurationManagerImpl.cpp @@ -284,5 +284,10 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) // sys_reset(); } +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Ameba/ConfigurationManagerImpl.h b/src/platform/Ameba/ConfigurationManagerImpl.h index def780ea343817..7587f5366d7ddf 100644 --- a/src/platform/Ameba/ConfigurationManagerImpl.h +++ b/src/platform/Ameba/ConfigurationManagerImpl.h @@ -76,5 +76,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp static void DoFactoryReset(intptr_t arg); }; +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +ConfigurationManager & ConfigurationMgrImpl(); + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Ameba/PlatformManagerImpl.cpp b/src/platform/Ameba/PlatformManagerImpl.cpp index 1d5a8d8aa2e9c8..0b89c4a8c24971 100644 --- a/src/platform/Ameba/PlatformManagerImpl.cpp +++ b/src/platform/Ameba/PlatformManagerImpl.cpp @@ -59,8 +59,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) CHIP_ERROR err; - SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); - // Make sure the LwIP core lock has been initialized err = Internal::InitLwIPCoreLock(); diff --git a/src/platform/CYW30739/ConfigurationManagerImpl.cpp b/src/platform/CYW30739/ConfigurationManagerImpl.cpp index 71d32970f10881..a706ceec55e492 100644 --- a/src/platform/CYW30739/ConfigurationManagerImpl.cpp +++ b/src/platform/CYW30739/ConfigurationManagerImpl.cpp @@ -212,5 +212,10 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) wiced_hal_wdog_reset_system(); } +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/CYW30739/ConfigurationManagerImpl.h b/src/platform/CYW30739/ConfigurationManagerImpl.h index 284f4d37e94551..40538888170245 100644 --- a/src/platform/CYW30739/ConfigurationManagerImpl.h +++ b/src/platform/CYW30739/ConfigurationManagerImpl.h @@ -74,5 +74,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp static void DoFactoryReset(intptr_t arg); }; +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +ConfigurationManager & ConfigurationMgrImpl(); + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/CYW30739/PlatformManagerImpl.cpp b/src/platform/CYW30739/PlatformManagerImpl.cpp index c8b547d199fba8..41e91ea0a205a6 100644 --- a/src/platform/CYW30739/PlatformManagerImpl.cpp +++ b/src/platform/CYW30739/PlatformManagerImpl.cpp @@ -45,8 +45,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) err = PersistedStorage::KeyValueStoreMgrImpl().Init(); SuccessOrExit(err); - SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); - /* Create the thread object. */ mThread = wiced_rtos_create_thread(); VerifyOrExit(mThread != nullptr, err = CHIP_ERROR_NO_MEMORY); diff --git a/src/platform/Darwin/ConfigurationManagerImpl.cpp b/src/platform/Darwin/ConfigurationManagerImpl.cpp index d6ff1e8b8bec94..d624821c9e8e5e 100644 --- a/src/platform/Darwin/ConfigurationManagerImpl.cpp +++ b/src/platform/Darwin/ConfigurationManagerImpl.cpp @@ -496,5 +496,10 @@ void ConfigurationManagerImpl::RunConfigUnitTest(void) #endif // CHIP_DISABLE_PLATFORM_KVS } +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Darwin/ConfigurationManagerImpl.h b/src/platform/Darwin/ConfigurationManagerImpl.h index 6fc79f5ffb2b89..74a13606be9c53 100644 --- a/src/platform/Darwin/ConfigurationManagerImpl.h +++ b/src/platform/Darwin/ConfigurationManagerImpl.h @@ -92,5 +92,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp void RunConfigUnitTest(void) override; }; +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +ConfigurationManager & ConfigurationMgrImpl(); + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Darwin/PlatformManagerImpl.cpp b/src/platform/Darwin/PlatformManagerImpl.cpp index d47d8830c215e5..8ce02ec77b62e6 100644 --- a/src/platform/Darwin/PlatformManagerImpl.cpp +++ b/src/platform/Darwin/PlatformManagerImpl.cpp @@ -52,7 +52,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack() SuccessOrExit(err); SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); #endif // CHIP_DISABLE_PLATFORM_KVS - SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); mRunLoopSem = dispatch_semaphore_create(0); diff --git a/src/platform/EFR32/ConfigurationManagerImpl.cpp b/src/platform/EFR32/ConfigurationManagerImpl.cpp index 9c370bf3b52e6d..64a66be824f61a 100644 --- a/src/platform/EFR32/ConfigurationManagerImpl.cpp +++ b/src/platform/EFR32/ConfigurationManagerImpl.cpp @@ -307,5 +307,10 @@ CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) } #endif +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/EFR32/ConfigurationManagerImpl.h b/src/platform/EFR32/ConfigurationManagerImpl.h index baa3e5849afaec..aaebd3ea65ac91 100644 --- a/src/platform/EFR32/ConfigurationManagerImpl.h +++ b/src/platform/EFR32/ConfigurationManagerImpl.h @@ -82,7 +82,15 @@ inline CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * b { return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } - #endif /* SL_WIFI */ + +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +ConfigurationManager & ConfigurationMgrImpl(); + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/EFR32/PlatformManagerImpl.cpp b/src/platform/EFR32/PlatformManagerImpl.cpp index 29dc7bbe1e17e7..8d5acfba621c95 100644 --- a/src/platform/EFR32/PlatformManagerImpl.cpp +++ b/src/platform/EFR32/PlatformManagerImpl.cpp @@ -50,8 +50,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) err = chip::DeviceLayer::PersistedStorage::KeyValueStoreMgrImpl().Init(); SuccessOrExit(err); - SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); - #if CHIP_SYSTEM_CONFIG_USE_LWIP // Initialize LwIP. tcpip_init(NULL, NULL); diff --git a/src/platform/ESP32/ConfigurationManagerImpl.cpp b/src/platform/ESP32/ConfigurationManagerImpl.cpp index ba2bdddef6b7d8..f11576f621a7fc 100644 --- a/src/platform/ESP32/ConfigurationManagerImpl.cpp +++ b/src/platform/ESP32/ConfigurationManagerImpl.cpp @@ -337,5 +337,10 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) esp_restart(); } +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/ESP32/ConfigurationManagerImpl.h b/src/platform/ESP32/ConfigurationManagerImpl.h index 01e31473a31ada..56c5e5ad7679a0 100644 --- a/src/platform/ESP32/ConfigurationManagerImpl.h +++ b/src/platform/ESP32/ConfigurationManagerImpl.h @@ -87,5 +87,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp static void DoFactoryReset(intptr_t arg); }; +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +ConfigurationManager & ConfigurationMgrImpl(); + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/ESP32/PlatformManagerImpl.cpp b/src/platform/ESP32/PlatformManagerImpl.cpp index d387814f3241f2..c96caeb03934ef 100644 --- a/src/platform/ESP32/PlatformManagerImpl.cpp +++ b/src/platform/ESP32/PlatformManagerImpl.cpp @@ -59,8 +59,6 @@ static int app_entropy_source(void * data, unsigned char * output, size_t len, s CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) { - SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); - esp_err_t err; // Arrange for CHIP-encapsulated ESP32 errors to be translated to text Internal::ESP32Utils::RegisterESP32ErrorFormatter(); diff --git a/src/platform/Linux/ConfigurationManagerImpl.cpp b/src/platform/Linux/ConfigurationManagerImpl.cpp index 68a624ae3ce066..2f603f1f3ba31e 100644 --- a/src/platform/Linux/ConfigurationManagerImpl.cpp +++ b/src/platform/Linux/ConfigurationManagerImpl.cpp @@ -397,5 +397,10 @@ CHIP_ERROR ConfigurationManagerImpl::GetLocationCapability(uint8_t & location) return err; } +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Linux/ConfigurationManagerImpl.h b/src/platform/Linux/ConfigurationManagerImpl.h index 866710fc8faac9..ecf5aea77830b3 100644 --- a/src/platform/Linux/ConfigurationManagerImpl.h +++ b/src/platform/Linux/ConfigurationManagerImpl.h @@ -88,5 +88,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp static void DoFactoryReset(intptr_t arg); }; +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +ConfigurationManager & ConfigurationMgrImpl(); + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Linux/PlatformManagerImpl.cpp b/src/platform/Linux/PlatformManagerImpl.cpp index 23ca6af8d07903..542e469e2c7a89 100644 --- a/src/platform/Linux/PlatformManagerImpl.cpp +++ b/src/platform/Linux/PlatformManagerImpl.cpp @@ -175,7 +175,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack() // Initialize the configuration system. ReturnErrorOnFailure(Internal::PosixConfig::Init()); - SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); // Call _InitChipStack() on the generic implementation base class diff --git a/src/platform/P6/ConfigurationManagerImpl.cpp b/src/platform/P6/ConfigurationManagerImpl.cpp index b8c2c0ad3eb618..afa771d5acb837 100644 --- a/src/platform/P6/ConfigurationManagerImpl.cpp +++ b/src/platform/P6/ConfigurationManagerImpl.cpp @@ -238,5 +238,10 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) NVIC_SystemReset(); } +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/P6/ConfigurationManagerImpl.h b/src/platform/P6/ConfigurationManagerImpl.h index a9fd74facf9220..1327b3bc546214 100644 --- a/src/platform/P6/ConfigurationManagerImpl.h +++ b/src/platform/P6/ConfigurationManagerImpl.h @@ -78,5 +78,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp static void DoFactoryReset(intptr_t arg); }; +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +ConfigurationManager & ConfigurationMgrImpl(); + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/P6/PlatformManagerImpl.cpp b/src/platform/P6/PlatformManagerImpl.cpp index 112c9c779745aa..ac22597407dc98 100644 --- a/src/platform/P6/PlatformManagerImpl.cpp +++ b/src/platform/P6/PlatformManagerImpl.cpp @@ -43,8 +43,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) { CHIP_ERROR err; - SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); - // Make sure the LwIP core lock has been initialized err = Internal::InitLwIPCoreLock(); SuccessOrExit(err); diff --git a/src/platform/SingletonConfigurationManager.cpp b/src/platform/SingletonConfigurationManager.cpp index 0658ebfbc776bc..01122c3ae0a030 100644 --- a/src/platform/SingletonConfigurationManager.cpp +++ b/src/platform/SingletonConfigurationManager.cpp @@ -21,6 +21,7 @@ */ #include +#include namespace chip { namespace DeviceLayer { @@ -37,8 +38,12 @@ ConfigurationManager * gInstance = nullptr; ConfigurationManager & ConfigurationMgr() { - VerifyOrDie(gInstance != nullptr); - return *gInstance; + if (gInstance != nullptr) + { + return *gInstance; + } + + return ConfigurationMgrImpl(); } void SetConfigurationMgr(ConfigurationManager * configurationManager) diff --git a/src/platform/Tizen/ConfigurationManagerImpl.cpp b/src/platform/Tizen/ConfigurationManagerImpl.cpp index 507c22cacdd8ac..d57bd6a7454d69 100644 --- a/src/platform/Tizen/ConfigurationManagerImpl.cpp +++ b/src/platform/Tizen/ConfigurationManagerImpl.cpp @@ -177,5 +177,10 @@ void ConfigurationManagerImpl::RunConfigUnitTest(void) PosixConfig::RunConfigUnitTest(); } +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Tizen/ConfigurationManagerImpl.h b/src/platform/Tizen/ConfigurationManagerImpl.h index 779fa93518a6a9..2180eec73da4a2 100644 --- a/src/platform/Tizen/ConfigurationManagerImpl.h +++ b/src/platform/Tizen/ConfigurationManagerImpl.h @@ -72,5 +72,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp void RunConfigUnitTest(void) override; }; +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +ConfigurationManager & ConfigurationMgrImpl(); + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Tizen/PlatformManagerImpl.cpp b/src/platform/Tizen/PlatformManagerImpl.cpp index b053ab44d7aaaf..5e0eb62e655549 100644 --- a/src/platform/Tizen/PlatformManagerImpl.cpp +++ b/src/platform/Tizen/PlatformManagerImpl.cpp @@ -39,7 +39,6 @@ PlatformManagerImpl PlatformManagerImpl::sInstance; CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) { ReturnErrorOnFailure(Internal::PosixConfig::Init()); - SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); return Internal::GenericPlatformManagerImpl_POSIX::_InitChipStack(); diff --git a/src/platform/Zephyr/ConfigurationManagerImpl.cpp b/src/platform/Zephyr/ConfigurationManagerImpl.cpp index 6dfe51ab023f55..bd19057e65d3bf 100644 --- a/src/platform/Zephyr/ConfigurationManagerImpl.cpp +++ b/src/platform/Zephyr/ConfigurationManagerImpl.cpp @@ -180,5 +180,10 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) PlatformMgr().Shutdown(); } +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Zephyr/ConfigurationManagerImpl.h b/src/platform/Zephyr/ConfigurationManagerImpl.h index 5f331d14d81897..166237fba32d81 100644 --- a/src/platform/Zephyr/ConfigurationManagerImpl.h +++ b/src/platform/Zephyr/ConfigurationManagerImpl.h @@ -99,5 +99,13 @@ inline CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * / return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +ConfigurationManager & ConfigurationMgrImpl(); + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Zephyr/PlatformManagerImpl.cpp b/src/platform/Zephyr/PlatformManagerImpl.cpp index 22c9961fba989b..53053b5eae74f7 100644 --- a/src/platform/Zephyr/PlatformManagerImpl.cpp +++ b/src/platform/Zephyr/PlatformManagerImpl.cpp @@ -106,7 +106,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) // Initialize the configuration system. err = Internal::ZephyrConfig::Init(); SuccessOrExit(err); - SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); #if !CONFIG_NORDIC_SECURITY_BACKEND // Add entropy source based on Zephyr entropy driver diff --git a/src/platform/android/ConfigurationManagerImpl.cpp b/src/platform/android/ConfigurationManagerImpl.cpp index 5c42175148e641..9ce80257b53fcc 100644 --- a/src/platform/android/ConfigurationManagerImpl.cpp +++ b/src/platform/android/ConfigurationManagerImpl.cpp @@ -215,5 +215,10 @@ CHIP_ERROR ConfigurationManagerImpl::GetUniqueId(char * buf, size_t bufSize) return ReadConfigValueStr(AndroidConfig::kConfigKey_UniqueId, buf, bufSize, dateLen); } +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/android/ConfigurationManagerImpl.h b/src/platform/android/ConfigurationManagerImpl.h index 45b93bdc76b618..6e1a2ed9870e66 100644 --- a/src/platform/android/ConfigurationManagerImpl.h +++ b/src/platform/android/ConfigurationManagerImpl.h @@ -83,5 +83,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp jobject mConfigurationManagerObject = nullptr; }; +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +ConfigurationManager & ConfigurationMgrImpl(); + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/android/PlatformManagerImpl.cpp b/src/platform/android/PlatformManagerImpl.cpp index 0fe62600ad6e0c..d2c2fc391f3002 100644 --- a/src/platform/android/PlatformManagerImpl.cpp +++ b/src/platform/android/PlatformManagerImpl.cpp @@ -46,7 +46,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack() // Initialize the configuration system. err = Internal::AndroidConfig::Init(); SuccessOrExit(err); - SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); // Call _InitChipStack() on the generic implementation base class diff --git a/src/platform/bouffalolab/BL602/ConfigurationManagerImpl.cpp b/src/platform/bouffalolab/BL602/ConfigurationManagerImpl.cpp index 23c860a1a32d82..b30390506580bd 100644 --- a/src/platform/bouffalolab/BL602/ConfigurationManagerImpl.cpp +++ b/src/platform/bouffalolab/BL602/ConfigurationManagerImpl.cpp @@ -180,5 +180,10 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) hal_reboot(); } +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/bouffalolab/BL602/ConfigurationManagerImpl.h b/src/platform/bouffalolab/BL602/ConfigurationManagerImpl.h index 0239f9a8dee22e..037ad2019967e7 100644 --- a/src/platform/bouffalolab/BL602/ConfigurationManagerImpl.h +++ b/src/platform/bouffalolab/BL602/ConfigurationManagerImpl.h @@ -91,9 +91,6 @@ class ConfigurationManagerImpl final : public Internal::GenericConfigurationMana CHIP_ERROR WriteConfigValueBin(Key key, const uint8_t * data, size_t dataLen) override; void RunConfigUnitTest(void) override; - friend ConfigurationManager & ConfigurationMgr(void); - friend ConfigurationManagerImpl & ConfigurationMgrImpl(void); - static ConfigurationManagerImpl sInstance; // ===== Private members reserved for use by this class only. @@ -101,33 +98,19 @@ class ConfigurationManagerImpl final : public Internal::GenericConfigurationMana static void DoFactoryReset(intptr_t arg); }; -/** - * Returns the public interface of the ConfigurationManager singleton object. - * - * Chip applications should use this to access features of the ConfigurationManager object - * that are common to all platforms. - */ -inline ConfigurationManager & ConfigurationMgr(void) +inline CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) { - return ConfigurationManagerImpl::sInstance; + log_error("ConfigurationManagerImpl::_GetPrimaryWiFiMACAddress() is not supported now.\r\n"); + return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } /** - * Returns the platform-specific implementation of the ConfigurationManager singleton object. + * Returns the platform-specific implementation of the ConfigurationManager object. * - * Chip applications can use this to gain access to features of the ConfigurationManager - * that are specific to the BL602 platform. + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. */ -inline ConfigurationManagerImpl & ConfigurationMgrImpl(void) -{ - return ConfigurationManagerImpl::sInstance; -} - -inline CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) -{ - log_error("ConfigurationManagerImpl::_GetPrimaryWiFiMACAddress() is not supported now.\r\n"); - return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; -} +ConfigurationManager & ConfigurationMgrImpl(); } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/bouffalolab/BL602/PlatformManagerImpl.cpp b/src/platform/bouffalolab/BL602/PlatformManagerImpl.cpp index 3e359ff707fbc6..26585e132fc91b 100644 --- a/src/platform/bouffalolab/BL602/PlatformManagerImpl.cpp +++ b/src/platform/bouffalolab/BL602/PlatformManagerImpl.cpp @@ -188,8 +188,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) { CHIP_ERROR err; - SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); - // Initialize the configuration system. err = Internal::BL602Config::Init(); log_error("err: %d\r\n", err); diff --git a/src/platform/cc13x2_26x2/ConfigurationManagerImpl.cpp b/src/platform/cc13x2_26x2/ConfigurationManagerImpl.cpp index 15a00a54aa1ca7..5ceae39b5d5ed4 100644 --- a/src/platform/cc13x2_26x2/ConfigurationManagerImpl.cpp +++ b/src/platform/cc13x2_26x2/ConfigurationManagerImpl.cpp @@ -184,5 +184,10 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) SysCtrlSystemReset(); } +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/cc13x2_26x2/ConfigurationManagerImpl.h b/src/platform/cc13x2_26x2/ConfigurationManagerImpl.h index ad44199c34ddb5..0e1cb7726c587e 100644 --- a/src/platform/cc13x2_26x2/ConfigurationManagerImpl.h +++ b/src/platform/cc13x2_26x2/ConfigurationManagerImpl.h @@ -75,5 +75,13 @@ inline CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * b return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +ConfigurationManager & ConfigurationMgrImpl(); + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/cc13x2_26x2/PlatformManagerImpl.cpp b/src/platform/cc13x2_26x2/PlatformManagerImpl.cpp index b9b85e67845717..ec87573cd54e98 100644 --- a/src/platform/cc13x2_26x2/PlatformManagerImpl.cpp +++ b/src/platform/cc13x2_26x2/PlatformManagerImpl.cpp @@ -107,7 +107,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) // Initialize the configuration system. err = Internal::CC13X2_26X2Config::Init(); SuccessOrExit(err); - SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); // DMM Addition DMMPolicy_Params dmmPolicyParams; diff --git a/src/platform/cc32xx/ConfigurationManagerImpl.cpp b/src/platform/cc32xx/ConfigurationManagerImpl.cpp index 36028eab69a18d..4ba66c9f80bce6 100644 --- a/src/platform/cc32xx/ConfigurationManagerImpl.cpp +++ b/src/platform/cc32xx/ConfigurationManagerImpl.cpp @@ -197,5 +197,10 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) MAP_PRCMHibernateCycleTrigger(); } +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/cc32xx/ConfigurationManagerImpl.h b/src/platform/cc32xx/ConfigurationManagerImpl.h index 64be94ae27f57e..48e1771597f7a8 100644 --- a/src/platform/cc32xx/ConfigurationManagerImpl.h +++ b/src/platform/cc32xx/ConfigurationManagerImpl.h @@ -69,5 +69,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp static void DoFactoryReset(intptr_t arg); }; +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +ConfigurationManager & ConfigurationMgrImpl(); + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/cc32xx/PlatformManagerImpl.cpp b/src/platform/cc32xx/PlatformManagerImpl.cpp index 36a81fb2330ca4..258fe59d580832 100644 --- a/src/platform/cc32xx/PlatformManagerImpl.cpp +++ b/src/platform/cc32xx/PlatformManagerImpl.cpp @@ -69,7 +69,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) // Initialize the configuration system. err = Internal::CC32XXConfig::Init(); SuccessOrExit(err); - SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); // Initialize LwIP. tcpip_init(NULL, NULL); diff --git a/src/platform/fake/BUILD.gn b/src/platform/fake/BUILD.gn index ab4fe755a1cfb9..858517e8bf74bd 100644 --- a/src/platform/fake/BUILD.gn +++ b/src/platform/fake/BUILD.gn @@ -20,6 +20,7 @@ assert(chip_device_platform == "fake") static_library("fake") { sources = [ + "../SingletonConfigurationManager.cpp", "CHIPDevicePlatformEvent.h", "ConfigurationManagerImpl.cpp", "ConfigurationManagerImpl.h", diff --git a/src/platform/fake/ConfigurationManagerImpl.cpp b/src/platform/fake/ConfigurationManagerImpl.cpp index abfaecbbe6dd44..04b4b52ca89df1 100644 --- a/src/platform/fake/ConfigurationManagerImpl.cpp +++ b/src/platform/fake/ConfigurationManagerImpl.cpp @@ -19,12 +19,10 @@ ConfigurationManagerImpl & ConfigurationManagerImpl::GetDefaultInstance() return sInstance; } -ConfigurationManager & ConfigurationMgr() +ConfigurationManager & ConfigurationMgrImpl() { return ConfigurationManagerImpl::GetDefaultInstance(); } -void SetConfigurationMgr(ConfigurationManager * configurationManager) {} - } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/fake/ConfigurationManagerImpl.h b/src/platform/fake/ConfigurationManagerImpl.h index 40f53e0d0f3c9d..c63b97eaaf83d5 100644 --- a/src/platform/fake/ConfigurationManagerImpl.h +++ b/src/platform/fake/ConfigurationManagerImpl.h @@ -108,5 +108,13 @@ class ConfigurationManagerImpl : public ConfigurationManager System::Clock::Seconds32 mFirmwareBuildChipEpochTime = System::Clock::Seconds32(0); }; +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +ConfigurationManager & ConfigurationMgrImpl(); + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/mbed/ConfigurationManagerImpl.cpp b/src/platform/mbed/ConfigurationManagerImpl.cpp index b22e48cdc7f6b3..1a5b98846143bf 100644 --- a/src/platform/mbed/ConfigurationManagerImpl.cpp +++ b/src/platform/mbed/ConfigurationManagerImpl.cpp @@ -235,5 +235,10 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) system_reset(); } +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/mbed/ConfigurationManagerImpl.h b/src/platform/mbed/ConfigurationManagerImpl.h index e73c14cae0f81f..30ac3a7083a238 100644 --- a/src/platform/mbed/ConfigurationManagerImpl.h +++ b/src/platform/mbed/ConfigurationManagerImpl.h @@ -75,5 +75,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp static void DoFactoryReset(intptr_t arg); }; +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +ConfigurationManager & ConfigurationMgrImpl(); + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/mbed/PlatformManagerImpl.cpp b/src/platform/mbed/PlatformManagerImpl.cpp index 6040d36b36eae3..25b5e5e5ccb723 100644 --- a/src/platform/mbed/PlatformManagerImpl.cpp +++ b/src/platform/mbed/PlatformManagerImpl.cpp @@ -92,8 +92,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) tcpip_init(NULL, NULL); #endif - SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); - auto err = System::Clock::InitClock_RealTime(); SuccessOrExit(err); diff --git a/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp index ec29b04d2e81a8..451536e8deedbd 100644 --- a/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.cpp @@ -291,5 +291,10 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) RESET_SystemReset(); } +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.h b/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.h index bdceee20899ace..689dc8d9732d0c 100644 --- a/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.h +++ b/src/platform/nxp/k32w/k32w0/ConfigurationManagerImpl.h @@ -84,5 +84,13 @@ inline CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * b return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +ConfigurationManager & ConfigurationMgrImpl(); + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp index 4e7240c1f32202..5f00b346bddcde 100644 --- a/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp +++ b/src/platform/nxp/k32w/k32w0/PlatformManagerImpl.cpp @@ -130,8 +130,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) goto exit; } - SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); - mStartTime = System::SystemClock().GetMonotonicTimestamp(); #if CHIP_SYSTEM_CONFIG_USE_LWIP diff --git a/src/platform/nxp/mw320/BUILD.gn b/src/platform/nxp/mw320/BUILD.gn index 4c934d9c682f2c..ad8f60c6240815 100644 --- a/src/platform/nxp/mw320/BUILD.gn +++ b/src/platform/nxp/mw320/BUILD.gn @@ -25,6 +25,7 @@ if (chip_enable_openthread) { static_library("mw320") { sources = [ "../../FreeRTOS/SystemTimeSupport.cpp", + "../../SingletonConfigurationManager.cpp", "BLEManagerImpl.cpp", "BLEManagerImpl.h", "CHIPDevicePlatformConfig.h", diff --git a/src/platform/nxp/mw320/ConfigurationManagerImpl.cpp b/src/platform/nxp/mw320/ConfigurationManagerImpl.cpp index 77bb20c5b84577..ce936e476cd716 100644 --- a/src/platform/nxp/mw320/ConfigurationManagerImpl.cpp +++ b/src/platform/nxp/mw320/ConfigurationManagerImpl.cpp @@ -48,11 +48,6 @@ ConfigurationManagerImpl & ConfigurationManagerImpl::GetDefaultInstance() return sInstance; } -ConfigurationManager & ConfigurationMgr() -{ - return ConfigurationManagerImpl::GetDefaultInstance(); -} - CHIP_ERROR ConfigurationManagerImpl::Init() { CHIP_ERROR err; @@ -200,5 +195,10 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) //__NVIC_SystemReset(void); } +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/nxp/mw320/ConfigurationManagerImpl.h b/src/platform/nxp/mw320/ConfigurationManagerImpl.h index ffb7bbe16bbdf8..fbfa1c5d1bb152 100644 --- a/src/platform/nxp/mw320/ConfigurationManagerImpl.h +++ b/src/platform/nxp/mw320/ConfigurationManagerImpl.h @@ -94,8 +94,6 @@ class ConfigurationManagerImpl final : public Internal::GenericConfigurationMana // ===== Members for internal use by the following friends. friend class Internal::NetworkProvisioningServerImpl; - friend ConfigurationManager & ConfigurationMgr(void); - friend ConfigurationManagerImpl & ConfigurationMgrImpl(void); // static ConfigurationManagerImpl sInstance; @@ -104,30 +102,6 @@ class ConfigurationManagerImpl final : public Internal::GenericConfigurationMana static void DoFactoryReset(intptr_t arg); }; -#if 0 -/** - * Returns the public interface of the ConfigurationManager singleton object. - * - * Chip applications should use this to access features of the ConfigurationManager object - * that are common to all platforms. - */ -inline ConfigurationManager & ConfigurationMgr(void) -{ - return ConfigurationManagerImpl::sInstance; -} - -/** - * Returns the platform-specific implementation of the ConfigurationManager singleton object. - * - * Chio applications can use this to gain access to features of the ConfigurationManager - * that are specific to the MW320 platform. - */ -inline ConfigurationManagerImpl & ConfigurationMgrImpl(void) -{ - return ConfigurationManagerImpl::sInstance; -} -#endif // 0 - inline CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf) { wifi_mac_addr_t mac_addr; @@ -139,5 +113,13 @@ inline CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * b return CHIP_NO_ERROR; } +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +ConfigurationManager & ConfigurationMgrImpl(); + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/nxp/mw320/PlatformManagerImpl.cpp b/src/platform/nxp/mw320/PlatformManagerImpl.cpp index 0ad103dc2babad..fa9732571ea6d6 100644 --- a/src/platform/nxp/mw320/PlatformManagerImpl.cpp +++ b/src/platform/nxp/mw320/PlatformManagerImpl.cpp @@ -61,8 +61,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) err = Internal::MW320Config::Init(); SuccessOrExit(err); - // SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); - // Initialize LwIP. // tcpip_init(NULL, NULL); diff --git a/src/platform/qpg/ConfigurationManagerImpl.cpp b/src/platform/qpg/ConfigurationManagerImpl.cpp index 139cce0d681b8c..797e3b46c947c5 100644 --- a/src/platform/qpg/ConfigurationManagerImpl.cpp +++ b/src/platform/qpg/ConfigurationManagerImpl.cpp @@ -190,5 +190,10 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) qvCHIP_ResetSystem(); } +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/qpg/ConfigurationManagerImpl.h b/src/platform/qpg/ConfigurationManagerImpl.h index d267c89bfcd57b..482ead8d743a52 100644 --- a/src/platform/qpg/ConfigurationManagerImpl.h +++ b/src/platform/qpg/ConfigurationManagerImpl.h @@ -74,5 +74,13 @@ inline CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * b return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; } +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +ConfigurationManager & ConfigurationMgrImpl(); + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/qpg/PlatformManagerImpl.cpp b/src/platform/qpg/PlatformManagerImpl.cpp index 737ac78533e623..3f32b261a4c27c 100644 --- a/src/platform/qpg/PlatformManagerImpl.cpp +++ b/src/platform/qpg/PlatformManagerImpl.cpp @@ -44,7 +44,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) // Initialize the configuration system. err = Internal::QPGConfig::Init(); SuccessOrExit(err); - SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); #if CHIP_SYSTEM_CONFIG_USE_LWIP // Initialize LwIP. diff --git a/src/platform/webos/ConfigurationManagerImpl.cpp b/src/platform/webos/ConfigurationManagerImpl.cpp index 769609406c9fd6..aaad2515f963d5 100644 --- a/src/platform/webos/ConfigurationManagerImpl.cpp +++ b/src/platform/webos/ConfigurationManagerImpl.cpp @@ -390,5 +390,10 @@ CHIP_ERROR ConfigurationManagerImpl::GetLocationCapability(uint8_t & location) return err; } +ConfigurationManager & ConfigurationMgrImpl() +{ + return ConfigurationManagerImpl::GetDefaultInstance(); +} + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/webos/ConfigurationManagerImpl.h b/src/platform/webos/ConfigurationManagerImpl.h index 178fd6135fd758..6fc9961d6e50c0 100644 --- a/src/platform/webos/ConfigurationManagerImpl.h +++ b/src/platform/webos/ConfigurationManagerImpl.h @@ -88,5 +88,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp static void DoFactoryReset(intptr_t arg); }; +/** + * Returns the platform-specific implementation of the ConfigurationManager object. + * + * Applications can use this to gain access to features of the ConfigurationManager + * that are specific to the selected platform. + */ +ConfigurationManager & ConfigurationMgrImpl(); + } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/webos/PlatformManagerImpl.cpp b/src/platform/webos/PlatformManagerImpl.cpp index ec04141e621dd1..23ed0c7be8f7b5 100644 --- a/src/platform/webos/PlatformManagerImpl.cpp +++ b/src/platform/webos/PlatformManagerImpl.cpp @@ -165,7 +165,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack() // Initialize the configuration system. ReturnErrorOnFailure(Internal::PosixConfig::Init()); - SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); SetDeviceInfoProvider(&DeviceInfoProviderImpl::GetDefaultInstance()); SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());