Skip to content

Commit 505ecd6

Browse files
jtguggedaljorgenmk
authored andcommitted
lib: lte_lc: Make all modules optional
Make all modules optional. The previously mandatory modules are now possible to disable, while keeping them enabled by default. Signed-off-by: Jan Tore Guggedal <[email protected]>
1 parent db2d830 commit 505ecd6

File tree

7 files changed

+98
-7
lines changed

7 files changed

+98
-7
lines changed

doc/nrf/nrf.doxyfile.in

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2457,6 +2457,11 @@ PREDEFINED = __DOXYGEN__ \
24572457
"CONFIG_NRF_MODEM=y" \
24582458
"CONFIG_NRF_CLOUD_GATEWAY=y" \
24592459
"CONFIG_BT_CENTRAL" \
2460+
"CONFIG_LTE_LC_FUNCTIONAL_MODE_MODULE=y" \
2461+
"CONFIG_LTE_LC_NETWORK_REGISTRATION_MODULE=y" \
2462+
"CONFIG_LTE_LC_CONNECTION_STATUS_MODULE=y" \
2463+
"CONFIG_LTE_LC_MODEM_EVENTS_MODULE=y" \
2464+
"CONFIG_LTE_LC_SYSTEM_MODE_MODULE=y" \
24602465
"CONFIG_LTE_LC_CONN_EVAL_MODULE=y" \
24612466
"CONFIG_LTE_LC_EDRX_MODULE=y" \
24622467
"CONFIG_LTE_LC_NEIGHBOR_CELL_MEAS_MODULE=y" \
@@ -2466,7 +2471,8 @@ PREDEFINED = __DOXYGEN__ \
24662471
"CONFIG_LTE_LC_MODEM_SLEEP_MODULE=y" \
24672472
"CONFIG_LTE_LC_TAU_PRE_WARNING_MODULE=y" \
24682473
"CONFIG_LTE_LC_ENV_EVAL_MODULE=y" \
2469-
"CONFIG_LTE_LC_PDN_MODULE=y"
2474+
"CONFIG_LTE_LC_PDN_MODULE=y" \
2475+
"CONFIG_LTE_LC_DNS_FALLBACK_MODULE=y"
24702476

24712477

24722478
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,9 @@ Modem libraries
909909
* New registration statuses and functional modes for the ``mfw_nrf9151-ntn`` modem firmware.
910910
* Support for PDP context and PDN connection management.
911911
The functionality is available when the :kconfig:option:`CONFIG_LTE_LC_PDN_MODULE` Kconfig option is enabled.
912+
* Support for also disabling the default modules that are enabled by default.
913+
This is useful when the application only needs a subset of the functionality provided by the library and to reduce the size of the application image.
914+
To disable a module, set the corresponding ``CONFIG_LTE_LC_<MODULE_NAME>_MODULE`` Kconfig option to ``n``.
912915

913916
* Updated:
914917

include/modem/lte_lc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,13 +473,15 @@ enum lte_lc_evt_type {
473473
LTE_LC_EVT_ENV_EVAL_RESULT = 13,
474474
#endif /* CONFIG_LTE_LC_ENV_EVAL_MODULE */
475475

476+
#if defined(CONFIG_LTE_LC_PDN_MODULE)
476477
/**
477478
* PDN event
478479
*
479480
* The associated payload is the @c lte_lc_evt.pdn member of type
480481
* @ref lte_lc_pdn_evt in the event.
481482
*/
482483
LTE_LC_EVT_PDN = 14,
484+
#endif /* CONFIG_LTE_LC_PDN_MODULE */
483485

484486
/**
485487
* A cellular profile is activated for the current access technology.

lib/lte_link_control/Kconfig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,37 @@ if LTE_LINK_CONTROL
1717
config HEAP_MEM_POOL_ADD_SIZE_LTE_LINK_CONTROL
1818
int "Heap required for event handlers"
1919
default 32
20+
default 96 if LTE_LC_PDN_MODULE
2021
help
2122
Extra heap size required for allocating event handlers.
2223
Default is enough for 4 handlers.
2324

2425
# Modules: these Kconfig options enable specific features of the library.
2526

27+
config LTE_LC_FUNCTIONAL_MODE_MODULE
28+
bool "Functional mode module"
29+
default y
30+
31+
config LTE_LC_NETWORK_REGISTRATION_MODULE
32+
bool "Network registration module"
33+
depends on LTE_LC_FUNCTIONAL_MODE_MODULE
34+
default y
35+
36+
config LTE_LC_CONNECTION_STATUS_MODULE
37+
bool "Connection status module"
38+
default y
39+
40+
config LTE_LC_MODEM_EVENTS_MODULE
41+
bool "Modem events module"
42+
default y
43+
44+
config LTE_LC_SYSTEM_MODE_MODULE
45+
bool "System mode module"
46+
default y
47+
2648
config LTE_LC_CONN_EVAL_MODULE
2749
bool "Connection Parameters Evaluation module"
50+
depends on LTE_LC_FUNCTIONAL_MODE_MODULE
2851

2952
config LTE_LC_EDRX_MODULE
3053
bool "Extended Discontinuous Reception (eDRX) module"
@@ -49,6 +72,7 @@ config LTE_LC_TAU_PRE_WARNING_MODULE
4972

5073
config LTE_LC_ENV_EVAL_MODULE
5174
bool "Environment Evaluation module"
75+
depends on LTE_LC_FUNCTIONAL_MODE_MODULE
5276

5377
config LTE_LC_PDN_MODULE
5478
bool "Packet Data Network (PDN) module"

lib/lte_link_control/modules/CMakeLists.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
#
66

7-
zephyr_library_sources(cereg.c)
8-
zephyr_library_sources(cfun.c)
9-
zephyr_library_sources(cscon.c)
10-
zephyr_library_sources(mdmev.c)
11-
zephyr_library_sources(xsystemmode.c)
7+
zephyr_library_sources_ifdef(CONFIG_LTE_LC_NETWORK_REGISTRATION_MODULE cereg.c)
8+
zephyr_library_sources_ifdef(CONFIG_LTE_LC_FUNCTIONAL_MODE_MODULE cfun.c)
9+
zephyr_library_sources_ifdef(CONFIG_LTE_LC_CONNECTION_STATUS_MODULE cscon.c)
10+
zephyr_library_sources_ifdef(CONFIG_LTE_LC_MODEM_EVENTS_MODULE mdmev.c)
11+
zephyr_library_sources_ifdef(CONFIG_LTE_LC_SYSTEM_MODE_MODULE xsystemmode.c)
1212
zephyr_library_sources_ifdef(CONFIG_LTE_LC_CONN_EVAL_MODULE coneval.c)
1313
zephyr_library_sources_ifdef(CONFIG_LTE_LC_EDRX_MODULE edrx.c)
1414
zephyr_library_sources_ifdef(CONFIG_LTE_LC_NEIGHBOR_CELL_MEAS_MODULE ncellmeas.c)

lib/lte_link_control/modules/cfun.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,21 @@ LOG_MODULE_DECLARE(lte_lc, CONFIG_LTE_LINK_CONTROL_LOG_LEVEL);
2727

2828
static int enable_notifications(void)
2929
{
30-
int err;
30+
int err = 0;
3131

32+
#if defined(CONFIG_LTE_LC_NETWORK_REGISTRATION_MODULE)
3233
err = cereg_notifications_enable();
3334
if (err) {
3435
return err;
3536
}
37+
#endif
3638

39+
#if defined(CONFIG_LTE_LC_CONNECTION_STATUS_MODULE)
3740
err = cscon_notifications_enable();
3841
if (err) {
3942
return err;
4043
}
44+
#endif
4145

4246
#if defined(CONFIG_LTE_LC_MODEM_SLEEP_MODULE)
4347
err = xmodemsleep_notifications_enable();
@@ -53,6 +57,7 @@ static int enable_notifications(void)
5357
}
5458
#endif
5559

60+
#if defined(CONFIG_LTE_LC_MODEM_EVENTS_MODULE)
5661
if (mdmev_enabled) {
5762
/* Modem events have been enabled by the application, so the notifications need
5863
* to be subscribed to again. This is done using the same function which is used
@@ -63,6 +68,7 @@ static int enable_notifications(void)
6368
return err;
6469
}
6570
}
71+
#endif /* CONFIG_LTE_LC_MODEM_EVENTS_MODULE */
6672

6773
return 0;
6874
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
10+
project(lte_lc_pdn)
11+
12+
FILE(GLOB app_sources src/*.c)
13+
target_sources(app PRIVATE ${app_sources})
14+
target_sources(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/stubs/lte_lc_stubs.c)
15+
16+
test_runner_generate(src/main.c)
17+
18+
target_sources(app
19+
PRIVATE
20+
${ZEPHYR_NRF_MODULE_DIR}/lib/lte_link_control/lte_lc.c
21+
${ZEPHYR_NRF_MODULE_DIR}/lib/lte_link_control/modules/pdn.c
22+
${ZEPHYR_NRF_MODULE_DIR}/lib/lte_link_control/modules/esm.c
23+
${ZEPHYR_NRF_MODULE_DIR}/lib/lte_link_control/modules/cellular_profile.c
24+
${ZEPHYR_NRF_MODULE_DIR}/lib/lte_link_control/common/event_handler_list.c
25+
)
26+
27+
zephyr_include_directories(${CMAKE_CURRENT_SOURCE_DIR}/stubs)
28+
zephyr_include_directories(${ZEPHYR_NRFXLIB_MODULE_DIR}/nrf_modem/include/)
29+
zephyr_include_directories(${ZEPHYR_NRF_MODULE_DIR}/include/modem/)
30+
zephyr_include_directories(${ZEPHYR_NRF_MODULE_DIR}/lib/lte_link_control/)
31+
zephyr_include_directories(${ZEPHYR_NRF_MODULE_DIR}/lib/lte_link_control/include)
32+
zephyr_include_directories(${ZEPHYR_NRF_MODULE_DIR}/lib/lte_link_control/include/modules/)
33+
zephyr_include_directories(${ZEPHYR_NRF_MODULE_DIR}/lib/lte_link_control/include/common/)
34+
zephyr_include_directories(${ZEPHYR_NRF_MODULE_DIR}/lib/at_monitor/)
35+
zephyr_include_directories(${ZEPHYR_NRF_MODULE_DIR}/lib/at_parser/)
36+
zephyr_include_directories(${ZEPHYR_BASE}/subsys/testsuite/include)
37+
38+
add_compile_definitions(CONFIG_LTE_LC_PDN_MODULE=1)
39+
add_compile_definitions(CONFIG_LTE_LC_PDN_HEAP_SIZE=64)
40+
add_compile_definitions(CONFIG_LTE_LC_PDN_ESM_TIMEOUT=1000)
41+
add_compile_definitions(CONFIG_LTE_LC_PDN_DEFAULTS_OVERRIDE)
42+
add_compile_definitions(CONFIG_LTE_LC_PDN_DEFAULT_APN="apn0")
43+
add_compile_definitions(CONFIG_LTE_LC_PDN_DEFAULT_FAM=2)
44+
add_compile_definitions(CONFIG_LTE_LC_PDN_ESM_STRERROR)
45+
add_compile_definitions(CONFIG_HEAP_MEM_POOL_ADD_SIZE_LTE_LC_PDN=64)
46+
add_compile_definitions(CONFIG_LTE_LINK_CONTROL)
47+
add_compile_definitions(CONFIG_LTE_LC_CELLULAR_PROFILE_MODULE=1)
48+
add_compile_definitions(CONFIG_LTE_LINK_CONTROL_LOG_LEVEL=0)
49+
add_compile_definitions(CONFIG_AT_MONITOR_LOG_LEVEL=0)
50+
add_compile_definitions(CONFIG_HEAP_MEM_POOL_ADD_SIZE_LTE_LINK_CONTROL=96)

0 commit comments

Comments
 (0)