<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Enabling eDRX on mqtt_simple on nRF9160</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/46944/enabling-edrx-on-mqtt_simple-on-nrf9160</link><description>Hi, 
 I want to activate eDRX on mqtt_simple example and measure the current consumption. I guess based on the code, by enabling &amp;quot;CONFIG_LTE_EDRX_REQ&amp;quot; it will be activated. Is there anything else that I should do in order to reduce power consumption?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 10 Jun 2019 17:22:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/46944/enabling-edrx-on-mqtt_simple-on-nrf9160" /><item><title>RE: Enabling eDRX on mqtt_simple on nRF9160</title><link>https://devzone.nordicsemi.com/thread/191875?ContentTypeID=1</link><pubDate>Mon, 10 Jun 2019 17:22:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1643d935-57b7-4ba4-aa4c-e508ef007945</guid><dc:creator>Bj&amp;#248;rn Kvaale</dc:creator><description>&lt;p&gt;Could you please open a new DevZone case? Thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enabling eDRX on mqtt_simple on nRF9160</title><link>https://devzone.nordicsemi.com/thread/191732?ContentTypeID=1</link><pubDate>Sat, 08 Jun 2019 09:44:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b5de20bc-8bf7-4348-bad2-ea4213f82bf7</guid><dc:creator>Yusuke</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;Bj&amp;oslash;rn&lt;/p&gt;
&lt;p&gt;I want to set a keep alive value of MQTT while eDRX is enabled, but it doesn&amp;#39;t work well. Could you give me any advice?&lt;/p&gt;
&lt;p&gt;Environment&lt;br /&gt;- hardware: nRF9160 DK 0.8.2&lt;br /&gt;- firmware: 0.7.0-29.alpha&lt;br /&gt;- nrf ver: 0.4.0&lt;br /&gt;- LTE-M&lt;br /&gt;- eDRX enable&lt;br /&gt;- mqtt_simple works fine with&amp;nbsp;mosquitto MQTT broker&lt;br /&gt;- project based on mqtt_simple&lt;br /&gt;- antenna power is fine&lt;br /&gt;- eDRX service is available here&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;AT+CEDRXS?
OK
AT+CEDRXS=1,4,&amp;quot;1000&amp;quot;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I added MQTT_KEEPALIVE param to Kconfig and CONF_MQTT_KEEPALIVE param to pro.conf&lt;br /&gt;I&amp;#39;ve tested several conditions&lt;br /&gt;[condition]&lt;br /&gt;- CONFIG_LTE_EDRX_REQ_VALUE=&amp;quot;0110&amp;quot; in prj.conf // 327.68 sec interval&lt;br /&gt; &lt;span&gt;-&amp;nbsp;&lt;/span&gt;CONF_MQTT_KEEPALIVE=300 in prj.conf&lt;br /&gt;[result]&lt;br /&gt; &lt;span&gt;-&amp;nbsp;&lt;/span&gt;eDRX doesn&amp;#39;t work properly. When I send a message to a MQTT broker, the DK receives it right after that. There should be a delay due to the eDRX.&lt;/p&gt;
&lt;p&gt;[condition]&lt;br /&gt; &lt;span&gt;-&amp;nbsp;&lt;/span&gt;CONFIG_LTE_EDRX_REQ_VALUE=&amp;quot;0110&amp;quot; in prj.conf // 327.68 sec interval&lt;br /&gt; &lt;span&gt;-&amp;nbsp;&lt;/span&gt;CONF_MQTT_KEEPALIVE=300 in prj.conf&lt;br /&gt;[result]&lt;br /&gt; &lt;span&gt;-&amp;nbsp;&lt;/span&gt;The DK does not receive any message after 360sec followed by disconnection.&lt;/p&gt;
&lt;p&gt;This is the whole project.&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;Kconfig&amp;gt;
menu &amp;quot;MQTT simple sample&amp;quot;
config MQTT_PUB_TOPIC
	string &amp;quot;MQTT publish topic&amp;quot;
	default &amp;quot;my/publish/topic&amp;quot;

config MQTT_SUB_TOPIC
	string &amp;quot;MQTT subscribe topic&amp;quot;
	default &amp;quot;my/subscribe/topic&amp;quot;

config MQTT_CLIENT_ID
	string &amp;quot;MQTT Client ID&amp;quot;
	default &amp;quot;my-client-id&amp;quot;

config MQTT_BROKER_HOSTNAME
	string &amp;quot;MQTT broker hostname&amp;quot;
	default &amp;quot;iot.eclipse.org&amp;quot;

config MQTT_BROKER_PORT
	int &amp;quot;MQTT broker port&amp;quot;
	default 1883

config MQTT_MESSAGE_BUFFER_SIZE
	int &amp;quot;&amp;quot;
	default 128

config MQTT_PAYLOAD_BUFFER_SIZE
	int &amp;quot;&amp;quot;
	default 128

config MQTT_KEEPALIVE
	int &amp;quot;&amp;quot;
	default 60

endmenu

menu &amp;quot;Zephyr Kernel&amp;quot;
source &amp;quot;$ZEPHYR_BASE/Kconfig.zephyr&amp;quot;
endmenu&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;lt;prj.conf&amp;gt;

# General config
CONFIG_TEST_RANDOM_GENERATOR=y

# Networking
CONFIG_NETWORKING=y
CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_NET_SOCKETS=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y

# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_NETWORK_MODE_LTE_M=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
# CONFIG_LTE_EDRX_REQ_ACTT_TYPE=&amp;quot;4&amp;quot;
CONFIG_LTE_EDRX_REQ=y
CONFIG_LTE_EDRX_REQ_VALUE=&amp;quot;0110&amp;quot;
# 0100 81.92sec
# 0101 163.84sec
# 0110 327.68sec
# 0111 655.36sec

# LTE link control
CONFIG_LTE_LINK_CONTROL=y
CONFIG_LTE_AUTO_INIT_AND_CONNECT=n

# BSD library
CONFIG_BSD_LIBRARY=y

# AT Host
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_AT_HOST_LIBRARY=y

# MQTT
CONFIG_MQTT_LIB=y
CONFIG_MQTT_LIB_TLS=n

# Appliaction
CONFIG_MQTT_PUB_TOPIC=&amp;quot;myPubTopic&amp;quot;
CONFIG_MQTT_SUB_TOPIC=&amp;quot;mySubTopic&amp;quot;
CONFIG_MQTT_CLIENT_ID=&amp;quot;myClientID&amp;quot;
CONFIG_MQTT_BROKER_HOSTNAME=&amp;quot;xxxxxxxxxx.com&amp;quot;
CONFIG_MQTT_BROKER_PORT=1883
CONFIG_MQTT_KEEPALIVE=300 # ADD here

# Main thread
CONFIG_MAIN_THREAD_PRIORITY=7
CONFIG_MAIN_STACK_SIZE=4096

CONFIG_HEAP_MEM_POOL_SIZE=1024
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;&amp;lt;main.c&amp;gt;

#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;uart.h&amp;gt;
#include &amp;lt;string.h&amp;gt;

#include &amp;lt;net/mqtt.h&amp;gt;
#include &amp;lt;net/socket.h&amp;gt;
#include &amp;lt;lte_lc.h&amp;gt;

#define MQTT_USERNAME &amp;quot;username&amp;quot;
#define MQTT_PASSWORD &amp;quot;password&amp;quot;
.
.
.

/**@brief Initialize the MQTT client structure
 */
static void client_init(struct mqtt_client *client)
{
	mqtt_client_init(client);

	broker_init();

    /* Add from here */
    static struct mqtt_utf8 password;
	static struct mqtt_utf8 user_name;

	password.utf8 = (u8_t *)MQTT_PASSWORD;
	password.size = strlen(MQTT_PASSWORD);
	user_name.utf8 = (u8_t *)MQTT_USERNAME;
	user_name.size = strlen(MQTT_USERNAME);
    /* to here */

	/* MQTT client configuration */
	client-&amp;gt;broker = &amp;amp;broker;
	client-&amp;gt;evt_cb = mqtt_evt_handler;
	client-&amp;gt;client_id.utf8 = (u8_t *)CONFIG_MQTT_CLIENT_ID;
	client-&amp;gt;client_id.size = strlen(CONFIG_MQTT_CLIENT_ID);
	client-&amp;gt;password = &amp;amp;password; // Add here
	client-&amp;gt;user_name = &amp;amp;user_name; // Add here
	client-&amp;gt;protocol_version = MQTT_VERSION_3_1_0; // originally MQTT_VERSION_3_1_1

	/* MQTT buffers configuration */
	client-&amp;gt;rx_buf = rx_buffer;
	client-&amp;gt;rx_buf_size = sizeof(rx_buffer);
	client-&amp;gt;tx_buf = tx_buffer;
	client-&amp;gt;tx_buf_size = sizeof(tx_buffer);

	/* MQTT transport configuration */
	client-&amp;gt;transport.type = MQTT_TRANSPORT_NON_SECURE;
}

.
.

void main(void)
{
	int err;

	printk(&amp;quot;The MQTT simple sample started\n&amp;quot;);

	modem_configure();

    /* ADD here */
    err = lte_lc_edrx_req(true);
    if (err) {
        printk(&amp;quot;ERROR: set edrx %d\n&amp;quot;, err);
        return;
    }
    /* ADD here */

	client_init(&amp;amp;client);

	err = mqtt_connect(&amp;amp;client);
	if (err != 0) {
		printk(&amp;quot;ERROR: mqtt_connect %d\n&amp;quot;, err);
		return;
	}

	err = fds_init(&amp;amp;client);
	if (err != 0) {
		printk(&amp;quot;ERROR: fds_init %d\n&amp;quot;, err);
		return;
	}

	while (1) {
		err = poll(&amp;amp;fds, 1, K_SECONDS(CONFIG_MQTT_KEEPALIVE)); 
		if (err &amp;lt; 0) {
			printk(&amp;quot;ERROR: poll %d\n&amp;quot;, errno);
			break;
		}

        err = mqtt_live(&amp;amp;client);
		if (err != 0) {
			printk(&amp;quot;ERROR: mqtt_live %d\n&amp;quot;, err);
			break;
		}

		if ((fds.revents &amp;amp; POLLIN) == POLLIN) {
			err = mqtt_input(&amp;amp;client); // if a publish event comes, mqtt_evt_handler is called here
			if (err != 0) {
				printk(&amp;quot;ERROR: mqtt_input %d\n&amp;quot;, err);
				break;
			}
		}

		if ((fds.revents &amp;amp; POLLERR) == POLLERR) {
			printk(&amp;quot;POLLERR\n&amp;quot;);
			break;
		}

		if ((fds.revents &amp;amp; POLLNVAL) == POLLNVAL) {
			printk(&amp;quot;POLLNVAL\n&amp;quot;);
			break;
		}
	}

}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is a test condition.&lt;br /&gt;Ideally, I want to set a longer keepalive value, like 1200(sec) to decrease power consumption.&lt;br /&gt;- keep alive of MQTT: 1200 sec&lt;br /&gt;- eDRX interval value: 655 sec&lt;/p&gt;
&lt;p&gt;I have been struggling with this issue more than two weeks, but I don&amp;#39;t really get the eDRX behavior. Any advice?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enabling eDRX on mqtt_simple on nRF9160</title><link>https://devzone.nordicsemi.com/thread/186925?ContentTypeID=1</link><pubDate>Tue, 14 May 2019 10:59:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f2eda02-e0cd-4eec-9bf4-950b55add754</guid><dc:creator>Bj&amp;#248;rn Kvaale</dc:creator><description>&lt;p&gt;You should cut SB44 on the DK.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enabling eDRX on mqtt_simple on nRF9160</title><link>https://devzone.nordicsemi.com/thread/186798?ContentTypeID=1</link><pubDate>Mon, 13 May 2019 22:02:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58778542-8db4-4f4a-8cd7-ff7c5a225aca</guid><dc:creator>Mohammad Amin</dc:creator><description>&lt;p&gt;Thanks. eDRX now is working. My development kit version is older than 0.8.5. Just one question. I am confused, should I cut the SB43 or SB44 for the current measurement?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Enabling eDRX on mqtt_simple on nRF9160</title><link>https://devzone.nordicsemi.com/thread/185442?ContentTypeID=1</link><pubDate>Mon, 06 May 2019 11:19:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f08ca21-cfa8-405c-8dbd-272a7dc4f910</guid><dc:creator>Bj&amp;#248;rn Kvaale</dc:creator><description>&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt;&amp;nbsp;Woops, forgot to answer your first question&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&amp;nbsp;Just add the following code to the mqtt simple example (after the modem_configure() function is a good place):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;        err = lte_lc_edrx_req(true);
        if (err) {
                printk(&amp;quot;ERROR: set edrx %d\n&amp;quot;, err);
                return;
        }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This function should be defined in lte_lc.c. You can then easily check to see that edrx is set by using the following AT command in LTE Link Monitor:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;AT+CEDRXS?&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You can naturally also check to make sure that no error has been returned.&lt;/p&gt;
&lt;p&gt;No, you cannot use the power profiler kit to measure the nRF9160 DK current consumption. If you have the v0.8.5 nRF91 DK, just follow the User Guide found &lt;a href="https://infocenter.nordicsemi.com/topic/ug_nrf91_dk/UG/nrf91_DK/revision_history.html?cp=2_0_2_0"&gt;here&lt;/a&gt;. If you have an older version of the nRF91 DK (i.e. &amp;lt;v0.8.5), take a look at &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/42387/instructions-for-setting-up-9160-dk-for-current-measurement-are-confusing/"&gt;this devzone case&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>