<?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>mqtt simple + timer collision</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83223/mqtt-simple-timer-collision</link><description>Dear Sir. 
 
 We are using software based on mqtt simple project . 
 We added a 1 hz timer, Every 1 hz we toggle a led on and off. 
 
 Sometime the led is stuck on &amp;quot; on &amp;quot; or &amp;quot; off which means to me that the timer is not 
 working fine or the mqtt routine</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 05 Jan 2022 12:07:45 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83223/mqtt-simple-timer-collision" /><item><title>RE: mqtt simple + timer collision</title><link>https://devzone.nordicsemi.com/thread/346161?ContentTypeID=1</link><pubDate>Wed, 05 Jan 2022 12:07:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a33d9b2-3d50-4f9d-a0dd-b307af2e53e0</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;If you se LOG_INF to log inside &amp;quot;my_expiry_function()&amp;quot;, you should get prints with timestamps. &lt;br /&gt;Then log inside the work done by &amp;quot;work_top&amp;quot;.&lt;/p&gt;
&lt;p&gt;This will help us find if the delay is in the timer or the work queue.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: mqtt simple + timer collision</title><link>https://devzone.nordicsemi.com/thread/345549?ContentTypeID=1</link><pubDate>Sun, 02 Jan 2022 13:40:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68980022-5270-4d0e-a7ab-e53249c06fb7</guid><dc:creator>ephraim</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Another input.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have found the following is responsible for the timer&amp;#39;s mismatch&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;if((get_mqtt_conn_flag() == 1)) { // &amp;amp;&amp;amp; (gtimer &amp;gt; 50)) {&lt;br /&gt; printk(&amp;quot;Try to connect - 1, %d \n&amp;quot;,gtimer); &lt;br /&gt; lte_lc_offline();&lt;br /&gt; set_mqtt_conn_flag(3);&lt;br /&gt; } else if (get_mqtt_conn_flag() == 2) { &lt;br /&gt; printk(&amp;quot;Try to connect - 2, %d \n&amp;quot;,gtimer);&lt;br /&gt; lte_lc_normal();&lt;br /&gt; battery_value = get_battery_value();&lt;br /&gt; set_latest_valid_battery_value(battery_value);&lt;br /&gt; set_mqtt_conn_flag(3);&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It is either the&amp;nbsp;&lt;span&gt;lte_lc_offline(); or the&amp;nbsp;lte_lc_normal();&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;Please Advise&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: mqtt simple + timer collision</title><link>https://devzone.nordicsemi.com/thread/345545?ContentTypeID=1</link><pubDate>Sun, 02 Jan 2022 09:02:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b173a4b-9f3d-446f-be88-578e717669cc</guid><dc:creator>ephraim</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;In main.c&amp;nbsp; configure timer&lt;/p&gt;
&lt;p&gt;k_timer_init(&amp;amp;my_timer, my_expiry_function, NULL); //Timer - 1 Hz&lt;br /&gt; k_timer_start(&amp;amp;my_timer, K_MSEC(TIEMR_INTERVAL_SEC), K_SECONDS(TIEMR_INTERVAL_SEC)); //Timer - 1 Hz&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;void my_expiry_function(struct k_timer *timer_id)&lt;br /&gt;{&lt;br /&gt; k_work_submit(&amp;amp;work_top);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The code of mqtt is the same as in the project mqtt simple , turning on and off the mqtt&lt;/p&gt;
&lt;p&gt;by issuing the commands&amp;nbsp; &amp;nbsp;&lt;span&gt;lte_lc_offline(); and&amp;nbsp;lte_lc_normal();&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Every time the the modem reconnect there is a delay in the timer ( see pic ). Sometimes the timer is stopped.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Please Advise.&lt;img alt=" " src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/scope_5F00_87.bmp" /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/scope_5F00_86.bmp" /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/scope_5F00_88.bmp" /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: mqtt simple + timer collision</title><link>https://devzone.nordicsemi.com/thread/345462?ContentTypeID=1</link><pubDate>Thu, 30 Dec 2021 11:24:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d145ef3-8fab-4e3c-bc1f-0f0ea356a90e</guid><dc:creator>Sigurd Hellesvik</dc:creator><description>&lt;p&gt;Hi Ephraim,&lt;/p&gt;
&lt;p&gt;My guess is that this is due to scheduling.&lt;/p&gt;
&lt;p&gt;Could you post the code and configuration you use for the timer?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Sigurd Hellesvik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>