diff --git a/applications/serial_lte_modem/doc/SOCKET_AT_commands.rst b/applications/serial_lte_modem/doc/SOCKET_AT_commands.rst index e75283c90f1..17c07ace753 100644 --- a/applications/serial_lte_modem/doc/SOCKET_AT_commands.rst +++ b/applications/serial_lte_modem/doc/SOCKET_AT_commands.rst @@ -539,30 +539,31 @@ Syntax * ```` is an integer that indicates the packet data network ID to bind to. - * ``50`` - :c:macro:`SO_RAI_NO_DATA` (set-only). - Immediately release the RRC. + * ``61`` - :c:macro:`SO_RAI` (set-only). + Release Assistance Indication (RAI). - * ```` is ignored. + * ```` The option accepts an integer, indicating the type of RAI. + Accepted values for the option are: - * ``51`` - :c:macro:`SO_RAI_LAST` (set-only). - Enter Radio Resource Control (RRC) idle immediately after the next send operation. + * ``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. - * ```` 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. - * ``52`` - :c:macro:`SO_RAI_ONE_RESP` (set-only). - Wait for one incoming packet after the next send operation, before entering RRC idle mode. + * ``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. - * ```` 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. - * ``53`` - :c:macro:`SO_RAI_ONGOING` (set-only). - Keep RRC in connected mode after the next send operation (client). - - * ```` is ignored. - - * ``54`` - :c:macro:`SO_RAI_WAIT_MORE` (set-only). - Keep RRC in connected mode after the next send operation (server). - - * ```` is ignored. + * ``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. See `nRF socket options`_ for explanation of the supported options. diff --git a/applications/serial_lte_modem/src/slm_at_socket.c b/applications/serial_lte_modem/src/slm_at_socket.c index 3846c380fd3..6665897cb89 100644 --- a/applications/serial_lte_modem/src/slm_at_socket.c +++ b/applications/serial_lte_modem/src/slm_at_socket.c @@ -339,16 +339,9 @@ static int do_socketopt_set(int option, int value) case SO_TCP_SRV_SESSTIMEO: ret = setsockopt(sock.fd, IPPROTO_TCP, option, &value, sizeof(int)); break; - - /* RAI-related */ - case SO_RAI_LAST: - case SO_RAI_NO_DATA: - case SO_RAI_ONE_RESP: - case SO_RAI_ONGOING: - case SO_RAI_WAIT_MORE: - ret = setsockopt(sock.fd, SOL_SOCKET, option, NULL, 0); + case SO_RAI: + ret = setsockopt(sock.fd, SOL_SOCKET, option, &value, sizeof(int)); break; - default: ret = -ENOTSUP; LOG_WRN("Unsupported option: %d", option); diff --git a/doc/nrf/releases_and_maturity/migration/migration_guide_2.6.rst b/doc/nrf/releases_and_maturity/migration/migration_guide_2.6.rst index 12747e4ee68..eb2475bf266 100644 --- a/doc/nrf/releases_and_maturity/migration/migration_guide_2.6.rst +++ b/doc/nrf/releases_and_maturity/migration/migration_guide_2.6.rst @@ -18,6 +18,40 @@ The following changes are mandatory to make your application work in the same wa Because of this, one setting is restored to its default value after the switch if you are using the :ref:`liblwm2m_carrier_readme` library. 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. + 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 Release Assistance Indication (RAI) socket options have been deprecated and replaced with a new consolidated socket option. + If your application uses :c:macro:`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)); * For the Matter samples and applications using Intermittently Connected Devices configuration (formerly called Sleepy End Devices): diff --git a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst index 04a0f8f412a..fce37865de7 100644 --- a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst +++ b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst @@ -605,10 +605,25 @@ 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). + This socket option substitutes the deprecated :c:macro:`SO_RAI_*` socket options. + To specify the indication, use the :c:macro:`RAI_*` values. + * The :c:macro:`SO_RAI` socket option 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. + + * Updated: - * Updated by renaming ``lte_connectivity`` module to ``lte_net_if``. - All related Kconfig options have been renamed accordingly. - * Changed 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 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. + * Renamed ``lte_connectivity`` module to ``lte_net_if``. + All related Kconfig options have been renamed accordingly. + * Changed 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. * Fixed: diff --git a/doc/nrf/test_and_optimize/optimizing/power_nrf91.rst b/doc/nrf/test_and_optimize/optimizing/power_nrf91.rst index a965e70c3ba..7b7ab719bbb 100644 --- a/doc/nrf/test_and_optimize/optimizing/power_nrf91.rst +++ b/doc/nrf/test_and_optimize/optimizing/power_nrf91.rst @@ -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 ==================== diff --git a/include/modem/lte_lc.h b/include/modem/lte_lc.h index 0e78fab44f0..3ac2ae8ee77 100644 --- a/include/modem/lte_lc.h +++ b/include/modem/lte_lc.h @@ -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. * @@ -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. * diff --git a/include/net/lwm2m_client_utils.h b/include/net/lwm2m_client_utils.h index d4a131e83d9..4f88a78717b 100644 --- a/include/net/lwm2m_client_utils.h +++ b/include/net/lwm2m_client_utils.h @@ -303,7 +303,7 @@ enum lwm2m_rai_mode { int lwm2m_init_rai(void); /** - * @brief Set socket option SO_RAI_NO_DATA to bypass + * @brief Set socket option @ref SO_RAI with value @ref RAI_NO_DATA to bypass * RRC Inactivity period and immediately switch to Idle mode. * * @return Zero if success, negative error code otherwise. @@ -311,7 +311,7 @@ int lwm2m_init_rai(void); int lwm2m_rai_no_data(void); /** - * @brief Set socket option SO_RAI_LAST and send dummy packet to bypass + * @brief Set socket option @ref SO_RAI with value @ref RAI_LAST and send dummy packet to bypass * RRC Inactivity period and immediately switch to Idle mode. * * @return Zero if success, negative error code otherwise. diff --git a/lib/lte_link_control/Kconfig b/lib/lte_link_control/Kconfig index ec46a662728..c171c3dd61b 100644 --- a/lib/lte_link_control/Kconfig +++ b/lib/lte_link_control/Kconfig @@ -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 diff --git a/lib/nrf_modem_lib/nrf91_sockets.c b/lib/nrf_modem_lib/nrf91_sockets.c index f5ce8122d49..958426ba849 100644 --- a/lib/nrf_modem_lib/nrf91_sockets.c +++ b/lib/nrf_modem_lib/nrf91_sockets.c @@ -213,6 +213,8 @@ static int z_to_nrf_optname(int z_in_level, int z_in_optname, case SO_REUSEADDR: *nrf_out_optname = NRF_SO_REUSEADDR; break; + + /* SO_RAI_* and NRF_SO_RAI_* are deprecated */ case SO_RAI_LAST: *nrf_out_optname = NRF_SO_RAI_LAST; break; @@ -227,6 +229,9 @@ static int z_to_nrf_optname(int z_in_level, int z_in_optname, break; case SO_RAI_WAIT_MORE: *nrf_out_optname = NRF_SO_RAI_WAIT_MORE; + + case SO_RAI: + *nrf_out_optname = NRF_SO_RAI; break; default: retval = -1; diff --git a/samples/cellular/modem_shell/src/ping/icmp_ping.c b/samples/cellular/modem_shell/src/ping/icmp_ping.c index 8d3dda881f5..164c31bd6af 100644 --- a/samples/cellular/modem_shell/src/ping/icmp_ping.c +++ b/samples/cellular/modem_shell/src/ping/icmp_ping.c @@ -321,12 +321,12 @@ static uint32_t send_ping_wait_reply(struct icmp_ping_shell_cmd_argv *ping_args, #endif if (rai != PING_RAI_NONE) { /* Set RAI option ONGOING except for the last packet for which we set ONE_RESP */ - int rai_option = SO_RAI_ONGOING; + int rai_option = RAI_ONGOING; if (rai == PING_RAI_LAST_PACKET) { - rai_option = SO_RAI_ONE_RESP; + rai_option = RAI_ONE_RESP; } - ret = setsockopt(fd, SOL_SOCKET, rai_option, NULL, 0); + ret = setsockopt(fd, SOL_SOCKET, SO_RAI, &rai_option, sizeof(rai_option)); if (ret) { ping_error(ping_args, "setsockopt() for RAI failed with error %d", errno); goto close_end; @@ -414,8 +414,9 @@ static uint32_t send_ping_wait_reply(struct icmp_ping_shell_cmd_argv *ping_args, } while (true); if (rai == PING_RAI_LAST_PACKET) { + int rai = RAI_NO_DATA; /* Set RAI option NO_DATA after last response has been received */ - ret = setsockopt(fd, SOL_SOCKET, SO_RAI_NO_DATA, NULL, 0); + ret = setsockopt(fd, SOL_SOCKET, SO_RAI, &rai, sizeof(rai)); if (ret) { ping_error( ping_args, "setsockopt() for SO_RAI_NO_DATA failed with error %d", diff --git a/samples/cellular/modem_shell/src/sock/sock.c b/samples/cellular/modem_shell/src/sock/sock.c index 67a9c25cd54..a5d268f257f 100644 --- a/samples/cellular/modem_shell/src/sock/sock.c +++ b/samples/cellular/modem_shell/src/sock/sock.c @@ -1203,10 +1203,11 @@ int sock_close(int socket_id) static int sock_rai_option_set(int fd, int option, char *option_string) { - int err = setsockopt(fd, SOL_SOCKET, option, NULL, 0); + int err = setsockopt(fd, SOL_SOCKET, SO_RAI, &option, sizeof(option)); if (err) { - mosh_error("setsockopt() for %s failed with error %d", option_string, errno); + mosh_error("setsockopt() for SO_RAI with value %s failed with error %d", + option_string, errno); return err; } @@ -1228,41 +1229,41 @@ int sock_rai(int socket_id, bool rai_last, bool rai_no_data, mosh_error("No socket specific RAI options given with -i"); } - /* SO_RAI_LAST */ + /* RAI_LAST */ if (rai_last) { - err = sock_rai_option_set(socket_info->fd, SO_RAI_LAST, "SO_RAI_LAST"); + err = sock_rai_option_set(socket_info->fd, RAI_LAST, "RAI_LAST"); if (err) { return err; } } - /* SO_RAI_NO_DATA */ + /* RAI_NO_DATA */ if (rai_no_data) { - err = sock_rai_option_set(socket_info->fd, SO_RAI_NO_DATA, "SO_RAI_NO_DATA"); + err = sock_rai_option_set(socket_info->fd, RAI_NO_DATA, "RAI_NO_DATA"); if (err) { return err; } } - /* SO_RAI_ONE_RESP */ + /* RAI_ONE_RESP */ if (rai_one_resp) { - err = sock_rai_option_set(socket_info->fd, SO_RAI_ONE_RESP, "SO_RAI_ONE_RESP"); + err = sock_rai_option_set(socket_info->fd, RAI_ONE_RESP, "RAI_ONE_RESP"); if (err) { return err; } } - /* SO_RAI_ONGOING */ + /* RAI_ONGOING */ if (rai_ongoing) { - err = sock_rai_option_set(socket_info->fd, SO_RAI_ONGOING, "SO_RAI_ONGOING"); + err = sock_rai_option_set(socket_info->fd, RAI_ONGOING, "RAI_ONGOING"); if (err) { return err; } } - /* SO_RAI_WAIT_MORE */ + /* RAI_WAIT_MORE */ if (rai_wait_more) { - err = sock_rai_option_set(socket_info->fd, SO_RAI_WAIT_MORE, "SO_RAI_WAIT_MORE"); + err = sock_rai_option_set(socket_info->fd, RAI_WAIT_MORE, "RAI_WAIT_MORE"); if (err) { return err; } diff --git a/samples/cellular/modem_shell/src/sock/sock_shell.c b/samples/cellular/modem_shell/src/sock/sock_shell.c index 5a8517ebced..97ddcd78da0 100644 --- a/samples/cellular/modem_shell/src/sock/sock_shell.c +++ b/samples/cellular/modem_shell/src/sock/sock_shell.c @@ -121,27 +121,27 @@ static const char sock_rai_usage_str[] = "Options:\n" " -i, --id, [int] Socket id. Use 'sock list' command to see open\n" " sockets.\n" - " --rai_last, Sets NRF_SO_RAI_LAST option.\n" + " --rai_last, Sets SO_RAI option with value RAI_LAST.\n" " Indicates that the next call to send/sendto will be\n" " the last one for some time, which means that the\n" " modem can get out of connected mode quicker when\n" " this data is sent.\n" - " --rai_no_data, Sets NRF_SO_RAI_NO_DATA option.\n" + " --rai_no_data, Sets SO_RAI option with value RAI_NO_DATA.\n" " Indicates that the application will not send any\n" " more data. This socket option will apply\n" " immediately, and does not require a call to send\n" " afterwards.\n" - " --rai_one_resp, Sets NRF_SO_RAI_ONE_RESP option.\n" + " --rai_one_resp, Sets SO_RAI option with value RAI_ONE_RESP.\n" " Indicates that after the next call to send/sendto,\n" " the application is expecting to receive one more\n" " data packet before this socket will not be used\n" " again for some time.\n" - " --rai_ongoing, Sets NRF_SO_RAI_ONGOING option.\n" + " --rai_ongoing, Sets SO_RAI option with value RAI_ONGOING.\n" " If a client application expects to use the socket\n" " more it can indicate that by setting this socket\n" " option before the next send call which will keep\n" " the modem in connected mode longer.\n" - " --rai_wait_more, Sets NRF_SO_RAI_WAIT_MORE option.\n" + " --rai_wait_more, Sets SO_RAI option with value RAI_WAIT_MORE.\n" " If a server application expects to use the socket\n" " more it can indicate that by setting this socket\n" " option before the next send call.\n" diff --git a/samples/cellular/udp/src/main.c b/samples/cellular/udp/src/main.c index 20f746d24ba..92a6b5c6344 100644 --- a/samples/cellular/udp/src/main.c +++ b/samples/cellular/udp/src/main.c @@ -25,6 +25,7 @@ static void socket_transmission_work_fn(struct k_work *work) { int err; char buffer[CONFIG_UDP_DATA_UPLOAD_SIZE_BYTES] = {"\0"}; + int rai; printk("Transmitting UDP/IP payload of %d bytes to the ", CONFIG_UDP_DATA_UPLOAD_SIZE_BYTES + UDP_IP_HEADER_SIZE); @@ -36,7 +37,8 @@ static void socket_transmission_work_fn(struct k_work *work) /* Let the modem know that this is the last packet for now and we do not * wait for a response. */ - err = setsockopt(client_fd, SOL_SOCKET, SO_RAI_LAST, NULL, 0); + rai = RAI_LAST; + err = setsockopt(client_fd, SOL_SOCKET, SO_RAI, &rai, sizeof(rai)); if (err) { printk("Failed to set socket option, error: %d\n", errno); } diff --git a/subsys/net/lib/lwm2m_client_utils/lwm2m/lwm2m_rai.c b/subsys/net/lib/lwm2m_client_utils/lwm2m/lwm2m_rai.c index a467749ca2c..cdcc7190a6b 100644 --- a/subsys/net/lib/lwm2m_client_utils/lwm2m/lwm2m_rai.c +++ b/subsys/net/lib/lwm2m_client_utils/lwm2m/lwm2m_rai.c @@ -113,6 +113,7 @@ int lwm2m_rai_no_data(void) { int ret; struct lwm2m_ctx *ctx; + int rai; if (rrc_connected) { ctx = lwm2m_rd_client_ctx(); @@ -122,10 +123,10 @@ int lwm2m_rai_no_data(void) } if (ctx->sock_fd >= 0) { - int dummy = 1; + int rai = RAI_NO_DATA; LOG_DBG("Set socket option SO_RAI_NO_DATA"); - ret = setsockopt(ctx->sock_fd, SOL_SOCKET, SO_RAI_NO_DATA, &dummy, - sizeof(dummy)); + ret = setsockopt(ctx->sock_fd, SOL_SOCKET, SO_RAI, &rai, + sizeof(rai)); if (ret < 0) { ret = -errno; @@ -151,10 +152,10 @@ int lwm2m_rai_last(void) } if (ctx->sock_fd >= 0) { - int dummy = 1; + int rai = RAI_LAST; LOG_DBG("Set socket option SO_RAI_LAST"); - ret = setsockopt(ctx->sock_fd, SOL_SOCKET, SO_RAI_LAST, &dummy, - sizeof(dummy)); + ret = setsockopt(ctx->sock_fd, SOL_SOCKET, SO_RAI, &rai, + sizeof(rai)); if (ret < 0) { ret = -errno; diff --git a/west.yml b/west.yml index ae9aa83428c..73ca4d6df1e 100644 --- a/west.yml +++ b/west.yml @@ -147,7 +147,7 @@ manifest: repo-path: sdk-nrfxlib path: nrfxlib remote: lemrey - revision: 235781994b2713ae322f9ea4553ae7b682c54675 + revision: 26a0fe5049f58efb1ed37013540cfb73c888d4cd - name: trusted-firmware-m repo-path: sdk-trusted-firmware-m path: modules/tee/tf-m/trusted-firmware-m