Skip to content
Merged
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
37 changes: 19 additions & 18 deletions applications/serial_lte_modem/doc/SOCKET_AT_commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -539,30 +539,31 @@ Syntax

* ``<value>`` 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).

* ``<value>`` is ignored.
* ``<value>`` 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.

* ``<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.

* ``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.

* ``<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.

* ``53`` - :c:macro:`SO_RAI_ONGOING` (set-only).
Keep RRC in connected mode after the next send operation (client).

* ``<value>`` is ignored.

* ``54`` - :c:macro:`SO_RAI_WAIT_MORE` (set-only).
Keep RRC in connected mode after the next send operation (server).

* ``<value>`` 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.

Expand Down
11 changes: 2 additions & 9 deletions applications/serial_lte_modem/src/slm_at_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
34 changes: 34 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 @@ -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):

Expand Down
21 changes: 18 additions & 3 deletions doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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:

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
4 changes: 2 additions & 2 deletions include/net/lwm2m_client_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,15 @@ 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.
*/
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.
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: 5 additions & 0 deletions lib/nrf_modem_lib/nrf91_sockets.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
9 changes: 5 additions & 4 deletions samples/cellular/modem_shell/src/ping/icmp_ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand Down
25 changes: 13 additions & 12 deletions samples/cellular/modem_shell/src/sock/sock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}
Expand Down
10 changes: 5 additions & 5 deletions samples/cellular/modem_shell/src/sock/sock_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion samples/cellular/udp/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down
13 changes: 7 additions & 6 deletions subsys/net/lib/lwm2m_client_utils/lwm2m/lwm2m_rai.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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;
Expand All @@ -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;
Expand Down
Loading