Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manifest: nrf_modem v2.6.0 #14173

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 22 additions & 20 deletions applications/serial_lte_modem/doc/SOCKET_AT_commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -540,35 +540,37 @@ Syntax

* ``<value>`` is an integer that indicates the packet data network ID to bind to.

* ``50`` - :c:macro:`SO_RAI_NO_DATA` (set-only).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment: I think that it makes sense to remove these from the documentation. Given that these are deprecated, we will map the old values to new values in SLM after the 2.6.0 release.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old values will be kept in the modem library for a couple of releases, so there should be no need to map the old values to the new ones.

Immediately release the RRC.

* ``<value>`` is ignored.

* ``51`` - :c:macro:`SO_RAI_LAST` (set-only).
Enter Radio Resource Control (RRC) idle immediately after the next send operation.
* ``55`` - :c:macro:`SO_TCP_SRV_SESSTIMEO`.

* ``<value>`` is ignored.
* ``<value>`` is an integer that indicates the TCP server session inactivity timeout for a socket.
It accepts value from range ``0`` to ``135``, where ``0`` is no timeout and ``135`` is 2 h 15 min.

* ``52`` - :c:macro:`SO_RAI_ONE_RESP` (set-only).
Wait for one incoming packet after the next send operation, before entering RRC idle mode.
* ``61`` - :c:macro:`SO_RAI` (set-only).
Release Assistance Indication (RAI).

* ``<value>`` is ignored.
* ``<value>`` The option accepts an integer, indicating the type of RAI.
Accepted values for the option are:

* ``53`` - :c:macro:`SO_RAI_ONGOING` (set-only).
Keep RRC in connected mode after the next send operation (client).
* ``1`` - :c:macro:`RAI_NO_DATA`.
Indicates that the application does not intend to send more data.
This socket option applies immediately and lets the modem exit connected mode more quickly.

* ``<value>`` is ignored.
* ``2`` - :c:macro:`RAI_LAST`.
Indicates that the application does not intend to send more data after the next call to :c:func:`send` or :c:func:`sendto`.
This lets the modem exit connected mode more quickly after sending the data.

* ``54`` - :c:macro:`SO_RAI_WAIT_MORE` (set-only).
Keep RRC in connected mode after the next send operation (server).
* ``3`` - :c:macro:`RAI_ONE_RESP`.
Indicates that the application is expecting to receive just one data packet after the next call to :c:func:`send` or :c:func:`sendto`.
This lets the modem exit connected mode more quickly after having received the data.

* ``<value>`` is ignored.
* ``4`` - :c:macro:`RAI_ONGOING`.
Indicates that the application is expecting to receive just one data packet after the next call to :c:func:`send` or :c:func:`sendto`.
This lets the modem exit connected mode more quickly after having received the data.

* ``55`` - :c:macro:`SO_TCP_SRV_SESSTIMEO`.
* ``5`` - :c:macro:`RAI_WAIT_MORE`.
Indicates that the socket is in active use by a server application.
This lets the modem stay in connected mode longer.

* ``<value>`` is an integer that indicates the TCP server session inactivity timeout for a socket.
It accepts value from range ``0`` to ``135``, where ``0`` is no timeout and ``135`` is 2 h 15 min.

See `nRF socket options`_ for explanation of the supported options.

Expand Down
4 changes: 4 additions & 0 deletions applications/serial_lte_modem/src/slm_at_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,10 @@ static int at_sockopt_to_sockopt(enum at_sockopt at_option, int *level, int *opt
*level = SOL_SOCKET;
*option = SO_BINDTOPDN;
break;
case AT_SO_RAI:
*level = SOL_SOCKET;
*option = SO_RAI;
break;
case AT_SO_RAI_NO_DATA:
*level = SOL_SOCKET;
*option = SO_RAI_NO_DATA;
Expand Down
3 changes: 2 additions & 1 deletion applications/serial_lte_modem/src/slm_sockopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ enum at_sockopt {
AT_SO_RAI_ONE_RESP = 52,
AT_SO_RAI_ONGOING = 53,
AT_SO_RAI_WAIT_MORE = 54,
AT_SO_TCP_SRV_SESSTIMEO = 55
AT_SO_TCP_SRV_SESSTIMEO = 55,
AT_SO_RAI = 61,
};

/**
Expand Down
6 changes: 6 additions & 0 deletions doc/nrf/libraries/modem/lte_lc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ These callbacks allow any part of the application to perform certain operations
For example, one kind of operation that the application or a library may need to perform and repeat, whenever the modem enters a certain functional mode is the subscription to AT notifications.
The application can set up a callback for modem`s functional mode changes using the :c:macro:`LTE_LC_ON_CFUN` macro.

.. important::
When the :c:macro:`LTE_LC_ON_CFUN` macro is used, the application must not call :c:func:`nrf_modem_at_cfun_handler_set` as that will override the handler set by the modem library integration layer.

.. note::
The CFUN callback is not supported with :c:func:`nrf_modem_at_cmd_async`.

The following code snippet shows how to use the :c:macro:`LTE_LC_ON_CFUN` macro:

.. code-block:: c
Expand Down
25 changes: 22 additions & 3 deletions doc/nrf/libraries/modem/nrf_modem_lib/nrf_modem_lib_wrapper.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ When using the Modem library in |NCS|, the library must be initialized and shutd

.. _mlil_callbacks:

Callbacks
*********
Modem library callbacks
***********************

The library wrapper also provides callbacks for the initialization and shutdown operations.
Modem initialization and shutdown
=================================

The library wrapper provides callbacks for the modem initialization and shutdown operations.
The application can set up a callback for the :c:func:`nrf_modem_lib_init` function using the :c:macro:`NRF_MODEM_LIB_ON_INIT` macro, and a callback for :c:func:`nrf_modem_lib_shutdown` function using the :c:macro:`NRF_MODEM_LIB_ON_SHUTDOWN` macro.
These compile-time callbacks allow any part of the application to perform any setup steps that require the modem to be in a certain state.
Furthermore, the callbacks ensure that the setup steps are repeated whenever another part of the application turns the modem on or off.
Expand All @@ -43,3 +46,19 @@ The callbacks registered using the :c:macro:`NRF_MODEM_LIB_ON_SHUTDOWN` macro ar
The callback context is provided to these callbacks.
Callbacks for the macro :c:macro:`NRF_MODEM_LIB_ON_SHUTDOWN` must have the signature ``void callback_name(void *ctx)``, where ``ctx`` is the context passed to the macro.
See the :ref:`modem_callbacks_sample` sample for more information.

Modem functional mode changes
=============================

The library wrapper provides macros for registering multiple callbacks on changes to the modem functional mode.
The application can set up a callback for AT CFUN calls using the :c:macro:`NRF_MODEM_LIB_ON_CFUN` macro.
This compile-time callback allows any part of the application to perform any steps that is required when the modem changes functional mode.
The callbacks registered using the :c:macro:`NRF_MODEM_LIB_ON_CFUN` macro are executed after the functional mode has been successfully set.
See the :ref:`modem_callbacks_sample` sample for more information.

.. important::
The application should not call :c:func:`nrf_modem_at_cfun_handler_set` as that will override the handler set by the modem library integration layer.
Instead, the application should use the :c:macro:`NRF_MODEM_LIB_ON_CFUN` macro to register to functional mode changes.

.. note::
The CFUN callback is not supported with :c:func:`nrf_modem_at_cmd_async`.
3 changes: 1 addition & 2 deletions doc/nrf/libraries/modem/pdn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ The library uses several AT commands, and it relies on the following two types o
* Notifications for unsolicited reporting of error codes sent by the network (``+CNEC``) - Subscribed by using the ``AT+CNEC=16`` command.
See the `AT+CNEC set command`_ section in the nRF9160 AT Commands Reference Guide or the `same section <nRF91x1 AT+CGEREP set command_>`_ in the nRF91x1 AT Commands Reference Guide, depending on the SiP you are using.

If the application uses the :ref:`lte_lc_readme` library to change the modem's functional mode, the PDN library automatically subscribes to the necessary AT notifications.
The PDN library automatically subscribes to the necessary AT notifications using :ref:`mlil_callbacks`.
This includes automatically resubscribing to the notifications upon functional mode changes.
If the application does not use the :ref:`lte_lc_readme` library to change the modem's functional mode, the application must subscribe to the necessary AT notifications manually.

.. note::
The subscription to AT notifications is lost upon changing the modem functional mode to ``+CFUN=0``.
Expand Down
40 changes: 40 additions & 0 deletions doc/nrf/releases_and_maturity/migration/migration_guide_2.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,46 @@ The following changes are mandatory to make your application work in the same wa
The setting controls whether the SLM connects automatically to the network on startup.
You can read and write it using the ``AT#XCARRIER="auto_connect"`` command.

* The handling of Release Assistance Indication (RAI) socket options has been updated in the ``#XSOCKETOPT`` command.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SLM part should be unnecessary as the old values work as well for now, and we will map those to new values under the hood after 2.6.0.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old values work as well for now, though the user should update their code to the new values. @divipillai should we add it to the migration guide for the NCS version where we deprecate functionality or the NCS version where we remove the old implementation completely (after it has been deprecated for a while)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we now have a mechanism in place in SLM to keep such values unchanged (we only change the mapping in SLM, so that the customer-facing interface doesn't change), it may well be that they will never change from the SLM user's point of view.
Though if doing this (which I think is what we want, to limit breaking changes) I don't know whether it actually makes sense to introduce the new values in the documentation unless they work somehow differently than the old ones?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the new values are more well thought out than the previous ones So I would like to have them in SLM.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have them then, but also keep the other ones forever (without advertising them)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For reference: The section about RAI in SLM is removed from the migration guide for this release. If the old values are removed at a later point (from SLM user perspective), it should be added to the migration guide then.

The individual RAI-related socket options have been consolidated into a single ``SO_RAI`` option.
You must modify your application to use the new ``SO_RAI`` option with the corresponding value to specify the RAI behavior.
The changes are as follows:

The ``SO_RAI_NO_DATA``, ``SO_RAI_LAST``, ``SO_RAI_ONE_RESP``, ``SO_RAI_ONGOING``, and ``SO_RAI_WAIT_MORE`` options have been replaced by the ``SO_RAI`` option with values from ``1`` to ``5``.

Here are the changes you need to make in your application code:

* If you previously used ``AT#XSOCKETOPT=1,50,`` replace it with ``AT#XSOCKETOPT=1,61,1`` to indicate ``RAI_NO_DATA``.
* If you previously used ``AT#XSOCKETOPT=1,51,`` replace it with ``AT#XSOCKETOPT=1,61,2`` to indicate ``RAI_LAST``.
* If you previously used ``AT#XSOCKETOPT=1,52,`` replace it with ``AT#XSOCKETOPT=1,61,3`` to indicate ``RAI_ONE_RESP``.
* If you previously used ``AT#XSOCKETOPT=1,53,`` replace it with ``AT#XSOCKETOPT=1,61,4`` to indicate ``RAI_ONGOING``.
* If you previously used ``AT#XSOCKETOPT=1,54,`` replace it with ``AT#XSOCKETOPT=1,61,5`` to indicate ``RAI_WAIT_MORE``.

* For applications using :ref:`nrf_modem_lib_readme`:

* The ``lte_connectivity`` module is renamed to ``lte_net_if``. Please make sure that all references are updated accordingly, including function names and Kconfig options.

* If your application is using the ``lte_net_if`` (formerly ``lte_connectivity``) without disabling :kconfig:option:`CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_START`, :kconfig:option:`CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_CONNECT`, and :kconfig:option:`CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_DOWN` Kconfig options, changes are required as the default values are changed from enabled to disabled.

* Consider using the :c:func:`conn_mgr_all_if_up`, :c:func:`conn_mgr_if_connect` and :c:func:`conn_mgr_if_disconnect` functions instead of enabling the Kconfig options to have better control of the initialization and connection establishment.

* The Release Assistance Indication (RAI) socket options have been deprecated and replaced with a new consolidated socket option.
If your application uses ``SO_RAI_*`` socket options, you need to update your socket configuration as follows:

#. Replace the deprecated socket options :c:macro:`SO_RAI_NO_DATA`, :c:macro:`SO_RAI_LAST`, :c:macro:`SO_RAI_ONE_RESP`, :c:macro:`SO_RAI_ONGOING`, and :c:macro:`SO_RAI_WAIT_MORE` with the new :c:macro:`SO_RAI` option.
#. Set the optval parameter of the :c:macro:`SO_RAI` socket option to one of the new values :c:macro:`RAI_NO_DATA`, :c:macro:`RAI_LAST`, :c:macro:`RAI_ONE_RESP`, :c:macro:`RAI_ONGOING`, or :c:macro:`RAI_WAIT_MORE` to specify the desired indication.

Example of migration:

.. code-block:: c

/* Before migration. */
setsockopt(socket_fd, SOL_SOCKET, SO_RAI_LAST, NULL, 0);

/* After migration. */
int rai_option = RAI_LAST;
setsockopt(socket_fd, SOL_SOCKET, SO_RAI, &rai_option, sizeof(rai_option));

* The ``AT#XCMNG`` AT command, which is activated with the :file:`overlay-native_tls.conf` overlay file, has been changed from using modem certificate storage to Zephyr settings storage.
You need to use the ``AT#XCMNG`` command to store previously stored credentials again.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -852,13 +852,26 @@ Modem libraries

* A mention about enabling TF-M logging while using modem traces in the :ref:`modem_trace_module`.
* The :kconfig:option:`CONFIG_NRF_MODEM_LIB_NET_IF_DOWN_DEFAULT_LTE_DISCONNECT` option, allowing the user to change the behavior of the driver's :c:func:`net_if_down` implementation at build time.
* The :c:macro:`SO_RAI` socket option for Release Assistance Indication (RAI).
The socket option uses values :c:macro:`RAI_NO_DATA`, :c:macro:`RAI_LAST`, :c:macro:`RAI_ONE_RESP`, :c:macro:`RAI_ONGOING`, or :c:macro:`RAI_WAIT_MORE` to specify the desired indication.
This socket option substitutes the deprecated RAI (``SO_RAI_*``) socket options.

* Updated:

* The library by renaming ``lte_connectivity`` module to ``lte_net_if``.
All related Kconfig options have been renamed accordingly.
* The default value of the :kconfig:option:`CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_START`, :kconfig:option:`CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_CONNECT`, and :kconfig:option:`CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_DOWN` Kconfig options from enabled to disabled.
* The modem trace shell command implementation is moved from :ref:`modem_shell_application` sample into :ref:`nrf_modem_lib_readme` to be used by any application with the :kconfig:option:`CONFIG_NRF_MODEM_LIB_SHELL_TRACE` option enabled.
* The following socket options have been deprecated:

* :c:macro:`SO_RAI_NO_DATA`
* :c:macro:`SO_RAI_LAST`
* :c:macro:`SO_RAI_ONE_RESP`
* :c:macro:`SO_RAI_ONGOING`
* :c:macro:`SO_RAI_WAIT_MORE`

Use the :c:macro:`SO_RAI` socket option instead.

* The library by renaming ``lte_connectivity`` module to ``lte_net_if``.
All related Kconfig options have been renamed accordingly.
* The default value of the :kconfig:option:`CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_START`, :kconfig:option:`CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_CONNECT`, and :kconfig:option:`CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_DOWN` Kconfig options from enabled to disabled.
* The modem trace shell command implementation is moved from :ref:`modem_shell_application` sample into :ref:`nrf_modem_lib_readme` to be used by any application with the :kconfig:option:`CONFIG_NRF_MODEM_LIB_SHELL_TRACE` option enabled.

* Fixed:

Expand All @@ -881,6 +894,7 @@ Modem libraries
* Added the :c:func:`pdn_dynamic_params_get` function to retrieve dynamic parameters of an active PDN connection.
* Fixed a potential issue where the library tries to free the PDN context twice, causing the application to crash.
* Updated the library to add PDP auto configuration to the :c:enumerator:`LTE_LC_FUNC_MODE_POWER_OFF` event.
* Removed the dependency on the :ref:`lte_lc_readme` library.

* :ref:`lib_at_host` library:

Expand Down
2 changes: 1 addition & 1 deletion doc/nrf/test_and_optimize/optimizing/power_nrf91.rst
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ Release Assistance Indication (RAI)

If you have low-level control over the protocol your IOT device uses, you might know when you should not expect more data.
In that case, you can request to skip the RRC idle mode using :term:`Release Assistance Indication (RAI)`.
The recommended way to do this is using setsockopt with an option like ``SO_RAI_LAST``.
The recommended way to do this is using :c:func:`setsockopt` with the option ``SO_RAI`` and value ``RAI_LAST``.

Low battery behavior
====================
Expand Down
4 changes: 2 additions & 2 deletions include/modem/lte_lc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1583,7 +1583,7 @@ int lte_lc_edrx_get(struct lte_lc_edrx_cfg *edrx_cfg);
*
* For reference see 3GPP 24.301 Ch. 9.9.4.25.
*
* @deprecated Use @kconfig{CONFIG_LTE_RAI_REQ} and socket options SO_RAI_* instead.
* @deprecated Use @kconfig{CONFIG_LTE_RAI_REQ} and socket option @ref SO_RAI instead.
*
* @note This feature is only supported by modem firmware versions < 2.0.0.
*
Expand All @@ -1600,7 +1600,7 @@ __deprecated int lte_lc_rai_param_set(const char *value);
* Used RAI value can be set using @kconfig{CONFIG_LTE_RAI_REQ_VALUE} or by calling
* lte_lc_rai_param_set().
*
* @deprecated Use @kconfig{CONFIG_LTE_RAI_REQ} and socket options SO_RAI_* instead.
* @deprecated Use @kconfig{CONFIG_LTE_RAI_REQ} and socket option @ref SO_RAI instead.
*
* @note This feature is only supported by modem firmware versions < 2.0.0.
*
Expand Down
26 changes: 24 additions & 2 deletions include/modem/nrf_modem_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,19 @@ struct nrf_modem_lib_shutdown_cb {
void *context;
};

/**
* @brief AT CFUN callback entry.
*/
struct nrf_modem_lib_at_cfun_cb {
/** CFUN callback. */
void (*callback)(int mode, void *ctx);
/** User defined context */
void *context;
};

/**
* @brief Define a callback for DFU result @ref nrf_modem_lib_init calls.
*
* The callback function @p _callback is invoked after the library has been initialized.
*
* @note The @c NRF_MODEM_LIB_ON_DFU_RES callback can be used to subscribe to the result of a modem
* DFU operation.
*
Expand Down Expand Up @@ -188,6 +196,20 @@ struct nrf_modem_lib_shutdown_cb {
.context = _context, \
};

/**
* @brief Define a callback for successful AT CFUN calls.
*
* @param name Callback name
* @param _callback Callback function name
* @param _context User-defined context for the callback
*/
#define NRF_MODEM_LIB_ON_CFUN(name, _callback, _context) \
static void _callback(int mode, void *ctx); \
STRUCT_SECTION_ITERABLE(nrf_modem_lib_at_cfun_cb, nrf_modem_at_cfun_hook_##name) = { \
.callback = _callback, \
.context = _context, \
};

/**
* @brief Modem fault handler.
*
Expand Down
2 changes: 1 addition & 1 deletion lib/lte_link_control/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ config LTE_RAI_REQ
bool "Release Assistance Indication (RAI) request"
help
Request use of RAI using AT%RAI. When RAI is enabled, the application needs to use
the RAI socket options (SO_RAI_*) to inform the modem when no more data is expected
the RAI socket option (SO_RAI) to inform the modem when no more data is expected
and the RRC connection can be released.

config LTE_RAI_REQ_VALUE
Expand Down
5 changes: 0 additions & 5 deletions lib/lte_link_control/lte_lc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1390,11 +1390,6 @@ int lte_lc_func_mode_set(enum lte_lc_func_mode mode)
return -EFAULT;
}

STRUCT_SECTION_FOREACH(lte_lc_cfun_cb, e) {
LOG_DBG("CFUN monitor callback: %p", e->callback);
e->callback(mode, e->context);
}

return 0;
}

Expand Down
12 changes: 12 additions & 0 deletions lib/lte_link_control/lte_lc_modem_hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ LOG_MODULE_DECLARE(lte_lc, CONFIG_LTE_LINK_CONTROL_LOG_LEVEL);
NRF_MODEM_LIB_ON_INIT(lte_lc_init_hook, on_modem_init, NULL);
NRF_MODEM_LIB_ON_SHUTDOWN(lte_lc_shutdown_hook, on_modem_shutdown, NULL);

NRF_MODEM_LIB_ON_CFUN(lte_lc_cfun_hook, on_modem_cfun, NULL);

static void on_modem_init(int err, void *ctx)
{
extern const enum lte_lc_system_mode lte_lc_sys_mode;
Expand Down Expand Up @@ -127,3 +129,13 @@ static void on_modem_shutdown(void *ctx)
(void)lte_lc_power_off();
}
}

static void on_modem_cfun(int mode, void *ctx)
{
ARG_UNUSED(ctx);

STRUCT_SECTION_FOREACH(lte_lc_cfun_cb, e) {
LOG_DBG("CFUN monitor callback: %p", e->callback);
e->callback(mode, e->context);
}
}
2 changes: 2 additions & 0 deletions lib/nrf_modem_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
zephyr_library()
zephyr_library_sources(nrf_modem_lib.c)
zephyr_library_sources(nrf_modem_os.c)
zephyr_library_sources_ifdef(CONFIG_NRF_MODEM_LIB_CFUN_HOOKS cfun_hooks.c)
zephyr_library_sources_ifdef(CONFIG_NRF_MODEM_LIB_MEM_DIAG diag.c)
zephyr_library_sources_ifdef(CONFIG_NET_SOCKETS nrf91_sockets.c)
zephyr_library_include_directories_ifdef(CONFIG_NET_SOCKETS ${ZEPHYR_BASE}/subsys/net/lib/sockets)
Expand All @@ -23,3 +24,4 @@ zephyr_library_sources(fault.c)
zephyr_library_sources(sanity.c)

zephyr_linker_sources(RODATA nrf_modem_lib.ld)
zephyr_linker_sources_IFDEF(CONFIG_NRF_MODEM_LIB_CFUN_HOOKS RODATA cfun_hooks.ld)
7 changes: 7 additions & 0 deletions lib/nrf_modem_lib/Kconfig.modemlib
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ config NRF_MODEM_LIB_ON_FAULT_APPLICATION_SPECIFIC

endchoice # NRF_MODEM_LIB_ON_FAULT

config NRF_MODEM_LIB_CFUN_HOOKS
bool "Modem CFUN hooks"
default y
help
Allow the application to subscribe to functional mode changes in the modem
using the NRF_MODEM_LIB_ON_CFUN macro.

config NRF_MODEM_LIB_FAULT_STRERROR
bool "Compile fault reason table"
help
Expand Down
30 changes: 30 additions & 0 deletions lib/nrf_modem_lib/cfun_hooks.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include <zephyr/kernel.h>
#include <zephyr/init.h>
#include <zephyr/logging/log.h>
#include <modem/nrf_modem_lib.h>
#include <nrf_modem_at.h>

LOG_MODULE_DECLARE(nrf_modem, CONFIG_NRF_MODEM_LIB_LOG_LEVEL);

static void cfun_callback(int mode)
{
STRUCT_SECTION_FOREACH(nrf_modem_lib_at_cfun_cb, e) {
LOG_DBG("CFUN callback %p", e->callback);
e->callback(mode, e->context);
}
}

static int nrf_modem_lib_cfun_hooks_init(void)
{
nrf_modem_at_cfun_handler_set(cfun_callback);

return 0;
}

SYS_INIT(nrf_modem_lib_cfun_hooks_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);
Loading
Loading