Skip to content

Commit 4f280ce

Browse files
authored
Do not setup ConfigurationMgr via PlatformMgr on each platform (#21075)
1 parent 641e3ad commit 4f280ce

File tree

60 files changed

+264
-91
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+264
-91
lines changed

src/include/platform/ConfigurationManager.h

+12-3
Original file line numberDiff line numberDiff line change
@@ -181,17 +181,26 @@ class ConfigurationManager
181181
/**
182182
* Returns a reference to a ConfigurationManager object.
183183
*
184-
* Applications should use this to access the features of the ConfigurationManager.
184+
* Applications should use this to access features of the ConfigurationManager object
185+
* that are common to all platforms.
185186
*/
186-
extern ConfigurationManager & ConfigurationMgr();
187+
ConfigurationManager & ConfigurationMgr();
188+
189+
/**
190+
* Returns the platform-specific implementation of the ConfigurationManager object.
191+
*
192+
* Applications can use this to gain access to features of the ConfigurationManager
193+
* that are specific to the selected platform.
194+
*/
195+
extern ConfigurationManager & ConfigurationMgrImpl();
187196

188197
/**
189198
* Sets a reference to a ConfigurationManager object.
190199
*
191200
* This must be called before any calls to ConfigurationMgr. If a nullptr is passed in,
192201
* no changes will be made.
193202
*/
194-
extern void SetConfigurationMgr(ConfigurationManager * configurationManager);
203+
void SetConfigurationMgr(ConfigurationManager * configurationManager);
195204

196205
inline CHIP_ERROR ConfigurationManager::GetLocationCapability(uint8_t & location)
197206
{

src/platform/Ameba/ConfigurationManagerImpl.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -284,5 +284,10 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg)
284284
// sys_reset();
285285
}
286286

287+
ConfigurationManager & ConfigurationMgrImpl()
288+
{
289+
return ConfigurationManagerImpl::GetDefaultInstance();
290+
}
291+
287292
} // namespace DeviceLayer
288293
} // namespace chip

src/platform/Ameba/ConfigurationManagerImpl.h

+8
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
7676
static void DoFactoryReset(intptr_t arg);
7777
};
7878

79+
/**
80+
* Returns the platform-specific implementation of the ConfigurationManager object.
81+
*
82+
* Applications can use this to gain access to features of the ConfigurationManager
83+
* that are specific to the selected platform.
84+
*/
85+
ConfigurationManager & ConfigurationMgrImpl();
86+
7987
} // namespace DeviceLayer
8088
} // namespace chip

src/platform/Ameba/PlatformManagerImpl.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
5959

6060
CHIP_ERROR err;
6161

62-
SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance());
63-
6462
// Make sure the LwIP core lock has been initialized
6563
err = Internal::InitLwIPCoreLock();
6664

src/platform/CYW30739/ConfigurationManagerImpl.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -212,5 +212,10 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg)
212212
wiced_hal_wdog_reset_system();
213213
}
214214

215+
ConfigurationManager & ConfigurationMgrImpl()
216+
{
217+
return ConfigurationManagerImpl::GetDefaultInstance();
218+
}
219+
215220
} // namespace DeviceLayer
216221
} // namespace chip

src/platform/CYW30739/ConfigurationManagerImpl.h

+8
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
7474
static void DoFactoryReset(intptr_t arg);
7575
};
7676

77+
/**
78+
* Returns the platform-specific implementation of the ConfigurationManager object.
79+
*
80+
* Applications can use this to gain access to features of the ConfigurationManager
81+
* that are specific to the selected platform.
82+
*/
83+
ConfigurationManager & ConfigurationMgrImpl();
84+
7785
} // namespace DeviceLayer
7886
} // namespace chip

src/platform/CYW30739/PlatformManagerImpl.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
4545
err = PersistedStorage::KeyValueStoreMgrImpl().Init();
4646
SuccessOrExit(err);
4747

48-
SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance());
49-
5048
/* Create the thread object. */
5149
mThread = wiced_rtos_create_thread();
5250
VerifyOrExit(mThread != nullptr, err = CHIP_ERROR_NO_MEMORY);

src/platform/Darwin/ConfigurationManagerImpl.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -496,5 +496,10 @@ void ConfigurationManagerImpl::RunConfigUnitTest(void)
496496
#endif // CHIP_DISABLE_PLATFORM_KVS
497497
}
498498

499+
ConfigurationManager & ConfigurationMgrImpl()
500+
{
501+
return ConfigurationManagerImpl::GetDefaultInstance();
502+
}
503+
499504
} // namespace DeviceLayer
500505
} // namespace chip

src/platform/Darwin/ConfigurationManagerImpl.h

+8
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
9292
void RunConfigUnitTest(void) override;
9393
};
9494

95+
/**
96+
* Returns the platform-specific implementation of the ConfigurationManager object.
97+
*
98+
* Applications can use this to gain access to features of the ConfigurationManager
99+
* that are specific to the selected platform.
100+
*/
101+
ConfigurationManager & ConfigurationMgrImpl();
102+
95103
} // namespace DeviceLayer
96104
} // namespace chip

src/platform/Darwin/PlatformManagerImpl.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack()
5252
SuccessOrExit(err);
5353
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());
5454
#endif // CHIP_DISABLE_PLATFORM_KVS
55-
SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance());
5655

5756
mRunLoopSem = dispatch_semaphore_create(0);
5857

src/platform/EFR32/ConfigurationManagerImpl.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -307,5 +307,10 @@ CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf)
307307
}
308308
#endif
309309

310+
ConfigurationManager & ConfigurationMgrImpl()
311+
{
312+
return ConfigurationManagerImpl::GetDefaultInstance();
313+
}
314+
310315
} // namespace DeviceLayer
311316
} // namespace chip

src/platform/EFR32/ConfigurationManagerImpl.h

+9-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,15 @@ inline CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * b
8282
{
8383
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
8484
}
85-
8685
#endif /* SL_WIFI */
86+
87+
/**
88+
* Returns the platform-specific implementation of the ConfigurationManager object.
89+
*
90+
* Applications can use this to gain access to features of the ConfigurationManager
91+
* that are specific to the selected platform.
92+
*/
93+
ConfigurationManager & ConfigurationMgrImpl();
94+
8795
} // namespace DeviceLayer
8896
} // namespace chip

src/platform/EFR32/PlatformManagerImpl.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
5050
err = chip::DeviceLayer::PersistedStorage::KeyValueStoreMgrImpl().Init();
5151
SuccessOrExit(err);
5252

53-
SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance());
54-
5553
#if CHIP_SYSTEM_CONFIG_USE_LWIP
5654
// Initialize LwIP.
5755
tcpip_init(NULL, NULL);

src/platform/ESP32/ConfigurationManagerImpl.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -337,5 +337,10 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg)
337337
esp_restart();
338338
}
339339

340+
ConfigurationManager & ConfigurationMgrImpl()
341+
{
342+
return ConfigurationManagerImpl::GetDefaultInstance();
343+
}
344+
340345
} // namespace DeviceLayer
341346
} // namespace chip

src/platform/ESP32/ConfigurationManagerImpl.h

+8
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
8787
static void DoFactoryReset(intptr_t arg);
8888
};
8989

90+
/**
91+
* Returns the platform-specific implementation of the ConfigurationManager object.
92+
*
93+
* Applications can use this to gain access to features of the ConfigurationManager
94+
* that are specific to the selected platform.
95+
*/
96+
ConfigurationManager & ConfigurationMgrImpl();
97+
9098
} // namespace DeviceLayer
9199
} // namespace chip

src/platform/ESP32/PlatformManagerImpl.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ static int app_entropy_source(void * data, unsigned char * output, size_t len, s
5959

6060
CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
6161
{
62-
SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance());
63-
6462
esp_err_t err;
6563
// Arrange for CHIP-encapsulated ESP32 errors to be translated to text
6664
Internal::ESP32Utils::RegisterESP32ErrorFormatter();

src/platform/Linux/ConfigurationManagerImpl.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -397,5 +397,10 @@ CHIP_ERROR ConfigurationManagerImpl::GetLocationCapability(uint8_t & location)
397397
return err;
398398
}
399399

400+
ConfigurationManager & ConfigurationMgrImpl()
401+
{
402+
return ConfigurationManagerImpl::GetDefaultInstance();
403+
}
404+
400405
} // namespace DeviceLayer
401406
} // namespace chip

src/platform/Linux/ConfigurationManagerImpl.h

+8
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
8888
static void DoFactoryReset(intptr_t arg);
8989
};
9090

91+
/**
92+
* Returns the platform-specific implementation of the ConfigurationManager object.
93+
*
94+
* Applications can use this to gain access to features of the ConfigurationManager
95+
* that are specific to the selected platform.
96+
*/
97+
ConfigurationManager & ConfigurationMgrImpl();
98+
9199
} // namespace DeviceLayer
92100
} // namespace chip

src/platform/Linux/PlatformManagerImpl.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack()
175175

176176
// Initialize the configuration system.
177177
ReturnErrorOnFailure(Internal::PosixConfig::Init());
178-
SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance());
179178
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());
180179

181180
// Call _InitChipStack() on the generic implementation base class

src/platform/P6/ConfigurationManagerImpl.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -238,5 +238,10 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg)
238238
NVIC_SystemReset();
239239
}
240240

241+
ConfigurationManager & ConfigurationMgrImpl()
242+
{
243+
return ConfigurationManagerImpl::GetDefaultInstance();
244+
}
245+
241246
} // namespace DeviceLayer
242247
} // namespace chip

src/platform/P6/ConfigurationManagerImpl.h

+8
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
7878
static void DoFactoryReset(intptr_t arg);
7979
};
8080

81+
/**
82+
* Returns the platform-specific implementation of the ConfigurationManager object.
83+
*
84+
* Applications can use this to gain access to features of the ConfigurationManager
85+
* that are specific to the selected platform.
86+
*/
87+
ConfigurationManager & ConfigurationMgrImpl();
88+
8189
} // namespace DeviceLayer
8290
} // namespace chip

src/platform/P6/PlatformManagerImpl.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
4343
{
4444
CHIP_ERROR err;
4545

46-
SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance());
47-
4846
// Make sure the LwIP core lock has been initialized
4947
err = Internal::InitLwIPCoreLock();
5048
SuccessOrExit(err);

src/platform/SingletonConfigurationManager.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222

2323
#include <lib/support/CodeUtils.h>
24+
#include <platform/ConfigurationManager.h>
2425

2526
namespace chip {
2627
namespace DeviceLayer {
@@ -37,8 +38,12 @@ ConfigurationManager * gInstance = nullptr;
3738

3839
ConfigurationManager & ConfigurationMgr()
3940
{
40-
VerifyOrDie(gInstance != nullptr);
41-
return *gInstance;
41+
if (gInstance != nullptr)
42+
{
43+
return *gInstance;
44+
}
45+
46+
return ConfigurationMgrImpl();
4247
}
4348

4449
void SetConfigurationMgr(ConfigurationManager * configurationManager)

src/platform/Tizen/ConfigurationManagerImpl.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -177,5 +177,10 @@ void ConfigurationManagerImpl::RunConfigUnitTest(void)
177177
PosixConfig::RunConfigUnitTest();
178178
}
179179

180+
ConfigurationManager & ConfigurationMgrImpl()
181+
{
182+
return ConfigurationManagerImpl::GetDefaultInstance();
183+
}
184+
180185
} // namespace DeviceLayer
181186
} // namespace chip

src/platform/Tizen/ConfigurationManagerImpl.h

+8
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
7272
void RunConfigUnitTest(void) override;
7373
};
7474

75+
/**
76+
* Returns the platform-specific implementation of the ConfigurationManager object.
77+
*
78+
* Applications can use this to gain access to features of the ConfigurationManager
79+
* that are specific to the selected platform.
80+
*/
81+
ConfigurationManager & ConfigurationMgrImpl();
82+
7583
} // namespace DeviceLayer
7684
} // namespace chip

src/platform/Tizen/PlatformManagerImpl.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ PlatformManagerImpl PlatformManagerImpl::sInstance;
3939
CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
4040
{
4141
ReturnErrorOnFailure(Internal::PosixConfig::Init());
42-
SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance());
4342
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());
4443

4544
return Internal::GenericPlatformManagerImpl_POSIX<PlatformManagerImpl>::_InitChipStack();

src/platform/Zephyr/ConfigurationManagerImpl.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -180,5 +180,10 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg)
180180
PlatformMgr().Shutdown();
181181
}
182182

183+
ConfigurationManager & ConfigurationMgrImpl()
184+
{
185+
return ConfigurationManagerImpl::GetDefaultInstance();
186+
}
187+
183188
} // namespace DeviceLayer
184189
} // namespace chip

src/platform/Zephyr/ConfigurationManagerImpl.h

+8
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,13 @@ inline CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * /
9999
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
100100
}
101101

102+
/**
103+
* Returns the platform-specific implementation of the ConfigurationManager object.
104+
*
105+
* Applications can use this to gain access to features of the ConfigurationManager
106+
* that are specific to the selected platform.
107+
*/
108+
ConfigurationManager & ConfigurationMgrImpl();
109+
102110
} // namespace DeviceLayer
103111
} // namespace chip

src/platform/Zephyr/PlatformManagerImpl.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
106106
// Initialize the configuration system.
107107
err = Internal::ZephyrConfig::Init();
108108
SuccessOrExit(err);
109-
SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance());
110109

111110
#if !CONFIG_NORDIC_SECURITY_BACKEND
112111
// Add entropy source based on Zephyr entropy driver

src/platform/android/ConfigurationManagerImpl.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -215,5 +215,10 @@ CHIP_ERROR ConfigurationManagerImpl::GetUniqueId(char * buf, size_t bufSize)
215215
return ReadConfigValueStr(AndroidConfig::kConfigKey_UniqueId, buf, bufSize, dateLen);
216216
}
217217

218+
ConfigurationManager & ConfigurationMgrImpl()
219+
{
220+
return ConfigurationManagerImpl::GetDefaultInstance();
221+
}
222+
218223
} // namespace DeviceLayer
219224
} // namespace chip

src/platform/android/ConfigurationManagerImpl.h

+8
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,13 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp
8383
jobject mConfigurationManagerObject = nullptr;
8484
};
8585

86+
/**
87+
* Returns the platform-specific implementation of the ConfigurationManager object.
88+
*
89+
* Applications can use this to gain access to features of the ConfigurationManager
90+
* that are specific to the selected platform.
91+
*/
92+
ConfigurationManager & ConfigurationMgrImpl();
93+
8694
} // namespace DeviceLayer
8795
} // namespace chip

src/platform/android/PlatformManagerImpl.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack()
4646
// Initialize the configuration system.
4747
err = Internal::AndroidConfig::Init();
4848
SuccessOrExit(err);
49-
SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance());
5049
SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl());
5150

5251
// Call _InitChipStack() on the generic implementation base class

0 commit comments

Comments
 (0)