Power saving mode and RAI

Hi,
I have issues configuring PSM together with RAI on my nRF9151-DK. I am trying to send UDP packet, wait for response and go to sleep for several minutes trying to consume as little power as possible.
The problem is that RAI seems to have no effect, the modem always enters the sleep in the same time (10 - 15 seconds) after I receieve packet whenever I enable or disable RAI.

int modem_send(void* buffer, size_t length)
{
	int err;
	int sock;
	int rai;
	struct sockaddr_storage host_addr;
	char recv_buf[64];
	struct sockaddr_in *server4 = ((struct sockaddr_in *)&host_addr);
	
	LOG_INF("Sending data to %s:%d, size %d", CONFIG_APP_SERVER_HOSTNAME, CONFIG_APP_SERVER_PORT, length);

	server4->sin_family = AF_INET;
	server4->sin_port = htons(CONFIG_APP_SERVER_PORT);
	inet_pton(AF_INET, CONFIG_APP_SERVER_HOSTNAME, &server4->sin_addr);

	sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
	if (sock < 0)
	{
		LOG_ERR("Failed to create UDP socket, error: %d", errno);
		return -errno;
	}

	struct timeval tv = {.tv_sec = 10, .tv_usec = 0};
	err = setsockopt(sock, SOL_SOCKET, SO_RCVTIMEO, (const char*)&tv, sizeof tv);
	if (err)
	{
		LOG_ERR("Failed to set socket option SO_RCVTIMEO, error: %d", errno);
		close(sock);
		return err;
	}

	err = connect(sock, (struct sockaddr *)&host_addr, sizeof(struct sockaddr_in));
	if (err < 0)
	{
		LOG_ERR("Failed to connect socket, error: %d", errno);
		close(sock);
		return err;
	}

	rai = RAI_ONE_RESP;
    err = setsockopt(sock, SOL_SOCKET, SO_RAI, &rai, sizeof(rai));
    if (err) {
        LOG_ERR("Failed to set NRF_SO_RAI option, error: %d", err);
    }
	
	err = send(sock, buffer, length, 0);
	if (err < 0)
	{
		LOG_ERR("Failed to transmit UDP packet, error: %d", errno);
		close(sock);
		return err;
	}
	LOG_INF("Waiting for response");
	err = recv(sock, recv_buf, sizeof(recv_buf) - 1, 0);
	if (err <= 0)
	{
		LOG_ERR("Failed to receive UDP packet, error: %d\n", errno);
		close(sock);
		return err;
	}
	recv_buf[err] = 0;
	LOG_INF("Received: %d bytes", err);
	
	close(sock);

	return 0;
}

# Networking
CONFIG_NETWORKING=y
CONFIG_NET_NATIVE=n
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_POSIX_API=y

# Modem library
CONFIG_NRF_MODEM_LIB=y

# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_LC_MODEM_SLEEP_MODULE=y
CONFIG_LTE_LC_MODEM_SLEEP_NOTIFICATIONS=y
CONFIG_LTE_LC_RAI_MODULE=y

# Configure PSM
CONFIG_LTE_LC_PSM_MODULE=y
CONFIG_LTE_PSM_REQ=y
CONFIG_LTE_PROPRIETARY_PSM_REQ=y
CONFIG_LTE_PSM_REQ_RPTAU="00101000"
CONFIG_LTE_PSM_REQ_RAT="00000001" 
CONFIG_LTE_LC_RAI_MODULE=y
CONFIG_LTE_RAI_REQ=y

# Logging
CONFIG_SERIAL=y
CONFIG_LOG=y

*** Booting nRF Connect SDK v3.0.2-89ba1294ac9b ***
*** Using Zephyr OS v4.0.99-f791c49f492c ***
[00:00:00.288,421] <inf> main: Starting application
[00:00:00.288,421] <inf> modem: Initializing modem library
[00:00:00.623,992] <inf> modem: Modem library initialized

[00:01:24.868,560] <inf> main: Executing work handler
[00:01:24.868,835] <inf> modem: Connecting to network
[00:01:24.868,835] <inf> modem: Allready connected to network
[00:01:24.899,902] <inf> modem: Sending data to xx.xx.xx.xx:xx, size 38
[00:01:24.939,727] <inf> modem: Waiting for response
[00:01:24.940,032] <inf> modem: Woken up from sleep mode
[00:01:25.465,484] <inf> modem: RRC mode: Connected
[00:01:25.678,039] <inf> modem: Received: 5 bytes
[00:01:25.678,283] <inf> main: Work handler finished, scheduling next run in 120 seconds
[00:01:35.969,879] <inf> modem: RRC mode: Idle
[00:01:40.994,903] <inf> modem: Entering proprietary sleep mode

Parents
  • I'm not sure, if the required RAI configuration "AT%RAI=2" (or "=1")  was executed.

    In general, RAI must be supported by the network as well.

    The mfw 2.0.2 is able to report that with an "%RAI" event (if configured with "=2"),  short after the network registration, e.g..

    +CEREG: 2,"BB12","031D7865",9
    %RAI: "031D7865","26202",0,1

    Therefore, please check, if you configured %RAI and your network supports RAI.

    And unfortunately, RAI comes with different flavors, CP-RAI (Rel 13, but NB-IoT only) and AS-RAI (Rel 14). Which one is supported by your network is encoded in the "%RAI" event above.

    In the past, it wasn't too transparent, which option is supported in which mode. My experience with that is somehow poor. In the past "RAI_ONE_RESP" only worked for CP-RAI, for AS-RAI you will need to add a "RAI_NO_DATA" after receiving the response and it takes about 2s to enter RRC idle after that. 

    See NAS-RAI (Non-Access Stratum RAI) used on NB-IoT with nRF9161/51 or search this forum for "AS-RAI", "CP-RAI" and "RAI", but be aware, that RAI in mfw 2.0.2 is different to mfw 1.3.7.

Reply
  • I'm not sure, if the required RAI configuration "AT%RAI=2" (or "=1")  was executed.

    In general, RAI must be supported by the network as well.

    The mfw 2.0.2 is able to report that with an "%RAI" event (if configured with "=2"),  short after the network registration, e.g..

    +CEREG: 2,"BB12","031D7865",9
    %RAI: "031D7865","26202",0,1

    Therefore, please check, if you configured %RAI and your network supports RAI.

    And unfortunately, RAI comes with different flavors, CP-RAI (Rel 13, but NB-IoT only) and AS-RAI (Rel 14). Which one is supported by your network is encoded in the "%RAI" event above.

    In the past, it wasn't too transparent, which option is supported in which mode. My experience with that is somehow poor. In the past "RAI_ONE_RESP" only worked for CP-RAI, for AS-RAI you will need to add a "RAI_NO_DATA" after receiving the response and it takes about 2s to enter RRC idle after that. 

    See NAS-RAI (Non-Access Stratum RAI) used on NB-IoT with nRF9161/51 or search this forum for "AS-RAI", "CP-RAI" and "RAI", but be aware, that RAI in mfw 2.0.2 is different to mfw 1.3.7.

Children
No Data
Related