|
27 | 27 | #include <app/data-model-provider/Provider.h>
|
28 | 28 | #include <app/server/Dnssd.h>
|
29 | 29 | #include <app/server/EchoHandler.h>
|
30 |
| -#include <app/util/DataModelHandler.h> |
31 | 30 |
|
32 | 31 | #if CONFIG_NETWORK_LAYER_BLE
|
33 | 32 | #include <ble/Ble.h>
|
@@ -170,17 +169,6 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
|
170 | 169 | SuccessOrExit(err = mAttributePersister.Init(mDeviceStorage));
|
171 | 170 | SetSafeAttributePersistenceProvider(&mAttributePersister);
|
172 | 171 |
|
173 |
| - // SetDataModelProvider() actually initializes/starts the provider. We need |
174 |
| - // to preserve the following ordering guarantees: |
175 |
| - // |
176 |
| - // 1) Provider initialization (under SetDataModelProvider) happens after |
177 |
| - // SetSafeAttributePersistenceProvider, since the provider can then use |
178 |
| - // the safe persistence provider to implement and initialize its own attribute persistence logic. |
179 |
| - // 2) For now, provider initialization happens before InitDataModelHandler(), which depends |
180 |
| - // on atttribute persistence being already set up before it runs. Longer-term, the logic from |
181 |
| - // InitDataModelHandler should just move into the codegen provider. |
182 |
| - app::InteractionModelEngine::GetInstance()->SetDataModelProvider(initParams.dataModelProvider); |
183 |
| - |
184 | 172 | {
|
185 | 173 | FabricTable::InitParams fabricTableInitParams;
|
186 | 174 | fabricTableInitParams.storage = mDeviceStorage;
|
@@ -302,8 +290,22 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
|
302 | 290 | }
|
303 | 291 | #endif // CHIP_CONFIG_ENABLE_SERVER_IM_EVENT
|
304 | 292 |
|
305 |
| - // This initializes clusters, so should come after lower level initialization. |
306 |
| - InitDataModelHandler(); |
| 293 | + // SetDataModelProvider() initializes and starts the provider, which in turn |
| 294 | + // triggers the initialization of cluster implementations. This callsite is |
| 295 | + // critical because it ensures that cluster-level initialization occurs only |
| 296 | + // after all necessary low-level dependencies have been set up. |
| 297 | + // |
| 298 | + // Ordering guarantees: |
| 299 | + // 1) Provider initialization (under SetDataModelProvider) must happen after |
| 300 | + // SetSafeAttributePersistenceProvider to ensure the provider can leverage |
| 301 | + // the safe persistence provider for attribute persistence logic. |
| 302 | + // 2) It must occur after all low-level components that cluster implementations |
| 303 | + // might depend on have been initialized, as they rely on these components |
| 304 | + // during their own initialization. |
| 305 | + // |
| 306 | + // This remains the single point of entry to ensure that all cluster-level |
| 307 | + // initialization is performed in the correct order. |
| 308 | + app::InteractionModelEngine::GetInstance()->SetDataModelProvider(initParams.dataModelProvider); |
307 | 309 |
|
308 | 310 | #if defined(CHIP_APP_USE_ECHO)
|
309 | 311 | err = InitEchoHandler(&mExchangeMgr);
|
|
0 commit comments