<?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>Advertising timeout event catch with SDK16</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/64370/advertising-timeout-event-catch-with-sdk16</link><description>Hi everyonoe, 
 
 I would like to set a timeout for advertising, and catch this event. So I have 
 
 According to ble_gap.h : 
 uint16_t duration; /**&amp;lt; Advertising duration in 10 ms units. When timeout is reached, an event of type @ref BLE_GAP_EVT_ADV_SET_TERMINATED</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 05 Aug 2020 15:14:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/64370/advertising-timeout-event-catch-with-sdk16" /><item><title>RE: Advertising timeout event catch with SDK16</title><link>https://devzone.nordicsemi.com/thread/263286?ContentTypeID=1</link><pubDate>Wed, 05 Aug 2020 15:14:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7d96565-ed5e-446c-9565-2e2b32f9fa14</guid><dc:creator>Ben34</dc:creator><description>&lt;p&gt;Hello, thank you for your help&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You are right about the 4s, the comment is wrong.&lt;/p&gt;
&lt;p&gt;In between, I found another solution with external timers, but I&amp;#39;ll eventually test the following :&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;m_adv_params.duration        = MSEC_TO_UNITS(5000, UNIT_10_MS); &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;As you suggest.&lt;/p&gt;
&lt;p&gt;I didn&amp;#39;t though my conversion could be the issue there, your advice is relevant, thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising timeout event catch with SDK16</title><link>https://devzone.nordicsemi.com/thread/263280?ContentTypeID=1</link><pubDate>Wed, 05 Aug 2020 15:02:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8af68ebe-c67f-4cb7-8aab-02c5f4c48c3a</guid><dc:creator>Marjeris Romero</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;m_adv_params.interval 		 = MSEC_TO_UNITS(4000, UNIT_0_625_MS); // 9s advertising so timeout occurs before, and SoftDevice accepts the value
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;When declared like this the advertising interval is set to 4 seconds, since:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/**@brief Macro for converting milliseconds to ticks.
 *
 * @param[in] TIME          Number of milliseconds to convert.
 * @param[in] RESOLUTION    Unit to be converted to in [us/ticks].
 */
#define MSEC_TO_UNITS(TIME, RESOLUTION) (((TIME) * 1000) / (RESOLUTION))&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;NIT_0_625_MS = 625,        /**&amp;lt; Number of microseconds in 0.625 milliseconds. */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The advertising duration should be declared in units of 10 ms, so you should use UNIT_10_MS:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;m_adv_params.duration        = MSEC_TO_UNITS(5000, UNIT_10_MS);       
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Marjeris&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>