<?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>nRF52 start advertising in timeout callback</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/89096/nrf52-start-advertising-in-timeout-callback</link><description>Hello, 
 I am waking nRF52805 up from SYSOFF by an accelerometer, after which I want to wait for a second and then start advertising for a short period. 
 All is working fine, expect when I try to create an app timer for this delay. 
 Timer is started</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 20 Jun 2022 06:58:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/89096/nrf52-start-advertising-in-timeout-callback" /><item><title>RE: nRF52 start advertising in timeout callback</title><link>https://devzone.nordicsemi.com/thread/373136?ContentTypeID=1</link><pubDate>Mon, 20 Jun 2022 06:58:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e4aee82-540c-4edb-b030-806cf5e80fef</guid><dc:creator>Einarh</dc:creator><description>&lt;p&gt;I would recommend using &lt;a href="http://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/kernel/services/synchronization/semaphores.html"&gt;Zephyr&amp;#39;s semaphore API&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;For the thread waiting you could then use k_sem_take with K_FOREVER as the timeout. This will make the thread sleep until it&amp;#39;s signaled by the callback.&lt;/p&gt;
&lt;p&gt;If you&amp;#39;re using the nRF5 SDK I believe you could do something similar using &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.1.0%2Fgroup__nrf__atomic.html"&gt;the nrf_atomic API&lt;/a&gt;. (&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/69664/semaphore-equivalents-for-nrf51822-and-nrf52840"&gt;See this thread&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;-Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 start advertising in timeout callback</title><link>https://devzone.nordicsemi.com/thread/373049?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2022 13:09:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ca8c5e9-c282-4f17-a43b-137b04f2b0ec</guid><dc:creator>Sophisti</dc:creator><description>&lt;p&gt;Thanks for the fast reply! I understand, and this seems very logical as you usually want to do as little as possible in a callback. Do you mean creating eg a global variable that is changed when the timeout is over?&amp;nbsp;And how do I wait for this while consuming as little power as possible?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 start advertising in timeout callback</title><link>https://devzone.nordicsemi.com/thread/373046?ContentTypeID=1</link><pubDate>Fri, 17 Jun 2022 13:00:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8447ea7-841c-4874-91dc-7ddf47633dff</guid><dc:creator>Einarh</dc:creator><description>&lt;p&gt;Hello!&lt;/p&gt;
&lt;p&gt;I think it would be a good idea to not start advertising from within the callback, and instead use a semaphore to signal from the callback and start your advertising from another thread in your code waiting for the semaphore. Have you tried this?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>