From b88446c2298cc8bc4dd4fabcdb12a03d5cf8de32 Mon Sep 17 00:00:00 2001 From: Emanuele Di Santo Date: Thu, 22 Jun 2023 16:55:26 +0200 Subject: [PATCH] lib: nrf_modem: rename `lte_connectivity` to `lte_net_if` `lte_connectivity` is not a good name for this component. It is possible to have full LTE connectivity without it. Rather, what it does is provide support for Zephyr net_if API, allowing the application to control the nRF91 as a Zephyr network interface. Rename to componenent `lte_net_if` and prefix Kconfig with `NRF_MODEM_LIB` to indicate that it belongs to the nrf_modem library NCS integration layer. Signed-off-by: Emanuele Di Santo --- lib/nrf_modem_lib/CMakeLists.txt | 2 +- lib/nrf_modem_lib/Kconfig | 2 +- lib/nrf_modem_lib/Kconfig.modemlib | 2 +- .../CMakeLists.txt | 2 +- .../{lte_connectivity => lte_net_if}/Kconfig | 24 ++++---- .../lte_ip_addr_helper.c | 2 +- .../lte_ip_addr_helper.h | 0 .../lte_net_if.c} | 60 +++++++++---------- .../lte_net_if.h} | 50 ++++++++-------- lib/nrf_modem_lib/nrf91_sockets.c | 30 +++++----- .../net/mqtt/boards/nrf9160dk_nrf9160_ns.conf | 6 +- .../net/mqtt/boards/thingy91_nrf9160_ns.conf | 6 +- .../mqtt/src/modules/network/Kconfig.network | 2 +- .../CMakeLists.txt | 20 +++---- .../{lte_connectivity => lte_net_if}/Kconfig | 2 +- .../{lte_connectivity => lte_net_if}/prj.conf | 0 .../src/main.c} | 52 ++++++++-------- .../testcase.yaml | 2 +- 18 files changed, 132 insertions(+), 132 deletions(-) rename lib/nrf_modem_lib/{lte_connectivity => lte_net_if}/CMakeLists.txt (74%) rename lib/nrf_modem_lib/{lte_connectivity => lte_net_if}/Kconfig (78%) rename lib/nrf_modem_lib/{lte_connectivity => lte_net_if}/lte_ip_addr_helper.c (98%) rename lib/nrf_modem_lib/{lte_connectivity => lte_net_if}/lte_ip_addr_helper.h (100%) rename lib/nrf_modem_lib/{lte_connectivity/lte_connectivity.c => lte_net_if/lte_net_if.c} (85%) rename lib/nrf_modem_lib/{lte_connectivity/lte_connectivity.h => lte_net_if/lte_net_if.h} (83%) rename tests/lib/nrf_modem_lib/{lte_connectivity => lte_net_if}/CMakeLists.txt (68%) rename tests/lib/nrf_modem_lib/{lte_connectivity => lte_net_if}/Kconfig (62%) rename tests/lib/nrf_modem_lib/{lte_connectivity => lte_net_if}/prj.conf (100%) rename tests/lib/nrf_modem_lib/{lte_connectivity/src/lte_connectivity_test.c => lte_net_if/src/main.c} (87%) rename tests/lib/nrf_modem_lib/{lte_connectivity => lte_net_if}/testcase.yaml (76%) diff --git a/lib/nrf_modem_lib/CMakeLists.txt b/lib/nrf_modem_lib/CMakeLists.txt index 00eeb69fb23c..44ae358348fa 100644 --- a/lib/nrf_modem_lib/CMakeLists.txt +++ b/lib/nrf_modem_lib/CMakeLists.txt @@ -10,7 +10,7 @@ zephyr_library_sources(nrf_modem_os.c) zephyr_library_sources_ifdef(CONFIG_NRF_MODEM_LIB_MEM_DIAG diag.c) zephyr_library_sources_ifdef(CONFIG_NET_SOCKETS nrf91_sockets.c) -add_subdirectory_ifdef(CONFIG_LTE_CONNECTIVITY lte_connectivity) +add_subdirectory_ifdef(CONFIG_NRF_MODEM_LIB_NET_IF lte_net_if) if(CONFIG_NRF_MODEM_LIB_TRACE) zephyr_library_sources(nrf_modem_lib_trace.c) diff --git a/lib/nrf_modem_lib/Kconfig b/lib/nrf_modem_lib/Kconfig index eaf17aa7d30e..6c03cd3af10f 100644 --- a/lib/nrf_modem_lib/Kconfig +++ b/lib/nrf_modem_lib/Kconfig @@ -21,6 +21,6 @@ menuconfig NRF_MODEM_LIB if NRF_MODEM_LIB rsource "Kconfig.modemlib" -rsource "lte_connectivity/Kconfig" +rsource "lte_net_if/Kconfig" endif # NRF_MODEM_LIB diff --git a/lib/nrf_modem_lib/Kconfig.modemlib b/lib/nrf_modem_lib/Kconfig.modemlib index 531f198a61c2..4f36e058b256 100644 --- a/lib/nrf_modem_lib/Kconfig.modemlib +++ b/lib/nrf_modem_lib/Kconfig.modemlib @@ -22,7 +22,7 @@ config NRF_MODEM_LIB_SYS_INIT config NRF_MODEM_LIB_NET_IF_AUTO_START bool "Network interface auto-start" - depends on LTE_CONNECTIVITY + depends on NRF_MODEM_LIB_NET_IF default y help If this option is enabled, the modem is automatically initialized from the main context diff --git a/lib/nrf_modem_lib/lte_connectivity/CMakeLists.txt b/lib/nrf_modem_lib/lte_net_if/CMakeLists.txt similarity index 74% rename from lib/nrf_modem_lib/lte_connectivity/CMakeLists.txt rename to lib/nrf_modem_lib/lte_net_if/CMakeLists.txt index 96c324fdb5b2..e1b558316e17 100644 --- a/lib/nrf_modem_lib/lte_connectivity/CMakeLists.txt +++ b/lib/nrf_modem_lib/lte_net_if/CMakeLists.txt @@ -5,5 +5,5 @@ # target_include_directories(app PRIVATE .) -target_sources(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/lte_connectivity.c) +target_sources(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/lte_net_if.c) target_sources(app PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/lte_ip_addr_helper.c) diff --git a/lib/nrf_modem_lib/lte_connectivity/Kconfig b/lib/nrf_modem_lib/lte_net_if/Kconfig similarity index 78% rename from lib/nrf_modem_lib/lte_connectivity/Kconfig rename to lib/nrf_modem_lib/lte_net_if/Kconfig index 3e0498aa144e..087ecd09ec5b 100644 --- a/lib/nrf_modem_lib/lte_connectivity/Kconfig +++ b/lib/nrf_modem_lib/lte_net_if/Kconfig @@ -3,8 +3,8 @@ # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause # -menuconfig LTE_CONNECTIVITY - bool "LTE Connectivity" +menuconfig NRF_MODEM_LIB_NET_IF + bool "Zephyr net_if API support" select PDN select PDN_ESM_STRERROR select LTE_LINK_CONTROL @@ -13,17 +13,17 @@ menuconfig LTE_CONNECTIVITY depends on !NET_IPV6_MLD depends on NRF_MODEM_LIB_ON_FAULT_APPLICATION_SPECIFIC help - Library used to provide connectivity for nRF91 based boards via Zephyr network management. + Add support for controlling the nRF91 modem using Zephyr network interface API. -if LTE_CONNECTIVITY +if NRF_MODEM_LIB_NET_IF -config LTE_CONNECTIVITY_WORKQUEUE_STACK_SIZE +config NRF_MODEM_LIB_NET_IF_WORKQUEUE_STACK_SIZE int "Workqueue stack size" default 1024 help Stack size of the internal workqueue. -config LTE_CONNECTIVITY_CONNECT_TIMEOUT_SECONDS +config NRF_MODEM_LIB_NET_IF_CONNECT_TIMEOUT_SECONDS int "Connect timeout in seconds" default 0 help @@ -33,7 +33,7 @@ config LTE_CONNECTIVITY_CONNECT_TIMEOUT_SECONDS When the timeout is disabled, the library relies solely on the modem's internal connection handling to upkeep the connection. -config LTE_CONNECTIVITY_CONNECTION_PERSISTENCE +config NRF_MODEM_LIB_NET_IF_CONNECTION_PERSISTENCE bool "Connection persistency" default y help @@ -42,7 +42,7 @@ config LTE_CONNECTIVITY_CONNECTION_PERSISTENCE Persistence can be updated run-time by calling conn_mgr_if_set_flag() with CONN_MGR_IF_PERSISTENT as flag parameter. -config LTE_CONNECTIVITY_AUTO_CONNECT +config NRF_MODEM_LIB_NET_IF_AUTO_CONNECT bool "Auto connect" default y help @@ -50,7 +50,7 @@ config LTE_CONNECTIVITY_AUTO_CONNECT network interface has been brought up. This option sets the default value, the option has a corresponding flag that can be set at run time by calling conn_mgr_if_set_flag(). -config LTE_CONNECTIVITY_AUTO_DOWN +config NRF_MODEM_LIB_NET_IF_AUTO_DOWN bool "Auto down" default y help @@ -58,8 +58,8 @@ config LTE_CONNECTIVITY_AUTO_DOWN down when it stops trying to connect. This option sets the default value, the option has a corresponding flag that can be set at run time by calling conn_mgr_if_set_flag(). -endif # LTE_CONNECTIVITY +endif # NRF_MODEM_LIB_NET_IF -module = LTE_CONNECTIVITY -module-str = LTE Connectivity +module = NRF_MODEM_LIB_NET_IF +module-str = Modem network interface source "subsys/logging/Kconfig.template.log_config" diff --git a/lib/nrf_modem_lib/lte_connectivity/lte_ip_addr_helper.c b/lib/nrf_modem_lib/lte_net_if/lte_ip_addr_helper.c similarity index 98% rename from lib/nrf_modem_lib/lte_connectivity/lte_ip_addr_helper.c rename to lib/nrf_modem_lib/lte_net_if/lte_ip_addr_helper.c index ba4b5c158d8b..0f322a059724 100644 --- a/lib/nrf_modem_lib/lte_connectivity/lte_ip_addr_helper.c +++ b/lib/nrf_modem_lib/lte_net_if/lte_ip_addr_helper.c @@ -14,7 +14,7 @@ #include -LOG_MODULE_REGISTER(ip_addr_helper, CONFIG_LTE_CONNECTIVITY_LOG_LEVEL); +LOG_MODULE_REGISTER(ip_addr_helper, CONFIG_NRF_MODEM_LIB_NET_IF_LOG_LEVEL); /* Structure that keeps track of the current IP addresses in use. */ static struct ip_addr_helper_data { diff --git a/lib/nrf_modem_lib/lte_connectivity/lte_ip_addr_helper.h b/lib/nrf_modem_lib/lte_net_if/lte_ip_addr_helper.h similarity index 100% rename from lib/nrf_modem_lib/lte_connectivity/lte_ip_addr_helper.h rename to lib/nrf_modem_lib/lte_net_if/lte_ip_addr_helper.h diff --git a/lib/nrf_modem_lib/lte_connectivity/lte_connectivity.c b/lib/nrf_modem_lib/lte_net_if/lte_net_if.c similarity index 85% rename from lib/nrf_modem_lib/lte_connectivity/lte_connectivity.c rename to lib/nrf_modem_lib/lte_net_if/lte_net_if.c index 02c8840787e5..512c1ef940c8 100644 --- a/lib/nrf_modem_lib/lte_connectivity/lte_connectivity.c +++ b/lib/nrf_modem_lib/lte_net_if/lte_net_if.c @@ -14,10 +14,10 @@ #include #include +#include "lte_net_if.h" #include "lte_ip_addr_helper.h" -#include "lte_connectivity.h" -LOG_MODULE_REGISTER(lte_connectivity, CONFIG_LTE_CONNECTIVITY_LOG_LEVEL); +LOG_MODULE_REGISTER(nrf_modem_lib_netif, CONFIG_NRF_MODEM_LIB_NET_IF_LOG_LEVEL); /* This library requires that Zephyr's IPv4 and IPv6 stacks are enabled. * @@ -34,7 +34,7 @@ BUILD_ASSERT((CONFIG_NET_CONNECTION_MANAGER_STACK_SIZE >= 1024), /* Forward declarations */ static void connection_timeout_work_fn(struct k_work *work); -int lte_connectivity_disconnect(struct conn_mgr_conn_binding *const if_conn); +int lte_net_if_disconnect(struct conn_mgr_conn_binding *const if_conn); /* Delayable work used to handle LTE connection timeouts. */ static K_WORK_DELAYABLE_DEFINE(connection_timeout_work, connection_timeout_work_fn); @@ -43,7 +43,7 @@ static K_WORK_DELAYABLE_DEFINE(connection_timeout_work, connection_timeout_work_ static struct net_if *iface_bound; /* Variable used to specify behavior when the network interface is brought down. */ -static uint8_t net_if_down_options = LTE_CONNECTIVITY_IF_DOWN_MODEM_SHUTDOWN; +static uint8_t net_if_down_options = NRF_MODEM_LIB_NET_IF_DOWN_MODEM_SHUTDOWN; /* Local functions */ @@ -54,7 +54,7 @@ static void fatal_error_notify_and_disconnect(void) { net_mgmt_event_notify(NET_EVENT_CONN_IF_FATAL_ERROR, iface_bound); net_if_dormant_on(iface_bound); - (void)lte_connectivity_disconnect(NULL); + (void)lte_net_if_disconnect(NULL); } /* Handler called on modem faults. */ @@ -71,10 +71,10 @@ static void connection_timeout_work_fn(struct k_work *work) LOG_DBG("LTE connection timeout"); - int ret = lte_connectivity_disconnect(NULL); + int ret = lte_net_if_disconnect(NULL); if (ret) { - LOG_ERR("lte_connectivity_disconnect, error: %d", ret); + LOG_ERR("lte_net_if_disconnect, error: %d", ret); net_mgmt_event_notify(NET_EVENT_CONN_IF_FATAL_ERROR, iface_bound); } @@ -196,7 +196,7 @@ static void on_pdn_deactivated(void) /* If persistence is disabled, LTE is deactivated upon a lost connection. * Re-establishment is reliant on the application calling conn_mgr_if_connect(). */ - ret = lte_connectivity_disconnect(NULL); + ret = lte_net_if_disconnect(NULL); if (ret) { LOG_ERR("lte_lc_func_mode_set, error: %d", ret); net_mgmt_event_notify(NET_EVENT_CONN_IF_FATAL_ERROR, iface_bound); @@ -264,16 +264,16 @@ static void pdn_event_handler(uint8_t cid, enum pdn_event event, int reason) } /* Public APIs */ -void lte_connectivity_init(struct conn_mgr_conn_binding *if_conn) +void lte_net_if_init(struct conn_mgr_conn_binding *if_conn) { int ret; - int timeout = CONFIG_LTE_CONNECTIVITY_CONNECT_TIMEOUT_SECONDS; - int persistent = IS_ENABLED(CONFIG_LTE_CONNECTIVITY_CONNECTION_PERSISTENCE); + int timeout = CONFIG_NRF_MODEM_LIB_NET_IF_CONNECT_TIMEOUT_SECONDS; + int persistent = IS_ENABLED(CONFIG_NRF_MODEM_LIB_NET_IF_CONNECTION_PERSISTENCE); net_if_dormant_on(if_conn->iface); /* Default auto features off. */ - if (!IS_ENABLED(CONFIG_LTE_CONNECTIVITY_AUTO_CONNECT)) { + if (!IS_ENABLED(CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_CONNECT)) { ret = conn_mgr_if_set_flag(if_conn->iface, CONN_MGR_IF_NO_AUTO_CONNECT, true); if (ret) { LOG_ERR("conn_mgr_if_set_flag, error: %d", ret); @@ -282,7 +282,7 @@ void lte_connectivity_init(struct conn_mgr_conn_binding *if_conn) } } - if (!IS_ENABLED(CONFIG_LTE_CONNECTIVITY_AUTO_DOWN)) { + if (!IS_ENABLED(CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_DOWN)) { ret = conn_mgr_if_set_flag(if_conn->iface, CONN_MGR_IF_NO_AUTO_DOWN, true); if (ret) { LOG_ERR("conn_mgr_if_set_flag, error: %d", ret); @@ -315,10 +315,10 @@ void lte_connectivity_init(struct conn_mgr_conn_binding *if_conn) /* Keep local reference to the network interface that the connectivity layer is bound to. */ iface_bound = if_conn->iface; - LOG_DBG("LTE Connectivity library initialized"); + LOG_DBG("Modem network interface ready"); } -int lte_connectivity_enable(void) +int lte_net_if_enable(void) { int ret; @@ -342,20 +342,20 @@ int lte_connectivity_enable(void) return 0; } -int lte_connectivity_disable(void) +int lte_net_if_disable(void) { int ret; - if (net_if_down_options == LTE_CONNECTIVITY_IF_DOWN_MODEM_SHUTDOWN) { + if (net_if_down_options == NRF_MODEM_LIB_NET_IF_DOWN_MODEM_SHUTDOWN) { ret = nrf_modem_lib_shutdown(); if (ret) { LOG_ERR("nrf_modem_lib_shutdown, retval: %d", ret); return ret; } - } else if (net_if_down_options == LTE_CONNECTIVITY_IF_DOWN_LTE_DISCONNECT) { - ret = lte_connectivity_disconnect(NULL); + } else if (net_if_down_options == NRF_MODEM_LIB_NET_IF_DOWN_LTE_DISCONNECT) { + ret = lte_net_if_disconnect(NULL); if (ret) { - LOG_ERR("lte_connectivity_disconnect, retval: %d", ret); + LOG_ERR("lte_net_if_disconnect, retval: %d", ret); return ret; } } else { @@ -366,7 +366,7 @@ int lte_connectivity_disable(void) return 0; } -int lte_connectivity_connect(struct conn_mgr_conn_binding *const if_conn) +int lte_net_if_connect(struct conn_mgr_conn_binding *const if_conn) { ARG_UNUSED(if_conn); @@ -384,7 +384,7 @@ int lte_connectivity_connect(struct conn_mgr_conn_binding *const if_conn) return 0; } -int lte_connectivity_disconnect(struct conn_mgr_conn_binding *const if_conn) +int lte_net_if_disconnect(struct conn_mgr_conn_binding *const if_conn) { ARG_UNUSED(if_conn); @@ -403,14 +403,14 @@ int lte_connectivity_disconnect(struct conn_mgr_conn_binding *const if_conn) return 0; } -int lte_connectivity_options_set(struct conn_mgr_conn_binding *const if_conn, int name, - const void *value, size_t length) +int lte_net_if_options_set(struct conn_mgr_conn_binding *const if_conn, int name, const void *value, + size_t length) { ARG_UNUSED(name); uint8_t *temp; - if (name != LTE_CONNECTIVITY_IF_DOWN) { + if (name != NRF_MODEM_LIB_NET_IF_DOWN) { return -ENOPROTOOPT; } @@ -422,10 +422,10 @@ int lte_connectivity_options_set(struct conn_mgr_conn_binding *const if_conn, in net_if_down_options = *temp; switch (net_if_down_options) { - case LTE_CONNECTIVITY_IF_DOWN_MODEM_SHUTDOWN: + case NRF_MODEM_LIB_NET_IF_DOWN_MODEM_SHUTDOWN: LOG_DBG("Shutdown modem when the network interface is brought down"); break; - case LTE_CONNECTIVITY_IF_DOWN_LTE_DISCONNECT: + case NRF_MODEM_LIB_NET_IF_DOWN_LTE_DISCONNECT: LOG_DBG("Disconnected from LTE when the network interface is brought down"); break; default: @@ -436,14 +436,14 @@ int lte_connectivity_options_set(struct conn_mgr_conn_binding *const if_conn, in return 0; } -int lte_connectivity_options_get(struct conn_mgr_conn_binding *const if_conn, int name, void *value, - size_t *length) +int lte_net_if_options_get(struct conn_mgr_conn_binding *const if_conn, int name, void *value, + size_t *length) { ARG_UNUSED(name); uint8_t *temp = (uint8_t *)value; - if (name != LTE_CONNECTIVITY_IF_DOWN) { + if (name != NRF_MODEM_LIB_NET_IF_DOWN) { return -ENOPROTOOPT; } diff --git a/lib/nrf_modem_lib/lte_connectivity/lte_connectivity.h b/lib/nrf_modem_lib/lte_net_if/lte_net_if.h similarity index 83% rename from lib/nrf_modem_lib/lte_connectivity/lte_connectivity.h rename to lib/nrf_modem_lib/lte_net_if/lte_net_if.h index e5287af52150..9454a62a974a 100644 --- a/lib/nrf_modem_lib/lte_connectivity/lte_connectivity.h +++ b/lib/nrf_modem_lib/lte_net_if/lte_net_if.h @@ -4,8 +4,8 @@ * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause */ -#ifndef LTE_CONNECTIVITY_H__ -#define LTE_CONNECTIVITY_H__ +#ifndef NRF_MODEM_LIB_NETIF_H__ +#define NRF_MODEM_LIB_NETIF_H__ #include #include @@ -28,24 +28,24 @@ extern "C" { /** @brief Options used to specify desired behavior when the network interface is brough down by * calling net_if_down(). */ -enum lte_connectivity_if_down_options { +enum nrf_modem_lib_net_if_down_options { /** Shutdown modem - GNSS functionality will not be preserved. */ - LTE_CONNECTIVITY_IF_DOWN_MODEM_SHUTDOWN = 1, + NRF_MODEM_LIB_NET_IF_DOWN_MODEM_SHUTDOWN = 1, /** Disconnect from LTE - GNSS functionality will be preserved. */ - LTE_CONNECTIVITY_IF_DOWN_LTE_DISCONNECT + NRF_MODEM_LIB_NET_IF_DOWN_LTE_DISCONNECT }; /** @brief Option types used to specify library behavior. */ -enum lte_connectivity_options { - /** Sets desired behavior when lte_connectivity_disable() / net_if_down() is called. */ - LTE_CONNECTIVITY_IF_DOWN = 1, +enum nrf_modem_lib_net_if_options { + /** Sets desired behavior when net_if_down() is called. */ + NRF_MODEM_LIB_NET_IF_DOWN = 1, }; /** @brief Macro used to define a private Connection Manager connectivity context type. * Required but not implemented. */ -#define LTE_CONNECTIVITY_CTX_TYPE void * +#define NRF_MODEM_LIB_NET_IF_CTX_TYPE void * /** @brief Initialize the LTE Connectivity layer. * @@ -55,7 +55,7 @@ enum lte_connectivity_options { * * @param if_conn Pointer to the Connection Manager binding structure. */ -void lte_connectivity_init(struct conn_mgr_conn_binding * const if_conn); +void lte_net_if_init(struct conn_mgr_conn_binding * const if_conn); /** @brief Enable the LTE Connectivity layer. * @@ -69,19 +69,19 @@ void lte_connectivity_init(struct conn_mgr_conn_binding * const if_conn); * If a positive value is returned, modem reinitialization failed. (DFU related) * DFU related error codes are listed in nrf_modem.h prefixed NRF_MODEM_DFU_RESULT. */ -int lte_connectivity_enable(void); +int lte_net_if_enable(void); /** @brief Disable the LTE Connectivity layer. * * @details The behavior of this function changes depending on library options: * - * If LTE_CONNECTIVITY_IF_DOWN_MODEM_SHUTDOWN is set: + * If NRF_MODEM_LIB_NET_IF_DOWN_MODEM_SHUTDOWN is set: * * Modem is completely shutdown and no modem functionality is preserved. * This is useful after modem DFU when the modem needs to be reinitialized which requires * that the modem is shutdown first. Default option. * - * If LTE_CONNECTIVITY_IF_DOWN_LTE_DISCONNECT is set: + * If NRF_MODEM_LIB_NET_IF_DOWN_LTE_DISCONNECT is set: * * Deactivates the LTE stack on the modem and cancels any ongoing LTE connection attempts. * The network interface will be marked as dormant if a pre-existing @@ -92,7 +92,7 @@ int lte_connectivity_enable(void); * * @returns 0 on success, negative value on failure. */ -int lte_connectivity_disable(void); +int lte_net_if_disable(void); /** @brief Connect to LTE. This is a non-blocking function. * @@ -112,7 +112,7 @@ int lte_connectivity_disable(void); * * @returns 0 on success, negative value on failure. */ -int lte_connectivity_connect(struct conn_mgr_conn_binding * const if_conn); +int lte_net_if_connect(struct conn_mgr_conn_binding * const if_conn); /** @brief Disconnect from LTE. * @@ -127,7 +127,7 @@ int lte_connectivity_connect(struct conn_mgr_conn_binding * const if_conn); * * @returns 0 on success, negative value on failure. */ -int lte_connectivity_disconnect(struct conn_mgr_conn_binding * const if_conn); +int lte_net_if_disconnect(struct conn_mgr_conn_binding * const if_conn); /** @brief Set connectivity options. * @@ -141,10 +141,10 @@ int lte_connectivity_disconnect(struct conn_mgr_conn_binding * const if_conn); * @retval -ENOPROTOOPT if name is not recognized. * @retval -EBADF if the passed in option value is not recognized. */ -int lte_connectivity_options_set(struct conn_mgr_conn_binding * const if_conn, - int name, - const void *value, - size_t length); +int lte_net_if_options_set(struct conn_mgr_conn_binding * const if_conn, + int name, + const void *value, + size_t length); /** @brief Get connectivity options. * @@ -156,10 +156,10 @@ int lte_connectivity_options_set(struct conn_mgr_conn_binding * const if_conn, * @returns 0 on success, negative value on failure. * @retval -ENOPROTOOPT if name is not recognized. */ -int lte_connectivity_options_get(struct conn_mgr_conn_binding * const if_conn, - int name, - void *value, - size_t *length); +int lte_net_if_options_get(struct conn_mgr_conn_binding * const if_conn, + int name, + void *value, + size_t *length); #ifdef __cplusplus } @@ -169,4 +169,4 @@ int lte_connectivity_options_get(struct conn_mgr_conn_binding * const if_conn, *@} */ -#endif /* LTE_CONNECTIVITY_H__ */ +#endif /* NRF_MODEM_LIB_NETIF_H__ */ diff --git a/lib/nrf_modem_lib/nrf91_sockets.c b/lib/nrf_modem_lib/nrf91_sockets.c index 405b4ef91fda..4271b1cc8661 100644 --- a/lib/nrf_modem_lib/nrf91_sockets.c +++ b/lib/nrf_modem_lib/nrf91_sockets.c @@ -33,9 +33,9 @@ #include #endif -#if defined(CONFIG_LTE_CONNECTIVITY) -#include "lte_connectivity/lte_connectivity.h" -#endif /* CONFIG_LTE_CONNECTIVITY */ +#if defined(CONFIG_NRF_MODEM_LIB_NET_IF) +#include "lte_net_if/lte_net_if.h" +#endif /* CONFIG_NRF_MODEM_LIB_NET_IF */ #if defined(CONFIG_NET_SOCKETS_OFFLOAD) @@ -1111,13 +1111,13 @@ static void nrf91_iface_api_init(struct net_if *iface) static int nrf91_iface_enable(const struct net_if *iface, bool enabled) { /* Enables or disable the device (in response to admin state change) */ -#if defined(CONFIG_LTE_CONNECTIVITY) - return enabled ? lte_connectivity_enable() : lte_connectivity_disable(); +#if defined(CONFIG_NRF_MODEM_LIB_NET_IF) + return enabled ? lte_net_if_enable() : lte_net_if_disable(); #else ARG_UNUSED(iface); ARG_UNUSED(enabled); return 0; -#endif /* CONFIG_NRF9160_CONNECTIVITY */ +#endif /* CONFIG_NRF_MODEM_LIB_NET_IF */ } static struct offloaded_if_api nrf91_iface_offload_api = { @@ -1132,18 +1132,18 @@ NET_DEVICE_OFFLOAD_INIT(nrf91_socket, "nrf91_socket", &nrf91_iface_data, NULL, 0, &nrf91_iface_offload_api, 1280); -#if defined(CONFIG_LTE_CONNECTIVITY) +#if defined(CONFIG_NRF_MODEM_LIB_NET_IF) /* Bind l2 connectity APIs. */ static struct conn_mgr_conn_api conn_api = { - .init = lte_connectivity_init, - .connect = lte_connectivity_connect, - .disconnect = lte_connectivity_disconnect, - .set_opt = lte_connectivity_options_set, - .get_opt = lte_connectivity_options_get, + .init = lte_net_if_init, + .connect = lte_net_if_connect, + .disconnect = lte_net_if_disconnect, + .set_opt = lte_net_if_options_set, + .get_opt = lte_net_if_options_get, }; -CONN_MGR_CONN_DEFINE(LTE_CONNECTIVITY, &conn_api); -CONN_MGR_BIND_CONN(nrf91_socket, LTE_CONNECTIVITY); -#endif /* CONFIG_LTE_CONNECTIVITY */ +CONN_MGR_CONN_DEFINE(NRF_MODEM_LIB_NET_IF, &conn_api); +CONN_MGR_BIND_CONN(nrf91_socket, NRF_MODEM_LIB_NET_IF); +#endif /* CONFIG_NRF_MODEM_LIB_NET_IF */ #endif /* CONFIG_NET_SOCKETS_OFFLOAD */ diff --git a/samples/net/mqtt/boards/nrf9160dk_nrf9160_ns.conf b/samples/net/mqtt/boards/nrf9160dk_nrf9160_ns.conf index 60107dd779de..97cc9000f5ab 100644 --- a/samples/net/mqtt/boards/nrf9160dk_nrf9160_ns.conf +++ b/samples/net/mqtt/boards/nrf9160dk_nrf9160_ns.conf @@ -22,10 +22,10 @@ CONFIG_NET_IPV6_MLD=n # Connection Manager and Connectivity layer CONFIG_NET_CONNECTION_MANAGER=y CONFIG_NET_CONNECTION_MANAGER_STACK_SIZE=1024 -CONFIG_LTE_CONNECTIVITY=y +CONFIG_NRF_MODEM_LIB_NET_IF=y CONFIG_NRF_MODEM_LIB_ON_FAULT_APPLICATION_SPECIFIC=y # Turn off automatic behavior to give more control to the application CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_START=n -CONFIG_LTE_CONNECTIVITY_AUTO_CONNECT=n -CONFIG_LTE_CONNECTIVITY_AUTO_DOWN=n +CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_CONNECT=n +CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_DOWN=n diff --git a/samples/net/mqtt/boards/thingy91_nrf9160_ns.conf b/samples/net/mqtt/boards/thingy91_nrf9160_ns.conf index 8446db020854..b91f4073b8a6 100644 --- a/samples/net/mqtt/boards/thingy91_nrf9160_ns.conf +++ b/samples/net/mqtt/boards/thingy91_nrf9160_ns.conf @@ -22,10 +22,10 @@ CONFIG_NET_IPV6_MLD=n # Connection Manager and Connectivity layer CONFIG_NET_CONNECTION_MANAGER=y CONFIG_NET_CONNECTION_MANAGER_STACK_SIZE=1024 -CONFIG_LTE_CONNECTIVITY=y +CONFIG_NRF_MODEM_LIB_NET_IF=y CONFIG_NRF_MODEM_LIB_ON_FAULT_APPLICATION_SPECIFIC=y # Turn off automatic behavior to give more control to the application CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_START=n -CONFIG_LTE_CONNECTIVITY_AUTO_CONNECT=n -CONFIG_LTE_CONNECTIVITY_AUTO_DOWN=n +CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_CONNECT=n +CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_DOWN=n diff --git a/samples/net/mqtt/src/modules/network/Kconfig.network b/samples/net/mqtt/src/modules/network/Kconfig.network index 8fb6ec3e442b..581268c6cbfb 100644 --- a/samples/net/mqtt/src/modules/network/Kconfig.network +++ b/samples/net/mqtt/src/modules/network/Kconfig.network @@ -5,7 +5,7 @@ # menu "Network" - depends on LTE_CONNECTIVITY || (WIFI_NRF700X && WIFI_MGMT_EXT) || BOARD_NATIVE_POSIX + depends on NRF_MODEM_LIB_NET_IF || (WIFI_NRF700X && WIFI_MGMT_EXT) || BOARD_NATIVE_POSIX config MQTT_SAMPLE_NETWORK_THREAD_STACK_SIZE int "Thread stack size" diff --git a/tests/lib/nrf_modem_lib/lte_connectivity/CMakeLists.txt b/tests/lib/nrf_modem_lib/lte_net_if/CMakeLists.txt similarity index 68% rename from tests/lib/nrf_modem_lib/lte_connectivity/CMakeLists.txt rename to tests/lib/nrf_modem_lib/lte_net_if/CMakeLists.txt index 2e4bb514e7f8..38cab246235d 100644 --- a/tests/lib/nrf_modem_lib/lte_connectivity/CMakeLists.txt +++ b/tests/lib/nrf_modem_lib/lte_net_if/CMakeLists.txt @@ -7,7 +7,7 @@ cmake_minimum_required(VERSION 3.20.0) find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) -project(lte_connectivity) +project(lte_net_if) # Turn off warnings of deprecated declarations zephyr_compile_options(-Wno-deprecated-declarations) @@ -24,23 +24,23 @@ cmock_handle(${ZEPHYR_NRFXLIB_MODULE_DIR}/nrf_modem/include/nrf_gai_errors.h) cmock_handle(${ZEPHYR_NRFXLIB_MODULE_DIR}/nrf_modem/include/nrf_modem_os.h) # Generate runner for the test -test_runner_generate(src/lte_connectivity_test.c) +test_runner_generate(src/main.c) # Add source folder target_include_directories(app PRIVATE src) # Add test file -target_sources(app PRIVATE src/lte_connectivity_test.c) +target_sources(app PRIVATE src/main.c) # Add UUT -target_sources(app PRIVATE ${NRF_DIR}/lib/nrf_modem_lib/lte_connectivity/lte_connectivity.c) -target_sources(app PRIVATE ${NRF_DIR}/lib/nrf_modem_lib/lte_connectivity/lte_ip_addr_helper.c) +target_sources(app PRIVATE ${NRF_DIR}/lib/nrf_modem_lib/lte_net_if/lte_net_if.c) +target_sources(app PRIVATE ${NRF_DIR}/lib/nrf_modem_lib/lte_net_if/lte_ip_addr_helper.c) target_sources(app PRIVATE ${NRF_DIR}/lib/nrf_modem_lib/nrf91_sockets.c) -target_include_directories(app PRIVATE ${NRF_DIR}/lib/nrf_modem_lib/lte_connectivity) +target_include_directories(app PRIVATE ${NRF_DIR}/lib/nrf_modem_lib/lte_net_if) add_compile_definitions(CONFIG_NRF_MODEM_LIB_MEM_DIAG) -add_compile_definitions(CONFIG_LTE_CONNECTIVITY_CONNECT_TIMEOUT_SECONDS=30) -add_compile_definitions(CONFIG_LTE_CONNECTIVITY) -add_compile_definitions(CONFIG_LTE_CONNECTIVITY_WORKQUEUE_STACK_SIZE=1024) -add_compile_definitions(CONFIG_LTE_CONNECTIVITY_CONNECTION_PERSISTENCE) +add_compile_definitions(CONFIG_NRF_MODEM_LIB_NET_IF_CONNECT_TIMEOUT_SECONDS=30) +add_compile_definitions(CONFIG_NRF_MODEM_LIB_NET_IF) +add_compile_definitions(CONFIG_NRF_MODEM_LIB_NET_IF_WORKQUEUE_STACK_SIZE=1024) +add_compile_definitions(CONFIG_NRF_MODEM_LIB_NET_IF_CONNECTION_PERSISTENCE) diff --git a/tests/lib/nrf_modem_lib/lte_connectivity/Kconfig b/tests/lib/nrf_modem_lib/lte_net_if/Kconfig similarity index 62% rename from tests/lib/nrf_modem_lib/lte_connectivity/Kconfig rename to tests/lib/nrf_modem_lib/lte_net_if/Kconfig index 38cf2d49c4fc..9507404291ee 100644 --- a/tests/lib/nrf_modem_lib/lte_connectivity/Kconfig +++ b/tests/lib/nrf_modem_lib/lte_net_if/Kconfig @@ -1,7 +1,7 @@ menu "Local sourcing" source "$(ZEPHYR_NRF_MODULE_DIR)/lib/nrf_modem_lib/Kconfig.modemlib" -source "$(ZEPHYR_NRF_MODULE_DIR)/lib/nrf_modem_lib/lte_connectivity/Kconfig" +source "$(ZEPHYR_NRF_MODULE_DIR)/lib/nrf_modem_lib/lte_net_if/Kconfig" endmenu diff --git a/tests/lib/nrf_modem_lib/lte_connectivity/prj.conf b/tests/lib/nrf_modem_lib/lte_net_if/prj.conf similarity index 100% rename from tests/lib/nrf_modem_lib/lte_connectivity/prj.conf rename to tests/lib/nrf_modem_lib/lte_net_if/prj.conf diff --git a/tests/lib/nrf_modem_lib/lte_connectivity/src/lte_connectivity_test.c b/tests/lib/nrf_modem_lib/lte_net_if/src/main.c similarity index 87% rename from tests/lib/nrf_modem_lib/lte_connectivity/src/lte_connectivity_test.c rename to tests/lib/nrf_modem_lib/lte_net_if/src/main.c index 469fe4cd4067..668df740e211 100644 --- a/tests/lib/nrf_modem_lib/lte_connectivity/src/lte_connectivity_test.c +++ b/tests/lib/nrf_modem_lib/lte_net_if/src/main.c @@ -11,7 +11,7 @@ #include /* UUT header file */ -#include "lte_connectivity.h" +#include "lte_net_if.h" /* Mocked libraries */ #include "cmock_lte_lc.h" @@ -42,13 +42,13 @@ static void bring_network_interface_up(void) TEST_ASSERT_EQUAL(0, net_if_up(net_if)); } -static void network_interface_down_option_set(enum lte_connectivity_if_down_options value, +static void network_interface_down_option_set(enum nrf_modem_lib_net_if_down_options value, int retval_expected) { uint8_t option = value; int ret = conn_mgr_if_set_opt(net_if_get_default(), - LTE_CONNECTIVITY_IF_DOWN, + NRF_MODEM_LIB_NET_IF_DOWN, (const void *)&option, sizeof(option)); @@ -95,16 +95,16 @@ void tearDown(void) struct net_if *net_if = net_if_get_default(); enum lte_lc_func_mode mode_expected = LTE_LC_FUNC_MODE_DEACTIVATE_LTE; - int ret = conn_mgr_if_get_opt(net_if, LTE_CONNECTIVITY_IF_DOWN, (void *)&option, &len); + int ret = conn_mgr_if_get_opt(net_if, NRF_MODEM_LIB_NET_IF_DOWN, (void *)&option, &len); TEST_ASSERT_EQUAL(0, ret); - /* Do teardown depending on the LTE_CONNECTIVITY_IF_DOWN option. */ + /* Do teardown depending on the NRF_MODEM_LIB_NET_IF_DOWN option. */ if (net_if_flag_is_set(net_if, NET_IF_UP)) { - if (option == LTE_CONNECTIVITY_IF_DOWN_LTE_DISCONNECT) { + if (option == NRF_MODEM_LIB_NET_IF_DOWN_LTE_DISCONNECT) { __cmock_lte_lc_func_mode_set_ExpectAndReturn(mode_expected, 0); TEST_ASSERT_EQUAL(0, net_if_down(net_if)); - } else if (option == LTE_CONNECTIVITY_IF_DOWN_MODEM_SHUTDOWN) { + } else if (option == NRF_MODEM_LIB_NET_IF_DOWN_MODEM_SHUTDOWN) { __cmock_nrf_modem_lib_shutdown_ExpectAndReturn(0); TEST_ASSERT_EQUAL(0, net_if_down(net_if)); } else { @@ -124,7 +124,7 @@ void tearDown(void) mock_nrf_modem_at_Verify(); } -/* Verify lte_connectivity_init(). +/* Verify nrf_modem_lib_netif_init(). * This function is called at SYS init by the Connection Manager. */ @@ -138,7 +138,7 @@ void test_init_should_set_network_interface_as_dormant(void) void test_init_should_set_timeout(void) { struct net_if *net_if = net_if_get_default(); - int timeout_desired = CONFIG_LTE_CONNECTIVITY_CONNECT_TIMEOUT_SECONDS; + int timeout_desired = CONFIG_NRF_MODEM_LIB_NET_IF_CONNECT_TIMEOUT_SECONDS; TEST_ASSERT_EQUAL(timeout_desired, conn_mgr_if_get_timeout(net_if)); } @@ -161,7 +161,7 @@ static int test_init_should_set_pdn_event_handler(void) } SYS_INIT(test_init_should_set_pdn_event_handler, POST_KERNEL, 0); -/* Verify lte_connectivity_enable() */ +/* Verify nrf_modem_lib_netif_enable() */ void test_enable_should_init_modem_and_link_controller(void) { @@ -196,7 +196,7 @@ void test_enable_should_return_error_upon_dfu_error(void) TEST_ASSERT_EQUAL(NRF_MODEM_DFU_RESULT_HARDWARE_ERROR, net_if_up(net_if)); } -/* Verify lte_connectivity_disable() */ +/* Verify nrf_modem_lib_netif_disable() */ void test_disable_should_shutdown_modem(void) { @@ -219,7 +219,7 @@ void test_disable_should_return_error_if_shutdown_of_modem_fails(void) void test_disable_should_disconnect_lte(void) { bring_network_interface_up(); - network_interface_down_option_set(LTE_CONNECTIVITY_IF_DOWN_LTE_DISCONNECT, 0); + network_interface_down_option_set(NRF_MODEM_LIB_NET_IF_DOWN_LTE_DISCONNECT, 0); __cmock_lte_lc_func_mode_set_ExpectAndReturn(LTE_LC_FUNC_MODE_DEACTIVATE_LTE, 0); @@ -229,14 +229,14 @@ void test_disable_should_disconnect_lte(void) void test_disable_should_return_error_if_lte_disconnect_fails(void) { bring_network_interface_up(); - network_interface_down_option_set(LTE_CONNECTIVITY_IF_DOWN_LTE_DISCONNECT, 0); + network_interface_down_option_set(NRF_MODEM_LIB_NET_IF_DOWN_LTE_DISCONNECT, 0); __cmock_lte_lc_func_mode_set_ExpectAndReturn(LTE_LC_FUNC_MODE_DEACTIVATE_LTE, -1); TEST_ASSERT_EQUAL(-1, net_if_down(net_if_get_default())); } -/* Verify lte_connectivity_connect() */ +/* Verify nrf_modem_lib_netif_connect() */ void test_connect_should_set_functional_mode(void) { @@ -256,7 +256,7 @@ void test_connect_should_return_error_if_setting_of_functional_mode_fails(void) TEST_ASSERT_EQUAL(-1, conn_mgr_if_connect(net_if_get_default())); } -/* Verify lte_connectivity_disconnect() */ +/* Verify nrf_modem_lib_netif_disconnect() */ void test_disconnect_should_set_functional_mode(void) { @@ -276,18 +276,18 @@ void test_disconnect_should_return_error_if_setting_of_functional_mode_fails(voi TEST_ASSERT_EQUAL(-1, conn_mgr_if_disconnect(net_if_get_default())); } -/* Verify lte_connectivity_options_set() */ +/* Verify nrf_modem_lib_netif_options_set() */ void test_options_set_should_return_success_when_setting_option_to_modem_shutdown(void) { - network_interface_down_option_set(LTE_CONNECTIVITY_IF_DOWN_MODEM_SHUTDOWN, 0); + network_interface_down_option_set(NRF_MODEM_LIB_NET_IF_DOWN_MODEM_SHUTDOWN, 0); } void test_options_set_should_return_error_upon_unsupported_option_name(void) { struct net_if *net_if = net_if_get_default(); - uint8_t option = LTE_CONNECTIVITY_IF_DOWN_LTE_DISCONNECT; + uint8_t option = NRF_MODEM_LIB_NET_IF_DOWN_LTE_DISCONNECT; int ret = conn_mgr_if_set_opt(net_if, UINT8_MAX, @@ -306,17 +306,17 @@ void test_options_set_should_return_error_on_too_large_input(void) { struct net_if *net_if = net_if_get_default(); - uint32_t option = LTE_CONNECTIVITY_IF_DOWN_LTE_DISCONNECT; + uint32_t option = NRF_MODEM_LIB_NET_IF_DOWN_LTE_DISCONNECT; int ret = conn_mgr_if_set_opt(net_if, - LTE_CONNECTIVITY_IF_DOWN, + NRF_MODEM_LIB_NET_IF_DOWN, (const void *)&option, sizeof(option)); TEST_ASSERT_EQUAL(-ENOBUFS, ret); } -/* Verify lte_connectivity_options_get() */ +/* Verify nrf_modem_lib_netif_options_get() */ void test_options_get_should_return_success(void) { @@ -324,7 +324,7 @@ void test_options_get_should_return_success(void) uint8_t option; size_t len; - int ret = conn_mgr_if_get_opt(net_if, LTE_CONNECTIVITY_IF_DOWN, (void *)&option, &len); + int ret = conn_mgr_if_get_opt(net_if, NRF_MODEM_LIB_NET_IF_DOWN, (void *)&option, &len); TEST_ASSERT_EQUAL(0, ret); } @@ -332,21 +332,21 @@ void test_options_get_should_return_success(void) void test_options_get_should_return_correct_option_value(void) { struct net_if *net_if = net_if_get_default(); - uint8_t option = LTE_CONNECTIVITY_IF_DOWN_MODEM_SHUTDOWN; + uint8_t option = NRF_MODEM_LIB_NET_IF_DOWN_MODEM_SHUTDOWN; size_t len; int ret; ret = conn_mgr_if_set_opt(net_if, - LTE_CONNECTIVITY_IF_DOWN, + NRF_MODEM_LIB_NET_IF_DOWN, (const void *)&option, sizeof(option)); TEST_ASSERT_EQUAL(0, ret); - ret = conn_mgr_if_get_opt(net_if, LTE_CONNECTIVITY_IF_DOWN, (void *)&option, &len); + ret = conn_mgr_if_get_opt(net_if, NRF_MODEM_LIB_NET_IF_DOWN, (void *)&option, &len); TEST_ASSERT_EQUAL(0, ret); - TEST_ASSERT_EQUAL(LTE_CONNECTIVITY_IF_DOWN_MODEM_SHUTDOWN, option); + TEST_ASSERT_EQUAL(NRF_MODEM_LIB_NET_IF_DOWN_MODEM_SHUTDOWN, option); } void test_options_get_should_return_error_if_wrong_option_name_is_used(void) diff --git a/tests/lib/nrf_modem_lib/lte_connectivity/testcase.yaml b/tests/lib/nrf_modem_lib/lte_net_if/testcase.yaml similarity index 76% rename from tests/lib/nrf_modem_lib/lte_connectivity/testcase.yaml rename to tests/lib/nrf_modem_lib/lte_net_if/testcase.yaml index 935a93cc8d44..78d4f2d1b726 100644 --- a/tests/lib/nrf_modem_lib/lte_connectivity/testcase.yaml +++ b/tests/lib/nrf_modem_lib/lte_net_if/testcase.yaml @@ -1,5 +1,5 @@ tests: - nrf_modem_lib.lte_connectivity: + nrf_modem_lib.lte_net_if: tags: nrf_modem_lib platform_allow: native_posix integration_platforms: