<?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>Modem connection state detection</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/117656/modem-connection-state-detection</link><description>Hello, Our board connects and remains connected to our server with only eDRX sleep periods. When a disconnect occurs we want to know if it&amp;#39;s a connection issue to our server or a modem level issue. Right now we check if the modem IsConnected by listening</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 07 Jan 2025 14:03:18 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/117656/modem-connection-state-detection" /><item><title>RE: Modem connection state detection</title><link>https://devzone.nordicsemi.com/thread/517253?ContentTypeID=1</link><pubDate>Tue, 07 Jan 2025 14:03:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3a59fd9-a796-4b65-9bc1-abdc90a1c470</guid><dc:creator>nicolae.georgescu</dc:creator><description>&lt;p&gt;Ok, understood, makes sense! Thank you for investigating this&amp;nbsp;in more detail, much appreciated!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Modem connection state detection</title><link>https://devzone.nordicsemi.com/thread/517133?ContentTypeID=1</link><pubDate>Tue, 07 Jan 2025 06:48:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7523fd6e-a17d-43b5-afc0-8876b3463d05</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;Update:&lt;br /&gt;&lt;br /&gt;Periodic searches can be configured using LTE LC API lte_lc_periodic_search_set(). If power consumption is not an issue, configure the time between periodic searches to a very low value, can even &lt;a href="https://docs.nordicsemi.com/bundle/ref_at_commands/page/REF/at_commands/nw_service/periodicsearchconf_set.html"&gt;set to 0 seconds&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;Modem being stuck offline for days is not caused by lack of periodic searches, but most likely a modem issue. If possible update the modem firmware to the newest one possible, there has been a lot of improvements since MFW v1.3.2.&lt;br /&gt; &lt;br /&gt;For extra safety, some kind of watchdog would probably be good. If modem can not connect to the network for a longer period of time, either reset the whole system or do the modemlib shutdown/init sequence&amp;nbsp;as you have suggested earlier. System reset could be preferable, because that would also handle problems on the application side.&lt;br /&gt;&lt;br /&gt;This would be the recommendations we have.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Modem connection state detection</title><link>https://devzone.nordicsemi.com/thread/516850?ContentTypeID=1</link><pubDate>Fri, 03 Jan 2025 21:22:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72cab09d-b49c-45a8-8ba9-cc321c1251d2</guid><dc:creator>JONATHAN LL</dc:creator><description>[quote user="nicolae.georgescu"]In the past, with modem fw 1.3.2 sometimes the device was stuck in offline for days. We don&amp;#39;t know why, no time to debug,[/quote]
&lt;p&gt;Would be good to have som info on the reason here so that if it is a bug or some other issue we can address it as best as possible. Would you be able to provide some debug info or best a modem trace.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote user="nicolae.georgescu"]So just to repeat the question: how can we control how fast/often the modem tries to reconnect?[/quote]
&lt;p&gt;will need to get back to you after I consult the experts on this here as to what would be best practice.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Jonathan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Modem connection state detection</title><link>https://devzone.nordicsemi.com/thread/516679?ContentTypeID=1</link><pubDate>Thu, 02 Jan 2025 15:57:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b799c3c-65aa-441e-a4b7-fa37d213b064</guid><dc:creator>nicolae.georgescu</dc:creator><description>&lt;p&gt;Happy New Year Jonathan!&lt;br /&gt;Thanks a lot for the detailed answer and for checking internally.&lt;br /&gt;&lt;br /&gt;For (1) understood&amp;nbsp;&lt;span&gt;LTE_LC_EVT_NW_REG_STATUS is enough.&amp;nbsp;I will double check on the events we received, a&amp;nbsp;LTE_LC_NW_REG_SEARCHING makes perfect sense.&lt;br /&gt;&lt;br /&gt;For (2) understood that the modem reconnects automatically. We can confirm this.&lt;br /&gt;&lt;br /&gt;The only question left is about timing. How can we control how fast/often the modem tries to reconnect?&lt;br /&gt;For us timing is very important, users control our device through an app, and we want app -&amp;gt; our server -&amp;gt; device to be &amp;lt; 5 seconds.&lt;br /&gt;In the past, with modem fw 1.3.2 sometimes the device was stuck in offline for days. We don&amp;#39;t know why, no time to debug, so&amp;nbsp;after 3 minutes of software retries we added a division by zero to force restart and this always worked.&lt;br /&gt;A reboot&amp;nbsp;has other downsides though, the device goes through full init phase + the 3 minutes of offline when the device doesn&amp;#39;t receive messages.&lt;br /&gt;This is why we wanted to do a softer reboot, to be faster &amp;lt;1 minute, ideally 30 sec, and without full reinitialization of our other components.&lt;br /&gt;&lt;br /&gt;So just to repeat the question: how can we control how fast/often the modem tries to reconnect?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Modem connection state detection</title><link>https://devzone.nordicsemi.com/thread/516656?ContentTypeID=1</link><pubDate>Thu, 02 Jan 2025 14:34:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55a0b72c-3e48-4c82-a608-43f0aa4547f2</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;Update:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote user=""]&lt;span&gt;&lt;span&gt;1. Is monitoring the&amp;nbsp;LTE_LC_EVT_NW_REG_STATUS a correct way to detect if a modem connection is still available or it dropped out of the sudden? &lt;br /&gt;If so, on first attempt to connect we get an&amp;nbsp;&lt;/span&gt;&lt;/span&gt;LTE_LC_NW_REG_NOT_REGISTERED and then it connects. We should ignore that first occurrence?
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;&lt;/div&gt;[/quote]
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;When modem starts searching for a network, there should be a &lt;code&gt;LTE_LC_NW_REG_SEARCHING&lt;/code&gt; event, not &lt;code&gt;LTE_LC_NW_REG_NOT_REGISTERED&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt; If you need a simple way to check if modem is connected to the network or not, the &lt;strong&gt;current way seems sufficient.&lt;/strong&gt; &lt;br /&gt;&lt;br /&gt;Another possibility would be to use the PDN library and follow the &lt;code&gt;PDN_EVENT_ACTIVATED&lt;/code&gt; and &lt;code&gt;PDN_EVENT_DEACTIVATED&lt;/code&gt; events.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;span dir="ltr"&gt;If you need to know between server and modem level issue,&amp;nbsp;you should probably use PDN library too. But I would think twice if it&amp;#39;s really needed and keep things simple with &lt;code&gt;LTE_LC_NW_REG_REGISTERED_HOME&lt;/code&gt; and &lt;code&gt;LTE_LC_NW_REG_REGISTERED_ROAMING&lt;/code&gt;.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
[quote user=""]2. Is the full modem reconnect code flow correct? Or should we do it without the&amp;nbsp;nrf_modem_lib_shutdown +&amp;nbsp;nrf_modem_lib_init?[/quote]
&lt;p&gt;&lt;span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;span dir="ltr"&gt;In most of the cases, there&amp;#39;s no need for any reconnect logic in the application. When LTE is enabled, modem tries to stay connected to the network automatically. When it has again successfully registered to the network, the application will receive a &lt;code&gt;LTE_LC_NW_REG_REGISTERED_HOME&lt;/code&gt; or &lt;code&gt;LTE_LC_NW_REG_REGISTERED_ROAMING&lt;/code&gt; event. If a suitable network can not be found, the modem enters sleep and periodically wakes up to search for a network. The sleep times between searches depend on the periodic search configuration.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span&gt;&lt;span dir="ltr"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;There is no need to reinitialize the modem ( &lt;code&gt;nrf_modem_lib_shutdown()&lt;/code&gt; -&amp;gt; &lt;code&gt;*_init()&lt;/code&gt;) to disconnect and reconnect to network.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&amp;nbsp;When the modem is in CFUN mode &lt;code&gt;1&lt;/code&gt; (or &lt;code&gt;21&lt;/code&gt;) with LTE activated, and looses network connectivity, it will attempt to reconnect automatically and trigger a new notification when reconnected with the network.&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So there does not need to be a manual disconnect and reconnect step here. It should sort it self out unless there is some specific reason you would want that.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Jonathan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Modem connection state detection</title><link>https://devzone.nordicsemi.com/thread/516631?ContentTypeID=1</link><pubDate>Thu, 02 Jan 2025 11:58:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfd6f4c5-f0fc-47bc-90b9-2c8a7501efed</guid><dc:creator>JONATHAN LL</dc:creator><description>&lt;p&gt;Happy New Year Nicolae,&lt;br /&gt;&lt;br /&gt;Looking in to this to see if there is something extra to do, what you are doing should work relatively well and the&amp;nbsp;&lt;span&gt;LTE_LC_EVT_NW_REG_STATUS will give you a response&amp;nbsp; CREG 1 or 5, so its a indicator.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;As for what would be the reason to why the disconnects happen not all can be picks up\debugged with these functions and might need a modem trace in some cases, its worth doing if this is a issue that you see often and there are no obvious reasons.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;So from the&amp;nbsp;LTE link controller library options I belive&amp;nbsp;LTE_LC_EVT_NW_REG_STATUS is the correct way to check if the connection is lost or not.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I am checking internally if the sequence you are using is the desired one or if there are other better ways.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Jonathan&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>