<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://test-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>nRF9160 persistent socket in eDRX</title><link>https://test-devzone.nordicsemi.com/f/nordic-q-a/86344/nrf9160-persistent-socket-in-edrx</link><description>My device is connected all the time to a server with a persistent socket. I’m using eDRX power save modes so current will stay low in my battery operated product. During operation the server can send data to the device. From another article it looks like</description><dc:language>en-US</dc:language><generator>Telligent Community 13 Non-Production</generator><lastBuildDate>Thu, 02 Jun 2022 13:23:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://test-devzone.nordicsemi.com/f/nordic-q-a/86344/nrf9160-persistent-socket-in-edrx" /><item><title>RE: nRF9160 persistent socket in eDRX</title><link>https://test-devzone.nordicsemi.com/thread/370714?ContentTypeID=1</link><pubDate>Thu, 02 Jun 2022 13:23:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee4872fa-b384-4e90-804d-a78620068f26</guid><dc:creator>user2115</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Normally you&amp;#39;d let poll time out,&amp;nbsp;as there&amp;#39;s not much else that can interrupt it, except when there&amp;#39;s activity on the socket itself.&lt;/p&gt;
&lt;p&gt;I do not see any immediate way to interrupt it mid-sequence other than the above, except maybe closing the socket (which should give you a POLLNVAL)? I suppose you&amp;nbsp;could try to call poll sequentially, ie. split it up into 20*1min timeouts?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 persistent socket in eDRX</title><link>https://test-devzone.nordicsemi.com/thread/370526?ContentTypeID=1</link><pubDate>Wed, 01 Jun 2022 19:47:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a947a600-c13d-4a1a-94f6-9d2aadc9f2b6</guid><dc:creator>user108651</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;H&amp;aring;kon,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I know it&amp;#39;s been a couple months since my last response.&amp;nbsp; The poll is working great to have the nRF9160 in a low power mode.&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Currently I have the poll with a 20min timeout running in a thread.&amp;nbsp; I have a scenario where I would like to interrupt the socket poll so it will stop listening.&amp;nbsp;&amp;nbsp;What is the best way to do this?&amp;nbsp; Is there a signal I can send to the poll?&amp;nbsp; The sdk code says poll is based on this command:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/poll.html"&gt;https://pubs.opengroup.org/onlinepubs/9699919799/functions/poll.html&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;One of the comments is this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;i&gt;poll&lt;/i&gt;() shall block until a requested event occurs or until the call is interrupted.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;How do I cause this&amp;nbsp;[EINTR] to occur or is there a better way to interrupt the poll?&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanksfor your help,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Chris&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 persistent socket in eDRX</title><link>https://test-devzone.nordicsemi.com/thread/360692?ContentTypeID=1</link><pubDate>Wed, 30 Mar 2022 08:51:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41c1396f-3458-477b-9447-d24145854963</guid><dc:creator>user2115</dc:creator><description>&lt;p&gt;Hi Chris,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Yes, that is correct.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 persistent socket in eDRX</title><link>https://test-devzone.nordicsemi.com/thread/360595?ContentTypeID=1</link><pubDate>Tue, 29 Mar 2022 15:05:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9b3d35b5-48b3-4d6a-950d-54f295d4c090</guid><dc:creator>user108651</dc:creator><description>&lt;p&gt;Great, thanks&amp;nbsp;H&amp;aring;kon.&amp;nbsp; I&amp;#39;ll test out using poll.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not using MQTT, but based on the code it looks like I can simply do a recv after the poll to get my data.&amp;nbsp; Is this correct?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;if&lt;/span&gt;&lt;span&gt; ((&lt;/span&gt;&lt;span&gt;fds&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;revents&lt;/span&gt;&lt;span&gt; &amp;amp; &lt;/span&gt;&lt;span&gt;POLLIN&lt;/span&gt;&lt;span&gt;) == &lt;/span&gt;&lt;span&gt;POLLIN&lt;/span&gt;&lt;span&gt;) {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; err =&amp;nbsp;&lt;/span&gt;&lt;span&gt;recv&lt;/span&gt;&lt;span&gt;(fd, recv_buf, length, &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; // handle error or data here....&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;}&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Thanks for the help,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Chris&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF9160 persistent socket in eDRX</title><link>https://test-devzone.nordicsemi.com/thread/360473?ContentTypeID=1</link><pubDate>Tue, 29 Mar 2022 08:44:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2412d40c-634f-4a23-8215-7f2837c9387d</guid><dc:creator>user2115</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]How do I know something is available for me to process? &amp;nbsp;Do I have to keep polling with a socket receive command?[/quote]
&lt;p&gt;You can use the poll() function, similar to what is done in the mqtt simple sample:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/nrfconnect/sdk-nrf/blob/main/samples/nrf9160/mqtt_simple/src/main.c#L622"&gt;https://github.com/nrfconnect/sdk-nrf/blob/main/samples/nrf9160/mqtt_simple/src/main.c#L622&lt;/a&gt;&lt;/p&gt;
[quote user=""]That seems like it would eat up my battery. &amp;nbsp; Recommendations on how I should best approach this for low power would be great.[/quote]
&lt;p&gt;poll() itself will not eat your battery. It is the responsiveness of your link that&amp;nbsp;consumes power&lt;/p&gt;
&lt;p&gt;Have you looked at the power calculator for nRF9160?&amp;nbsp;&lt;a href="https://test-devzone.nordicsemi.com/power/w/opp/3/online-power-profiler-for-lte"&gt;https://devzone.nordicsemi.com/power/w/opp/3/online-power-profiler-for-lte&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please note that if your device is TX oriented (ie. you drive the communication), I&amp;#39;d recommend that you use PSM instead and send data on-demand instead.&lt;/p&gt;
&lt;p&gt;However, if you expect to receive data from a server, eDRX would be wise to use.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>