net: lwm2m: Add LWM2M_ON_INIT() macro
Add macro that allows registration of initialization functions that are called when LwM2M engine starts. On LwM2M engine starts up, it first executes all initialization functions in following priority order: 1. LWM2M_PRIO_ENGINE 2. LWM2M_PRIO_CORE, this is where all LwM2M core objects are initialized 3. LWM2M_PRIO_OBJ, this is where all other objects are initialized 4. LwM2M_PRIO_APP, application initialization. Now on the initialization phase, we could rely that certain objects have already been registered. For example custom objects can register callbacks to core objects. On application phase, we can initialize sensor objects and register their callbacks because objects have already been initialized. This LWM2M_ON_INIT() should replace all use of SYS_INIT() with the default CONFIG_KERNEL_INIT_PRIORITY_DEFAULT. Priority order is actually just alphabetical order of names, so the order is set on a linkin phase, and we don't need any runtime checking for it. Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
This commit is contained in:
parent
d1e4c17e6d
commit
ec3ec8cd2a
36 changed files with 105 additions and 47 deletions
|
@ -10,6 +10,7 @@ set(APP_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
|||
target_sources(app PRIVATE ${APP_SRC_DIR}/main.c)
|
||||
target_sources(app PRIVATE ${APP_SRC_DIR}/stubs.c)
|
||||
target_sources(app PRIVATE ${ZEPHYR_BASE}/subsys/net/lib/lwm2m/lwm2m_engine.c)
|
||||
zephyr_linker_sources(SECTIONS ${ZEPHYR_BASE}/subsys/net/lib/lwm2m/iterables.ld)
|
||||
|
||||
# Add includes directories
|
||||
target_include_directories(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||
|
|
|
@ -612,7 +612,6 @@ ZTEST(lwm2m_registry, test_resource_cache)
|
|||
struct lwm2m_time_series_elem e;
|
||||
|
||||
/* Resource cache is turned off */
|
||||
zassert_equal(lwm2m_engine_data_cache_init(), 0);
|
||||
zassert_is_null(lwm2m_cache_entry_get_by_object(&path));
|
||||
zassert_equal(lwm2m_enable_cache(&path, &e, 1), -ENOTSUP);
|
||||
/* deprecated */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue