<?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</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/80332/mqtt-simple-timer</link><description>Hello 
 
 I wanted to use the MQTT simple example (which works great) and add timer, so that MQTT will be send every 20 seconds: 
 on main I added: 
 struct k_timer my_timer; 
 k_timer_init(&amp;amp;bz_timer, bz_func, NULL); k_timer_start(&amp;amp;bz_timer, K_SECONDS</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 05 Oct 2021 14:32:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/80332/mqtt-simple-timer" /><item><title>RE: MQTT simple + timer</title><link>https://devzone.nordicsemi.com/thread/332677?ContentTypeID=1</link><pubDate>Tue, 05 Oct 2021 14:32:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9e879e05-6f66-4ea1-9d04-ce4bc809b6dd</guid><dc:creator>kamacode</dc:creator><description>&lt;p&gt;resolved that.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;if anyone will encounter that, of course it will fail since timer is in interrupt context, we can not call the MQTT from it&lt;/p&gt;
&lt;p&gt;the solution is calling to workqueue from the timer, which works great!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>