Skip to content

Commit

Permalink
lib: nrf_modem: rename lte_connectivity to lte_net_if
Browse files Browse the repository at this point in the history
`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 <emdi@nordicsemi.no>
  • Loading branch information
lemrey committed Jun 27, 2023
1 parent 3d70b5d commit b88446c
Show file tree
Hide file tree
Showing 18 changed files with 132 additions and 132 deletions.
2 changes: 1 addition & 1 deletion lib/nrf_modem_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/nrf_modem_lib/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/nrf_modem_lib/Kconfig.modemlib
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -42,24 +42,24 @@ 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
If this option is set the Connection Manager will automatically call connect after the
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
If this option is set the Connection Manager will automatically take the network interface
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"
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include <zephyr/logging/log.h>

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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
#include <modem/lte_lc.h>
#include <modem/pdn.h>

#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.
*
Expand All @@ -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);
Expand All @@ -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 */

Expand All @@ -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. */
Expand All @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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;

Expand All @@ -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 {
Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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;
}

Expand All @@ -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:
Expand All @@ -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;
}

Expand Down
Loading

0 comments on commit b88446c

Please sign in to comment.